📄 vjcomp.h
字号:
/** Copyright (c) 1998-2001 by NETsilicon Inc.** This software is copyrighted by and is the sole property of* NETsilicon. All rights, title, ownership, or other interests* in the software remain the property of NETsilicon. This* software may only be used in accordance with the corresponding* license agreement. Any unauthorized use, duplication, transmission,* distribution, or disclosure of this software is expressly forbidden.** This Copyright notice may not be removed or modified without prior* written consent of NETsilicon.** NETsilicon, reserves the right to modify this software* without notice.** NETsilicon* 411 Waverley Oaks Road USA 781.647.1234* Suite 227 http://www.netsilicon.com* Waltham, MA 02452 AmericaSales@netsilicon.com*************************************************************************** $Date: 2001/09/20 10:25:00 $* $Source: M:/psisrc/ppp/incl/rcs/vjcomp.h $* $Revision: 1.15 $************************************************************************** File Description: Header file for routines that call VJ compression * *************************************************************************/#ifndef _VJCOMP_#define _VJCOMP_/* defines to handle special items */#define u_short u16#define u_char u8#define u_int u32#define u_long u32#include "vjcdefs.h"#include "ip.h"struct mbuf { u8 *m_off; /* pointer to start of data */ long m_len; /* length of data */};#define mtod(m, t) ((t)(m->m_off))/* * Bits in first octet of compressed packet *//* flag bits for what changed in a packet */#define NEW_C 0x40#define NEW_I 0x20#define TCP_PUSH_BIT 0x10#define NEW_S 0x08#define NEW_A 0x04#define NEW_W 0x02#define NEW_U 0x01/* reserved, special-case values of above */#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)/* * "state" data for each active tcp conversation on the wire. This is * basically a copy of the entire IP/TCP header from the last packet together * with a small identifier the transmit & receive ends of the line use to * locate saved header. */struct cstate { struct cstate *cs_next; /* next most recently used cstate (xmit only) */ u16 cs_hlen; /* size of hdr (receive only) */ u8 cs_id; /* connection # associated with this state */ u8 cs_filler; union { char hdr[MAX_HDR]; IPH_T csu_ip[SIZEOF_IPH_T]; /* ip/tcp hdr from most recent packet */ } slcs_u;};#define cs_ip slcs_u.csu_ip#define cs_hdr slcs_u.csu_hdr/* * all the state data for one serial line (we need one of these per line). */typedef struct slcompress { struct cstate *last_cs; /* most recently used tstate */ u8 last_recv; /* last rcvd conn. id */ u8 last_xmit; /* last sent conn. id */ u16 flags; struct cstate tstate[MAX_STATES]; /* xmit connection states */ struct cstate rstate[MAX_STATES]; /* receive connection states */} slcompress;/* #define OVBCOPY(a, b, c) memmove(b, a, c) *//* flag values */#define SLF_TOSS 1 /* tossing rcvd frames because of input err *//* * The following macros are used to encode and decode numbers. They all * assume that `cp' points to a buffer where the next byte encoded (decoded) * is to be stored (retrieved). Since the decode routines do arithmetic, * they have to convert from and to network byte order. *//* * ENCODE encodes a number that is known to be non-zero. ENCODEZ checks for * zero (zero has to be encoded in the long, 3 byte form). */#define ENCODE(n) { \ if ((u16)(n) >= 256) { \ *cp++ = 0; \ *cp++ = (u_char)((n) >> 8); \ *cp++ = (u_char)(n); \ } else { \ *cp++ = (u_char)(n); \ } \}#define ENCODEZ(n) { \ if ((u16)(n) >= 256 || (u_short)(n) == 0) { \ *cp++ = 0; \ *cp++ = (u_char)((n) >> 8); \ *cp++ = (u_char)(n); \ } else { \ *cp++ = (u_char)(n); \ } \}/* * DECODEL takes the (compressed) change at byte cp and adds it to the * current value of packet field 'f' (which must be a 4-byte (long) integer * in network byte order). DECODES does the same for a 2-byte (short) field. * DECODEU takes the change at cp and stuffs it into the (short) field f. * 'cp' is updated to point to the next field in the compressed header. */#define DECODEL(f) { \ if (*cp == 0) {\ HostToNet32 ((f), NetToHost32((f)) + (((u32)cp[1] << 8) | (u32)cp[2])); \ cp += 3; \ } else { \ HostToNet32 ((f), NetToHost32((f)) + (u32)*cp++); \ } \}#define DECODES(f) { \ if (*cp == 0) {\ HostToNet16 ((f), (u16)(NetToHost16((f)) + (u16)(((u16)cp[1] << 8) | (u16)cp[2]))); \ cp += 3; \ } else { \ HostToNet16 ((f), (u16)(NetToHost16((f)) + (u16)*cp++)); \ } \}#define DECODEU(f) { \ if (*cp == (u8)0) {\ HostToNet16 ((f), (u16)((u16)(cp[1] << 8) | (u16)cp[2])); \ cp += (u8)3; \ } else { \ HostToNet16 ((f), (u16)*cp++); \ } \}extern int is_tcpip(char *bufp);extern char *fns_compress(char *bufp, u16 *len, u8 *mtype, u8 comp_cid, slcompress *slcomp);extern char *fns_uncompress(u8 *bufp, u16 len, int mtype, slcompress * slcomp);extern void sl_compress_init(slcompress *comp);#endif /* _VJCOMP_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -