Changeset 9cd8165 in mainline for uspace/srv/net
- Timestamp:
- 2012-01-27T12:54:09Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 790d6d1
- Parents:
- 7174403
- Location:
- uspace/srv/net
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/cfg/e1k.nic
r7174403 r9cd8165 12 12 13 13 IP_CONFIG=static 14 IP_ADDR=1 0.0.2.1514 IP_ADDR=192.168.0.4 15 15 IP_ROUTING=yes 16 IP_NETMASK=255.255.255. 24017 IP_BROADCAST=1 0.0.2.25518 IP_GATEWAY=1 0.0.2.216 IP_NETMASK=255.255.255.0 17 IP_BROADCAST=192.168.0.255 18 IP_GATEWAY=192.168.0.1 19 19 ARP=arp 20 20 -
uspace/srv/net/cfg/ne2k.nic
r7174403 r9cd8165 12 12 13 13 IP_CONFIG=static 14 IP_ADDR=1 0.0.2.1514 IP_ADDR=192.168.0.4 15 15 IP_ROUTING=yes 16 IP_NETMASK=255.255.255. 24017 IP_BROADCAST=1 0.0.2.25518 IP_GATEWAY=1 0.0.2.216 IP_NETMASK=255.255.255.0 17 IP_BROADCAST=192.168.0.255 18 IP_GATEWAY=192.168.0.1 19 19 ARP=arp 20 20 -
uspace/srv/net/nil/eth/eth.c
r7174403 r9cd8165 173 173 void *arg); 174 174 175 static int eth_device_state( nic_device_id_t device_id, sysarg_t state)175 static int eth_device_state(eth_device_t *device, sysarg_t state) 176 176 { 177 177 int index; … … 183 183 proto = eth_protos_get_index(ð_globals.protos, index); 184 184 if ((proto) && (proto->sess)) { 185 il_device_state_msg(proto->sess, device _id, state,186 proto->service);185 il_device_state_msg(proto->sess, device->device_id, 186 state, proto->service); 187 187 } 188 188 } … … 347 347 } 348 348 349 rc = nic_callback_create(device->sess, device_id, 350 eth_nic_cb_connection, NULL); 349 rc = nic_callback_create(device->sess, eth_nic_cb_connection, device); 351 350 if (rc != EOK) { 352 351 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 825 824 } 826 825 827 static int eth_received( nic_device_id_t device_id)826 static int eth_received(eth_device_t *device) 828 827 { 829 828 void *data; … … 845 844 free(data); 846 845 847 return nil_received_msg_local(device _id, packet);848 } 849 850 static int eth_addr_changed( nic_device_id_t device_id)846 return nil_received_msg_local(device->device_id, packet); 847 } 848 849 static int eth_addr_changed(eth_device_t *device) 851 850 { 852 851 nic_address_t address; … … 866 865 867 866 fibril_rwlock_write_lock(ð_globals.devices_lock); 868 /* An existing device? */ 869 eth_device_t *device = eth_devices_find(ð_globals.devices, device_id); 870 if (device) { 871 printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n", 872 device_id, ARGSMAC(device->addr.address), ARGSMAC(address.address)); 873 memcpy(&device->addr, &address, sizeof (nic_address_t)); 874 fibril_rwlock_write_unlock(ð_globals.devices_lock); 875 876 /* Notify all upper layer modules */ 877 fibril_rwlock_read_lock(ð_globals.protos_lock); 878 int index; 879 for (index = 0; index < eth_protos_count(ð_globals.protos); index++) { 880 eth_proto_t *proto = eth_protos_get_index(ð_globals.protos, index); 881 if (proto->sess != NULL) { 882 il_addr_changed_msg(proto->sess, device->device_id, 883 ETH_ADDR, address.address); 884 } 885 } 886 887 fibril_rwlock_read_unlock(ð_globals.protos_lock); 888 return EOK; 889 } else { 890 return ENOENT; 891 } 867 868 printf("Device %d changing address from " PRIMAC " to " PRIMAC "\n", 869 device->device_id, ARGSMAC(device->addr.address), 870 ARGSMAC(address.address)); 871 memcpy(&device->addr, &address, sizeof (nic_address_t)); 872 fibril_rwlock_write_unlock(ð_globals.devices_lock); 873 874 /* Notify all upper layer modules */ 875 fibril_rwlock_read_lock(ð_globals.protos_lock); 876 int index; 877 for (index = 0; index < eth_protos_count(ð_globals.protos); index++) { 878 eth_proto_t *proto = eth_protos_get_index(ð_globals.protos, index); 879 if (proto->sess != NULL) { 880 il_addr_changed_msg(proto->sess, device->device_id, 881 ETH_ADDR, address.address); 882 } 883 } 884 885 fibril_rwlock_read_unlock(ð_globals.protos_lock); 886 return EOK; 892 887 } 893 888 … … 962 957 static void eth_nic_cb_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 963 958 { 959 eth_device_t *device = (eth_device_t *)arg; 964 960 int rc; 965 961 … … 975 971 switch (IPC_GET_IMETHOD(call)) { 976 972 case NIC_EV_DEVICE_STATE: 977 rc = eth_device_state(IPC_GET_ARG1(call), 978 IPC_GET_ARG2(call)); 973 rc = eth_device_state(device, IPC_GET_ARG1(call)); 979 974 async_answer_0(callid, (sysarg_t) rc); 980 975 break; 981 976 case NIC_EV_RECEIVED: 982 rc = eth_received( IPC_GET_ARG1(call));977 rc = eth_received(device); 983 978 async_answer_0(callid, (sysarg_t) rc); 984 979 break; 985 980 case NIC_EV_ADDR_CHANGED: 986 rc = eth_addr_changed( IPC_GET_ARG1(call));981 rc = eth_addr_changed(device); 987 982 async_answer_0(callid, (sysarg_t) rc); 988 983 break; -
uspace/srv/net/nil/nildummy/nildummy.c
r7174403 r9cd8165 73 73 void *arg); 74 74 75 static int nildummy_device_state(ni c_device_id_t device_id, sysarg_t state)75 static int nildummy_device_state(nildummy_device_t *device, sysarg_t state) 76 76 { 77 77 fibril_rwlock_read_lock(&nildummy_globals.protos_lock); 78 78 if (nildummy_globals.proto.sess) 79 il_device_state_msg(nildummy_globals.proto.sess, device_id,80 state, nildummy_globals.proto.service);79 il_device_state_msg(nildummy_globals.proto.sess, 80 device->device_id, state, nildummy_globals.proto.service); 81 81 fibril_rwlock_read_unlock(&nildummy_globals.protos_lock); 82 82 … … 84 84 } 85 85 86 static int nildummy_addr_changed(ni c_device_id_t device_id)86 static int nildummy_addr_changed(nildummy_device_t *device) 87 87 { 88 88 return ENOTSUP; … … 182 182 } 183 183 184 int rc = nic_callback_create(device->sess, device_id,185 nildummy_nic_cb_conn, NULL);184 int rc = nic_callback_create(device->sess, nildummy_nic_cb_conn, 185 device); 186 186 if (rc != EOK) { 187 187 async_hangup(device->sess); … … 383 383 } 384 384 385 static int nildummy_received(ni c_device_id_t device_id)385 static int nildummy_received(nildummy_device_t *device) 386 386 { 387 387 void *data; … … 401 401 free(pdata); 402 402 403 return nil_received_msg_local(device _id, packet);403 return nil_received_msg_local(device->device_id, packet); 404 404 } 405 405 … … 465 465 static void nildummy_nic_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 466 466 { 467 nildummy_device_t *device = (nildummy_device_t *)arg; 467 468 int rc; 468 469 … … 478 479 switch (IPC_GET_IMETHOD(call)) { 479 480 case NIC_EV_DEVICE_STATE: 480 rc = nildummy_device_state(IPC_GET_ARG1(call), 481 IPC_GET_ARG2(call)); 481 rc = nildummy_device_state(device, IPC_GET_ARG1(call)); 482 482 async_answer_0(callid, (sysarg_t) rc); 483 483 break; 484 484 case NIC_EV_RECEIVED: 485 rc = nildummy_received( IPC_GET_ARG1(call));485 rc = nildummy_received(device); 486 486 async_answer_0(callid, (sysarg_t) rc); 487 487 break; 488 488 case NIC_EV_ADDR_CHANGED: 489 rc = nildummy_addr_changed( IPC_GET_ARG1(call));489 rc = nildummy_addr_changed(device); 490 490 async_answer_0(callid, (sysarg_t) rc); 491 491 break;
Note:
See TracChangeset
for help on using the changeset viewer.