Changes in uspace/srv/net/netif/lo/lo.c [14f1db0:849ed54] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/netif/lo/lo.c
r14f1db0 r849ed54 51 51 #include <nil_interface.h> 52 52 #include <nil_messages.h> 53 #include <netif _interface.h>54 #include <netif_ local.h>53 #include <netif.h> 54 #include <netif_module.h> 55 55 56 56 /** Default hardware address. … … 64 64 /** Loopback module name. 65 65 */ 66 #define NAME "lo"66 #define NAME "lo - loopback interface" 67 67 68 68 /** Network interface global data. … … 76 76 * @returns EOK otherwise. 77 77 */ 78 int change_state_message( netif_device_t *device, device_state_t state);78 int change_state_message(device_ref device, device_state_t state); 79 79 80 80 /** Creates and returns the loopback network interface structure. … … 85 85 * @returns ENOMEM if there is not enough memory left. 86 86 */ 87 int create(device_id_t device_id, netif_device_t ** device);87 int create(device_id_t device_id, device_ref * device); 88 88 89 89 int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ … … 103 103 ERROR_DECLARE; 104 104 105 netif_device_t *device;105 device_ref device; 106 106 107 107 if(! stats){ … … 113 113 } 114 114 115 int change_state_message(netif_device_t * device, device_state_t state) 116 { 117 if (device->state != state) { 115 int change_state_message(device_ref device, device_state_t state){ 116 if(device->state != state){ 118 117 device->state = state; 119 120 printf("%s: State changed to %s\n", NAME, 121 (state == NETIF_ACTIVE) ? "active" : "stopped"); 122 118 printf("State changed to %s\n", (state == NETIF_ACTIVE) ? "ACTIVE" : "STOPPED"); 123 119 return state; 124 120 } 125 126 return EOK; 127 } 128 129 int create(device_id_t device_id, netif_device_t * * device){ 121 return EOK; 122 } 123 124 int create(device_id_t device_id, device_ref * device){ 130 125 int index; 131 126 132 if( netif_device_map_count(&netif_globals.device_map) > 0){127 if(device_map_count(&netif_globals.device_map) > 0){ 133 128 return EXDEV; 134 129 }else{ 135 *device = ( netif_device_t *) malloc(sizeof(netif_device_t));130 *device = (device_ref) malloc(sizeof(device_t)); 136 131 if(!(*device)){ 137 132 return ENOMEM; … … 146 141 (** device).nil_phone = -1; 147 142 (** device).state = NETIF_STOPPED; 148 index = netif_device_map_add(&netif_globals.device_map, (** device).device_id, * device);143 index = device_map_add(&netif_globals.device_map, (** device).device_id, * device); 149 144 if(index < 0){ 150 145 free(*device); … … 166 161 ERROR_DECLARE; 167 162 168 netif_device_t *device;163 device_ref device; 169 164 170 165 // create a new device 171 166 ERROR_PROPAGATE(create(device_id, &device)); 172 167 // print the settings 173 printf(" %s: Device created (id: %d)\n", NAME, device->device_id);168 printf("New device created:\n\tid\t= %d\n", device->device_id); 174 169 return EOK; 175 170 } … … 178 173 ERROR_DECLARE; 179 174 180 netif_device_t *device;175 device_ref device; 181 176 size_t length; 182 177 packet_t next; … … 204 199 } 205 200 206 int netif_start_message( netif_device_t *device){201 int netif_start_message(device_ref device){ 207 202 return change_state_message(device, NETIF_ACTIVE); 208 203 } 209 204 210 int netif_stop_message( netif_device_t *device){205 int netif_stop_message(device_ref device){ 211 206 return change_state_message(device, NETIF_STOPPED); 212 207 } 213 208 209 #ifdef CONFIG_NETWORKING_modular 210 211 #include <netif_standalone.h> 212 214 213 /** Default thread for new connections. 215 214 * 216 * @param[in] iid The initial message identifier.217 * @param[in] icall The initial message call structure.218 * 219 */ 220 static void netif_client_connection(ipc_callid_t iid, ipc_call_t * icall)215 * @param[in] iid The initial message identifier. 216 * @param[in] icall The initial message call structure. 217 * 218 */ 219 static void netif_client_connection(ipc_callid_t iid, ipc_call_t * icall) 221 220 { 222 221 /* … … 238 237 239 238 /* Process the message */ 240 int res = netif_module_message(NAME, callid, &call, &answer, 241 &answer_count); 239 int res = netif_module_message(callid, &call, &answer, &answer_count); 242 240 243 241 /* End if said to either by the message or the processing result */ … … 250 248 } 251 249 250 /** Starts the module. 251 * 252 * @param argc The count of the command line arguments. Ignored parameter. 253 * @param argv The command line parameters. Ignored parameter. 254 * 255 * @returns EOK on success. 256 * @returns Other error codes as defined for each specific module start function. 257 * 258 */ 252 259 int main(int argc, char *argv[]) 253 260 { 254 261 ERROR_DECLARE; 255 262 263 /* Print the module label */ 264 printf("Task %d - %s\n", task_get_id(), NAME); 265 256 266 /* Start the module */ 257 if (ERROR_OCCURRED(netif_module_start(netif_client_connection))) 267 if (ERROR_OCCURRED(netif_module_start(netif_client_connection))) { 268 printf(" - ERROR %i\n", ERROR_CODE); 258 269 return ERROR_CODE; 259 260 return EOK; 261 } 270 } 271 272 return EOK; 273 } 274 275 #endif /* CONFIG_NETWORKING_modular */ 262 276 263 277 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.