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