Changeset c3b25985 in mainline
- Timestamp:
- 2014-08-05T21:43:50Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ee95794
- Parents:
- 1f1fa64
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink.c
r1f1fa64 rc3b25985 171 171 } 172 172 173 int iplink_set_mac48(iplink_t *iplink, addr48_t mac) 174 { 175 async_exch_t *exch = async_exchange_begin(iplink->sess); 176 177 ipc_call_t answer; 178 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 179 180 int rc = async_data_read_start(exch, mac, sizeof(addr48_t)); 181 182 loc_exchange_end(exch); 183 184 if (rc != EOK) { 185 async_forget(req); 186 return rc; 187 } 188 189 sysarg_t retval; 190 async_wait_for(req, &retval); 191 192 return (int) retval; 193 } 194 195 173 196 int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr) 174 197 { … … 230 253 free(sdu.data); 231 254 async_answer_0(iid, rc); 255 } 256 257 static void iplink_ev_change_addr(iplink_t *iplink, ipc_callid_t iid, 258 ipc_call_t *icall) 259 { 260 addr48_t *addr; 261 size_t size; 262 263 int rc = async_data_write_accept((void **)&addr, false, 264 sizeof(addr48_t), sizeof(addr48_t), 0, &size); 265 if (rc != EOK) { 266 async_answer_0(iid, rc); 267 return; 268 } 269 270 rc = iplink->ev_ops->change_addr(iplink, *addr); 271 free(addr); 272 async_answer_0(iid, EOK); 232 273 } 233 274 … … 249 290 iplink_ev_recv(iplink, callid, &call); 250 291 break; 292 case IPLINK_EV_CHANGE_ADDR: 293 iplink_ev_change_addr(iplink, callid, &call); 251 294 default: 252 295 async_answer_0(callid, ENOTSUP); -
uspace/lib/c/generic/iplink_srv.c
r1f1fa64 rc3b25985 81 81 } 82 82 83 static void iplink_set_mac48_srv(iplink_srv_t *srv, ipc_callid_t iid, 84 ipc_call_t *icall) 85 { 86 int rc; 87 size_t size; 88 addr48_t mac; 89 ipc_callid_t callid; 90 91 rc = async_data_write_receive(&callid, &size); 92 if (rc != EOK) { 93 async_answer_0(callid, (sysarg_t) rc); 94 async_answer_0(iid, (sysarg_t) rc); 95 } 96 97 rc = srv->ops->set_mac48(srv, &mac); 98 if (rc != EOK) { 99 async_answer_0(iid, rc); 100 return; 101 } 102 103 rc = async_data_read_finalize(callid, &mac, sizeof(addr48_t)); 104 if (rc != EOK) 105 async_answer_0(callid, rc); 106 107 async_answer_0(iid, (sysarg_t) rc); 108 } 109 83 110 static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_callid_t iid, 84 111 ipc_call_t *icall) … … 252 279 iplink_get_mac48_srv(srv, callid, &call); 253 280 break; 281 case IPLINK_SET_MAC48: 282 iplink_set_mac48_srv(srv, callid, &call); 283 break; 254 284 case IPLINK_SEND: 255 285 iplink_send_srv(srv, callid, &call); … … 300 330 } 301 331 332 int iplink_ev_change_addr(iplink_srv_t *srv, addr48_t *addr) 333 { 334 if (srv->client_sess == NULL) 335 return EIO; 336 337 async_exch_t *exch = async_exchange_begin(srv->client_sess); 338 339 ipc_call_t answer; 340 aid_t req = async_send_0(exch, IPLINK_EV_CHANGE_ADDR, &answer); 341 342 int rc = async_data_write_start(exch, addr, sizeof(addr48_t)); 343 async_exchange_end(exch); 344 345 if (rc != EOK) { 346 async_forget(req); 347 return rc; 348 } 349 350 sysarg_t retval; 351 async_wait_for(req, &retval); 352 if (retval != EOK) 353 return retval; 354 355 return EOK; 356 } 357 302 358 /** @} 303 359 */ -
uspace/lib/c/include/inet/iplink.h
r1f1fa64 rc3b25985 78 78 typedef struct iplink_ev_ops { 79 79 int (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t); 80 int (*change_addr)(iplink_t *, addr48_t); 80 81 } iplink_ev_ops_t; 81 82 … … 88 89 extern int iplink_get_mtu(iplink_t *, size_t *); 89 90 extern int iplink_get_mac48(iplink_t *, addr48_t *); 91 extern int iplink_set_mac48(iplink_t *, addr48_t); 90 92 91 93 #endif -
uspace/lib/c/include/inet/iplink_srv.h
r1f1fa64 rc3b25985 59 59 int (*get_mtu)(iplink_srv_t *, size_t *); 60 60 int (*get_mac48)(iplink_srv_t *, addr48_t *); 61 int (*set_mac48)(iplink_srv_t *, addr48_t *); 61 62 int (*addr_add)(iplink_srv_t *, inet_addr_t *); 62 63 int (*addr_remove)(iplink_srv_t *, inet_addr_t *); … … 67 68 extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *); 68 69 extern int iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t); 70 extern int iplink_ev_change_addr(iplink_srv_t *, addr48_t *); 69 71 70 72 #endif -
uspace/lib/c/include/ipc/iplink.h
r1f1fa64 rc3b25985 41 41 IPLINK_GET_MTU = IPC_FIRST_USER_METHOD, 42 42 IPLINK_GET_MAC48, 43 IPLINK_SET_MAC48, 43 44 IPLINK_SEND, 44 45 IPLINK_SEND6, … … 48 49 49 50 typedef enum { 50 IPLINK_EV_RECV = IPC_FIRST_USER_METHOD 51 IPLINK_EV_RECV = IPC_FIRST_USER_METHOD, 52 IPLINK_EV_CHANGE_ADDR, 51 53 } iplink_event_t; 52 54 -
uspace/lib/nic/src/nic_driver.c
r1f1fa64 rc3b25985 532 532 fibril_rwlock_write_lock(&nic_data->stats_lock); 533 533 534 log_msg(LOG_DEFAULT, LVL_WARN, "nic_received_frame(), check=%d", check); 535 534 536 if (nic_data->state == NIC_STATE_ACTIVE && check) { 535 537 nic_data->stats.receive_packets++; -
uspace/srv/net/ethip/ethip.c
r1f1fa64 rc3b25985 58 58 static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu); 59 59 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac); 60 static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac); 60 61 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 61 62 static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); … … 70 71 .get_mtu = ethip_get_mtu, 71 72 .get_mac48 = ethip_get_mac48, 73 .set_mac48 = ethip_set_mac48, 72 74 .addr_add = ethip_addr_add, 73 75 .addr_remove = ethip_addr_remove … … 283 285 } 284 286 287 static int ethip_set_mac48(iplink_srv_t *srv, addr48_t *mac) 288 { 289 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_set_mac48()"); 290 291 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 292 addr48(*mac, nic->mac_addr); 293 294 return EOK; 295 } 296 285 297 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr) 286 298 { -
uspace/srv/net/ethip/ethip_nic.c
r1f1fa64 rc3b25985 245 245 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); 246 246 247 memcpy(&nic->mac_addr, addr, sizeof(nic->mac_addr)); 248 249 rc = iplink_ev_change_addr(&nic->iplink, &nic->mac_addr); 250 if (rc != EOK) { 251 log_msg(LOG_DEFAULT, LVL_DEBUG, "iplink_ev_change_addr() failed"); 252 return; 253 } 254 247 255 free(addr); 248 256 async_answer_0(callid, EOK); -
uspace/srv/net/inetsrv/inet_link.c
r1f1fa64 rc3b25985 55 55 56 56 static int inet_iplink_recv(iplink_t *, iplink_recv_sdu_t *, ip_ver_t); 57 static int inet_iplink_change_addr(iplink_t *, addr48_t); 57 58 static inet_link_t *inet_link_get_by_id_locked(sysarg_t); 58 59 59 60 static iplink_ev_ops_t inet_iplink_ev_ops = { 60 .recv = inet_iplink_recv 61 .recv = inet_iplink_recv, 62 .change_addr = inet_iplink_change_addr, 61 63 }; 62 64 … … 110 112 111 113 return rc; 114 } 115 116 static int inet_iplink_change_addr(iplink_t *iplink, addr48_t mac) 117 { 118 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_iplink_change_addr(): " 119 "new addr=%02x:%02x:%02x:%02x:%02x:%02x", 120 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 121 122 list_foreach(inet_links, link_list, inet_link_t, ilink) { 123 if (ilink->sess == iplink->sess) 124 memcpy(&ilink->mac, mac, sizeof(addr48_t)); 125 } 126 127 return EOK; 112 128 } 113 129
Note:
See TracChangeset
for help on using the changeset viewer.