Changes in uspace/lib/net/netif/netif_skel.c [ee2fa30a:ffa2c8ef] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/netif/netif_skel.c
ree2fa30a rffa2c8ef 61 61 /** Probe the existence of the device. 62 62 * 63 * @param[in] netif_phone Network interface phone. 63 64 * @param[in] device_id Device identifier. 64 65 * @param[in] irq Device interrupt number. … … 70 71 * 71 72 */ 72 static int netif_probe_req_local(device_id_t device_id, int irq, void *io) 73 static int netif_probe_req_local(int netif_phone, device_id_t device_id, 74 int irq, void *io) 73 75 { 74 76 fibril_rwlock_write_lock(&netif_globals.lock); … … 81 83 /** Send the packet queue. 82 84 * 85 * @param[in] netif_phone Network interface phone. 83 86 * @param[in] device_id Device identifier. 84 87 * @param[in] packet Packet queue. … … 90 93 * 91 94 */ 92 static int netif_send_msg_local( device_id_t device_id, packet_t *packet,93 services_t sender)95 static int netif_send_msg_local(int netif_phone, device_id_t device_id, 96 packet_t *packet, services_t sender) 94 97 { 95 98 fibril_rwlock_write_lock(&netif_globals.lock); … … 102 105 /** Start the device. 103 106 * 107 * @param[in] netif_phone Network interface phone. 104 108 * @param[in] device_id Device identifier. 105 109 * … … 111 115 * 112 116 */ 113 static int netif_start_req_local( device_id_t device_id)117 static int netif_start_req_local(int netif_phone, device_id_t device_id) 114 118 { 115 119 fibril_rwlock_write_lock(&netif_globals.lock); … … 124 128 int result = netif_start_message(device); 125 129 if (result > NETIF_NULL) { 126 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 130 int phone = device->nil_phone; 131 nil_device_state_msg(phone, device_id, result); 127 132 fibril_rwlock_write_unlock(&netif_globals.lock); 128 133 return EOK; … … 136 141 /** Stop the device. 137 142 * 143 * @param[in] netif_phone Network interface phone. 138 144 * @param[in] device_id Device identifier. 139 145 * … … 145 151 * 146 152 */ 147 static int netif_stop_req_local( device_id_t device_id)153 static int netif_stop_req_local(int netif_phone, device_id_t device_id) 148 154 { 149 155 fibril_rwlock_write_lock(&netif_globals.lock); … … 158 164 int result = netif_stop_message(device); 159 165 if (result > NETIF_NULL) { 160 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 166 int phone = device->nil_phone; 167 nil_device_state_msg(phone, device_id, result); 161 168 fibril_rwlock_write_unlock(&netif_globals.lock); 162 169 return EOK; … … 212 219 void netif_pq_release(packet_id_t packet_id) 213 220 { 214 pq_release_remote(netif_globals. sess, packet_id);221 pq_release_remote(netif_globals.net_phone, packet_id); 215 222 } 216 223 … … 225 232 packet_t *netif_packet_get_1(size_t content) 226 233 { 227 return packet_get_1_remote(netif_globals. sess, content);234 return packet_get_1_remote(netif_globals.net_phone, content); 228 235 } 229 236 230 237 /** Register the device notification receiver, 231 238 * 232 * Register a network interface layer module as the device239 * Register a network interface layer module as the device 233 240 * notification receiver. 234 241 * 235 * @param[in] sess Session to the network interface layer module. 236 * 237 * @return EOK on success. 242 * @param[in] device_id Device identifier. 243 * @param[in] phone Network interface layer module phone. 244 * 245 * @return EOK on success. 246 * @return ENOENT if there is no such device. 238 247 * @return ELIMIT if there is another module registered. 239 248 * 240 249 */ 241 static int register_message(async_sess_t *sess) 242 { 243 fibril_rwlock_write_lock(&netif_globals.lock); 244 if (netif_globals.nil_sess != NULL) { 245 fibril_rwlock_write_unlock(&netif_globals.lock); 250 static int register_message(device_id_t device_id, int phone) 251 { 252 netif_device_t *device; 253 int rc = find_device(device_id, &device); 254 if (rc != EOK) 255 return rc; 256 257 if (device->nil_phone >= 0) 246 258 return ELIMIT; 247 } 248 249 netif_globals.nil_sess = sess; 250 251 fibril_rwlock_write_unlock(&netif_globals.lock); 259 260 device->nil_phone = phone; 252 261 return EOK; 253 262 } … … 279 288 *count = 0; 280 289 281 if (!IPC_GET_IMETHOD(*call)) 290 switch (IPC_GET_IMETHOD(*call)) { 291 case IPC_M_PHONE_HUNGUP: 282 292 return EOK; 283 293 284 async_sess_t *callback =285 async_callback_receive_start(EXCHANGE_SERIALIZE, call);286 if (callback)287 return register_message(callback);288 289 switch (IPC_GET_IMETHOD(*call)) {290 294 case NET_NETIF_PROBE: 291 return netif_probe_req_local( IPC_GET_DEVICE(*call),295 return netif_probe_req_local(0, IPC_GET_DEVICE(*call), 292 296 NETIF_GET_IRQ(*call), NETIF_GET_IO(*call)); 293 297 298 case IPC_M_CONNECT_TO_ME: 299 fibril_rwlock_write_lock(&netif_globals.lock); 300 301 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call)); 302 303 fibril_rwlock_write_unlock(&netif_globals.lock); 304 return rc; 305 294 306 case NET_NETIF_SEND: 295 rc = packet_translate_remote(netif_globals. sess, &packet,307 rc = packet_translate_remote(netif_globals.net_phone, &packet, 296 308 IPC_GET_PACKET(*call)); 297 309 if (rc != EOK) 298 310 return rc; 299 311 300 return netif_send_msg_local( IPC_GET_DEVICE(*call), packet,312 return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 301 313 IPC_GET_SENDER(*call)); 302 314 303 315 case NET_NETIF_START: 304 return netif_start_req_local( IPC_GET_DEVICE(*call));316 return netif_start_req_local(0, IPC_GET_DEVICE(*call)); 305 317 306 318 case NET_NETIF_STATS: … … 328 340 329 341 case NET_NETIF_STOP: 330 return netif_stop_req_local( IPC_GET_DEVICE(*call));342 return netif_stop_req_local(0, IPC_GET_DEVICE(*call)); 331 343 332 344 case NET_NETIF_GET_ADDR: … … 350 362 * 351 363 */ 352 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall, 353 void *arg) 364 static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall) 354 365 { 355 366 /* … … 374 385 375 386 /* End if said to either by the message or the processing result */ 376 if ((!IPC_GET_IMETHOD(call)) || (res == EHANGUP)) 387 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 388 (res == EHANGUP)) 377 389 return; 378 390 … … 397 409 async_set_client_connection(netif_client_connection); 398 410 399 netif_globals.sess = connect_to_service(SERVICE_NETWORKING); 400 netif_globals.nil_sess = NULL; 411 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 401 412 netif_device_map_initialize(&netif_globals.device_map); 402 413
Note:
See TracChangeset
for help on using the changeset viewer.