Changes in uspace/srv/net/tcp/pdu.c [12df1f1:5a324d99] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/pdu.c
r12df1f1 r5a324d99 40 40 #include <mem.h> 41 41 #include <stdlib.h> 42 #include <net/socket_codes.h>43 42 #include "pdu.h" 44 43 #include "segment.h" … … 145 144 } 146 145 147 static uint16_t tcp_phdr_setup(tcp_pdu_t *pdu, tcp_phdr_t *phdr,146 static ip_ver_t tcp_phdr_setup(tcp_pdu_t *pdu, tcp_phdr_t *phdr, 148 147 tcp_phdr6_t *phdr6) 149 148 { 150 149 addr32_t src_v4; 151 150 addr128_t src_v6; 152 uint16_t src_ af= inet_addr_get(&pdu->src, &src_v4, &src_v6);153 151 uint16_t src_ver = inet_addr_get(&pdu->src, &src_v4, &src_v6); 152 154 153 addr32_t dest_v4; 155 154 addr128_t dest_v6; 156 uint16_t dest_ af= inet_addr_get(&pdu->dest, &dest_v4, &dest_v6);157 158 assert(src_ af == dest_af);159 160 switch (src_ af) {161 case AF_INET:155 uint16_t dest_ver = inet_addr_get(&pdu->dest, &dest_v4, &dest_v6); 156 157 assert(src_ver == dest_ver); 158 159 switch (src_ver) { 160 case ip_v4: 162 161 phdr->src = host2uint32_t_be(src_v4); 163 162 phdr->dest = host2uint32_t_be(dest_v4); … … 167 166 host2uint16_t_be(pdu->header_size + pdu->text_size); 168 167 break; 169 case AF_INET6:168 case ip_v6: 170 169 host2addr128_t_be(src_v6, phdr6->src); 171 170 host2addr128_t_be(dest_v6, phdr6->dest); … … 178 177 assert(false); 179 178 } 180 181 return src_ af;179 180 return src_ver; 182 181 } 183 182 … … 266 265 tcp_phdr_t phdr; 267 266 tcp_phdr6_t phdr6; 268 269 uint16_t af= tcp_phdr_setup(pdu, &phdr, &phdr6);270 switch ( af) {271 case AF_INET:267 268 ip_ver_t ver = tcp_phdr_setup(pdu, &phdr, &phdr6); 269 switch (ver) { 270 case ip_v4: 272 271 cs_phdr = tcp_checksum_calc(TCP_CHECKSUM_INIT, (void *) &phdr, 273 272 sizeof(tcp_phdr_t)); 274 273 break; 275 case AF_INET6:274 case ip_v6: 276 275 cs_phdr = tcp_checksum_calc(TCP_CHECKSUM_INIT, (void *) &phdr6, 277 276 sizeof(tcp_phdr6_t)); … … 280 279 assert(false); 281 280 } 282 281 283 282 cs_headers = tcp_checksum_calc(cs_phdr, pdu->header, pdu->header_size); 284 283 return tcp_checksum_calc(cs_headers, pdu->text, pdu->text_size);
Note:
See TracChangeset
for help on using the changeset viewer.