# typedef unsigned short unshort; /* Queue structures */ struct item { struct item *q_fwd; struct item *q_bwd; }; struct que { struct item q_head; int q_items; }; /* VII net header */ struct net_hdr { char v2_dest; /* V2 net dest. addr. */ char v2_src; /* V2 net src addr. */ char v2_prot1; /* MIT protocol hdr word (MPHW) */ char v2_prot2; /* Subfield for MPHW */ short v2_zero; /* Padding */ }; #define NETHSIZ sizeof(struct net_hdr) #define NETMAX 2046 #define INETPROT 1 /* Internet header */ struct inet_hdr { char ip_ihlver; /* Inet hdr length in 32 bit words */ /* Header version */ char ip_tsrv; /* Type of service */ short ip_len; /* Total packet length inc. header */ unshort ip_id; /* Id to help in fragmentation */ unshort ip_frag; /* Fragment offset/flags */ char ip_time; /* Packet time to live in secs */ char ip_prot; /* Protocol number */ unshort ip_chksum; /* Inet hdr chksum */ long ip_src; /* Source name */ long ip_dest; /* Dest. name */ }; #define IPHSIZ sizeof(struct inet_hdr) #define MAXINET 576 /* Standard max. inet pkt size */ #define IP_OPTSZ 40 /* Internet hdr - option max len */ #define IP_VERHL 0x45 /* Version, inet hdr length */ #define IP_TSRV 0 /* Type of service */ #define IP_TIME 250 /* Time to live */ #define IPOPT_SECURITY 0202 /* Security option type id */ #define TCPPROT 6 /* Internet TCP protocol */ /* TCP Header */ struct tcp_hdr { unshort tc_sskt; /* Source socket */ unshort tc_dskt; /* Destination socket */ long tc_seqno; /* Sequence no. */ long tc_ackno; /* Acknowledgement no. */ char tc_off; /* Tcp hdr len in 32 bit wds (left 4 bits) */ char tc_flags; /* Urg/Ack/Psh/Rst/Syn/Fin (right 6 bits) */ unshort tc_window; /* Window size */ unshort tc_cksum; /* Chksum */ unshort tc_urgp; /* Urgent pointer */ }; #define TCPHSIZ sizeof(struct tcp_hdr) #define TELNETICP 23 /* Telnet Tcp well known skt no */ #define TESTICP 9 /* Test TCP well known skt no */ /* Tcp Flags */ #define FIN 01 #define SYN 02 #define RST 04 #define PSH 010 #define ACK 020 #define URG 040 #define RWINDOW 3500 /* Tcp header options */ struct tcp_opt { char tc_okind; char tc_olen; short tc_odata; }; #define TCPOPT_MAXSEG 2 /* Tcp pseudo-header */ struct tcp_phdr { long pt_src; /* Src addr */ long pt_dest; /* Dest addr */ char pt_zero; char pt_prot; /* Protocol */ int pt_len; /* Length - tcp hdr + data */ }; #define PTCPHSIZ sizeof(struct tcp_phdr) /* Tcp state bits */ #define LISTEN 0 #define SYN_SENT 01 #define SYN_ACK 02 #define SYN_RCVD 04 #define FIN_SENT 010 #define FIN_ACK 020 #define FIN_RCVD 040 #define CLOSED2 0100 #define OPEN (SYN_SENT|SYN_ACK|SYN_RCVD) #define CLOSED (FIN_SENT|FIN_ACK|FIN_RCVD)