Changeset b4edc96 in mainline for uspace/srv/net/ethip
- Timestamp:
- 2021-08-08T09:20:20Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3e6bca8
- Parents:
- d5ed54b
- Location:
- uspace/srv/net/ethip
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/arp.c
rd5ed54b rb4edc96 36 36 37 37 #include <errno.h> 38 #include <io/log.h>39 38 #include <inet/iplink_srv.h> 40 39 #include <inet/addr.h> 40 #include <inet/eth_addr.h> 41 #include <io/log.h> 41 42 #include <stdlib.h> 42 43 #include "arp.h" … … 95 96 96 97 errno_t arp_translate(ethip_nic_t *nic, addr32_t src_addr, addr32_t ip_addr, 97 addr48_t *mac_addr)98 eth_addr_t *mac_addr) 98 99 { 99 100 /* Broadcast address */ 100 101 if (ip_addr == addr32_broadcast_all_hosts) { 101 *mac_addr = addr48_broadcast;102 *mac_addr = eth_addr_broadcast; 102 103 return EOK; 103 104 } … … 112 113 packet.sender_hw_addr = nic->mac_addr; 113 114 packet.sender_proto_addr = src_addr; 114 packet.target_hw_addr = addr48_broadcast;115 packet.target_hw_addr = eth_addr_broadcast; 115 116 packet.target_proto_addr = ip_addr; 116 117 -
uspace/srv/net/ethip/arp.h
rd5ed54b rb4edc96 38 38 #define ARP_H_ 39 39 40 #include <inet/addr.h> 41 #include <inet/eth_addr.h> 40 42 #include <inet/iplink_srv.h> 41 #include <inet/addr.h>42 43 #include "ethip.h" 43 44 44 45 extern void arp_received(ethip_nic_t *, eth_frame_t *); 45 extern errno_t arp_translate(ethip_nic_t *, addr32_t, addr32_t, addr48_t *);46 extern errno_t arp_translate(ethip_nic_t *, addr32_t, addr32_t, eth_addr_t *); 46 47 47 48 #endif -
uspace/srv/net/ethip/atrans.c
rd5ed54b rb4edc96 38 38 #include <errno.h> 39 39 #include <fibril_synch.h> 40 #include <inet/eth_addr.h> 40 41 #include <inet/iplink_srv.h> 41 42 #include <stdlib.h> … … 59 60 } 60 61 61 errno_t atrans_add(addr32_t ip_addr, addr48_t *mac_addr)62 errno_t atrans_add(addr32_t ip_addr, eth_addr_t *mac_addr) 62 63 { 63 64 ethip_atrans_t *atrans; … … 103 104 } 104 105 105 static errno_t atrans_lookup_locked(addr32_t ip_addr, addr48_t *mac_addr)106 static errno_t atrans_lookup_locked(addr32_t ip_addr, eth_addr_t *mac_addr) 106 107 { 107 108 ethip_atrans_t *atrans = atrans_find(ip_addr); … … 113 114 } 114 115 115 errno_t atrans_lookup(addr32_t ip_addr, addr48_t *mac_addr)116 errno_t atrans_lookup(addr32_t ip_addr, eth_addr_t *mac_addr) 116 117 { 117 118 errno_t rc; … … 135 136 136 137 errno_t atrans_lookup_timeout(addr32_t ip_addr, usec_t timeout, 137 addr48_t *mac_addr)138 eth_addr_t *mac_addr) 138 139 { 139 140 fibril_timer_t *t; -
uspace/srv/net/ethip/atrans.h
rd5ed54b rb4edc96 38 38 #define ATRANS_H_ 39 39 40 #include <inet/addr.h> 41 #include <inet/eth_addr.h> 40 42 #include <inet/iplink_srv.h> 41 #include <inet/addr.h>42 43 #include "ethip.h" 43 44 44 extern errno_t atrans_add(addr32_t, addr48_t *);45 extern errno_t atrans_add(addr32_t, eth_addr_t *); 45 46 extern errno_t atrans_remove(addr32_t); 46 extern errno_t atrans_lookup(addr32_t, addr48_t *);47 extern errno_t atrans_lookup_timeout(addr32_t, usec_t, addr48_t *);47 extern errno_t atrans_lookup(addr32_t, eth_addr_t *); 48 extern errno_t atrans_lookup_timeout(addr32_t, usec_t, eth_addr_t *); 48 49 49 50 #endif -
uspace/srv/net/ethip/ethip.c
rd5ed54b rb4edc96 39 39 #include <async.h> 40 40 #include <errno.h> 41 #include <inet/eth_addr.h> 41 42 #include <inet/iplink_srv.h> 42 43 #include <io/log.h> … … 58 59 static errno_t ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu); 59 60 static errno_t ethip_get_mtu(iplink_srv_t *srv, size_t *mtu); 60 static errno_t ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac);61 static errno_t ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac);61 static errno_t ethip_get_mac48(iplink_srv_t *srv, eth_addr_t *mac); 62 static errno_t ethip_set_mac48(iplink_srv_t *srv, eth_addr_t *mac); 62 63 static errno_t ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 63 64 static errno_t ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); … … 276 277 } 277 278 278 static errno_t ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac)279 static errno_t ethip_get_mac48(iplink_srv_t *srv, eth_addr_t *mac) 279 280 { 280 281 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_get_mac48()"); … … 286 287 } 287 288 288 static errno_t ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac)289 static errno_t ethip_set_mac48(iplink_srv_t *srv, eth_addr_t *mac) 289 290 { 290 291 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_set_mac48()"); -
uspace/srv/net/ethip/ethip.h
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 40 40 #include <adt/list.h> 41 41 #include <async.h> 42 #include <inet/addr.h> 43 #include <inet/eth_addr.h> 42 44 #include <inet/iplink_srv.h> 43 #include <inet/addr.h>44 45 #include <loc.h> 45 46 #include <stddef.h> … … 61 62 62 63 /** MAC address */ 63 addr48_t mac_addr;64 eth_addr_t mac_addr; 64 65 65 66 /** … … 73 74 typedef struct { 74 75 /** Destination Address */ 75 addr48_t dest;76 eth_addr_t dest; 76 77 /** Source Address */ 77 addr48_t src;78 eth_addr_t src; 78 79 /** Ethertype or Length */ 79 80 uint16_t etype_len; … … 100 101 arp_opcode_t opcode; 101 102 /** Sender hardware address */ 102 addr48_t sender_hw_addr;103 eth_addr_t sender_hw_addr; 103 104 /** Sender protocol address */ 104 105 addr32_t sender_proto_addr; 105 106 /** Target hardware address */ 106 addr48_t target_hw_addr;107 eth_addr_t target_hw_addr; 107 108 /** Target protocol address */ 108 109 addr32_t target_proto_addr; … … 113 114 link_t atrans_list; 114 115 addr32_t ip_addr; 115 addr48_t mac_addr;116 eth_addr_t mac_addr; 116 117 } ethip_atrans_t; 117 118 -
uspace/srv/net/ethip/ethip_nic.c
rd5ed54b rb4edc96 37 37 #include <adt/list.h> 38 38 #include <async.h> 39 #include <stdbool.h>40 39 #include <errno.h> 41 #include <str_error.h>42 40 #include <fibril_synch.h> 41 #include <inet/eth_addr.h> 43 42 #include <inet/iplink_srv.h> 44 43 #include <io/log.h> 45 44 #include <loc.h> 45 #include <mem.h> 46 46 #include <nic_iface.h> 47 #include <stdbool.h> 47 48 #include <stdlib.h> 48 #include < mem.h>49 #include <str_error.h> 49 50 #include "ethip.h" 50 51 #include "ethip_nic.h" … … 193 194 } 194 195 195 mac48_decode(nic_address.address, &nic->mac_addr);196 eth_addr_decode(nic_address.address, &nic->mac_addr); 196 197 197 198 rc = nic_set_state(nic->sess, NIC_STATE_ACTIVE); … … 399 400 assert(i < count); 400 401 401 addr48_t mac;402 addr48_solicited_node(v6, &mac);402 eth_addr_t mac; 403 eth_addr_solicited_node(v6, &mac); 403 404 404 405 /* Avoid duplicate addresses in the list */ … … 407 408 408 409 for (size_t j = 0; j < i; j++) { 409 addr48_t mac_entry;410 mac48_decode(mac_list[j].address, &mac_entry);411 if ( addr48_compare(&mac_entry, &mac)) {410 eth_addr_t mac_entry; 411 eth_addr_decode(mac_list[j].address, &mac_entry); 412 if (eth_addr_compare(&mac_entry, &mac)) { 412 413 found = true; 413 414 break; … … 416 417 417 418 if (!found) { 418 mac48_encode(&mac, mac_list[i].address);419 eth_addr_encode(&mac, mac_list[i].address); 419 420 i++; 420 421 } else { -
uspace/srv/net/ethip/pdu.c
rd5ed54b rb4edc96 60 60 61 61 hdr = (eth_header_t *)data; 62 mac48_encode(&frame->src, hdr->src);63 mac48_encode(&frame->dest, hdr->dest);62 eth_addr_encode(&frame->src, hdr->src); 63 eth_addr_encode(&frame->dest, hdr->dest); 64 64 hdr->etype_len = host2uint16_t_be(frame->etype_len); 65 65 … … 93 93 return ENOMEM; 94 94 95 mac48_decode(hdr->src, &frame->src);96 mac48_decode(hdr->dest, &frame->dest);95 eth_addr_decode(hdr->src, &frame->src); 96 eth_addr_decode(hdr->dest, &frame->dest); 97 97 frame->etype_len = uint16_t_be2host(hdr->etype_len); 98 98 … … 140 140 pfmt->proto_addr_size = IPV4_ADDR_SIZE; 141 141 pfmt->opcode = host2uint16_t_be(fopcode); 142 mac48_encode(&packet->sender_hw_addr, pfmt->sender_hw_addr);142 eth_addr_encode(&packet->sender_hw_addr, pfmt->sender_hw_addr); 143 143 pfmt->sender_proto_addr = 144 144 host2uint32_t_be(packet->sender_proto_addr); 145 mac48_encode(&packet->target_hw_addr, pfmt->target_hw_addr);145 eth_addr_encode(&packet->target_hw_addr, pfmt->target_hw_addr); 146 146 pfmt->target_proto_addr = 147 147 host2uint32_t_be(packet->target_proto_addr); … … 203 203 } 204 204 205 mac48_decode(pfmt->sender_hw_addr, &packet->sender_hw_addr);205 eth_addr_decode(pfmt->sender_hw_addr, &packet->sender_hw_addr); 206 206 packet->sender_proto_addr = 207 207 uint32_t_be2host(pfmt->sender_proto_addr); 208 mac48_decode(pfmt->target_hw_addr, &packet->target_hw_addr);208 eth_addr_decode(pfmt->target_hw_addr, &packet->target_hw_addr); 209 209 packet->target_proto_addr = 210 210 uint32_t_be2host(pfmt->target_proto_addr); -
uspace/srv/net/ethip/pdu.h
rd5ed54b rb4edc96 44 44 extern errno_t arp_pdu_encode(arp_eth_packet_t *, void **, size_t *); 45 45 extern errno_t arp_pdu_decode(void *, size_t, arp_eth_packet_t *); 46 extern void mac48_encode(addr48_t *, void *);47 extern void mac48_decode(void *, addr48_t *);48 46 49 47 #endif
Note:
See TracChangeset
for help on using the changeset viewer.