Changeset 849ed54 in mainline for uspace/srv/net/nil
- Timestamp:
- 2010-03-30T18:39:04Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7553689
- Parents:
- 7d6fe4db
- Location:
- uspace/srv/net/nil
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/Makefile
r7d6fe4db r849ed54 28 28 # 29 29 30 NET_BASE = ../..31 30 USPACE_PREFIX = ../../../.. 31 LIBS = $(LIBNETIF_PREFIX)/libnetif.a $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 32 EXTRA_CFLAGS = -I$(LIBNETIF_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 32 33 BINARY = eth 33 34 34 35 SOURCES = \ 35 36 eth.c \ 36 eth_module.c \ 37 $(NET_BASE)/checksum.c \ 38 $(NET_BASE)/module.c \ 39 $(NET_BASE)/modules.c \ 40 $(NET_BASE)/net/net_remote.c \ 41 $(NET_BASE)/netif/netif_remote.c \ 42 $(NET_BASE)/structures/measured_strings.c \ 43 $(NET_BASE)/structures/packet/packet.c \ 44 $(NET_BASE)/structures/packet/packet_client.c \ 45 $(NET_BASE)/structures/packet/packet_remote.c 37 eth_module.c 46 38 47 39 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/net/nil/eth/eth.c
r7d6fe4db r849ed54 45 45 #include <ipc/services.h> 46 46 47 #include "../../err.h" 48 #include "../../messages.h" 49 #include "../../modules.h" 50 51 #include "../../include/byteorder.h" 52 #include "../../include/checksum.h" 53 #include "../../include/ethernet_lsap.h" 54 #include "../../include/ethernet_protocols.h" 55 #include "../../include/protocol_map.h" 56 #include "../../include/device.h" 57 #include "../../include/netif_interface.h" 58 #include "../../include/net_interface.h" 59 #include "../../include/nil_interface.h" 60 #include "../../include/il_interface.h" 61 62 #include "../../structures/measured_strings.h" 63 #include "../../structures/packet/packet_client.h" 64 65 #include "../nil_module.h" 47 #include <net_err.h> 48 #include <net_messages.h> 49 #include <net_modules.h> 50 #include <net_byteorder.h> 51 #include <net_checksum.h> 52 #include <ethernet_lsap.h> 53 #include <ethernet_protocols.h> 54 #include <protocol_map.h> 55 #include <net_device.h> 56 #include <netif_interface.h> 57 #include <net_interface.h> 58 #include <nil_interface.h> 59 #include <il_interface.h> 60 #include <adt/measured_strings.h> 61 #include <packet/packet_client.h> 66 62 67 63 #include "eth.h" 68 64 #include "eth_header.h" 65 66 /** The module name. 67 */ 68 #define NAME "Ethernet protocol" 69 69 70 70 /** Reserved packet prefix length. … … 769 769 } 770 770 771 #ifdef CONFIG_NETWORKING_modular 772 773 #include <nil_standalone.h> 774 775 /** Default thread for new connections. 776 * 777 * @param[in] iid The initial message identifier. 778 * @param[in] icall The initial message call structure. 779 * 780 */ 781 static void nil_client_connection(ipc_callid_t iid, ipc_call_t * icall) 782 { 783 /* 784 * Accept the connection 785 * - Answer the first IPC_M_CONNECT_ME_TO call. 786 */ 787 ipc_answer_0(iid, EOK); 788 789 while(true) { 790 ipc_call_t answer; 791 int answer_count; 792 793 /* Clear the answer structure */ 794 refresh_answer(&answer, &answer_count); 795 796 /* Fetch the next message */ 797 ipc_call_t call; 798 ipc_callid_t callid = async_get_call(&call); 799 800 /* Process the message */ 801 int res = nil_module_message(callid, &call, &answer, &answer_count); 802 803 /* End if said to either by the message or the processing result */ 804 if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP)) 805 return; 806 807 /* Answer the message */ 808 answer_call(callid, res, &answer, answer_count); 809 } 810 } 811 812 /** Starts the module. 813 * 814 * @param argc The count of the command line arguments. Ignored parameter. 815 * @param argv The command line parameters. Ignored parameter. 816 * 817 * @returns EOK on success. 818 * @returns Other error codes as defined for each specific module start function. 819 * 820 */ 821 int main(int argc, char *argv[]) 822 { 823 ERROR_DECLARE; 824 825 /* Print the module label */ 826 printf("Task %d - %s\n", task_get_id(), NAME); 827 828 /* Start the module */ 829 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) { 830 printf(" - ERROR %i\n", ERROR_CODE); 831 return ERROR_CODE; 832 } 833 834 return EOK; 835 } 836 837 #endif /* CONFIG_NETWORKING_modular */ 838 771 839 /** @} 772 840 */ -
uspace/srv/net/nil/eth/eth.h
r7d6fe4db r849ed54 41 41 #include <ipc/services.h> 42 42 43 #include "../../include/device.h"44 #include "../../structures/measured_strings.h"43 #include <net_device.h> 44 #include <adt/measured_strings.h> 45 45 46 46 /** Type definition of the Ethernet global data. … … 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.h 166 * @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 149 170 #endif 150 171 -
uspace/srv/net/nil/eth/eth_module.c
r7d6fe4db r849ed54 42 42 #include <ipc/services.h> 43 43 44 #include "../../err.h" 45 #include "../../modules.h" 46 47 #include "../../include/net_interface.h" 48 49 #include "../../structures/packet/packet.h" 50 51 #include "../nil_module.h" 44 #include <net_err.h> 45 #include <net_modules.h> 46 #include <net_interface.h> 47 #include <packet/packet.h> 48 #include <nil_standalone.h> 52 49 53 50 #include "eth.h" 54 55 /** The module name.56 */57 #define NAME "Ethernet protocol"58 59 /** Prints the module name.60 */61 void module_print_name(void);62 51 63 52 /** Starts the Ethernet module. … … 69 58 * @returns Other error codes as defined for the REGISTER_ME() macro function. 70 59 */ 71 int module_start(async_client_conn_t client_connection); 72 73 /** Passes the parameters to the module specific nil_message() function. 74 * @param[in] callid The message identifier. 75 * @param[in] call The message parameters. 76 * @param[out] answer The message answer parameters. 77 * @param[out] answer_count The last parameter for the actual answer in the answer parameter. 78 * @returns EOK on success. 79 * @returns ENOTSUP if the message is not known. 80 * @returns Other error codes as defined for each specific module message function. 81 */ 82 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 83 84 void module_print_name(void){ 85 printf("%s", NAME); 86 } 87 88 int module_start(async_client_conn_t client_connection){ 60 int nil_module_start(async_client_conn_t client_connection){ 89 61 ERROR_DECLARE; 90 62 … … 107 79 } 108 80 109 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 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. 89 */ 90 int nil_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 110 91 return nil_message(callid, call, answer, answer_count); 111 92 } -
uspace/srv/net/nil/nildummy/Makefile
r7d6fe4db r849ed54 28 28 # 29 29 30 NET_BASE = ../..31 30 USPACE_PREFIX = ../../../.. 31 LIBS = $(LIBNETIF_PREFIX)/libnetif.a $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 32 EXTRA_CFLAGS = -I$(LIBNETIF_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 32 33 BINARY = nildummy 33 34 34 35 SOURCES = \ 35 36 nildummy.c \ 36 nildummy_module.c \ 37 $(NET_BASE)/module.c \ 38 $(NET_BASE)/modules.c \ 39 $(NET_BASE)/net/net_remote.c \ 40 $(NET_BASE)/netif/netif_remote.c \ 41 $(NET_BASE)/structures/measured_strings.c \ 42 $(NET_BASE)/structures/packet/packet.c \ 43 $(NET_BASE)/structures/packet/packet_client.c \ 44 $(NET_BASE)/structures/packet/packet_remote.c 37 nildummy_module.c 45 38 46 39 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/net/nil/nildummy/nildummy.c
r7d6fe4db r849ed54 45 45 #include <ipc/services.h> 46 46 47 #include "../../err.h" 48 #include "../../messages.h" 49 #include "../../modules.h" 50 51 #include "../../include/device.h" 52 #include "../../include/netif_interface.h" 53 #include "../../include/nil_interface.h" 54 #include "../../include/il_interface.h" 55 56 #include "../../structures/measured_strings.h" 57 #include "../../structures/packet/packet.h" 58 59 #include "../nil_module.h" 47 #include <net_err.h> 48 #include <net_messages.h> 49 #include <net_modules.h> 50 #include <net_device.h> 51 #include <netif_interface.h> 52 #include <nil_interface.h> 53 #include <il_interface.h> 54 #include <adt/measured_strings.h> 55 #include <packet/packet.h> 56 #include <nil_module.h> 60 57 61 58 #include "nildummy.h" 59 60 /** The module name. 61 */ 62 #define NAME "Dummy nil protocol" 62 63 63 64 /** Default maximum transmission unit. … … 373 374 } 374 375 376 #ifdef CONFIG_NETWORKING_modular 377 378 #include <nil_standalone.h> 379 380 /** Default thread for new connections. 381 * 382 * @param[in] iid The initial message identifier. 383 * @param[in] icall The initial message call structure. 384 * 385 */ 386 static void nil_client_connection(ipc_callid_t iid, ipc_call_t * icall) 387 { 388 /* 389 * Accept the connection 390 * - Answer the first IPC_M_CONNECT_ME_TO call. 391 */ 392 ipc_answer_0(iid, EOK); 393 394 while(true) { 395 ipc_call_t answer; 396 int answer_count; 397 398 /* Clear the answer structure */ 399 refresh_answer(&answer, &answer_count); 400 401 /* Fetch the next message */ 402 ipc_call_t call; 403 ipc_callid_t callid = async_get_call(&call); 404 405 /* Process the message */ 406 int res = nil_module_message(callid, &call, &answer, &answer_count); 407 408 /* End if said to either by the message or the processing result */ 409 if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP)) 410 return; 411 412 /* Answer the message */ 413 answer_call(callid, res, &answer, answer_count); 414 } 415 } 416 417 /** Starts the module. 418 * 419 * @param argc The count of the command line arguments. Ignored parameter. 420 * @param argv The command line parameters. Ignored parameter. 421 * 422 * @returns EOK on success. 423 * @returns Other error codes as defined for each specific module start function. 424 * 425 */ 426 int main(int argc, char *argv[]) 427 { 428 ERROR_DECLARE; 429 430 /* Print the module label */ 431 printf("Task %d - %s\n", task_get_id(), NAME); 432 433 /* Start the module */ 434 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) { 435 printf(" - ERROR %i\n", ERROR_CODE); 436 return ERROR_CODE; 437 } 438 439 return EOK; 440 } 441 442 #endif /* CONFIG_NETWORKING_modular */ 443 375 444 /** @} 376 445 */ -
uspace/srv/net/nil/nildummy/nildummy.h
r7d6fe4db r849ed54 41 41 #include <ipc/services.h> 42 42 43 #include "../../include/device.h"44 #include "../../structures/measured_strings.h"43 #include <net_device.h> 44 #include <adt/measured_strings.h> 45 45 46 46 /** Type definition of the dummy nil global data. -
uspace/srv/net/nil/nildummy/nildummy_module.c
r7d6fe4db r849ed54 42 42 #include <ipc/services.h> 43 43 44 #include "../../err.h" 45 #include "../../modules.h" 46 47 #include "../../include/net_interface.h" 48 49 #include "../../structures/packet/packet.h" 50 51 #include "../nil_module.h" 44 #include <net_err.h> 45 #include <net_modules.h> 46 #include <net_interface.h> 47 #include <packet/packet.h> 48 #include <nil_module.h> 49 #include <nil_standalone.h> 52 50 53 51 #include "nildummy.h" 54 55 /** The module name.56 */57 #define NAME "Dummy nil protocol"58 59 /** Prints the module name.60 */61 void module_print_name(void);62 52 63 53 /** Starts the dummy nil module. … … 69 59 * @returns Other error codes as defined for the REGISTER_ME() macro function. 70 60 */ 71 int module_start(async_client_conn_t client_connection); 72 73 /** Passes the parameters to the module specific nil_message() function. 74 * @param[in] callid The message identifier. 75 * @param[in] call The message parameters. 76 * @param[out] answer The message answer parameters. 77 * @param[out] answer_count The last parameter for the actual answer in the answer parameter. 78 * @returns EOK on success. 79 * @returns ENOTSUP if the message is not known. 80 * @returns Other error codes as defined for each specific module message function. 81 */ 82 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count); 83 84 void module_print_name(void){ 85 printf("%s", NAME); 86 } 87 88 int module_start(async_client_conn_t client_connection){ 61 int nil_module_start(async_client_conn_t client_connection){ 89 62 ERROR_DECLARE; 90 63 … … 107 80 } 108 81 109 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 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 */ 91 int nil_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 110 92 return nil_message(callid, call, answer, answer_count); 111 93 }
Note:
See TracChangeset
for help on using the changeset viewer.