Changes in uspace/srv/net/nil/eth/eth.c [fb04cba8:4ef32e0c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
rfb04cba8 r4ef32e0c 204 204 fibril_rwlock_write_lock(ð_globals.protos_lock); 205 205 eth_globals.net_phone = net_phone; 206 207 206 eth_globals.broadcast_addr = 208 207 measured_string_create_bulk("\xFF\xFF\xFF\xFF\xFF\xFF", … … 212 211 goto out; 213 212 } 214 215 213 rc = eth_devices_initialize(ð_globals.devices); 216 214 if (rc != EOK) { … … 218 216 goto out; 219 217 } 220 221 218 rc = eth_protos_initialize(ð_globals.protos); 222 219 if (rc != EOK) { … … 283 280 * netif_get_addr_req() function. 284 281 */ 285 static int eth_device_message(device_id_t device_id, services_t service,286 282 static int 283 eth_device_message(device_id_t device_id, services_t service, size_t mtu) 287 284 { 288 285 eth_device_ref device; … … 305 302 306 303 fibril_rwlock_write_lock(ð_globals.devices_lock); 307 / * An existing device? */304 // an existing device? 308 305 device = eth_devices_find(ð_globals.devices, device_id); 309 306 if (device) { … … 314 311 } 315 312 316 / * Update mtu */313 // update mtu 317 314 if ((mtu > 0) && (mtu <= ETH_MAX_TAGGED_CONTENT(device->flags))) 318 315 device->mtu = mtu; … … 324 321 fibril_rwlock_write_unlock(ð_globals.devices_lock); 325 322 326 / * Notify all upper layer modules */323 // notify all upper layer modules 327 324 fibril_rwlock_read_lock(ð_globals.protos_lock); 328 325 for (index = 0; index < eth_protos_count(ð_globals.protos); … … 336 333 } 337 334 } 338 339 335 fibril_rwlock_read_unlock(ð_globals.protos_lock); 340 336 return EOK; 341 337 } 342 338 343 / * Create a new device */339 // create a new device 344 340 device = (eth_device_ref) malloc(sizeof(eth_device_t)); 345 341 if (!device) … … 362 358 return rc; 363 359 } 364 365 360 if (configuration) { 366 361 if (!str_lcmp(configuration[0].value, "DIX", … … 383 378 } 384 379 385 / * Bind the device driver */380 // bind the device driver 386 381 device->phone = netif_bind_service(device->service, device->device_id, 387 382 SERVICE_ETHERNET, eth_receiver); … … 392 387 } 393 388 394 / * Get hardware address */389 // get hardware address 395 390 rc = netif_get_addr_req(device->phone, device->device_id, &device->addr, 396 391 &device->addr_data); … … 401 396 } 402 397 403 / * Add to the cache */398 // add to the cache 404 399 index = eth_devices_add(ð_globals.devices, device->device_id, 405 400 device); … … 458 453 459 454 if (type >= ETH_MIN_PROTO) { 460 / * DIX Ethernet */455 // DIX Ethernet 461 456 prefix = sizeof(eth_header_t); 462 457 suffix = 0; … … 464 459 length -= sizeof(eth_fcs_t); 465 460 } else if(type <= ETH_MAX_CONTENT) { 466 / * Translate "LSAP" values */461 // translate "LSAP" values 467 462 if ((header->lsap.dsap == ETH_LSAP_GLSAP) && 468 463 (header->lsap.ssap == ETH_LSAP_GLSAP)) { 469 /* Raw packet -- discard */ 464 // raw packet 465 // discard 470 466 return NULL; 471 467 } else if((header->lsap.dsap == ETH_LSAP_SNAP) && 472 468 (header->lsap.ssap == ETH_LSAP_SNAP)) { 473 /* 474 * IEEE 802.3 + 802.2 + LSAP + SNAP 475 * organization code not supported 476 */ 469 // IEEE 802.3 + 802.2 + LSAP + SNAP 470 // organization code not supported 477 471 type = ntohs(header->snap.ethertype); 478 472 prefix = sizeof(eth_header_t) + … … 480 474 sizeof(eth_header_snap_t); 481 475 } else { 482 / * IEEE 802.3 + 802.2 LSAP */476 // IEEE 802.3 + 802.2 LSAP 483 477 type = lsap_map(header->lsap.dsap); 484 478 prefix = sizeof(eth_header_t) + 485 479 sizeof(eth_header_lsap_t); 486 480 } 487 488 481 suffix = (type < ETH_MIN_CONTENT) ? ETH_MIN_CONTENT - type : 0U; 489 482 fcs = (eth_fcs_ref) data + prefix + type + suffix; … … 491 484 length = prefix + type + suffix; 492 485 } else { 493 / * Invalid length/type, should not occur */486 // invalid length/type, should not occurr 494 487 return NULL; 495 488 } … … 513 506 } 514 507 515 int nil_received_msg_local(int nil_phone, device_id_t device_id, 516 packet_t packet, services_t target) 508 int 509 nil_received_msg_local(int nil_phone, device_id_t device_id, packet_t packet, 510 services_t target) 517 511 { 518 512 eth_proto_ref proto; … … 527 521 return ENOENT; 528 522 } 529 530 523 flags = device->flags; 531 524 fibril_rwlock_read_unlock(ð_globals.devices_lock); … … 545 538 packet = next; 546 539 } while(packet); 547 548 540 fibril_rwlock_read_unlock(ð_globals.protos_lock); 541 549 542 return EOK; 550 543 } … … 561 554 * @returns ENOENT if there is no such device. 562 555 */ 563 static int eth_packet_space_message(device_id_t device_id, size_t *addr_len, 556 static int 557 eth_packet_space_message(device_id_t device_id, size_t *addr_len, 564 558 size_t *prefix, size_t *content, size_t *suffix) 565 559 { … … 575 569 return ENOENT; 576 570 } 577 578 571 *content = device->mtu; 579 572 fibril_rwlock_read_unlock(ð_globals.devices_lock); … … 582 575 *prefix = ETH_PREFIX; 583 576 *suffix = ETH_MIN_CONTENT + ETH_SUFFIX; 584 585 577 return EOK; 586 578 } … … 595 587 * @returns ENOENT if there no such device. 596 588 */ 597 static int eth_addr_message(device_id_t device_id, eth_addr_type_t type, 589 static int 590 eth_addr_message(device_id_t device_id, eth_addr_type_t type, 598 591 measured_string_ref *address) 599 592 { … … 651 644 return ENOMEM; 652 645 } 653 654 646 proto->service = service; 655 647 proto->protocol = protocol; 656 648 proto->phone = phone; 657 658 649 index = eth_protos_add(ð_globals.protos, protocol, proto); 659 650 if (index < 0) { … … 714 705 if (!padding) 715 706 return ENOMEM; 716 717 707 bzero(padding, ETH_MIN_TAGGED_CONTENT(flags) - length); 718 708 } … … 792 782 * @returns EINVAL if the service parameter is not known. 793 783 */ 794 static int eth_send_message(device_id_t device_id, packet_t packet,795 784 static int 785 eth_send_message(device_id_t device_id, packet_t packet, services_t sender) 796 786 { 797 787 eth_device_ref device; … … 814 804 } 815 805 816 / * Process packet queue */806 // process packet queue 817 807 next = packet; 818 808 do { … … 820 810 (uint8_t *) device->addr->value, ethertype, device->mtu); 821 811 if (rc != EOK) { 822 / * Release invalid packet */812 // release invalid packet 823 813 tmp = pq_detach(next); 824 814 if (next == packet) … … 832 822 } while(next); 833 823 834 / * Send packet queue */824 // send packet queue 835 825 if (packet) { 836 826 netif_send_msg(device->phone, device_id, packet, 837 827 SERVICE_ETHERNET); 838 828 } 839 840 829 fibril_rwlock_read_unlock(ð_globals.devices_lock); 830 841 831 return EOK; 842 832 } 843 833 844 int nil_message_standalone(const char *name, ipc_callid_t callid, 845 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 834 int 835 nil_message_standalone(const char *name, ipc_callid_t callid, ipc_call_t *call, 836 ipc_call_t *answer, int *answer_count) 846 837 { 847 838 measured_string_ref address; … … 903 894 * @param[in] iid The initial message identifier. 904 895 * @param[in] icall The initial message call structure. 896 * 905 897 */ 906 898 static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall)
Note:
See TracChangeset
for help on using the changeset viewer.