This source file includes following definitions.
- exp_getu16
- exp_getn16
- imp_putu16
- imp_putn16
- exp_getu32
- exp_getn32
- imp_putu32
- imp_putn32
- ip_explode
- icmp_explode
- igmp_explode
- tcp_explode
- udp_explode
1
2
3
4
5
6
7
8
9
10
11
12
13 extern __inline__ unsigned char *exp_getu16(unsigned char *bp, unsigned short *u)
14 {
15 *u=(*bp<<8)|bp[1];
16 return bp+2;
17 }
18
19 extern __inline__ unsigned char *exp_getn16(unsigned char *bp, unsigned short *u)
20 {
21 unsigned char *tp=(unsigned char *)u;
22 *tp++=*bp++;
23 *tp++=*bp++;
24 return bp;
25 }
26
27 extern __inline__ unsigned char *imp_putu16(unsigned char *bp, unsigned short n)
28 {
29 *bp=(n>>8);
30 bp[1]=n&0xFF;
31 return bp+2;
32 }
33
34 extern __inline__ unsigned char *imp_putn16(unsigned char *bp, unsigned short n)
35 {
36 unsigned char *sp=(unsigned char *)&n;
37 *bp++=*sp++;
38 *bp++=*sp++;
39 return bp;
40 }
41
42 extern __inline__ unsigned char *exp_getu32(unsigned char *bp, unsigned long *u)
43 {
44 *u=(bp[0]<<24)|(bp[1]<<16)|(bp[2]<<8)|bp[3];
45 return bp+4;
46 }
47
48 extern __inline__ unsigned char *exp_getn32(unsigned char *bp, unsigned long *u)
49 {
50 unsigned char *tp=(unsigned char *)u;
51 *tp++=*bp++;
52 *tp++=*bp++;
53 *tp++=*bp++;
54 *tp++=*bp++;
55 return bp;
56 }
57
58 extern __inline__ unsigned char *imp_putu32(unsigned char *bp, unsigned long n)
59 {
60 bp[0]=n>>24;
61 bp[1]=(n>>16)&0xFF;
62 bp[2]=(n>>8)&0xFF;
63 bp[3]=n&0xFF;
64 return bp+4;
65 }
66
67 extern __inline__ unsigned char *imp_putn32(unsigned char *bp, unsigned long n)
68 {
69 unsigned char *sp=(unsigned char *)&n;
70 *bp++=*sp++;
71 *bp++=*sp++;
72 *bp++=*sp++;
73 *bp++=*sp++;
74 return bp;
75 }
76
77 #if 0
78
79 extern __inline__ unsigned char *ip_explode(unsigned char *iph, struct ip_header *ip)
80 {
81 ip->version=*iph>>4;
82 ip->ihl=(*iph++)&0xF;
83 ip->tos=*iph++;
84 iph=exp_getu16(iph,&ip->tot_len);
85 iph=exp_getu16(iph,&ip->id);
86 iph=exp_getu16(iph,&ip->frag_off);
87 ip->ttl=*iph++;
88 ip->protocol=*iph++;
89 iph=exp_getn16(iph,&ip->check);
90 iph=exp_getn32(iph,&ip->saddr);
91 iph=exp_getn32(iph,&ip->daddr);
92 return iph;
93 }
94
95 extern __inline__ unsigned char *icmp_explode(unsigned char *icmph, struct icmp_header *icmp)
96 {
97 icmp->type=*icmp++;
98 icmp->code=*icmp++;
99 icmph=exp_getn16(icmph,&icmp->checksum);
100
101 exp_getu32(icmph,&icmp->gateway);
102 icmph=exp_getu16(icmph,&icmp->id);
103 icmph=exp_getu16(icmph,&icmp->sequence);
104 return icmph;
105 }
106
107 #endif
108
109 extern __inline__ unsigned char *igmp_explode(unsigned char *igmph, struct igmp_header *igmp)
110 {
111 igmp->type=*igmph++;
112 igmph++;
113 igmph=exp_getn16(igmph,&igmp->csum);
114 igmph=exp_getn32(igmph,&igmp->group);
115 return igmph;
116 }
117
118 #if 0
119 extern __inline__ unsigned char *tcp_explode(unsigned char *tcph, struct tcp_header *tcp)
120 {
121 tcph=exp_getu16(tcph,&tcp->source);
122 tcph=exp_getu16(tcph,&tcp->dest);
123 tcph=exp_getu32(tcph,&tcp->seq);
124 tcph=exp_getu32(tcph,&tcp->ack_seq);
125 tcph=exp_getu16(tcph,&tcp->u.bitmask);
126 tcph=exp_getu16(tcph,&tcp->window);
127 tcph=exp_getn16(tcph,&tcp->check);
128 tcph=exp_getu16(tcph,&tcp->urg_ptr);
129 return tcph;
130 }
131
132 extern __inline__ unsigned char *udp_explode(unsigned char *udph, struct udp_header *udp)
133 {
134 udph=exp_getu16(tcph,&udp->source);
135 udph=exp_getu16(udph,&udp->dest);
136 udph=exp_getu16(udph,&udp->len);
137 udph=exp_getn16(udph,&udp->check);
138 return udph;
139 }
140 #endif