Changeset 6a44ee4 in mainline for uspace/srv/net/nil/nildummy/nildummy.c
- Timestamp:
- 2011-07-20T15:26:21Z (14 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/srv/net/nil/nildummy/nildummy.c
r25bef0ff r6a44ee4 44 44 #include <ipc/net.h> 45 45 #include <ipc/services.h> 46 47 46 #include <net/modules.h> 48 47 #include <net/device.h> … … 53 52 #include <netif_remote.h> 54 53 #include <nil_skel.h> 55 56 54 #include "nildummy.h" 57 55 … … 67 65 DEVICE_MAP_IMPLEMENT(nildummy_devices, nildummy_device_t); 68 66 69 int nil_device_state_msg_local( int nil_phone, device_id_t device_id, int state)67 int nil_device_state_msg_local(device_id_t device_id, sysarg_t state) 70 68 { 71 69 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 72 if (nildummy_globals.proto. phone)73 il_device_state_msg(nildummy_globals.proto. phone, device_id,70 if (nildummy_globals.proto.sess) 71 il_device_state_msg(nildummy_globals.proto.sess, device_id, 74 72 state, nildummy_globals.proto.service); 75 73 fibril_rwlock_read_unlock(&nildummy_globals.protos_lock); … … 78 76 } 79 77 80 int nil_initialize( int net_phone)78 int nil_initialize(async_sess_t *sess) 81 79 { 82 80 fibril_rwlock_initialize(&nildummy_globals.devices_lock); … … 85 83 fibril_rwlock_write_lock(&nildummy_globals.protos_lock); 86 84 87 nildummy_globals.net_ phone = net_phone;88 nildummy_globals.proto. phone = 0;85 nildummy_globals.net_sess = sess; 86 nildummy_globals.proto.sess = NULL; 89 87 int rc = nildummy_devices_initialize(&nildummy_globals.devices); 90 88 … … 99 97 * @param[in] iid Message identifier. 100 98 * @param[in,out] icall Message parameters. 101 * 102 */ 103 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall) 99 * @param[in] arg Local argument. 100 * 101 */ 102 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg) 104 103 { 105 104 packet_t *packet; … … 109 108 switch (IPC_GET_IMETHOD(*icall)) { 110 109 case NET_NIL_DEVICE_STATE: 111 rc = nil_device_state_msg_local( 0,112 IPC_GET_ DEVICE(*icall), IPC_GET_STATE(*icall));110 rc = nil_device_state_msg_local(IPC_GET_DEVICE(*icall), 111 IPC_GET_STATE(*icall)); 113 112 async_answer_0(iid, (sysarg_t) rc); 114 113 break; 115 114 116 115 case NET_NIL_RECEIVED: 117 rc = packet_translate_remote(nildummy_globals.net_ phone,116 rc = packet_translate_remote(nildummy_globals.net_sess, 118 117 &packet, IPC_GET_PACKET(*icall)); 119 118 if (rc == EOK) 120 rc = nil_received_msg_local( 0,121 IPC_GET_DEVICE(*icall),packet, 0);119 rc = nil_received_msg_local(IPC_GET_DEVICE(*icall), 120 packet, 0); 122 121 123 122 async_answer_0(iid, (sysarg_t) rc); … … 177 176 /* Notify the upper layer module */ 178 177 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 179 if (nildummy_globals.proto. phone) {180 il_mtu_changed_msg(nildummy_globals.proto. phone,178 if (nildummy_globals.proto.sess) { 179 il_mtu_changed_msg(nildummy_globals.proto.sess, 181 180 device->device_id, device->mtu, 182 181 nildummy_globals.proto.service); … … 200 199 201 200 /* Bind the device driver */ 202 device-> phone= netif_bind_service(device->service, device->device_id,201 device->sess = netif_bind_service(device->service, device->device_id, 203 202 SERVICE_ETHERNET, nildummy_receiver); 204 if (device-> phone < 0) {203 if (device->sess == NULL) { 205 204 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); 206 205 free(device); 207 return device->phone;206 return ENOENT; 208 207 } 209 208 210 209 /* Get hardware address */ 211 int rc = netif_get_addr_req(device-> phone, device->device_id,210 int rc = netif_get_addr_req(device->sess, device->device_id, 212 211 &device->addr, &device->addr_data); 213 212 if (rc != EOK) { … … 304 303 } 305 304 306 int nil_received_msg_local( int nil_phone, device_id_t device_id,307 packet_t *packet,services_t target)305 int nil_received_msg_local(device_id_t device_id, packet_t *packet, 306 services_t target) 308 307 { 309 308 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 310 309 311 if (nildummy_globals.proto. phone) {310 if (nildummy_globals.proto.sess) { 312 311 do { 313 312 packet_t *next = pq_detach(packet); 314 il_received_msg(nildummy_globals.proto. phone, device_id,313 il_received_msg(nildummy_globals.proto.sess, device_id, 315 314 packet, nildummy_globals.proto.service); 316 315 packet = next; … … 328 327 * 329 328 * @param[in] service Module service. 330 * @param[in] phone Service phone.329 * @param[in] sess Service session. 331 330 * 332 331 * @return EOK on success. … … 335 334 * 336 335 */ 337 static int nildummy_register_message(services_t service, int phone)336 static int nildummy_register_message(services_t service, async_sess_t *sess) 338 337 { 339 338 fibril_rwlock_write_lock(&nildummy_globals.protos_lock); 340 339 nildummy_globals.proto.service = service; 341 nildummy_globals.proto. phone = phone;342 343 printf("%s: Protocol registered (service: %d , phone: %d)\n",344 NAME, nildummy_globals.proto.service , nildummy_globals.proto.phone);340 nildummy_globals.proto.sess = sess; 341 342 printf("%s: Protocol registered (service: %d)\n", 343 NAME, nildummy_globals.proto.service); 345 344 346 345 fibril_rwlock_write_unlock(&nildummy_globals.protos_lock); … … 373 372 /* Send packet queue */ 374 373 if (packet) 375 netif_send_msg(device-> phone, device_id, packet,374 netif_send_msg(device->sess, device_id, packet, 376 375 SERVICE_NILDUMMY); 377 376 … … 393 392 394 393 *answer_count = 0; 394 395 if (!IPC_GET_IMETHOD(*call)) 396 return EOK; 397 398 async_sess_t *callback = 399 async_callback_receive_start(EXCHANGE_SERIALIZE, call); 400 if (callback) 401 return nildummy_register_message(NIL_GET_PROTO(*call), callback); 402 395 403 switch (IPC_GET_IMETHOD(*call)) { 396 case IPC_M_PHONE_HUNGUP:397 return EOK;398 399 404 case NET_NIL_DEVICE: 400 405 return nildummy_device_message(IPC_GET_DEVICE(*call), … … 402 407 403 408 case NET_NIL_SEND: 404 rc = packet_translate_remote(nildummy_globals.net_ phone,409 rc = packet_translate_remote(nildummy_globals.net_sess, 405 410 &packet, IPC_GET_PACKET(*call)); 406 411 if (rc != EOK) … … 432 437 return rc; 433 438 return measured_strings_reply(address, 1); 434 435 case IPC_M_CONNECT_TO_ME:436 return nildummy_register_message(NIL_GET_PROTO(*call),437 IPC_GET_PHONE(*call));438 439 } 439 440
Note:
See TracChangeset
for help on using the changeset viewer.