Changes in uspace/srv/net/udp/pdu.c [12df1f1:f023251] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/pdu.c
r12df1f1 rf023251 85 85 } 86 86 87 static uint16_t udp_phdr_setup(udp_pdu_t *pdu, udp_phdr_t *phdr,87 static ip_ver_t udp_phdr_setup(udp_pdu_t *pdu, udp_phdr_t *phdr, 88 88 udp_phdr6_t *phdr6) 89 89 { 90 90 addr32_t src_v4; 91 91 addr128_t src_v6; 92 uint16_t src_af= inet_addr_get(&pdu->src, &src_v4, &src_v6);93 92 ip_ver_t src_ver = inet_addr_get(&pdu->src, &src_v4, &src_v6); 93 94 94 addr32_t dest_v4; 95 95 addr128_t dest_v6; 96 uint16_t dest_af= inet_addr_get(&pdu->dest, &dest_v4, &dest_v6);97 98 assert(src_ af == dest_af);99 100 switch (src_ af) {101 case AF_INET:96 ip_ver_t dest_ver = inet_addr_get(&pdu->dest, &dest_v4, &dest_v6); 97 98 assert(src_ver == dest_ver); 99 100 switch (src_ver) { 101 case ip_v4: 102 102 phdr->src_addr = host2uint32_t_be(src_v4); 103 103 phdr->dest_addr = host2uint32_t_be(dest_v4); … … 106 106 phdr->udp_length = host2uint16_t_be(pdu->data_size); 107 107 break; 108 case AF_INET6:108 case ip_v6: 109 109 host2addr128_t_be(src_v6, phdr6->src_addr); 110 110 host2addr128_t_be(dest_v6, phdr6->dest_addr); … … 116 116 assert(false); 117 117 } 118 119 return src_ af;118 119 return src_ver; 120 120 } 121 121 … … 136 136 udp_phdr_t phdr; 137 137 udp_phdr6_t phdr6; 138 139 uint16_t af= udp_phdr_setup(pdu, &phdr, &phdr6);140 switch ( af) {141 case AF_INET:138 139 ip_ver_t ver = udp_phdr_setup(pdu, &phdr, &phdr6); 140 switch (ver) { 141 case ip_v4: 142 142 cs_phdr = udp_checksum_calc(UDP_CHECKSUM_INIT, (void *) &phdr, 143 143 sizeof(udp_phdr_t)); 144 144 break; 145 case AF_INET6:145 case ip_v6: 146 146 cs_phdr = udp_checksum_calc(UDP_CHECKSUM_INIT, (void *) &phdr6, 147 147 sizeof(udp_phdr6_t)); … … 150 150 assert(false); 151 151 } 152 152 153 153 return udp_checksum_calc(cs_phdr, pdu->data, pdu->data_size); 154 154 } … … 215 215 return ENOMEM; 216 216 217 npdu->iplink = sp->iplink; 217 218 npdu->src = sp->local.addr; 218 219 npdu->dest = sp->foreign.addr;
Note:
See TracChangeset
for help on using the changeset viewer.