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