Changeset f023251 in mainline for uspace/srv/net/tcp/pdu.c
- Timestamp:
- 2013-09-29T21:06:10Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e948fde
- Parents:
- 13be2583
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/pdu.c
r13be2583 rf023251 145 145 } 146 146 147 static uint16_t tcp_phdr_setup(tcp_pdu_t *pdu, tcp_phdr_t *phdr,147 static ip_ver_t tcp_phdr_setup(tcp_pdu_t *pdu, tcp_phdr_t *phdr, 148 148 tcp_phdr6_t *phdr6) 149 149 { 150 150 addr32_t src_v4; 151 151 addr128_t src_v6; 152 uint16_t src_ af= inet_addr_get(&pdu->src, &src_v4, &src_v6);153 152 uint16_t src_ver = inet_addr_get(&pdu->src, &src_v4, &src_v6); 153 154 154 addr32_t dest_v4; 155 155 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:156 uint16_t dest_ver = inet_addr_get(&pdu->dest, &dest_v4, &dest_v6); 157 158 assert(src_ver == dest_ver); 159 160 switch (src_ver) { 161 case ip_v4: 162 162 phdr->src = host2uint32_t_be(src_v4); 163 163 phdr->dest = host2uint32_t_be(dest_v4); … … 167 167 host2uint16_t_be(pdu->header_size + pdu->text_size); 168 168 break; 169 case AF_INET6:169 case ip_v6: 170 170 host2addr128_t_be(src_v6, phdr6->src); 171 171 host2addr128_t_be(dest_v6, phdr6->dest); … … 178 178 assert(false); 179 179 } 180 181 return src_ af;180 181 return src_ver; 182 182 } 183 183 … … 266 266 tcp_phdr_t phdr; 267 267 tcp_phdr6_t phdr6; 268 269 uint16_t af= tcp_phdr_setup(pdu, &phdr, &phdr6);270 switch ( af) {271 case AF_INET:268 269 ip_ver_t ver = tcp_phdr_setup(pdu, &phdr, &phdr6); 270 switch (ver) { 271 case ip_v4: 272 272 cs_phdr = tcp_checksum_calc(TCP_CHECKSUM_INIT, (void *) &phdr, 273 273 sizeof(tcp_phdr_t)); 274 274 break; 275 case AF_INET6:275 case ip_v6: 276 276 cs_phdr = tcp_checksum_calc(TCP_CHECKSUM_INIT, (void *) &phdr6, 277 277 sizeof(tcp_phdr6_t)); … … 280 280 assert(false); 281 281 } 282 282 283 283 cs_headers = tcp_checksum_calc(cs_phdr, pdu->header, pdu->header_size); 284 284 return tcp_checksum_calc(cs_headers, pdu->text, pdu->text_size);
Note:
See TracChangeset
for help on using the changeset viewer.