Changes in uspace/lib/net/netif/netif_skel.c [9934f7d:ee2fa30a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/netif/netif_skel.c
r9934f7d ree2fa30a 54 54 #include <nil_remote.h> 55 55 56 // FIXME: remove this header57 #include <kernel/ipc/ipc_methods.h>58 59 56 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); 60 57 … … 64 61 /** Probe the existence of the device. 65 62 * 66 * @param[in] netif_phone Network interface phone.67 63 * @param[in] device_id Device identifier. 68 64 * @param[in] irq Device interrupt number. … … 74 70 * 75 71 */ 76 static int netif_probe_req_local(int netif_phone, device_id_t device_id, 77 int irq, void *io) 72 static int netif_probe_req_local(device_id_t device_id, int irq, void *io) 78 73 { 79 74 fibril_rwlock_write_lock(&netif_globals.lock); … … 86 81 /** Send the packet queue. 87 82 * 88 * @param[in] netif_phone Network interface phone.89 83 * @param[in] device_id Device identifier. 90 84 * @param[in] packet Packet queue. … … 96 90 * 97 91 */ 98 static int netif_send_msg_local( int netif_phone, device_id_t device_id,99 packet_t *packet,services_t sender)92 static int netif_send_msg_local(device_id_t device_id, packet_t *packet, 93 services_t sender) 100 94 { 101 95 fibril_rwlock_write_lock(&netif_globals.lock); … … 108 102 /** Start the device. 109 103 * 110 * @param[in] netif_phone Network interface phone.111 104 * @param[in] device_id Device identifier. 112 105 * … … 118 111 * 119 112 */ 120 static int netif_start_req_local( int netif_phone,device_id_t device_id)113 static int netif_start_req_local(device_id_t device_id) 121 114 { 122 115 fibril_rwlock_write_lock(&netif_globals.lock); … … 131 124 int result = netif_start_message(device); 132 125 if (result > NETIF_NULL) { 133 int phone = device->nil_phone; 134 nil_device_state_msg(phone, device_id, result); 126 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 135 127 fibril_rwlock_write_unlock(&netif_globals.lock); 136 128 return EOK; … … 144 136 /** Stop the device. 145 137 * 146 * @param[in] netif_phone Network interface phone.147 138 * @param[in] device_id Device identifier. 148 139 * … … 154 145 * 155 146 */ 156 static int netif_stop_req_local( int netif_phone,device_id_t device_id)147 static int netif_stop_req_local(device_id_t device_id) 157 148 { 158 149 fibril_rwlock_write_lock(&netif_globals.lock); … … 167 158 int result = netif_stop_message(device); 168 159 if (result > NETIF_NULL) { 169 int phone = device->nil_phone; 170 nil_device_state_msg(phone, device_id, result); 160 nil_device_state_msg(netif_globals.nil_sess, device_id, result); 171 161 fibril_rwlock_write_unlock(&netif_globals.lock); 172 162 return EOK; … … 222 212 void netif_pq_release(packet_id_t packet_id) 223 213 { 224 pq_release_remote(netif_globals. net_phone, packet_id);214 pq_release_remote(netif_globals.sess, packet_id); 225 215 } 226 216 … … 235 225 packet_t *netif_packet_get_1(size_t content) 236 226 { 237 return packet_get_1_remote(netif_globals. net_phone, content);227 return packet_get_1_remote(netif_globals.sess, content); 238 228 } 239 229 240 230 /** Register the device notification receiver, 241 231 * 242 * Register a 232 * Register a network interface layer module as the device 243 233 * notification receiver. 244 234 * 245 * @param[in] device_id Device identifier. 246 * @param[in] phone Network interface layer module phone. 247 * 248 * @return EOK on success. 249 * @return ENOENT if there is no such device. 235 * @param[in] sess Session to the network interface layer module. 236 * 237 * @return EOK on success. 250 238 * @return ELIMIT if there is another module registered. 251 239 * 252 240 */ 253 static int register_message(device_id_t device_id, int phone) 254 { 255 netif_device_t *device; 256 int rc = find_device(device_id, &device); 257 if (rc != EOK) 258 return rc; 259 260 if (device->nil_phone >= 0) 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); 261 246 return ELIMIT; 262 263 device->nil_phone = phone; 247 } 248 249 netif_globals.nil_sess = sess; 250 251 fibril_rwlock_write_unlock(&netif_globals.lock); 264 252 return EOK; 265 253 } … … 294 282 return EOK; 295 283 284 async_sess_t *callback = 285 async_callback_receive_start(EXCHANGE_SERIALIZE, call); 286 if (callback) 287 return register_message(callback); 288 296 289 switch (IPC_GET_IMETHOD(*call)) { 297 290 case NET_NETIF_PROBE: 298 return netif_probe_req_local( 0,IPC_GET_DEVICE(*call),291 return netif_probe_req_local(IPC_GET_DEVICE(*call), 299 292 NETIF_GET_IRQ(*call), NETIF_GET_IO(*call)); 300 293 301 case IPC_M_CONNECT_TO_ME:302 fibril_rwlock_write_lock(&netif_globals.lock);303 304 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));305 306 fibril_rwlock_write_unlock(&netif_globals.lock);307 return rc;308 309 294 case NET_NETIF_SEND: 310 rc = packet_translate_remote(netif_globals. net_phone, &packet,295 rc = packet_translate_remote(netif_globals.sess, &packet, 311 296 IPC_GET_PACKET(*call)); 312 297 if (rc != EOK) 313 298 return rc; 314 299 315 return netif_send_msg_local( 0,IPC_GET_DEVICE(*call), packet,300 return netif_send_msg_local(IPC_GET_DEVICE(*call), packet, 316 301 IPC_GET_SENDER(*call)); 317 302 318 303 case NET_NETIF_START: 319 return netif_start_req_local( 0,IPC_GET_DEVICE(*call));304 return netif_start_req_local(IPC_GET_DEVICE(*call)); 320 305 321 306 case NET_NETIF_STATS: … … 343 328 344 329 case NET_NETIF_STOP: 345 return netif_stop_req_local( 0,IPC_GET_DEVICE(*call));330 return netif_stop_req_local(IPC_GET_DEVICE(*call)); 346 331 347 332 case NET_NETIF_GET_ADDR: … … 412 397 async_set_client_connection(netif_client_connection); 413 398 414 netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING); 399 netif_globals.sess = connect_to_service(SERVICE_NETWORKING); 400 netif_globals.nil_sess = NULL; 415 401 netif_device_map_initialize(&netif_globals.device_map); 416 402
Note:
See TracChangeset
for help on using the changeset viewer.