Changeset 26e7d6d in mainline for uspace/srv/net/nil/nildummy/nildummy.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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
r3842a955 r26e7d6d 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 // FIXME: remove this header57 #include <kernel/ipc/ipc_methods.h>58 59 54 #include "nildummy.h" 60 55 … … 70 65 DEVICE_MAP_IMPLEMENT(nildummy_devices, nildummy_device_t); 71 66 72 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) 73 68 { 74 69 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 75 if (nildummy_globals.proto. phone)76 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, 77 72 state, nildummy_globals.proto.service); 78 73 fibril_rwlock_read_unlock(&nildummy_globals.protos_lock); … … 81 76 } 82 77 83 int nil_initialize( int net_phone)78 int nil_initialize(async_sess_t *sess) 84 79 { 85 80 fibril_rwlock_initialize(&nildummy_globals.devices_lock); … … 88 83 fibril_rwlock_write_lock(&nildummy_globals.protos_lock); 89 84 90 nildummy_globals.net_ phone = net_phone;91 nildummy_globals.proto. phone = 0;85 nildummy_globals.net_sess = sess; 86 nildummy_globals.proto.sess = NULL; 92 87 int rc = nildummy_devices_initialize(&nildummy_globals.devices); 93 88 … … 102 97 * @param[in] iid Message identifier. 103 98 * @param[in,out] icall Message parameters. 104 * @param[in] arg Local argument. 99 * @param[in] arg Local argument. 100 * 105 101 */ 106 102 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg) … … 112 108 switch (IPC_GET_IMETHOD(*icall)) { 113 109 case NET_NIL_DEVICE_STATE: 114 rc = nil_device_state_msg_local( 0,115 IPC_GET_ DEVICE(*icall), IPC_GET_STATE(*icall));110 rc = nil_device_state_msg_local(IPC_GET_DEVICE(*icall), 111 IPC_GET_STATE(*icall)); 116 112 async_answer_0(iid, (sysarg_t) rc); 117 113 break; 118 114 119 115 case NET_NIL_RECEIVED: 120 rc = packet_translate_remote(nildummy_globals.net_ phone,116 rc = packet_translate_remote(nildummy_globals.net_sess, 121 117 &packet, IPC_GET_PACKET(*icall)); 122 118 if (rc == EOK) 123 rc = nil_received_msg_local( 0,124 IPC_GET_DEVICE(*icall),packet, 0);119 rc = nil_received_msg_local(IPC_GET_DEVICE(*icall), 120 packet, 0); 125 121 126 122 async_answer_0(iid, (sysarg_t) rc); … … 180 176 /* Notify the upper layer module */ 181 177 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 182 if (nildummy_globals.proto. phone) {183 il_mtu_changed_msg(nildummy_globals.proto. phone,178 if (nildummy_globals.proto.sess) { 179 il_mtu_changed_msg(nildummy_globals.proto.sess, 184 180 device->device_id, device->mtu, 185 181 nildummy_globals.proto.service); … … 203 199 204 200 /* Bind the device driver */ 205 device-> phone= netif_bind_service(device->service, device->device_id,201 device->sess = netif_bind_service(device->service, device->device_id, 206 202 SERVICE_ETHERNET, nildummy_receiver); 207 if (device-> phone < 0) {203 if (device->sess == NULL) { 208 204 fibril_rwlock_write_unlock(&nildummy_globals.devices_lock); 209 205 free(device); 210 return device->phone;206 return ENOENT; 211 207 } 212 208 213 209 /* Get hardware address */ 214 int rc = netif_get_addr_req(device-> phone, device->device_id,210 int rc = netif_get_addr_req(device->sess, device->device_id, 215 211 &device->addr, &device->addr_data); 216 212 if (rc != EOK) { … … 307 303 } 308 304 309 int nil_received_msg_local( int nil_phone, device_id_t device_id,310 packet_t *packet,services_t target)305 int nil_received_msg_local(device_id_t device_id, packet_t *packet, 306 services_t target) 311 307 { 312 308 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 313 309 314 if (nildummy_globals.proto. phone) {310 if (nildummy_globals.proto.sess) { 315 311 do { 316 312 packet_t *next = pq_detach(packet); 317 il_received_msg(nildummy_globals.proto. phone, device_id,313 il_received_msg(nildummy_globals.proto.sess, device_id, 318 314 packet, nildummy_globals.proto.service); 319 315 packet = next; … … 331 327 * 332 328 * @param[in] service Module service. 333 * @param[in] phone Service phone.329 * @param[in] sess Service session. 334 330 * 335 331 * @return EOK on success. … … 338 334 * 339 335 */ 340 static int nildummy_register_message(services_t service, int phone)336 static int nildummy_register_message(services_t service, async_sess_t *sess) 341 337 { 342 338 fibril_rwlock_write_lock(&nildummy_globals.protos_lock); 343 339 nildummy_globals.proto.service = service; 344 nildummy_globals.proto. phone = phone;345 346 printf("%s: Protocol registered (service: %d , phone: %d)\n",347 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); 348 344 349 345 fibril_rwlock_write_unlock(&nildummy_globals.protos_lock); … … 376 372 /* Send packet queue */ 377 373 if (packet) 378 netif_send_msg(device-> phone, device_id, packet,374 netif_send_msg(device->sess, device_id, packet, 379 375 SERVICE_NILDUMMY); 380 376 … … 400 396 return EOK; 401 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 402 403 switch (IPC_GET_IMETHOD(*call)) { 403 404 case NET_NIL_DEVICE: … … 406 407 407 408 case NET_NIL_SEND: 408 rc = packet_translate_remote(nildummy_globals.net_ phone,409 rc = packet_translate_remote(nildummy_globals.net_sess, 409 410 &packet, IPC_GET_PACKET(*call)); 410 411 if (rc != EOK) … … 436 437 return rc; 437 438 return measured_strings_reply(address, 1); 438 439 case IPC_M_CONNECT_TO_ME:440 return nildummy_register_message(NIL_GET_PROTO(*call),441 IPC_GET_PHONE(*call));442 439 } 443 440
Note:
See TracChangeset
for help on using the changeset viewer.