Changeset b86a32e in mainline for uspace/srv/net/ethip/ethip.c
- Timestamp:
- 2013-07-15T12:14:55Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c84146d3
- Parents:
- 87159eb8 (diff), 956d4281 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/ethip.c
r87159eb8 rb86a32e 56 56 static int ethip_close(iplink_srv_t *srv); 57 57 static int ethip_send(iplink_srv_t *srv, iplink_sdu_t *sdu); 58 static int ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu); 58 59 static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu); 60 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac); 59 61 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 60 62 static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); … … 66 68 .close = ethip_close, 67 69 .send = ethip_send, 70 .send6 = ethip_send6, 68 71 .get_mtu = ethip_get_mtu, 72 .get_mac48 = ethip_get_mac48, 69 73 .addr_add = ethip_addr_add, 70 74 .addr_remove = ethip_addr_remove … … 169 173 170 174 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 171 172 addr32_t src_v4;173 addr128_t src_v6;174 uint16_t src_af = inet_addr_get(&sdu->src, &src_v4, &src_v6);175 176 addr32_t dest_v4;177 addr128_t dest_v6;178 uint16_t dest_af = inet_addr_get(&sdu->dest, &dest_v4, &dest_v6);179 180 if (src_af != dest_af)181 return EINVAL;182 183 int rc;184 175 eth_frame_t frame; 185 176 186 switch (src_af) { 187 case AF_INET: 188 rc = arp_translate(nic, src_v4, dest_v4, frame.dest); 189 if (rc != EOK) { 190 log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%" 191 PRIx32, dest_v4); 192 return rc; 193 } 194 195 addr48(nic->mac_addr, frame.src); 196 frame.etype_len = ETYPE_IP; 197 frame.data = sdu->data; 198 frame.size = sdu->size; 199 200 break; 201 case AF_INET6: 202 // FIXME TODO 203 return ENOTSUP; 204 default: 205 return EINVAL; 206 } 177 int rc = arp_translate(nic, sdu->src, sdu->dest, frame.dest); 178 if (rc != EOK) { 179 log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%" 180 PRIx32, sdu->dest); 181 return rc; 182 } 183 184 addr48(nic->mac_addr, frame.src); 185 frame.etype_len = ETYPE_IP; 186 frame.data = sdu->data; 187 frame.size = sdu->size; 207 188 208 189 void *data; 209 190 size_t size; 210 191 rc = eth_pdu_encode(&frame, &data, &size); 192 if (rc != EOK) 193 return rc; 194 195 rc = ethip_nic_send(nic, data, size); 196 free(data); 197 198 return rc; 199 } 200 201 static int ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu) 202 { 203 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_send6()"); 204 205 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 206 eth_frame_t frame; 207 208 addr48(sdu->dest, frame.dest); 209 addr48(nic->mac_addr, frame.src); 210 frame.etype_len = ETYPE_IPV6; 211 frame.data = sdu->data; 212 frame.size = sdu->size; 213 214 void *data; 215 size_t size; 216 int rc = eth_pdu_encode(&frame, &data, &size); 211 217 if (rc != EOK) 212 218 return rc; … … 268 274 } 269 275 276 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac) 277 { 278 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_get_mac48()"); 279 280 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 281 addr48(nic->mac_addr, *mac); 282 283 return EOK; 284 } 285 270 286 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr) 271 287 {
Note:
See TracChangeset
for help on using the changeset viewer.