Changeset 4011fa0 in mainline for uspace/srv/net/netstart/netstart.c
- Timestamp:
- 2010-03-31T13:32:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 85c2a4b
- Parents:
- 7553689
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/netstart/netstart.c
r7553689 r4011fa0 28 28 29 29 /** @addtogroup net 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Starts the networking subsystem. 35 * Performs self test if configured to. 36 * @see configuration.h 34 * 35 * Start the networking subsystem. 36 * Perform networking self-test if executed 37 * with the -s argument. 38 * 37 39 */ 40 41 #define NAME "netstart" 38 42 39 43 #include <async.h> 40 44 #include <stdio.h> 41 45 #include <task.h> 42 43 46 #include <ipc/ipc.h> 44 47 #include <ipc/services.h> … … 47 50 #include <net_modules.h> 48 51 #include <net_net_messages.h> 52 49 53 #include "self_test.h" 50 54 51 /** Networking startup module name. 55 /** Start a module. 56 * 57 * @param[in] desc The module description 58 * @param[in] path The module absolute path. 59 * 60 * @returns true on succesful spanwning 61 * @returns false on failure 62 * 52 63 */ 53 #define NAME "Networking startup" 54 55 /** Starts the module. 56 * @param[in] fname The module absolute name. 57 * @returns The started module task identifier. 58 * @returns Other error codes as defined for the task_spawn() function. 59 */ 60 static task_id_t spawn(const char * fname){ 61 const char * argv[2]; 62 task_id_t res; 63 64 argv[0] = fname; 64 static bool spawn(const char *desc, const char *path) 65 { 66 printf("%s: Spawning %s (%s)\n", NAME, desc, path); 67 68 const char *argv[2]; 69 70 argv[0] = path; 65 71 argv[1] = NULL; 66 res = task_spawn(fname, argv);67 72 68 return res; 73 if (task_spawn(path, argv) == 0) { 74 fprintf(stderr, "%s: Error spawning %s\n", NAME, path); 75 return false; 76 } 77 78 return true; 69 79 } 70 80 71 /** Module entry point. 72 * @param[in] argc The number of command line parameters. 73 * @param[in] argv The command line parameters. 74 * @returns EOK on success. 75 * @returns EINVAL if the net module cannot be started. 76 * @returns Other error codes as defined for the self_test() function. 77 * @returns Other error codes as defined for the NET_NET_STARTUP message. 81 /** Network startup entry point. 82 * 83 * @param[in] argc The number of command line parameters. 84 * @param[in] argv The command line parameters. 85 * 86 * @returns EOK on success. 87 * @returns EINVAL if the net module cannot be started. 88 * @returns Other error codes as defined for the self_test() function. 89 * @returns Other error codes as defined for the NET_NET_STARTUP message. 90 * 78 91 */ 79 int main(int argc, char * argv[]){ 92 int main(int argc, char *argv[]) 93 { 80 94 ERROR_DECLARE; 81 82 int net_phone; 83 84 // print the module label 85 printf("Task %d - ", task_get_id()); 86 printf("%s\n", NAME); 87 88 // run self tests 89 ERROR_PROPAGATE(self_test()); 90 91 // start the networking service 92 if(! spawn("/srv/net")){ 93 fprintf(stderr, "Could not spawn net\n"); 95 96 /* Run self-tests */ 97 if ((argc > 1) && (str_cmp(argv[1], "-s") == 0)) 98 ERROR_PROPAGATE(self_test()); 99 100 if (!spawn("networking service", "/srv/net")) 94 101 return EINVAL; 102 103 printf("%s: Initializing networking\n", NAME); 104 105 int net_phone = connect_to_service(SERVICE_NETWORKING); 106 if (ERROR_OCCURRED(ipc_call_sync_0_0(net_phone, NET_NET_STARTUP))) { 107 fprintf(stderr, "%s: Networking error %d\n", NAME, ERROR_CODE); 108 return ERROR_CODE; 95 109 } 96 97 // start the networking 98 net_phone = connect_to_service(SERVICE_NETWORKING); 99 if(ERROR_OCCURRED(ipc_call_sync_0_0(net_phone, NET_NET_STARTUP))){ 100 printf("ERROR %d\n", ERROR_CODE); 101 return ERROR_CODE; 102 }else{ 103 printf("OK\n"); 104 } 105 110 106 111 return EOK; 107 112 }
Note:
See TracChangeset
for help on using the changeset viewer.