Changeset b7fd2a0 in mainline for uspace/srv/net/ethip
- Timestamp:
- 2018-01-13T03:10:29Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- Location:
- uspace/srv/net/ethip
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/arp.c
r36f0738 rb7fd2a0 50 50 #define ARP_REQUEST_TIMEOUT (3 * 1000 * 1000) 51 51 52 static int arp_send_packet(ethip_nic_t *nic, arp_eth_packet_t *packet);52 static errno_t arp_send_packet(ethip_nic_t *nic, arp_eth_packet_t *packet); 53 53 54 54 void arp_received(ethip_nic_t *nic, eth_frame_t *frame) … … 57 57 58 58 arp_eth_packet_t packet; 59 int rc = arp_pdu_decode(frame->data, frame->size, &packet);59 errno_t rc = arp_pdu_decode(frame->data, frame->size, &packet); 60 60 if (rc != EOK) 61 61 return; … … 94 94 } 95 95 96 int arp_translate(ethip_nic_t *nic, addr32_t src_addr, addr32_t ip_addr,96 errno_t arp_translate(ethip_nic_t *nic, addr32_t src_addr, addr32_t ip_addr, 97 97 addr48_t mac_addr) 98 98 { … … 103 103 } 104 104 105 int rc = atrans_lookup(ip_addr, mac_addr);105 errno_t rc = atrans_lookup(ip_addr, mac_addr); 106 106 if (rc == EOK) 107 107 return EOK; … … 122 122 } 123 123 124 static int arp_send_packet(ethip_nic_t *nic, arp_eth_packet_t *packet)124 static errno_t arp_send_packet(ethip_nic_t *nic, arp_eth_packet_t *packet) 125 125 { 126 int rc;126 errno_t rc; 127 127 void *pdata; 128 128 size_t psize; -
uspace/srv/net/ethip/arp.h
r36f0738 rb7fd2a0 43 43 44 44 extern void arp_received(ethip_nic_t *, eth_frame_t *); 45 extern int arp_translate(ethip_nic_t *, addr32_t, addr32_t, addr48_t);45 extern errno_t arp_translate(ethip_nic_t *, addr32_t, addr32_t, addr48_t); 46 46 47 47 #endif -
uspace/srv/net/ethip/atrans.c
r36f0738 rb7fd2a0 59 59 } 60 60 61 int atrans_add(addr32_t ip_addr, addr48_t mac_addr)61 errno_t atrans_add(addr32_t ip_addr, addr48_t mac_addr) 62 62 { 63 63 ethip_atrans_t *atrans; … … 85 85 } 86 86 87 int atrans_remove(addr32_t ip_addr)87 errno_t atrans_remove(addr32_t ip_addr) 88 88 { 89 89 ethip_atrans_t *atrans; … … 103 103 } 104 104 105 static int atrans_lookup_locked(addr32_t ip_addr, addr48_t mac_addr)105 static errno_t atrans_lookup_locked(addr32_t ip_addr, addr48_t mac_addr) 106 106 { 107 107 ethip_atrans_t *atrans = atrans_find(ip_addr); … … 113 113 } 114 114 115 int atrans_lookup(addr32_t ip_addr, addr48_t mac_addr)115 errno_t atrans_lookup(addr32_t ip_addr, addr48_t mac_addr) 116 116 { 117 int rc;117 errno_t rc; 118 118 119 119 fibril_mutex_lock(&atrans_list_lock); … … 134 134 } 135 135 136 int atrans_lookup_timeout(addr32_t ip_addr, suseconds_t timeout,136 errno_t atrans_lookup_timeout(addr32_t ip_addr, suseconds_t timeout, 137 137 addr48_t mac_addr) 138 138 { 139 139 fibril_timer_t *t; 140 140 bool timedout; 141 int rc;141 errno_t rc; 142 142 143 143 t = fibril_timer_create(NULL); -
uspace/srv/net/ethip/atrans.h
r36f0738 rb7fd2a0 42 42 #include "ethip.h" 43 43 44 extern int atrans_add(addr32_t, addr48_t);45 extern int atrans_remove(addr32_t);46 extern int atrans_lookup(addr32_t, addr48_t);47 extern int atrans_lookup_timeout(addr32_t, suseconds_t, addr48_t);44 extern errno_t atrans_add(addr32_t, addr48_t); 45 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, suseconds_t, addr48_t); 48 48 49 49 #endif -
uspace/srv/net/ethip/ethip.c
r36f0738 rb7fd2a0 53 53 #define NAME "ethip" 54 54 55 static int ethip_open(iplink_srv_t *srv);56 static int ethip_close(iplink_srv_t *srv);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);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);61 static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac);62 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr);63 static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr);55 static errno_t ethip_open(iplink_srv_t *srv); 56 static errno_t ethip_close(iplink_srv_t *srv); 57 static errno_t ethip_send(iplink_srv_t *srv, iplink_sdu_t *sdu); 58 static errno_t ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu); 59 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); 62 static errno_t ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 63 static errno_t ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); 64 64 65 65 static void ethip_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 77 77 }; 78 78 79 static int ethip_init(void)79 static errno_t ethip_init(void) 80 80 { 81 81 async_set_fallback_port_handler(ethip_client_conn, NULL); 82 82 83 int rc = loc_server_register(NAME);83 errno_t rc = loc_server_register(NAME); 84 84 if (rc != EOK) { 85 85 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server."); … … 94 94 } 95 95 96 int ethip_iplink_init(ethip_nic_t *nic)97 { 98 int rc;96 errno_t ethip_iplink_init(ethip_nic_t *nic) 97 { 98 errno_t rc; 99 99 service_id_t sid; 100 100 category_id_t iplink_cat; … … 158 158 } 159 159 160 static int ethip_open(iplink_srv_t *srv)160 static errno_t ethip_open(iplink_srv_t *srv) 161 161 { 162 162 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_open()"); … … 164 164 } 165 165 166 static int ethip_close(iplink_srv_t *srv)166 static errno_t ethip_close(iplink_srv_t *srv) 167 167 { 168 168 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_close()"); … … 170 170 } 171 171 172 static int ethip_send(iplink_srv_t *srv, iplink_sdu_t *sdu)172 static errno_t ethip_send(iplink_srv_t *srv, iplink_sdu_t *sdu) 173 173 { 174 174 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_send()"); … … 177 177 eth_frame_t frame; 178 178 179 int rc = arp_translate(nic, sdu->src, sdu->dest, frame.dest);179 errno_t rc = arp_translate(nic, sdu->src, sdu->dest, frame.dest); 180 180 if (rc != EOK) { 181 181 log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%" … … 201 201 } 202 202 203 static int ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu)203 static errno_t ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu) 204 204 { 205 205 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_send6()"); … … 216 216 void *data; 217 217 size_t size; 218 int rc = eth_pdu_encode(&frame, &data, &size);218 errno_t rc = eth_pdu_encode(&frame, &data, &size); 219 219 if (rc != EOK) 220 220 return rc; … … 226 226 } 227 227 228 int ethip_received(iplink_srv_t *srv, void *data, size_t size)228 errno_t ethip_received(iplink_srv_t *srv, void *data, size_t size) 229 229 { 230 230 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_received(): srv=%p", srv); … … 234 234 235 235 eth_frame_t frame; 236 int rc = eth_pdu_decode(data, size, &frame);236 errno_t rc = eth_pdu_decode(data, size, &frame); 237 237 if (rc != EOK) { 238 238 log_msg(LOG_DEFAULT, LVL_DEBUG, " - eth_pdu_decode failed"); … … 269 269 } 270 270 271 static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu)271 static errno_t ethip_get_mtu(iplink_srv_t *srv, size_t *mtu) 272 272 { 273 273 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_get_mtu()"); … … 276 276 } 277 277 278 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac)278 static errno_t ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac) 279 279 { 280 280 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_get_mac48()"); … … 286 286 } 287 287 288 static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac)288 static errno_t ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac) 289 289 { 290 290 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_set_mac48()"); … … 296 296 } 297 297 298 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr)298 static errno_t ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr) 299 299 { 300 300 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; … … 303 303 } 304 304 305 static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr)305 static errno_t ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr) 306 306 { 307 307 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; … … 312 312 int main(int argc, char *argv[]) 313 313 { 314 int rc;314 errno_t rc; 315 315 316 316 printf(NAME ": HelenOS IP over Ethernet service\n"); -
uspace/srv/net/ethip/ethip.h
r36f0738 rb7fd2a0 116 116 } ethip_atrans_t; 117 117 118 extern int ethip_iplink_init(ethip_nic_t *);119 extern int ethip_received(iplink_srv_t *, void *, size_t);118 extern errno_t ethip_iplink_init(ethip_nic_t *); 119 extern errno_t ethip_received(iplink_srv_t *, void *, size_t); 120 120 121 121 #endif -
uspace/srv/net/ethip/ethip_nic.c
r36f0738 rb7fd2a0 51 51 #include "pdu.h" 52 52 53 static int ethip_nic_open(service_id_t sid);53 static errno_t ethip_nic_open(service_id_t sid); 54 54 static void ethip_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg); 55 55 … … 57 57 static FIBRIL_MUTEX_INITIALIZE(ethip_discovery_lock); 58 58 59 static int ethip_nic_check_new(void)59 static errno_t ethip_nic_check_new(void) 60 60 { 61 61 bool already_known; … … 63 63 service_id_t *svcs; 64 64 size_t count, i; 65 int rc;65 errno_t rc; 66 66 67 67 fibril_mutex_lock(ðip_discovery_lock); … … 147 147 } 148 148 149 static int ethip_nic_open(service_id_t sid)149 static errno_t ethip_nic_open(service_id_t sid) 150 150 { 151 151 bool in_list = false; … … 157 157 return ENOMEM; 158 158 159 int rc = loc_service_get_name(sid, &nic->svc_name);159 errno_t rc = loc_service_get_name(sid, &nic->svc_name); 160 160 if (rc != EOK) { 161 161 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed getting service name."); … … 234 234 uint8_t *addr; 235 235 size_t size; 236 int rc;236 errno_t rc; 237 237 238 238 rc = async_data_write_accept((void **)&addr, false, 0, 0, 0, &size); … … 261 261 ipc_call_t *call) 262 262 { 263 int rc;263 errno_t rc; 264 264 void *data; 265 265 size_t size; … … 324 324 } 325 325 326 int ethip_nic_discovery_start(void)327 { 328 int rc = loc_register_cat_change_cb(ethip_nic_cat_change_cb);326 errno_t ethip_nic_discovery_start(void) 327 { 328 errno_t rc = loc_register_cat_change_cb(ethip_nic_cat_change_cb); 329 329 if (rc != EOK) { 330 330 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering callback for NIC " … … 353 353 } 354 354 355 int ethip_nic_send(ethip_nic_t *nic, void *data, size_t size)356 { 357 int rc;355 errno_t ethip_nic_send(ethip_nic_t *nic, void *data, size_t size) 356 { 357 errno_t rc; 358 358 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_send(size=%zu)", size); 359 359 rc = nic_send_frame(nic->sess, data, size); … … 368 368 * 369 369 */ 370 static int ethip_nic_setup_multicast(ethip_nic_t *nic)370 static errno_t ethip_nic_setup_multicast(ethip_nic_t *nic) 371 371 { 372 372 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_setup_multicast()"); … … 425 425 /* Setup the multicast MAC list */ 426 426 427 int rc = nic_multicast_set_mode(nic->sess, NIC_MULTICAST_LIST,427 errno_t rc = nic_multicast_set_mode(nic->sess, NIC_MULTICAST_LIST, 428 428 mac_list, count); 429 429 … … 432 432 } 433 433 434 int ethip_nic_addr_add(ethip_nic_t *nic, inet_addr_t *addr)434 errno_t ethip_nic_addr_add(ethip_nic_t *nic, inet_addr_t *addr) 435 435 { 436 436 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_add()"); … … 445 445 } 446 446 447 int ethip_nic_addr_remove(ethip_nic_t *nic, inet_addr_t *addr)447 errno_t ethip_nic_addr_remove(ethip_nic_t *nic, inet_addr_t *addr) 448 448 { 449 449 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_remove()"); -
uspace/srv/net/ethip/ethip_nic.h
r36f0738 rb7fd2a0 42 42 #include "ethip.h" 43 43 44 extern int ethip_nic_discovery_start(void);44 extern errno_t ethip_nic_discovery_start(void); 45 45 extern ethip_nic_t *ethip_nic_find_by_iplink_sid(service_id_t); 46 extern int ethip_nic_send(ethip_nic_t *, void *, size_t);47 extern int ethip_nic_addr_add(ethip_nic_t *, inet_addr_t *);48 extern int ethip_nic_addr_remove(ethip_nic_t *, inet_addr_t *);46 extern errno_t ethip_nic_send(ethip_nic_t *, void *, size_t); 47 extern errno_t ethip_nic_addr_add(ethip_nic_t *, inet_addr_t *); 48 extern errno_t ethip_nic_addr_remove(ethip_nic_t *, inet_addr_t *); 49 49 extern ethip_link_addr_t *ethip_nic_addr_find(ethip_nic_t *, inet_addr_t *); 50 50 -
uspace/srv/net/ethip/pdu.c
r36f0738 rb7fd2a0 47 47 48 48 /** Encode Ethernet PDU. */ 49 int eth_pdu_encode(eth_frame_t *frame, void **rdata, size_t *rsize)49 errno_t eth_pdu_encode(eth_frame_t *frame, void **rdata, size_t *rsize) 50 50 { 51 51 void *data; … … 75 75 76 76 /** Decode Ethernet PDU. */ 77 int eth_pdu_decode(void *data, size_t size, eth_frame_t *frame)77 errno_t eth_pdu_decode(void *data, size_t size, eth_frame_t *frame) 78 78 { 79 79 eth_header_t *hdr; … … 106 106 107 107 /** Encode ARP PDU. */ 108 int arp_pdu_encode(arp_eth_packet_t *packet, void **rdata, size_t *rsize)108 errno_t arp_pdu_encode(arp_eth_packet_t *packet, void **rdata, size_t *rsize) 109 109 { 110 110 void *data; … … 149 149 150 150 /** Decode ARP PDU. */ 151 int arp_pdu_decode(void *data, size_t size, arp_eth_packet_t *packet)151 errno_t arp_pdu_decode(void *data, size_t size, arp_eth_packet_t *packet) 152 152 { 153 153 arp_eth_packet_fmt_t *pfmt; -
uspace/srv/net/ethip/pdu.h
r36f0738 rb7fd2a0 40 40 #include "ethip.h" 41 41 42 extern int eth_pdu_encode(eth_frame_t *, void **, size_t *);43 extern int eth_pdu_decode(void *, size_t, eth_frame_t *);44 extern int arp_pdu_encode(arp_eth_packet_t *, void **, size_t *);45 extern int arp_pdu_decode(void *, size_t, arp_eth_packet_t *);42 extern errno_t eth_pdu_encode(eth_frame_t *, void **, size_t *); 43 extern errno_t eth_pdu_decode(void *, size_t, eth_frame_t *); 44 extern errno_t arp_pdu_encode(arp_eth_packet_t *, void **, size_t *); 45 extern errno_t arp_pdu_decode(void *, size_t, arp_eth_packet_t *); 46 46 47 47 #endif
Note:
See TracChangeset
for help on using the changeset viewer.