Changeset 3aae4e8 in mainline for uspace/srv/net/netstart/netstart.c
- Timestamp:
- 2010-04-04T22:07:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 23de644
- Parents:
- 9f10660f (diff), 73060801 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/netstart/netstart.c
r9f10660f r3aae4e8 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> 45 48 46 #include "../../err.h"47 #include "../../modules.h"48 #include "../../self_test.h"49 #include <net_err.h> 50 #include <net_modules.h> 51 #include <net_net_messages.h> 49 52 50 #include " ../net_messages.h"53 #include "self_test.h" 51 54 52 /** 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 * 53 63 */ 54 #define NAME "Networking startup" 55 56 /** Module entry point. 57 * @param[in] argc The number of command line parameters. 58 * @param[in] argv The command line parameters. 59 * @returns EOK on success. 60 * @returns EINVAL if the net module cannot be started. 61 * @returns Other error codes as defined for the self_test() function. 62 * @returns Other error codes as defined for the NET_NET_STARTUP message. 63 */ 64 int main(int argc, char * argv[]); 65 66 /** Starts the module. 67 * @param[in] fname The module absolute name. 68 * @returns The started module task identifier. 69 * @returns Other error codes as defined for the task_spawn() function. 70 */ 71 task_id_t spawn(const char * fname); 72 73 int main(int argc, char * argv[]){ 74 ERROR_DECLARE; 75 76 int net_phone; 77 78 // print the module label 79 printf("Task %d - ", task_get_id()); 80 printf("%s\n", NAME); 81 82 // run self tests 83 ERROR_PROPAGATE(self_test()); 84 85 // start the networking service 86 if(! spawn("/srv/net")){ 87 fprintf(stderr, "Could not spawn net\n"); 88 return EINVAL; 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; 71 argv[1] = NULL; 72 73 if (task_spawn(path, argv) == 0) { 74 fprintf(stderr, "%s: Error spawning %s\n", NAME, path); 75 return false; 89 76 } 90 91 // start the networking 92 net_phone = connect_to_service(SERVICE_NETWORKING); 93 if(ERROR_OCCURRED(ipc_call_sync_0_0(net_phone, NET_NET_STARTUP))){ 94 printf("ERROR %d\n", ERROR_CODE); 95 return ERROR_CODE; 96 }else{ 97 printf("OK\n"); 98 } 99 100 return EOK; 77 78 return true; 101 79 } 102 80 103 task_id_t spawn(const char * fname){ 104 const char * argv[2]; 105 task_id_t res; 106 107 argv[0] = fname; 108 argv[1] = NULL; 109 res = task_spawn(fname, argv); 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 * 91 */ 92 int main(int argc, char *argv[]) 93 { 94 ERROR_DECLARE; 110 95 111 return res; 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")) 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; 109 } 110 111 return EOK; 112 112 } 113 113
Note:
See TracChangeset
for help on using the changeset viewer.