Changes in uspace/srv/net/nil/eth/eth.c [46d4d9f:fb04cba8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r46d4d9f rfb04cba8 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_type 160 */ 161 typedef eth_addr_type_t *eth_addr_type_ref; 162 158 163 /** Ethernet address type. */ 159 164 enum eth_addr_type { … … 173 178 { 174 179 int index; 175 eth_proto_ t *proto;180 eth_proto_ref proto; 176 181 177 182 fibril_rwlock_read_lock(ð_globals.protos_lock); … … 234 239 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall) 235 240 { 236 packet_t *packet;241 packet_t packet; 237 242 int rc; 238 243 … … 268 273 * @param[in] service The device driver service. 269 274 * @param[in] mtu The device maximum transmission unit. 270 * @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 the275 * @returns EOK on success. 276 * @returns EEXIST if the device with the different service exists. 277 * @returns ENOMEM if there is not enough memory left. 278 * @returns Other error codes as defined for the 274 279 * net_get_device_conf_req() function. 275 * @return Other error codes as defined for the280 * @returns Other error codes as defined for the 276 281 * netif_bind_service() function. 277 * @return Other error codes as defined for the282 * @returns Other error codes as defined for the 278 283 * netif_get_addr_req() function. 279 284 */ … … 281 286 size_t mtu) 282 287 { 283 eth_device_ t *device;288 eth_device_ref device; 284 289 int index; 285 290 measured_string_t names[2] = { … … 293 298 } 294 299 }; 295 measured_string_ t *configuration;300 measured_string_ref configuration; 296 301 size_t count = sizeof(names) / sizeof(measured_string_t); 297 302 char *data; 298 eth_proto_ t *proto;303 eth_proto_ref proto; 299 304 int rc; 300 305 … … 337 342 338 343 /* Create a new device */ 339 device = (eth_device_ t *) malloc(sizeof(eth_device_t));344 device = (eth_device_ref) malloc(sizeof(eth_device_t)); 340 345 if (!device) 341 346 return ENOMEM; … … 422 427 * @param[in] flags The device flags. 423 428 * @param[in] packet The packet. 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;429 * @returns The target registered module. 430 * @returns NULL if the packet is not long enough. 431 * @returns NULL if the packet is too long. 432 * @returns NULL if the raw ethernet protocol is used. 433 * @returns NULL if the dummy device FCS checksum is invalid. 434 * @returns NULL if the packet address length is not big enough. 435 */ 436 static eth_proto_ref eth_process_packet(int flags, packet_t packet) 437 { 438 eth_header_snap_ref header; 434 439 size_t length; 435 440 eth_type_t type; 436 441 size_t prefix; 437 442 size_t suffix; 438 eth_fcs_ t *fcs;443 eth_fcs_ref fcs; 439 444 uint8_t *data; 440 445 int rc; … … 449 454 450 455 data = packet_get_data(packet); 451 header = (eth_header_snap_ t *) data;456 header = (eth_header_snap_ref) data; 452 457 type = ntohs(header->header.ethertype); 453 458 … … 456 461 prefix = sizeof(eth_header_t); 457 462 suffix = 0; 458 fcs = (eth_fcs_ t *) data + length - sizeof(eth_fcs_t);463 fcs = (eth_fcs_ref) data + length - sizeof(eth_fcs_t); 459 464 length -= sizeof(eth_fcs_t); 460 465 } else if(type <= ETH_MAX_CONTENT) { … … 482 487 483 488 suffix = (type < ETH_MIN_CONTENT) ? ETH_MIN_CONTENT - type : 0U; 484 fcs = (eth_fcs_ t *) data + prefix + type + suffix;489 fcs = (eth_fcs_ref) data + prefix + type + suffix; 485 490 suffix += length - prefix - type; 486 491 length = prefix + type + suffix; … … 509 514 510 515 int nil_received_msg_local(int nil_phone, device_id_t device_id, 511 packet_t *packet, services_t target)512 { 513 eth_proto_ t *proto;514 packet_t *next;515 eth_device_ t *device;516 packet_t packet, services_t target) 517 { 518 eth_proto_ref proto; 519 packet_t next; 520 eth_device_ref device; 516 521 int flags; 517 522 … … 552 557 * @param[out] content The maximum content size. 553 558 * @param[out] suffix The minimum reserved suffix size. 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.559 * @returns EOK on success. 560 * @returns EBADMEM if either one of the parameters is NULL. 561 * @returns ENOENT if there is no such device. 557 562 */ 558 563 static int eth_packet_space_message(device_id_t device_id, size_t *addr_len, 559 564 size_t *prefix, size_t *content, size_t *suffix) 560 565 { 561 eth_device_ t *device;566 eth_device_ref device; 562 567 563 568 if (!addr_len || !prefix || !content || !suffix) … … 586 591 * @param[in] type Type of the desired address. 587 592 * @param[out] address The device hardware address. 588 * @return EOK on success.589 * @return EBADMEM if the address parameter is NULL.590 * @return ENOENT if there no such device.593 * @returns EOK on success. 594 * @returns EBADMEM if the address parameter is NULL. 595 * @returns ENOENT if there no such device. 591 596 */ 592 597 static int eth_addr_message(device_id_t device_id, eth_addr_type_t type, 593 measured_string_ t **address)594 { 595 eth_device_ t *device;598 measured_string_ref *address) 599 { 600 eth_device_ref device; 596 601 597 602 if (!address) … … 620 625 * @param[in] service The module service. 621 626 * @param[in] phone The service phone. 622 * @return EOK on success.623 * @return ENOENT if the service is not known.624 * @return ENOMEM if there is not enough memory left.627 * @returns EOK on success. 628 * @returns ENOENT if the service is not known. 629 * @returns ENOMEM if there is not enough memory left. 625 630 */ 626 631 static int eth_register_message(services_t service, int phone) 627 632 { 628 eth_proto_ t *proto;633 eth_proto_ref proto; 629 634 int protocol; 630 635 int index; … … 641 646 return EOK; 642 647 } else { 643 proto = (eth_proto_ t *) malloc(sizeof(eth_proto_t));648 proto = (eth_proto_ref) malloc(sizeof(eth_proto_t)); 644 649 if (!proto) { 645 650 fibril_rwlock_write_unlock(ð_globals.protos_lock); … … 673 678 * @param[in] ethertype The ethernet protocol type. 674 679 * @param[in] mtu The device maximum transmission unit. 675 * @return EOK on success.676 * @return EINVAL if the packet addresses length is not long680 * @returns EOK on success. 681 * @returns EINVAL if the packet addresses length is not long 677 682 * enough. 678 * @return EINVAL if the packet is bigger than the device MTU.679 * @return ENOMEM if there is not enough memory in the packet.683 * @returns EINVAL if the packet is bigger than the device MTU. 684 * @returns ENOMEM if there is not enough memory in the packet. 680 685 */ 681 686 static int 682 eth_prepare_packet(int flags, packet_t *packet, uint8_t *src_addr, int ethertype,687 eth_prepare_packet(int flags, packet_t packet, uint8_t *src_addr, int ethertype, 683 688 size_t mtu) 684 689 { 685 eth_header_snap_ t *header;686 eth_header_lsap_ t *header_lsap;687 eth_header_ t *header_dix;688 eth_fcs_ t *fcs;690 eth_header_snap_ref header; 691 eth_header_lsap_ref header_lsap; 692 eth_header_ref header_dix; 693 eth_fcs_ref fcs; 689 694 uint8_t *src; 690 695 uint8_t *dest; … … 692 697 int i; 693 698 void *padding; 694 eth_preamble_ t *preamble;699 eth_preamble_ref preamble; 695 700 696 701 i = packet_get_addr(packet, &src, &dest); … … 783 788 * @param[in] packet The packet queue. 784 789 * @param[in] sender The sending module service. 785 * @return EOK on success.786 * @return ENOENT if there no such device.787 * @return EINVAL if the service parameter is not known.788 */ 789 static int eth_send_message(device_id_t device_id, packet_t *packet,790 * @returns EOK on success. 791 * @returns ENOENT if there no such device. 792 * @returns EINVAL if the service parameter is not known. 793 */ 794 static int eth_send_message(device_id_t device_id, packet_t packet, 790 795 services_t sender) 791 796 { 792 eth_device_ t *device;793 packet_t *next;794 packet_t *tmp;797 eth_device_ref device; 798 packet_t next; 799 packet_t tmp; 795 800 int ethertype; 796 801 int rc; … … 840 845 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 841 846 { 842 measured_string_ t *address;843 packet_t *packet;847 measured_string_ref address; 848 packet_t packet; 844 849 size_t addrlen; 845 850 size_t prefix;
Note:
See TracChangeset
for help on using the changeset viewer.