Changeset 24ab58b3 in mainline for uspace/srv/net/nil
- Timestamp:
- 2010-04-06T11:41:48Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 14f1db0
- Parents:
- 4dd8529
- Location:
- uspace/srv/net/nil
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r4dd8529 r24ab58b3 60 60 #include <adt/measured_strings.h> 61 61 #include <packet/packet_client.h> 62 #include <nil_module.h> 62 63 63 64 #include "eth.h" … … 66 67 /** The module name. 67 68 */ 68 #define NAME "Ethernet protocol"69 #define NAME "eth" 69 70 70 71 /** Reserved packet prefix length. … … 401 402 return index; 402 403 } 403 printf("New device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n\taddress\t= %X:%X:%X:%X:%X:%X\n\tflags\t= 0x%x\n", device->device_id, device->service, device->mtu, device->addr_data[0], device->addr_data[1], device->addr_data[2], device->addr_data[3], device->addr_data[4], device->addr_data[5], device->flags); 404 printf("%s: Device registered (id: %d, service: %d: mtu: %d, " 405 "mac: %x:%x:%x:%x:%x:%x, flags: 0x%x)\n", 406 NAME, device->device_id, device->service, device->mtu, 407 device->addr_data[0], device->addr_data[1], 408 device->addr_data[2], device->addr_data[3], 409 device->addr_data[4], device->addr_data[5], device->flags); 404 410 } 405 411 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 571 577 } 572 578 } 573 printf("New protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d\n", proto->protocol, proto->service, proto->phone); 579 580 printf("%s: Protocol registered (protocol: %d, service: %d, phone: %d)\n", 581 NAME, proto->protocol, proto->service, proto->phone); 582 574 583 fibril_rwlock_write_unlock(ð_globals.protos_lock); 575 584 return EOK; … … 704 713 } 705 714 706 int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 715 int nil_message(const char *name, ipc_callid_t callid, ipc_call_t *call, 716 ipc_call_t *answer, int *answer_count) 717 { 707 718 ERROR_DECLARE; 708 719 709 720 measured_string_ref address; 710 721 packet_t packet; … … 713 724 size_t suffix; 714 725 size_t content; 715 716 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_NIL_FIRST); 726 717 727 *answer_count = 0; 718 switch (IPC_GET_METHOD(*call)){728 switch (IPC_GET_METHOD(*call)) { 719 729 case IPC_M_PHONE_HUNGUP: 720 730 return EOK; 721 731 case NET_NIL_DEVICE: 722 return eth_device_message(IPC_GET_DEVICE(call), IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 732 return eth_device_message(IPC_GET_DEVICE(call), 733 IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 723 734 case NET_NIL_SEND: 724 ERROR_PROPAGATE(packet_translate(eth_globals.net_phone, &packet, IPC_GET_PACKET(call))); 725 return eth_send_message(IPC_GET_DEVICE(call), packet, IPC_GET_SERVICE(call)); 735 ERROR_PROPAGATE(packet_translate(eth_globals.net_phone, &packet, 736 IPC_GET_PACKET(call))); 737 return eth_send_message(IPC_GET_DEVICE(call), packet, 738 IPC_GET_SERVICE(call)); 726 739 case NET_NIL_PACKET_SPACE: 727 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix)); 740 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), 741 &addrlen, &prefix, &content, &suffix)); 728 742 IPC_SET_ADDR(answer, addrlen); 729 743 IPC_SET_PREFIX(answer, prefix); … … 733 747 return EOK; 734 748 case NET_NIL_ADDR: 735 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR, &address)); 749 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 750 ETH_LOCAL_ADDR, &address)); 736 751 return measured_strings_reply(address, 1); 737 752 case NET_NIL_BROADCAST_ADDR: 738 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR, &address)); 753 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 754 ETH_BROADCAST_ADDR, &address)); 739 755 return measured_strings_reply(address, 1); 740 756 case IPC_M_CONNECT_TO_ME: 741 return eth_register_message(NIL_GET_PROTO(call), IPC_GET_PHONE(call)); 742 } 757 return eth_register_message(NIL_GET_PROTO(call), 758 IPC_GET_PHONE(call)); 759 } 760 743 761 return ENOTSUP; 744 762 } … … 799 817 800 818 /* Process the message */ 801 int res = nil_module_message(callid, &call, &answer, &answer_count); 819 int res = nil_module_message(NAME, callid, &call, &answer, 820 &answer_count); 802 821 803 822 /* End if said to either by the message or the processing result */ … … 823 842 ERROR_DECLARE; 824 843 825 /* Print the module label */826 printf("Task %d - %s\n", task_get_id(), NAME);827 828 844 /* Start the module */ 829 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) { 830 printf(" - ERROR %i\n", ERROR_CODE); 845 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) 831 846 return ERROR_CODE; 832 }833 847 834 848 return EOK; -
uspace/srv/net/nil/eth/eth.h
r4dd8529 r24ab58b3 147 147 }; 148 148 149 /** Module initialization.150 * Is called by the module_start() function.151 * @param[in] net_phone The networking moduel phone.152 * @returns EOK on success.153 * @returns Other error codes as defined for each specific module initialize function.154 */155 extern int nil_initialize(int net_phone);156 157 /** Message processing function.158 * @param[in] callid The message identifier.159 * @param[in] call The message parameters.160 * @param[out] answer The message answer parameters.161 * @param[out] answer_count The last parameter for the actual answer in the answer parameter.162 * @returns EOK on success.163 * @returns ENOTSUP if the message is not known.164 * @returns Other error codes as defined for each specific module message function.165 * @see nil_interface.h166 * @see IS_NET_NIL_MESSAGE()167 */168 extern int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);169 170 149 #endif 171 150 -
uspace/srv/net/nil/eth/eth_module.c
r4dd8529 r24ab58b3 46 46 #include <net_interface.h> 47 47 #include <packet/packet.h> 48 #include <nil_module.h> 48 49 #include <nil_standalone.h> 49 50 … … 79 80 } 80 81 81 /** Passes the parameters to the module specific nil_message() function. 82 * @param[in] callid The message identifier. 83 * @param[in] call The message parameters. 84 * @param[out] answer The message answer parameters. 85 * @param[out] answer_count The last parameter for the actual answer in the answer parameter. 86 * @returns EOK on success. 87 * @returns ENOTSUP if the message is not known. 88 * @returns Other error codes as defined for each specific module message function. 82 /** Pass the parameters to the module specific nil_message() function. 83 * 84 * @param[in] name Module name. 85 * @param[in] callid The message identifier. 86 * @param[in] call The message parameters. 87 * @param[out] answer The message answer parameters. 88 * @param[out] answer_count The last parameter for the actual answer 89 * in the answer parameter. 90 * 91 * @return EOK on success. 92 * @return ENOTSUP if the message is not known. 93 * @return Other error codes as defined for each 94 * specific module message function. 95 * 89 96 */ 90 int nil_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 91 return nil_message(callid, call, answer, answer_count); 97 int nil_module_message(const char *name, ipc_callid_t callid, ipc_call_t *call, 98 ipc_call_t *answer, int *answer_count) 99 { 100 return nil_message(name, callid, call, answer, answer_count); 92 101 } 93 102 -
uspace/srv/net/nil/nildummy/nildummy.c
r4dd8529 r24ab58b3 60 60 /** The module name. 61 61 */ 62 #define NAME "Dummy nil protocol"62 #define NAME "nildummy" 63 63 64 64 /** Default maximum transmission unit. … … 228 228 return index; 229 229 } 230 printf("New device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n", device->device_id, device->service, device->mtu); 230 printf("%s: Device registered (id: %d, service: %d, mtu: %d)\n", 231 NAME, device->device_id, device->service, device->mtu); 231 232 } 232 233 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); … … 290 291 nildummy_globals.proto.service = service; 291 292 nildummy_globals.proto.phone = phone; 292 printf("New protocol registered:\n\tservice\t= %d\n\tphone\t= %d\n", nildummy_globals.proto.service, nildummy_globals.proto.phone); 293 294 printf("%s: Protocol registered (service: %d, phone: %d)\n", 295 NAME, nildummy_globals.proto.service, nildummy_globals.proto.phone); 296 293 297 fibril_rwlock_write_unlock(&nildummy_globals.protos_lock); 294 298 return EOK; … … 312 316 } 313 317 314 int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 318 int nil_message(const char *name, ipc_callid_t callid, ipc_call_t *call, 319 ipc_call_t *answer, int *answer_count) 320 { 315 321 ERROR_DECLARE; 316 322 317 323 measured_string_ref address; 318 324 packet_t packet; … … 321 327 size_t suffix; 322 328 size_t content; 323 324 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_NIL_FIRST); 329 325 330 *answer_count = 0; 326 switch (IPC_GET_METHOD(*call)){331 switch (IPC_GET_METHOD(*call)) { 327 332 case IPC_M_PHONE_HUNGUP: 328 333 return EOK; 329 334 case NET_NIL_DEVICE: 330 return nildummy_device_message(IPC_GET_DEVICE(call), IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 335 return nildummy_device_message(IPC_GET_DEVICE(call), 336 IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 331 337 case NET_NIL_SEND: 332 ERROR_PROPAGATE(packet_translate(nildummy_globals.net_phone, &packet, IPC_GET_PACKET(call))); 333 return nildummy_send_message(IPC_GET_DEVICE(call), packet, IPC_GET_SERVICE(call)); 338 ERROR_PROPAGATE(packet_translate(nildummy_globals.net_phone, 339 &packet, IPC_GET_PACKET(call))); 340 return nildummy_send_message(IPC_GET_DEVICE(call), packet, 341 IPC_GET_SERVICE(call)); 334 342 case NET_NIL_PACKET_SPACE: 335 ERROR_PROPAGATE(nildummy_packet_space_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix)); 343 ERROR_PROPAGATE(nildummy_packet_space_message(IPC_GET_DEVICE(call), 344 &addrlen, &prefix, &content, &suffix)); 336 345 IPC_SET_ADDR(answer, addrlen); 337 346 IPC_SET_PREFIX(answer, prefix); … … 341 350 return EOK; 342 351 case NET_NIL_ADDR: 343 ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call), &address)); 352 ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call), 353 &address)); 344 354 return measured_strings_reply(address, 1); 345 355 case IPC_M_CONNECT_TO_ME: 346 return nildummy_register_message(NIL_GET_PROTO(call), IPC_GET_PHONE(call)); 347 } 356 return nildummy_register_message(NIL_GET_PROTO(call), 357 IPC_GET_PHONE(call)); 358 } 359 348 360 return ENOTSUP; 349 361 } … … 404 416 405 417 /* Process the message */ 406 int res = nil_module_message(callid, &call, &answer, &answer_count); 418 int res = nil_module_message(NAME, callid, &call, &answer, 419 &answer_count); 407 420 408 421 /* End if said to either by the message or the processing result */ … … 428 441 ERROR_DECLARE; 429 442 430 /* Print the module label */431 printf("Task %d - %s\n", task_get_id(), NAME);432 433 443 /* Start the module */ 434 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) { 435 printf(" - ERROR %i\n", ERROR_CODE); 444 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) 436 445 return ERROR_CODE; 437 }438 446 439 447 return EOK; -
uspace/srv/net/nil/nildummy/nildummy_module.c
r4dd8529 r24ab58b3 51 51 #include "nildummy.h" 52 52 53 /** Starts the dummy nil module. 54 * Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop. 55 * @param[in] client_connection The client connection processing function. The module skeleton propagates its own one. 56 * @returns EOK on success. 57 * @returns Other error codes as defined for the pm_init() function. 58 * @returns Other error codes as defined for the nil_initialize() function. 59 * @returns Other error codes as defined for the REGISTER_ME() macro function. 53 /** Start the dummy nil module. 54 * 55 * Initialize the client connection serving function, initialize 56 * the module, register the module service and start the async 57 * manager, processing IPC messages in an infinite loop. 58 * 59 * @param[in] client_connection The client connection processing 60 * function. The module skeleton propagates 61 * its own one. 62 * 63 * @return EOK on success. 64 * @return Other error codes as defined for the pm_init() function. 65 * @return Other error codes as defined for the nil_initialize() function. 66 * @return Other error codes as defined for the REGISTER_ME() macro function. 67 * 60 68 */ 61 int nil_module_start(async_client_conn_t client_connection){ 69 int nil_module_start(async_client_conn_t client_connection) 70 { 62 71 ERROR_DECLARE; 63 72 73 async_set_client_connection(client_connection); 74 int net_phone = net_connect_module(SERVICE_NETWORKING); 75 ERROR_PROPAGATE(pm_init()); 76 64 77 ipcarg_t phonehash; 65 int net_phone; 66 67 async_set_client_connection(client_connection); 68 net_phone = net_connect_module(SERVICE_NETWORKING); 69 ERROR_PROPAGATE(pm_init()); 70 if(ERROR_OCCURRED(nil_initialize(net_phone)) 71 || ERROR_OCCURRED(REGISTER_ME(SERVICE_NILDUMMY, &phonehash))){ 78 if (ERROR_OCCURRED(nil_initialize(net_phone)) 79 || ERROR_OCCURRED(REGISTER_ME(SERVICE_NILDUMMY, &phonehash))){ 72 80 pm_destroy(); 73 81 return ERROR_CODE; 74 82 } 75 83 76 84 async_manager(); 77 85 78 86 pm_destroy(); 79 87 return EOK; 80 88 } 81 89 82 /** Passes the parameters to the module specific nil_message() function. 83 * @param[in] callid The message identifier. 84 * @param[in] call The message parameters. 85 * @param[out] answer The message answer parameters. 86 * @param[out] answer_count The last parameter for the actual answer in the answer parameter. 87 * @returns EOK on success. 88 * @returns ENOTSUP if the message is not known. 89 * @returns Other error codes as defined for each specific module message function. 90 /** Pass the parameters to the module specific nil_message() function. 91 * 92 * @param[in] name Module name. 93 * @param[in] callid The message identifier. 94 * @param[in] call The message parameters. 95 * @param[out] answer The message answer parameters. 96 * @param[out] answer_count The last parameter for the actual answer 97 * in the answer parameter. 98 * 99 * @return EOK on success. 100 * @return ENOTSUP if the message is not known. 101 * @return Other error codes as defined for each specific 102 * module message function. 103 * 90 104 */ 91 int nil_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 92 return nil_message(callid, call, answer, answer_count); 105 int nil_module_message(const char *name, ipc_callid_t callid, 106 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 107 { 108 return nil_message(name, callid, call, answer, answer_count); 93 109 } 94 110
Note:
See TracChangeset
for help on using the changeset viewer.