1*433d6423SLionel Sambuc /* 2*433d6423SLionel Sambuc net/gen/vjhc.h 3*433d6423SLionel Sambuc 4*433d6423SLionel Sambuc Defines for Van Jacobson TCP/IP Header Compression as defined in RFC-1144 5*433d6423SLionel Sambuc 6*433d6423SLionel Sambuc Created: Nov 15, 1993 by Philip Homburg <philip@cs.vu.nl> 7*433d6423SLionel Sambuc */ 8*433d6423SLionel Sambuc 9*433d6423SLionel Sambuc #ifndef __NET__GEN__VJHC_H__ 10*433d6423SLionel Sambuc #define __NET__GEN__VJHC_H__ 11*433d6423SLionel Sambuc 12*433d6423SLionel Sambuc #define VJHC_FLAG_U 0x01 13*433d6423SLionel Sambuc #define VJHC_FLAG_W 0x02 14*433d6423SLionel Sambuc #define VJHC_FLAG_A 0x04 15*433d6423SLionel Sambuc #define VJHC_FLAG_S 0x08 16*433d6423SLionel Sambuc #define VJHC_FLAG_P 0x10 17*433d6423SLionel Sambuc #define VJHC_FLAG_I 0x20 18*433d6423SLionel Sambuc #define VJHC_FLAG_C 0x40 19*433d6423SLionel Sambuc 20*433d6423SLionel Sambuc #define VJHC_SPEC_I (VJHC_FLAG_S | VJHC_FLAG_W | VJHC_FLAG_U) 21*433d6423SLionel Sambuc #define VJHC_SPEC_D (VJHC_FLAG_S | VJHC_FLAG_A | VJHC_FLAG_W | VJHC_FLAG_U) 22*433d6423SLionel Sambuc #define VJHC_SPEC_MASK (VJHC_FLAG_S | VJHC_FLAG_A | VJHC_FLAG_W | VJHC_FLAG_U) 23*433d6423SLionel Sambuc 24*433d6423SLionel Sambuc #define VJHC_ENCODE(cp, n) \ 25*433d6423SLionel Sambuc { \ 26*433d6423SLionel Sambuc if ((u16_t)(n) >= 256) \ 27*433d6423SLionel Sambuc { \ 28*433d6423SLionel Sambuc *(cp)++= 0; \ 29*433d6423SLionel Sambuc *(cp)++= (n >> 8); \ 30*433d6423SLionel Sambuc *(cp)++= (n); \ 31*433d6423SLionel Sambuc } \ 32*433d6423SLionel Sambuc else \ 33*433d6423SLionel Sambuc *(cp)++= (n); \ 34*433d6423SLionel Sambuc } 35*433d6423SLionel Sambuc 36*433d6423SLionel Sambuc #define VJHC_ENCODEZ(cp, n) \ 37*433d6423SLionel Sambuc { \ 38*433d6423SLionel Sambuc if ((u16_t)(n) == 0 || (u16_t)(n) >= 256) \ 39*433d6423SLionel Sambuc { \ 40*433d6423SLionel Sambuc *(cp)++= 0; \ 41*433d6423SLionel Sambuc *(cp)++= (n >> 8); \ 42*433d6423SLionel Sambuc *(cp)++= (n); \ 43*433d6423SLionel Sambuc } \ 44*433d6423SLionel Sambuc else \ 45*433d6423SLionel Sambuc *(cp)++= (n); \ 46*433d6423SLionel Sambuc } 47*433d6423SLionel Sambuc 48*433d6423SLionel Sambuc #define VJHC_DECODEL(cp, l) \ 49*433d6423SLionel Sambuc { \ 50*433d6423SLionel Sambuc if (*(cp) == 0) \ 51*433d6423SLionel Sambuc { \ 52*433d6423SLionel Sambuc (l)= htonl(ntohl((l)) + (((cp)[1] << 8) | (cp)[2])); \ 53*433d6423SLionel Sambuc (cp) += 3; \ 54*433d6423SLionel Sambuc } \ 55*433d6423SLionel Sambuc else \ 56*433d6423SLionel Sambuc (l)= htonl(ntohl((l)) + (u32_t)*(cp)++); \ 57*433d6423SLionel Sambuc } 58*433d6423SLionel Sambuc 59*433d6423SLionel Sambuc #define VJHC_DECODES(cp, s) \ 60*433d6423SLionel Sambuc { \ 61*433d6423SLionel Sambuc if (*(cp) == 0) \ 62*433d6423SLionel Sambuc { \ 63*433d6423SLionel Sambuc (s)= htons(ntohs((s)) + (((cp)[1] << 8) | (cp)[2])); \ 64*433d6423SLionel Sambuc (cp) += 3; \ 65*433d6423SLionel Sambuc } \ 66*433d6423SLionel Sambuc else \ 67*433d6423SLionel Sambuc (s)= htons(ntohs((s)) + (u16_t)*(cp)++); \ 68*433d6423SLionel Sambuc } 69*433d6423SLionel Sambuc 70*433d6423SLionel Sambuc #define VJHC_DECODEU(cp, s) \ 71*433d6423SLionel Sambuc { \ 72*433d6423SLionel Sambuc if (*(cp) == 0) \ 73*433d6423SLionel Sambuc { \ 74*433d6423SLionel Sambuc (s)= htons(((cp)[1] << 8) | (cp)[2]); \ 75*433d6423SLionel Sambuc (cp) += 3; \ 76*433d6423SLionel Sambuc } \ 77*433d6423SLionel Sambuc else \ 78*433d6423SLionel Sambuc (s)= htons((u16_t)*(cp)++); \ 79*433d6423SLionel Sambuc } 80*433d6423SLionel Sambuc 81*433d6423SLionel Sambuc #endif /* __NET__GEN__VJHC_H__ */ 82*433d6423SLionel Sambuc 83*433d6423SLionel Sambuc /* 84*433d6423SLionel Sambuc * $PchId: vjhc.h,v 1.2 1995/11/17 22:14:46 philip Exp $ 85*433d6423SLionel Sambuc */ 86