Changeset 093c0a1 in mainline
- Timestamp:
- 2010-11-03T20:45:49Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5e9e8b7
- Parents:
- 2e236901
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/nildummy/nildummy.c
r2e236901 r093c0a1 41 41 #include <stdio.h> 42 42 #include <str.h> 43 #include <err.h>44 43 #include <ipc/ipc.h> 45 44 #include <ipc/net.h> … … 82 81 int nil_initialize(int net_phone) 83 82 { 84 ERROR_DECLARE;83 int rc; 85 84 86 85 fibril_rwlock_initialize(&nildummy_globals.devices_lock); … … 91 90 nildummy_globals.net_phone = net_phone; 92 91 nildummy_globals.proto.phone = 0; 93 ERROR_CODE= nildummy_devices_initialize(&nildummy_globals.devices);92 rc = nildummy_devices_initialize(&nildummy_globals.devices); 94 93 95 94 fibril_rwlock_write_unlock(&nildummy_globals.protos_lock); 96 95 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); 97 96 98 return ERROR_CODE;97 return rc; 99 98 } 100 99 … … 107 106 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall) 108 107 { 109 ERROR_DECLARE;110 111 108 packet_t packet; 109 int rc; 112 110 113 111 while (true) { 114 112 switch (IPC_GET_METHOD(*icall)) { 115 113 case NET_NIL_DEVICE_STATE: 116 ERROR_CODE= nil_device_state_msg_local(0,114 rc = nil_device_state_msg_local(0, 117 115 IPC_GET_DEVICE(icall), IPC_GET_STATE(icall)); 118 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);116 ipc_answer_0(iid, (ipcarg_t) rc); 119 117 break; 120 118 121 119 case NET_NIL_RECEIVED: 122 if (ERROR_NONE(packet_translate_remote(123 nildummy_globals.net_phone, &packet,124 IPC_GET_PACKET(icall)))) {125 ERROR_CODE= nil_received_msg_local(0,120 rc = packet_translate_remote(nildummy_globals.net_phone, 121 &packet, IPC_GET_PACKET(icall)); 122 if (rc == EOK) { 123 rc = nil_received_msg_local(0, 126 124 IPC_GET_DEVICE(icall), packet, 0); 127 125 } 128 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);126 ipc_answer_0(iid, (ipcarg_t) rc); 129 127 break; 130 128 … … 155 153 nildummy_device_message(device_id_t device_id, services_t service, size_t mtu) 156 154 { 157 ERROR_DECLARE;158 159 155 nildummy_device_ref device; 160 156 int index; 157 int rc; 161 158 162 159 fibril_rwlock_write_lock(&nildummy_globals.devices_lock); … … 216 213 217 214 // get hardware address 218 if (ERROR_OCCURRED(netif_get_addr_req(device->phone, device->device_id, 219 &device->addr, &device->addr_data))) { 215 rc = netif_get_addr_req(device->phone, device->device_id, &device->addr, 216 &device->addr_data); 217 if (rc != EOK) { 220 218 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); 221 219 free(device); 222 return ERROR_CODE;220 return rc; 223 221 } 224 222 … … 380 378 ipc_call_t *answer, int *answer_count) 381 379 { 382 ERROR_DECLARE;383 384 380 measured_string_ref address; 385 381 packet_t packet; … … 388 384 size_t suffix; 389 385 size_t content; 386 int rc; 390 387 391 388 *answer_count = 0; … … 399 396 400 397 case NET_NIL_SEND: 401 ERROR_PROPAGATE(packet_translate_remote( 402 nildummy_globals.net_phone, &packet, IPC_GET_PACKET(call))); 398 rc = packet_translate_remote(nildummy_globals.net_phone, 399 &packet, IPC_GET_PACKET(call)); 400 if (rc != EOK) 401 return rc; 403 402 return nildummy_send_message(IPC_GET_DEVICE(call), packet, 404 403 IPC_GET_SERVICE(call)); 405 404 406 405 case NET_NIL_PACKET_SPACE: 407 ERROR_PROPAGATE(nildummy_packet_space_message( 408 IPC_GET_DEVICE(call), &addrlen, &prefix, &content, 409 &suffix)); 406 rc = nildummy_packet_space_message(IPC_GET_DEVICE(call), 407 &addrlen, &prefix, &content, &suffix); 408 if (rc != EOK) 409 return rc; 410 410 IPC_SET_ADDR(answer, addrlen); 411 411 IPC_SET_PREFIX(answer, prefix); … … 416 416 417 417 case NET_NIL_ADDR: 418 ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call), 419 &address)); 418 rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address); 419 if (rc != EOK) 420 return rc; 420 421 return measured_strings_reply(address, 1); 421 422 422 423 case NET_NIL_BROADCAST_ADDR: 423 ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call), 424 &address)); 424 rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address); 425 if (rc != EOK) 426 return rc; 425 427 return measured_strings_reply(address, 1); 426 428 … … 476 478 int main(int argc, char *argv[]) 477 479 { 478 ERROR_DECLARE;480 int rc; 479 481 480 482 /* Start the module */ 481 ERROR_PROPAGATE(nil_module_start_standalone(nil_client_connection));482 return EOK;483 rc = nil_module_start_standalone(nil_client_connection); 484 return rc; 483 485 } 484 486
Note:
See TracChangeset
for help on using the changeset viewer.