Changeset fdbc3ff in mainline for uspace/srv/net/nil/eth/eth.c
- Timestamp:
- 2010-11-19T23:50:06Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 46d4d9f
- Parents:
- b4c9c61 (diff), a9c6b966 (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/eth/eth.c
rb4c9c61 rfdbc3ff 156 156 typedef enum eth_addr_type eth_addr_type_t; 157 157 158 /** Type definition of the ethernet address type pointer.159 * @see eth_addr_type160 */161 typedef eth_addr_type_t *eth_addr_type_ref;162 163 158 /** Ethernet address type. */ 164 159 enum eth_addr_type { … … 178 173 { 179 174 int index; 180 eth_proto_ refproto;175 eth_proto_t *proto; 181 176 182 177 fibril_rwlock_read_lock(ð_globals.protos_lock); … … 273 268 * @param[in] service The device driver service. 274 269 * @param[in] mtu The device maximum transmission unit. 275 * @return sEOK on success.276 * @return sEEXIST if the device with the different service exists.277 * @return sENOMEM if there is not enough memory left.278 * @return sOther error codes as defined for the270 * @return EOK on success. 271 * @return EEXIST if the device with the different service exists. 272 * @return ENOMEM if there is not enough memory left. 273 * @return Other error codes as defined for the 279 274 * net_get_device_conf_req() function. 280 * @return sOther error codes as defined for the275 * @return Other error codes as defined for the 281 276 * netif_bind_service() function. 282 * @return sOther error codes as defined for the277 * @return Other error codes as defined for the 283 278 * netif_get_addr_req() function. 284 279 */ … … 286 281 size_t mtu) 287 282 { 288 eth_device_ refdevice;283 eth_device_t *device; 289 284 int index; 290 285 measured_string_t names[2] = { … … 298 293 } 299 294 }; 300 measured_string_ refconfiguration;295 measured_string_t *configuration; 301 296 size_t count = sizeof(names) / sizeof(measured_string_t); 302 297 char *data; 303 eth_proto_ refproto;298 eth_proto_t *proto; 304 299 int rc; 305 300 … … 342 337 343 338 /* Create a new device */ 344 device = (eth_device_ ref) malloc(sizeof(eth_device_t));339 device = (eth_device_t *) malloc(sizeof(eth_device_t)); 345 340 if (!device) 346 341 return ENOMEM; … … 427 422 * @param[in] flags The device flags. 428 423 * @param[in] packet The packet. 429 * @return sThe target registered module.430 * @return sNULL if the packet is not long enough.431 * @return sNULL if the packet is too long.432 * @return sNULL if the raw ethernet protocol is used.433 * @return sNULL if the dummy device FCS checksum is invalid.434 * @return sNULL if the packet address length is not big enough.435 */ 436 static eth_proto_ refeth_process_packet(int flags, packet_t packet)437 { 438 eth_header_snap_ refheader;424 * @return The target registered module. 425 * @return NULL if the packet is not long enough. 426 * @return NULL if the packet is too long. 427 * @return NULL if the raw ethernet protocol is used. 428 * @return NULL if the dummy device FCS checksum is invalid. 429 * @return NULL if the packet address length is not big enough. 430 */ 431 static eth_proto_t *eth_process_packet(int flags, packet_t packet) 432 { 433 eth_header_snap_t *header; 439 434 size_t length; 440 435 eth_type_t type; 441 436 size_t prefix; 442 437 size_t suffix; 443 eth_fcs_ reffcs;438 eth_fcs_t *fcs; 444 439 uint8_t *data; 445 440 int rc; … … 454 449 455 450 data = packet_get_data(packet); 456 header = (eth_header_snap_ ref) data;451 header = (eth_header_snap_t *) data; 457 452 type = ntohs(header->header.ethertype); 458 453 … … 461 456 prefix = sizeof(eth_header_t); 462 457 suffix = 0; 463 fcs = (eth_fcs_ ref) data + length - sizeof(eth_fcs_t);458 fcs = (eth_fcs_t *) data + length - sizeof(eth_fcs_t); 464 459 length -= sizeof(eth_fcs_t); 465 460 } else if(type <= ETH_MAX_CONTENT) { … … 487 482 488 483 suffix = (type < ETH_MIN_CONTENT) ? ETH_MIN_CONTENT - type : 0U; 489 fcs = (eth_fcs_ ref) data + prefix + type + suffix;484 fcs = (eth_fcs_t *) data + prefix + type + suffix; 490 485 suffix += length - prefix - type; 491 486 length = prefix + type + suffix; … … 516 511 packet_t packet, services_t target) 517 512 { 518 eth_proto_ refproto;513 eth_proto_t *proto; 519 514 packet_t next; 520 eth_device_ refdevice;515 eth_device_t *device; 521 516 int flags; 522 517 … … 557 552 * @param[out] content The maximum content size. 558 553 * @param[out] suffix The minimum reserved suffix size. 559 * @return sEOK on success.560 * @return sEBADMEM if either one of the parameters is NULL.561 * @return sENOENT if there is no such device.554 * @return EOK on success. 555 * @return EBADMEM if either one of the parameters is NULL. 556 * @return ENOENT if there is no such device. 562 557 */ 563 558 static int eth_packet_space_message(device_id_t device_id, size_t *addr_len, 564 559 size_t *prefix, size_t *content, size_t *suffix) 565 560 { 566 eth_device_ refdevice;561 eth_device_t *device; 567 562 568 563 if (!addr_len || !prefix || !content || !suffix) … … 591 586 * @param[in] type Type of the desired address. 592 587 * @param[out] address The device hardware address. 593 * @return sEOK on success.594 * @return sEBADMEM if the address parameter is NULL.595 * @return sENOENT if there no such device.588 * @return EOK on success. 589 * @return EBADMEM if the address parameter is NULL. 590 * @return ENOENT if there no such device. 596 591 */ 597 592 static int eth_addr_message(device_id_t device_id, eth_addr_type_t type, 598 measured_string_ ref*address)599 { 600 eth_device_ refdevice;593 measured_string_t **address) 594 { 595 eth_device_t *device; 601 596 602 597 if (!address) … … 625 620 * @param[in] service The module service. 626 621 * @param[in] phone The service phone. 627 * @return sEOK on success.628 * @return sENOENT if the service is not known.629 * @return sENOMEM if there is not enough memory left.622 * @return EOK on success. 623 * @return ENOENT if the service is not known. 624 * @return ENOMEM if there is not enough memory left. 630 625 */ 631 626 static int eth_register_message(services_t service, int phone) 632 627 { 633 eth_proto_ refproto;628 eth_proto_t *proto; 634 629 int protocol; 635 630 int index; … … 646 641 return EOK; 647 642 } else { 648 proto = (eth_proto_ ref) malloc(sizeof(eth_proto_t));643 proto = (eth_proto_t *) malloc(sizeof(eth_proto_t)); 649 644 if (!proto) { 650 645 fibril_rwlock_write_unlock(ð_globals.protos_lock); … … 678 673 * @param[in] ethertype The ethernet protocol type. 679 674 * @param[in] mtu The device maximum transmission unit. 680 * @return sEOK on success.681 * @return sEINVAL if the packet addresses length is not long675 * @return EOK on success. 676 * @return EINVAL if the packet addresses length is not long 682 677 * enough. 683 * @return sEINVAL if the packet is bigger than the device MTU.684 * @return sENOMEM if there is not enough memory in the packet.678 * @return EINVAL if the packet is bigger than the device MTU. 679 * @return ENOMEM if there is not enough memory in the packet. 685 680 */ 686 681 static int … … 688 683 size_t mtu) 689 684 { 690 eth_header_snap_ refheader;691 eth_header_lsap_ refheader_lsap;692 eth_header_ refheader_dix;693 eth_fcs_ reffcs;685 eth_header_snap_t *header; 686 eth_header_lsap_t *header_lsap; 687 eth_header_t *header_dix; 688 eth_fcs_t *fcs; 694 689 uint8_t *src; 695 690 uint8_t *dest; … … 697 692 int i; 698 693 void *padding; 699 eth_preamble_ refpreamble;694 eth_preamble_t *preamble; 700 695 701 696 i = packet_get_addr(packet, &src, &dest); … … 788 783 * @param[in] packet The packet queue. 789 784 * @param[in] sender The sending module service. 790 * @return sEOK on success.791 * @return sENOENT if there no such device.792 * @return sEINVAL if the service parameter is not known.785 * @return EOK on success. 786 * @return ENOENT if there no such device. 787 * @return EINVAL if the service parameter is not known. 793 788 */ 794 789 static int eth_send_message(device_id_t device_id, packet_t packet, 795 790 services_t sender) 796 791 { 797 eth_device_ refdevice;792 eth_device_t *device; 798 793 packet_t next; 799 794 packet_t tmp; … … 845 840 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 846 841 { 847 measured_string_ refaddress;842 measured_string_t *address; 848 843 packet_t packet; 849 844 size_t addrlen;
Note:
See TracChangeset
for help on using the changeset viewer.