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