Changes in uspace/srv/net/nil/eth/eth.c [0a3fbc7:4ef32e0c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r0a3fbc7 r4ef32e0c 42 42 #include <byteorder.h> 43 43 #include <str.h> 44 #include <err .h>44 #include <errno.h> 45 45 46 46 #include <ipc/ipc.h> … … 196 196 int nil_initialize(int net_phone) 197 197 { 198 ERROR_DECLARE;198 int rc; 199 199 200 200 fibril_rwlock_initialize(ð_globals.devices_lock); … … 208 208 CONVERT_SIZE(uint8_t, char, ETH_ADDR)); 209 209 if (!eth_globals.broadcast_addr) { 210 ERROR_CODE= ENOMEM;210 rc = ENOMEM; 211 211 goto out; 212 212 } 213 if (ERROR_OCCURRED(eth_devices_initialize(ð_globals.devices))) { 213 rc = eth_devices_initialize(ð_globals.devices); 214 if (rc != EOK) { 214 215 free(eth_globals.broadcast_addr); 215 216 goto out; 216 217 } 217 if (ERROR_OCCURRED(eth_protos_initialize(ð_globals.protos))) { 218 rc = eth_protos_initialize(ð_globals.protos); 219 if (rc != EOK) { 218 220 free(eth_globals.broadcast_addr); 219 221 eth_devices_destroy(ð_globals.devices); … … 223 225 fibril_rwlock_write_unlock(ð_globals.devices_lock); 224 226 225 return ERROR_CODE;227 return rc; 226 228 } 227 229 … … 234 236 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall) 235 237 { 236 ERROR_DECLARE;237 238 238 packet_t packet; 239 int rc; 239 240 240 241 while (true) { … … 246 247 break; 247 248 case NET_NIL_RECEIVED: 248 if (ERROR_NONE(packet_translate_remote(249 eth_globals.net_phone, &packet,250 IPC_GET_PACKET(icall)))) {251 ERROR_CODE= nil_received_msg_local(0,249 rc = packet_translate_remote(eth_globals.net_phone, 250 &packet, IPC_GET_PACKET(icall)); 251 if (rc == EOK) { 252 rc = nil_received_msg_local(0, 252 253 IPC_GET_DEVICE(icall), packet, 0); 253 254 } 254 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);255 ipc_answer_0(iid, (ipcarg_t) rc); 255 256 break; 256 257 default: … … 282 283 eth_device_message(device_id_t device_id, services_t service, size_t mtu) 283 284 { 284 ERROR_DECLARE;285 286 285 eth_device_ref device; 287 286 int index; … … 300 299 char *data; 301 300 eth_proto_ref proto; 301 int rc; 302 302 303 303 fibril_rwlock_write_lock(ð_globals.devices_lock); … … 351 351 352 352 configuration = &names[0]; 353 if (ERROR_OCCURRED(net_get_device_conf_req(eth_globals.net_phone, 354 device->device_id, &configuration, count, &data))) { 353 rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id, 354 &configuration, count, &data); 355 if (rc != EOK) { 355 356 fibril_rwlock_write_unlock(ð_globals.devices_lock); 356 357 free(device); 357 return ERROR_CODE;358 return rc; 358 359 } 359 360 if (configuration) { … … 387 388 388 389 // get hardware address 389 if (ERROR_OCCURRED(netif_get_addr_req(device->phone, device->device_id, 390 &device->addr, &device->addr_data))) { 390 rc = netif_get_addr_req(device->phone, device->device_id, &device->addr, 391 &device->addr_data); 392 if (rc != EOK) { 391 393 fibril_rwlock_write_unlock(ð_globals.devices_lock); 392 394 free(device); 393 return ERROR_CODE;395 return rc; 394 396 } 395 397 … … 429 431 static eth_proto_ref eth_process_packet(int flags, packet_t packet) 430 432 { 431 ERROR_DECLARE;432 433 433 eth_header_snap_ref header; 434 434 size_t length; … … 437 437 size_t suffix; 438 438 eth_fcs_ref fcs; 439 uint8_t * data; 439 uint8_t *data; 440 int rc; 440 441 441 442 length = packet_get_data_length(packet); … … 488 489 489 490 if (IS_DUMMY(flags)) { 490 if ( (~compute_crc32(~0U, data, length * 8)) != ntohl(*fcs))491 if (~compute_crc32(~0U, data, length * 8) != ntohl(*fcs)) 491 492 return NULL; 492 493 suffix += sizeof(eth_fcs_t); 493 494 } 494 495 495 if (ERROR_OCCURRED(packet_set_addr(packet,496 header->header. source_address, header->header.destination_address,497 ETH_ADDR)) || ERROR_OCCURRED(packet_trim(packet, prefix, suffix))) {496 rc = packet_set_addr(packet, header->header.source_address, 497 header->header.destination_address, ETH_ADDR); 498 if (rc != EOK) 498 499 return NULL; 499 } 500 501 rc = packet_trim(packet, prefix, suffix); 502 if (rc != EOK) 503 return NULL; 500 504 501 505 return eth_protos_find(ð_globals.protos, type); … … 781 785 eth_send_message(device_id_t device_id, packet_t packet, services_t sender) 782 786 { 783 ERROR_DECLARE;784 785 787 eth_device_ref device; 786 788 packet_t next; 787 789 packet_t tmp; 788 790 int ethertype; 791 int rc; 789 792 790 793 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); … … 804 807 next = packet; 805 808 do { 806 if (ERROR_OCCURRED(eth_prepare_packet(device->flags, next, 807 (uint8_t *) device->addr->value, ethertype, device->mtu))) { 809 rc = eth_prepare_packet(device->flags, next, 810 (uint8_t *) device->addr->value, ethertype, device->mtu); 811 if (rc != EOK) { 808 812 // release invalid packet 809 813 tmp = pq_detach(next); … … 832 836 ipc_call_t *answer, int *answer_count) 833 837 { 834 ERROR_DECLARE;835 836 838 measured_string_ref address; 837 839 packet_t packet; … … 840 842 size_t suffix; 841 843 size_t content; 844 int rc; 842 845 843 846 *answer_count = 0; … … 850 853 IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 851 854 case NET_NIL_SEND: 852 ERROR_PROPAGATE(packet_translate_remote(eth_globals.net_phone, 853 &packet, IPC_GET_PACKET(call))); 855 rc = packet_translate_remote(eth_globals.net_phone, &packet, 856 IPC_GET_PACKET(call)); 857 if (rc != EOK) 858 return rc; 854 859 return eth_send_message(IPC_GET_DEVICE(call), packet, 855 860 IPC_GET_SERVICE(call)); 856 861 case NET_NIL_PACKET_SPACE: 857 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), 858 &addrlen, &prefix, &content, &suffix)); 862 rc = eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen, 863 &prefix, &content, &suffix); 864 if (rc != EOK) 865 return rc; 859 866 IPC_SET_ADDR(answer, addrlen); 860 867 IPC_SET_PREFIX(answer, prefix); … … 864 871 return EOK; 865 872 case NET_NIL_ADDR: 866 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 867 ETH_LOCAL_ADDR, &address)); 873 rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR, 874 &address); 875 if (rc != EOK) 876 return rc; 868 877 return measured_strings_reply(address, 1); 869 878 case NET_NIL_BROADCAST_ADDR: 870 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 871 ETH_BROADCAST_ADDR, &address)); 879 rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR, 880 &address); 881 if (rc != EOK) 882 return EOK; 872 883 return measured_strings_reply(address, 1); 873 884 case IPC_M_CONNECT_TO_ME: … … 923 934 int main(int argc, char *argv[]) 924 935 { 925 ERROR_DECLARE;936 int rc; 926 937 927 938 /* Start the module */ 928 ERROR_PROPAGATE(nil_module_start_standalone(nil_client_connection));929 return EOK;939 rc = nil_module_start_standalone(nil_client_connection); 940 return rc; 930 941 } 931 942
Note:
See TracChangeset
for help on using the changeset viewer.