Changeset b4edc96 in mainline
- Timestamp:
- 2021-08-08T09:20:20Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3e6bca8
- Parents:
- d5ed54b
- Location:
- uspace
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/inet/include/inet/addr.h
rd5ed54b rb4edc96 37 37 38 38 #include <errno.h> 39 #include <inet/eth_addr.h> 39 40 #include <stdint.h> 40 41 41 42 typedef uint32_t addr32_t; 42 43 #define ETH_ADDR_SIZE 644 45 typedef struct {46 uint8_t b[ETH_ADDR_SIZE];47 } addr48_t;48 43 49 44 typedef uint8_t addr128_t[16]; … … 84 79 85 80 extern const addr32_t addr32_broadcast_all_hosts; 86 extern const addr48_t addr48_broadcast;87 81 88 82 extern void addr128(const addr128_t, addr128_t); 89 83 90 extern int addr48_compare(const addr48_t *, const addr48_t *);91 84 extern int addr128_compare(const addr128_t, const addr128_t); 92 93 extern void addr48_solicited_node(const addr128_t, addr48_t *); 85 extern void eth_addr_solicited_node(const addr128_t, eth_addr_t *); 94 86 95 87 extern void host2addr128_t_be(const addr128_t, addr128_t); -
uspace/lib/inet/include/inet/eth_addr.h
rd5ed54b rb4edc96 38 38 #define _LIBC_INET_ETH_ADDR_H_ 39 39 40 // XXX Move addr48 here 41 #include <inet/addr.h> 40 #include <stdint.h> 42 41 43 extern void mac48_encode(addr48_t *, void *); 44 extern void mac48_decode(const void *, addr48_t *); 42 #define ETH_ADDR_SIZE 6 43 44 typedef struct { 45 uint8_t b[ETH_ADDR_SIZE]; 46 } eth_addr_t; 47 48 extern const eth_addr_t eth_addr_broadcast; 49 50 extern void eth_addr_encode(eth_addr_t *, void *); 51 extern void eth_addr_decode(const void *, eth_addr_t *); 52 53 extern int eth_addr_compare(const eth_addr_t *, const eth_addr_t *); 45 54 46 55 #endif -
uspace/lib/inet/include/inet/iplink.h
rd5ed54b rb4edc96 38 38 #include <async.h> 39 39 #include <inet/addr.h> 40 #include <inet/eth_addr.h> 40 41 41 42 struct iplink_ev_ops; … … 62 63 typedef struct { 63 64 /** Local MAC destination address */ 64 addr48_t dest;65 eth_addr_t dest; 65 66 /** Serialized IP packet */ 66 67 void *data; … … 79 80 typedef struct iplink_ev_ops { 80 81 errno_t (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t); 81 errno_t (*change_addr)(iplink_t *, addr48_t *);82 errno_t (*change_addr)(iplink_t *, eth_addr_t *); 82 83 } iplink_ev_ops_t; 83 84 … … 89 90 extern errno_t iplink_addr_remove(iplink_t *, inet_addr_t *); 90 91 extern errno_t iplink_get_mtu(iplink_t *, size_t *); 91 extern errno_t iplink_get_mac48(iplink_t *, addr48_t *);92 extern errno_t iplink_set_mac48(iplink_t *, addr48_t *);92 extern errno_t iplink_get_mac48(iplink_t *, eth_addr_t *); 93 extern errno_t iplink_set_mac48(iplink_t *, eth_addr_t *); 93 94 extern void *iplink_get_userptr(iplink_t *); 94 95 -
uspace/lib/inet/include/inet/iplink_srv.h
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #include <async.h> 39 39 #include <fibril_synch.h> 40 #include <inet/addr.h> 41 #include <inet/eth_addr.h> 42 #include <inet/iplink.h> 40 43 #include <stdbool.h> 41 #include <inet/addr.h>42 #include <inet/iplink.h>43 44 44 45 struct iplink_ops; … … 58 59 errno_t (*send6)(iplink_srv_t *, iplink_sdu6_t *); 59 60 errno_t (*get_mtu)(iplink_srv_t *, size_t *); 60 errno_t (*get_mac48)(iplink_srv_t *, addr48_t *);61 errno_t (*set_mac48)(iplink_srv_t *, addr48_t *);61 errno_t (*get_mac48)(iplink_srv_t *, eth_addr_t *); 62 errno_t (*set_mac48)(iplink_srv_t *, eth_addr_t *); 62 63 errno_t (*addr_add)(iplink_srv_t *, inet_addr_t *); 63 64 errno_t (*addr_remove)(iplink_srv_t *, inet_addr_t *); … … 68 69 extern errno_t iplink_conn(ipc_call_t *, void *); 69 70 extern errno_t iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t); 70 extern errno_t iplink_ev_change_addr(iplink_srv_t *, addr48_t *);71 extern errno_t iplink_ev_change_addr(iplink_srv_t *, eth_addr_t *); 71 72 72 73 #endif -
uspace/lib/inet/include/types/inetcfg.h
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 20 13Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 #define _LIBC_TYPES_INETCFG_H_ 37 37 38 #include <inet/eth_addr.h> 38 39 #include <inet/inet.h> 39 40 #include <stddef.h> … … 56 57 size_t def_mtu; 57 58 /** Link layer address */ 58 addr48_t mac_addr;59 eth_addr_t mac_addr; 59 60 } inet_link_info_t; 60 61 -
uspace/lib/inet/src/addr.c
rd5ed54b rb4edc96 37 37 #include <errno.h> 38 38 #include <inet/addr.h> 39 #include <inet/eth_addr.h> 39 40 #include <stdio.h> 40 41 #include <stddef.h> … … 54 55 const addr32_t addr32_broadcast_all_hosts = 0xffffffff; 55 56 56 const addr48_t addr48_broadcast = { 57 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 58 }; 59 60 static const addr48_t inet_addr48_solicited_node = { 57 static const eth_addr_t inet_eth_addr_solicited_node = { 61 58 0x33, 0x33, 0xff, 0, 0, 0 62 59 }; … … 77 74 } 78 75 79 /** Compare addr48.80 *81 * @return Non-zero if equal, zero if not equal.82 */83 int addr48_compare(const addr48_t *a, const addr48_t *b)84 {85 return memcmp(a->b, b->b, 6) == 0;86 }87 88 76 /** Compare addr128. 89 77 * … … 101 89 * 102 90 */ 103 void addr48_solicited_node(const addr128_t ip, addr48_t *mac)104 { 105 memcpy(&mac->b[0], &inet_ addr48_solicited_node.b[0], 3);91 void eth_addr_solicited_node(const addr128_t ip, eth_addr_t *mac) 92 { 93 memcpy(&mac->b[0], &inet_eth_addr_solicited_node.b[0], 3); 106 94 memcpy(&mac->b[3], ip + 13, 3); 107 95 } -
uspace/lib/inet/src/eth_addr.c
rd5ed54b rb4edc96 38 38 #include <mem.h> 39 39 40 void mac48_encode(addr48_t *addr, void *buf) 40 const eth_addr_t eth_addr_broadcast = { 41 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 42 }; 43 44 void eth_addr_encode(eth_addr_t *addr, void *buf) 41 45 { 42 46 uint8_t *bp = (uint8_t *)buf; … … 45 49 } 46 50 47 void mac48_decode(const void *buf, addr48_t *addr)51 void eth_addr_decode(const void *buf, eth_addr_t *addr) 48 52 { 49 53 const uint8_t *bp = (uint8_t *)buf; … … 52 56 } 53 57 58 /** Compare ethernet addresses. 59 * 60 * @return Non-zero if equal, zero if not equal. 61 */ 62 int eth_addr_compare(const eth_addr_t *a, const eth_addr_t *b) 63 { 64 return memcmp(a->b, b->b, ETH_ADDR_SIZE) == 0; 65 } 66 54 67 /** @} 55 68 */ -
uspace/lib/inet/src/inetcfg.c
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 30 30 #include <assert.h> 31 31 #include <errno.h> 32 #include <inet/eth_addr.h> 32 33 #include <inet/inetcfg.h> 33 34 #include <ipc/inet.h> … … 292 293 aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer); 293 294 aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply); 294 errno_t rc = async_data_read_start(exch, &linfo->mac_addr, sizeof( addr48_t));295 errno_t rc = async_data_read_start(exch, &linfo->mac_addr, sizeof(eth_addr_t)); 295 296 async_wait_for(dreq, &dretval); 296 297 -
uspace/lib/inet/src/iplink.c
rd5ed54b rb4edc96 38 38 #include <assert.h> 39 39 #include <errno.h> 40 #include <inet/addr.h> 41 #include <inet/eth_addr.h> 40 42 #include <inet/iplink.h> 41 #include <inet/addr.h>42 43 #include <ipc/iplink.h> 43 44 #include <ipc/services.h> … … 115 116 aid_t req = async_send_0(exch, IPLINK_SEND6, &answer); 116 117 117 errno_t rc = async_data_write_start(exch, &sdu->dest, sizeof( addr48_t));118 errno_t rc = async_data_write_start(exch, &sdu->dest, sizeof(eth_addr_t)); 118 119 if (rc != EOK) { 119 120 async_exchange_end(exch); … … 153 154 } 154 155 155 errno_t iplink_get_mac48(iplink_t *iplink, addr48_t *mac)156 errno_t iplink_get_mac48(iplink_t *iplink, eth_addr_t *mac) 156 157 { 157 158 async_exch_t *exch = async_exchange_begin(iplink->sess); … … 160 161 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 161 162 162 errno_t rc = async_data_read_start(exch, mac, sizeof( addr48_t));163 errno_t rc = async_data_read_start(exch, mac, sizeof(eth_addr_t)); 163 164 164 165 loc_exchange_end(exch); … … 175 176 } 176 177 177 errno_t iplink_set_mac48(iplink_t *iplink, addr48_t *mac)178 errno_t iplink_set_mac48(iplink_t *iplink, eth_addr_t *mac) 178 179 { 179 180 async_exch_t *exch = async_exchange_begin(iplink->sess); … … 182 183 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 183 184 184 errno_t rc = async_data_read_start(exch, mac, sizeof( addr48_t));185 errno_t rc = async_data_read_start(exch, mac, sizeof(eth_addr_t)); 185 186 186 187 loc_exchange_end(exch); … … 264 265 static void iplink_ev_change_addr(iplink_t *iplink, ipc_call_t *icall) 265 266 { 266 addr48_t *addr;267 eth_addr_t *addr; 267 268 size_t size; 268 269 269 270 errno_t rc = async_data_write_accept((void **) &addr, false, 270 sizeof( addr48_t), sizeof(addr48_t), 0, &size);271 sizeof(eth_addr_t), sizeof(eth_addr_t), 0, &size); 271 272 if (rc != EOK) { 272 273 async_answer_0(icall, rc); -
uspace/lib/inet/src/iplink_srv.c
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 37 37 #include <errno.h> 38 #include <inet/eth_addr.h> 38 39 #include <ipc/iplink.h> 39 40 #include <stdlib.h> … … 51 52 static void iplink_get_mac48_srv(iplink_srv_t *srv, ipc_call_t *icall) 52 53 { 53 addr48_t mac;54 eth_addr_t mac; 54 55 errno_t rc = srv->ops->get_mac48(srv, &mac); 55 56 if (rc != EOK) { … … 66 67 } 67 68 68 if (size != sizeof( addr48_t)) {69 if (size != sizeof(eth_addr_t)) { 69 70 async_answer_0(&call, EINVAL); 70 71 async_answer_0(icall, EINVAL); … … 83 84 errno_t rc; 84 85 size_t size; 85 addr48_t mac;86 eth_addr_t mac; 86 87 87 88 ipc_call_t call; … … 97 98 } 98 99 99 rc = async_data_read_finalize(&call, &mac, sizeof( addr48_t));100 rc = async_data_read_finalize(&call, &mac, sizeof(eth_addr_t)); 100 101 if (rc != EOK) 101 102 async_answer_0(&call, rc); … … 189 190 } 190 191 191 if (size != sizeof( addr48_t)) {192 if (size != sizeof(eth_addr_t)) { 192 193 async_answer_0(&call, EINVAL); 193 194 async_answer_0(icall, EINVAL); … … 322 323 } 323 324 324 errno_t iplink_ev_change_addr(iplink_srv_t *srv, addr48_t *addr)325 errno_t iplink_ev_change_addr(iplink_srv_t *srv, eth_addr_t *addr) 325 326 { 326 327 if (srv->client_sess == NULL) … … 332 333 aid_t req = async_send_0(exch, IPLINK_EV_CHANGE_ADDR, &answer); 333 334 334 errno_t rc = async_data_write_start(exch, addr, sizeof( addr48_t));335 errno_t rc = async_data_write_start(exch, addr, sizeof(eth_addr_t)); 335 336 async_exchange_end(exch); 336 337 -
uspace/srv/net/dhcp/dhcp.c
rd5ed54b rb4edc96 42 42 #include <fibril_synch.h> 43 43 #include <inet/addr.h> 44 #include <inet/eth_addr.h> 44 45 #include <inet/dnsr.h> 45 46 #include <inet/inetcfg.h> … … 157 158 hdr->op = op_bootrequest; 158 159 hdr->htype = 1; /* AHRD_ETHERNET */ 159 hdr->hlen = sizeof(addr48_t);160 hdr->hlen = ETH_ADDR_SIZE; 160 161 hdr->xid = host2uint32_t_be(42); 161 162 hdr->flags = flag_broadcast; -
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 -
uspace/srv/net/inetsrv/addrobj.c
rd5ed54b rb4edc96 38 38 #include <errno.h> 39 39 #include <fibril_synch.h> 40 #include <inet/eth_addr.h> 40 41 #include <io/log.h> 41 42 #include <ipc/loc.h> … … 229 230 230 231 errno_t rc; 231 addr48_t ldest_mac;232 eth_addr_t ldest_mac; 232 233 233 234 switch (ldest_ver) { -
uspace/srv/net/inetsrv/inet_link.c
rd5ed54b rb4edc96 35 35 */ 36 36 37 #include <stdbool.h>38 37 #include <errno.h> 39 #include <str_error.h>40 38 #include <fibril_synch.h> 39 #include <inet/eth_addr.h> 41 40 #include <inet/iplink.h> 42 41 #include <io/log.h> 43 42 #include <loc.h> 43 #include <stdbool.h> 44 44 #include <stdlib.h> 45 45 #include <str.h> 46 #include <str_error.h> 46 47 #include "addrobj.h" 47 48 #include "inetsrv.h" … … 56 57 57 58 static errno_t inet_iplink_recv(iplink_t *, iplink_recv_sdu_t *, ip_ver_t); 58 static errno_t inet_iplink_change_addr(iplink_t *, addr48_t *);59 static errno_t inet_iplink_change_addr(iplink_t *, eth_addr_t *); 59 60 static inet_link_t *inet_link_get_by_id_locked(sysarg_t); 60 61 … … 70 71 { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xfe, 0, 0, 0 }; 71 72 72 static void inet_link_local_node_ip( addr48_t *mac_addr,73 static void inet_link_local_node_ip(eth_addr_t *mac_addr, 73 74 addr128_t ip_addr) 74 75 { … … 121 122 } 122 123 123 static errno_t inet_iplink_change_addr(iplink_t *iplink, addr48_t *mac)124 static errno_t inet_iplink_change_addr(iplink_t *iplink, eth_addr_t *mac) 124 125 { 125 126 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): " … … 129 130 list_foreach(inet_links, link_list, inet_link_t, ilink) { 130 131 if (ilink->sess == iplink->sess) 131 memcpy(&ilink->mac, mac, sizeof(addr48_t));132 ilink->mac = *mac; 132 133 } 133 134 … … 387 388 * 388 389 */ 389 errno_t inet_link_send_dgram6(inet_link_t *ilink, addr48_t *ldest,390 errno_t inet_link_send_dgram6(inet_link_t *ilink, eth_addr_t *ldest, 390 391 inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df) 391 392 { -
uspace/srv/net/inetsrv/inet_link.h
rd5ed54b rb4edc96 38 38 #define INET_LINK_H_ 39 39 40 #include <inet/eth_addr.h> 40 41 #include <stddef.h> 41 42 #include <stdint.h> … … 45 46 extern errno_t inet_link_send_dgram(inet_link_t *, addr32_t, 46 47 addr32_t, inet_dgram_t *, uint8_t, uint8_t, int); 47 extern errno_t inet_link_send_dgram6(inet_link_t *, addr48_t *, inet_dgram_t *,48 extern errno_t inet_link_send_dgram6(inet_link_t *, eth_addr_t *, inet_dgram_t *, 48 49 uint8_t, uint8_t, int); 49 50 extern inet_link_t *inet_link_get_by_id(sysarg_t); -
uspace/srv/net/inetsrv/inetsrv.h
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <stdbool.h> 42 42 #include <inet/addr.h> 43 #include <inet/eth_addr.h> 43 44 #include <inet/iplink.h> 44 45 #include <ipc/loc.h> … … 109 110 iplink_t *iplink; 110 111 size_t def_mtu; 111 addr48_t mac;112 eth_addr_t mac; 112 113 bool mac_valid; 113 114 } inet_link_t; -
uspace/srv/net/inetsrv/ndp.c
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2013 Antonin Steinhauser 3 4 * All rights reserved. … … 36 37 37 38 #include <errno.h> 39 #include <inet/eth_addr.h> 40 #include <io/log.h> 38 41 #include <mem.h> 39 42 #include <stdlib.h> 40 #include <io/log.h>41 43 #include "ntrans.h" 42 44 #include "addrobj.h" … … 151 153 * 152 154 */ 153 errno_t ndp_translate(addr128_t src_addr, addr128_t ip_addr, addr48_t *mac_addr,155 errno_t ndp_translate(addr128_t src_addr, addr128_t ip_addr, eth_addr_t *mac_addr, 154 156 inet_link_t *ilink) 155 157 { … … 170 172 addr128(src_addr, packet.sender_proto_addr); 171 173 addr128(ip_addr, packet.solicited_ip); 172 addr48_solicited_node(ip_addr, &packet.target_hw_addr);174 eth_addr_solicited_node(ip_addr, &packet.target_hw_addr); 173 175 ndp_solicited_node_ip(ip_addr, packet.target_proto_addr); 174 176 -
uspace/srv/net/inetsrv/ndp.h
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2013 Antonin Steinhauser 3 4 * All rights reserved. … … 39 40 40 41 #include <inet/addr.h> 42 #include <inet/eth_addr.h> 41 43 #include "inetsrv.h" 42 44 #include "icmpv6_std.h" … … 52 54 ndp_opcode_t opcode; 53 55 /** Sender hardware address */ 54 addr48_t sender_hw_addr;56 eth_addr_t sender_hw_addr; 55 57 /** Sender protocol address */ 56 58 addr128_t sender_proto_addr; 57 59 /** Target hardware address */ 58 addr48_t target_hw_addr;60 eth_addr_t target_hw_addr; 59 61 /** Target protocol address */ 60 62 addr128_t target_proto_addr; … … 64 66 65 67 extern errno_t ndp_received(inet_dgram_t *); 66 extern errno_t ndp_translate(addr128_t, addr128_t, addr48_t *, inet_link_t *);68 extern errno_t ndp_translate(addr128_t, addr128_t, eth_addr_t *, inet_link_t *); 67 69 68 70 #endif -
uspace/srv/net/inetsrv/ntrans.c
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2013 Antonin Steinhauser 3 4 * All rights reserved. … … 38 39 #include <errno.h> 39 40 #include <fibril_synch.h> 41 #include <inet/eth_addr.h> 40 42 #include <inet/iplink_srv.h> 41 43 #include <stdlib.h> … … 73 75 * 74 76 */ 75 errno_t ntrans_add(addr128_t ip_addr, addr48_t *mac_addr)77 errno_t ntrans_add(addr128_t ip_addr, eth_addr_t *mac_addr) 76 78 { 77 79 inet_ntrans_t *ntrans; … … 134 136 * 135 137 */ 136 errno_t ntrans_lookup(addr128_t ip_addr, addr48_t *mac_addr)138 errno_t ntrans_lookup(addr128_t ip_addr, eth_addr_t *mac_addr) 137 139 { 138 140 fibril_mutex_lock(&ntrans_list_lock); -
uspace/srv/net/inetsrv/ntrans.h
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2013 Antonin Steinhauser 3 4 * All rights reserved. … … 38 39 #define NTRANS_H_ 39 40 41 #include <inet/addr.h> 42 #include <inet/eth_addr.h> 40 43 #include <inet/iplink_srv.h> 41 #include <inet/addr.h>42 44 43 45 /** Address translation table element */ … … 45 47 link_t ntrans_list; 46 48 addr128_t ip_addr; 47 addr48_t mac_addr;49 eth_addr_t mac_addr; 48 50 } inet_ntrans_t; 49 51 50 extern errno_t ntrans_add(addr128_t, addr48_t *);52 extern errno_t ntrans_add(addr128_t, eth_addr_t *); 51 53 extern errno_t ntrans_remove(addr128_t); 52 extern errno_t ntrans_lookup(addr128_t, addr48_t *);54 extern errno_t ntrans_lookup(addr128_t, eth_addr_t *); 53 55 extern errno_t ntrans_wait_timeout(usec_t); 54 56 -
uspace/srv/net/inetsrv/pdu.c
rd5ed54b rb4edc96 505 505 506 506 message->length = 1; 507 mac48_encode(&ndp->sender_hw_addr, message->mac);507 eth_addr_encode(&ndp->sender_hw_addr, message->mac); 508 508 509 509 icmpv6_phdr_t phdr; … … 553 553 554 554 addr128_t_be2host(message->target_address, ndp->target_proto_addr); 555 mac48_decode(message->mac, &ndp->sender_hw_addr);555 eth_addr_decode(message->mac, &ndp->sender_hw_addr); 556 556 557 557 return EOK; -
uspace/srv/net/loopip/loopip.c
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <inet/iplink_srv.h> 42 42 #include <inet/addr.h> 43 #include <inet/eth_addr.h> 43 44 #include <io/log.h> 44 45 #include <loc.h> … … 55 56 static errno_t loopip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu); 56 57 static errno_t loopip_get_mtu(iplink_srv_t *srv, size_t *mtu); 57 static errno_t loopip_get_mac48(iplink_srv_t *srv, addr48_t *mac);58 static errno_t loopip_get_mac48(iplink_srv_t *srv, eth_addr_t *mac); 58 59 static errno_t loopip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 59 60 static errno_t loopip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); … … 231 232 } 232 233 233 static errno_t loopip_get_mac48(iplink_srv_t *src, addr48_t *mac)234 static errno_t loopip_get_mac48(iplink_srv_t *src, eth_addr_t *mac) 234 235 { 235 236 log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip_get_mac48()"); -
uspace/srv/net/slip/slip.c
rd5ed54b rb4edc96 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2013 Jakub Jermar 3 4 * All rights reserved. … … 40 41 #include <loc.h> 41 42 #include <inet/addr.h> 43 #include <inet/eth_addr.h> 42 44 #include <inet/iplink_srv.h> 43 45 #include <io/chardev.h> … … 62 64 static errno_t slip_send6(iplink_srv_t *, iplink_sdu6_t *); 63 65 static errno_t slip_get_mtu(iplink_srv_t *, size_t *); 64 static errno_t slip_get_mac48(iplink_srv_t *, addr48_t *);66 static errno_t slip_get_mac48(iplink_srv_t *, eth_addr_t *); 65 67 static errno_t slip_addr_add(iplink_srv_t *, inet_addr_t *); 66 68 static errno_t slip_addr_remove(iplink_srv_t *, inet_addr_t *); … … 176 178 } 177 179 178 errno_t slip_get_mac48(iplink_srv_t *src, addr48_t *mac)180 errno_t slip_get_mac48(iplink_srv_t *src, eth_addr_t *mac) 179 181 { 180 182 log_msg(LOG_DEFAULT, LVL_DEBUG, "slip_get_mac48()");
Note:
See TracChangeset
for help on using the changeset viewer.