1*0Sstevel@tonic-gate /* $OpenBSD: getput.h,v 1.8 2002/03/04 17:27:39 stevesk Exp $ */ 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate #ifndef _GETPUT_H 4*0Sstevel@tonic-gate #define _GETPUT_H 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate #ifdef __cplusplus 9*0Sstevel@tonic-gate extern "C" { 10*0Sstevel@tonic-gate #endif 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate /* 14*0Sstevel@tonic-gate * Author: Tatu Ylonen <ylo@cs.hut.fi> 15*0Sstevel@tonic-gate * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 16*0Sstevel@tonic-gate * All rights reserved 17*0Sstevel@tonic-gate * Macros for storing and retrieving data in msb first and lsb first order. 18*0Sstevel@tonic-gate * 19*0Sstevel@tonic-gate * As far as I am concerned, the code I have written for this software 20*0Sstevel@tonic-gate * can be used freely for any purpose. Any derived versions of this 21*0Sstevel@tonic-gate * software must be clearly marked as such, and if the derived work is 22*0Sstevel@tonic-gate * incompatible with the protocol description in the RFC file, it must be 23*0Sstevel@tonic-gate * called by a name other than "ssh" or "Secure Shell". 24*0Sstevel@tonic-gate */ 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate /*------------ macros for storing/extracting msb first words -------------*/ 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #define GET_64BIT(cp) (((u_int64_t)(u_char)(cp)[0] << 56) | \ 29*0Sstevel@tonic-gate ((u_int64_t)(u_char)(cp)[1] << 48) | \ 30*0Sstevel@tonic-gate ((u_int64_t)(u_char)(cp)[2] << 40) | \ 31*0Sstevel@tonic-gate ((u_int64_t)(u_char)(cp)[3] << 32) | \ 32*0Sstevel@tonic-gate ((u_int64_t)(u_char)(cp)[4] << 24) | \ 33*0Sstevel@tonic-gate ((u_int64_t)(u_char)(cp)[5] << 16) | \ 34*0Sstevel@tonic-gate ((u_int64_t)(u_char)(cp)[6] << 8) | \ 35*0Sstevel@tonic-gate ((u_int64_t)(u_char)(cp)[7])) 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #define GET_32BIT(cp) (((u_long)(u_char)(cp)[0] << 24) | \ 38*0Sstevel@tonic-gate ((u_long)(u_char)(cp)[1] << 16) | \ 39*0Sstevel@tonic-gate ((u_long)(u_char)(cp)[2] << 8) | \ 40*0Sstevel@tonic-gate ((u_long)(u_char)(cp)[3])) 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate #define GET_16BIT(cp) (((u_long)(u_char)(cp)[0] << 8) | \ 43*0Sstevel@tonic-gate ((u_long)(u_char)(cp)[1])) 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #define PUT_64BIT(cp, value) do { \ 46*0Sstevel@tonic-gate (cp)[0] = (value) >> 56; \ 47*0Sstevel@tonic-gate (cp)[1] = (value) >> 48; \ 48*0Sstevel@tonic-gate (cp)[2] = (value) >> 40; \ 49*0Sstevel@tonic-gate (cp)[3] = (value) >> 32; \ 50*0Sstevel@tonic-gate (cp)[4] = (value) >> 24; \ 51*0Sstevel@tonic-gate (cp)[5] = (value) >> 16; \ 52*0Sstevel@tonic-gate (cp)[6] = (value) >> 8; \ 53*0Sstevel@tonic-gate (cp)[7] = (value); } while (0) 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #define PUT_32BIT(cp, value) do { \ 56*0Sstevel@tonic-gate (cp)[0] = (value) >> 24; \ 57*0Sstevel@tonic-gate (cp)[1] = (value) >> 16; \ 58*0Sstevel@tonic-gate (cp)[2] = (value) >> 8; \ 59*0Sstevel@tonic-gate (cp)[3] = (value); } while (0) 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate #define PUT_16BIT(cp, value) do { \ 62*0Sstevel@tonic-gate (cp)[0] = (value) >> 8; \ 63*0Sstevel@tonic-gate (cp)[1] = (value); } while (0) 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate #ifdef __cplusplus 66*0Sstevel@tonic-gate } 67*0Sstevel@tonic-gate #endif 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate #endif /* _GETPUT_H */ 70