Changes in uspace/srv/net/nil/eth/eth.c [14f1db0:849ed54] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/nil/eth/eth.c
r14f1db0 r849ed54 60 60 #include <adt/measured_strings.h> 61 61 #include <packet/packet_client.h> 62 #include <packet_remote.h>63 #include <nil_local.h>64 62 65 63 #include "eth.h" … … 68 66 /** The module name. 69 67 */ 70 #define NAME "eth"68 #define NAME "Ethernet protocol" 71 69 72 70 /** Reserved packet prefix length. … … 272 270 INT_MAP_IMPLEMENT(eth_protos, eth_proto_t) 273 271 274 int nil_device_state_msg _local(int nil_phone, device_id_t device_id, int state){272 int nil_device_state_msg(int nil_phone, device_id_t device_id, int state){ 275 273 int index; 276 274 eth_proto_ref proto; … … 403 401 return index; 404 402 } 405 printf("%s: Device registered (id: %d, service: %d: mtu: %d, " 406 "mac: %x:%x:%x:%x:%x:%x, flags: 0x%x)\n", 407 NAME, device->device_id, device->service, device->mtu, 408 device->addr_data[0], device->addr_data[1], 409 device->addr_data[2], device->addr_data[3], 410 device->addr_data[4], device->addr_data[5], device->flags); 403 printf("New device registered:\n\tid\t= %d\n\tservice\t= %d\n\tMTU\t= %d\n\taddress\t= %X:%X:%X:%X:%X:%X\n\tflags\t= 0x%x\n", device->device_id, device->service, device->mtu, device->addr_data[0], device->addr_data[1], device->addr_data[2], device->addr_data[3], device->addr_data[4], device->addr_data[5], device->flags); 411 404 } 412 405 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 476 469 } 477 470 478 int nil_received_msg _local(int nil_phone, device_id_t device_id, packet_t packet, services_t target){471 int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target){ 479 472 eth_proto_ref proto; 480 473 packet_t next; … … 498 491 }else{ 499 492 // drop invalid/unknown 500 pq_release _remote(eth_globals.net_phone, packet_get_id(packet));493 pq_release(eth_globals.net_phone, packet_get_id(packet)); 501 494 } 502 495 packet = next; … … 578 571 } 579 572 } 580 581 printf("%s: Protocol registered (protocol: %d, service: %d, phone: %d)\n", 582 NAME, proto->protocol, proto->service, proto->phone); 583 573 printf("New protocol registered:\n\tprotocol\t= 0x%x\n\tservice\t= %d\n\tphone\t= %d\n", proto->protocol, proto->service, proto->phone); 584 574 fibril_rwlock_write_unlock(ð_globals.protos_lock); 585 575 return EOK; … … 682 672 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 683 673 if(! ethertype){ 684 pq_release _remote(eth_globals.net_phone, packet_get_id(packet));674 pq_release(eth_globals.net_phone, packet_get_id(packet)); 685 675 return EINVAL; 686 676 } … … 700 690 packet = tmp; 701 691 } 702 pq_release _remote(eth_globals.net_phone, packet_get_id(next));692 pq_release(eth_globals.net_phone, packet_get_id(next)); 703 693 next = tmp; 704 694 }else{ … … 714 704 } 715 705 716 int nil_message_standalone(const char *name, ipc_callid_t callid, ipc_call_t *call, 717 ipc_call_t *answer, int *answer_count) 718 { 706 int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 719 707 ERROR_DECLARE; 720 708 721 709 measured_string_ref address; 722 710 packet_t packet; … … 725 713 size_t suffix; 726 714 size_t content; 727 715 716 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_NIL_FIRST); 728 717 *answer_count = 0; 729 switch (IPC_GET_METHOD(*call)){718 switch(IPC_GET_METHOD(*call)){ 730 719 case IPC_M_PHONE_HUNGUP: 731 720 return EOK; 732 721 case NET_NIL_DEVICE: 733 return eth_device_message(IPC_GET_DEVICE(call), 734 IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 722 return eth_device_message(IPC_GET_DEVICE(call), IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 735 723 case NET_NIL_SEND: 736 ERROR_PROPAGATE(packet_translate_remote(eth_globals.net_phone, &packet, 737 IPC_GET_PACKET(call))); 738 return eth_send_message(IPC_GET_DEVICE(call), packet, 739 IPC_GET_SERVICE(call)); 724 ERROR_PROPAGATE(packet_translate(eth_globals.net_phone, &packet, IPC_GET_PACKET(call))); 725 return eth_send_message(IPC_GET_DEVICE(call), packet, IPC_GET_SERVICE(call)); 740 726 case NET_NIL_PACKET_SPACE: 741 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), 742 &addrlen, &prefix, &content, &suffix)); 727 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix)); 743 728 IPC_SET_ADDR(answer, addrlen); 744 729 IPC_SET_PREFIX(answer, prefix); … … 748 733 return EOK; 749 734 case NET_NIL_ADDR: 750 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 751 ETH_LOCAL_ADDR, &address)); 735 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR, &address)); 752 736 return measured_strings_reply(address, 1); 753 737 case NET_NIL_BROADCAST_ADDR: 754 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 755 ETH_BROADCAST_ADDR, &address)); 738 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR, &address)); 756 739 return measured_strings_reply(address, 1); 757 740 case IPC_M_CONNECT_TO_ME: 758 return eth_register_message(NIL_GET_PROTO(call), 759 IPC_GET_PHONE(call)); 760 } 761 741 return eth_register_message(NIL_GET_PROTO(call), IPC_GET_PHONE(call)); 742 } 762 743 return ENOTSUP; 763 744 } … … 772 753 switch(IPC_GET_METHOD(*icall)){ 773 754 case NET_NIL_DEVICE_STATE: 774 nil_device_state_msg _local(0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall));755 nil_device_state_msg(0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall)); 775 756 ipc_answer_0(iid, EOK); 776 757 break; 777 758 case NET_NIL_RECEIVED: 778 if(! ERROR_OCCURRED(packet_translate _remote(eth_globals.net_phone, &packet, IPC_GET_PACKET(icall)))){779 ERROR_CODE = nil_received_msg _local(0, IPC_GET_DEVICE(icall), packet, 0);759 if(! ERROR_OCCURRED(packet_translate(eth_globals.net_phone, &packet, IPC_GET_PACKET(icall)))){ 760 ERROR_CODE = nil_received_msg(0, IPC_GET_DEVICE(icall), packet, 0); 780 761 } 781 762 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE); … … 788 769 } 789 770 790 #ifndef CONFIG_NETIF_NIL_BUNDLE 771 #ifdef CONFIG_NETWORKING_modular 772 773 #include <nil_standalone.h> 791 774 792 775 /** Default thread for new connections. 793 776 * 794 * @param[in] iid The initial message identifier.795 * @param[in] icall The initial message call structure.777 * @param[in] iid The initial message identifier. 778 * @param[in] icall The initial message call structure. 796 779 * 797 780 */ 798 static void nil_client_connection(ipc_callid_t iid, ipc_call_t * icall)781 static void nil_client_connection(ipc_callid_t iid, ipc_call_t * icall) 799 782 { 800 783 /* … … 816 799 817 800 /* Process the message */ 818 int res = nil_module_message_standalone(NAME, callid, &call, &answer, 819 &answer_count); 801 int res = nil_module_message(callid, &call, &answer, &answer_count); 820 802 821 803 /* End if said to either by the message or the processing result */ … … 828 810 } 829 811 812 /** Starts the module. 813 * 814 * @param argc The count of the command line arguments. Ignored parameter. 815 * @param argv The command line parameters. Ignored parameter. 816 * 817 * @returns EOK on success. 818 * @returns Other error codes as defined for each specific module start function. 819 * 820 */ 830 821 int main(int argc, char *argv[]) 831 822 { 832 823 ERROR_DECLARE; 833 824 825 /* Print the module label */ 826 printf("Task %d - %s\n", task_get_id(), NAME); 827 834 828 /* Start the module */ 835 if (ERROR_OCCURRED(nil_module_start_standalone(nil_client_connection))) 829 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) { 830 printf(" - ERROR %i\n", ERROR_CODE); 836 831 return ERROR_CODE; 832 } 837 833 838 834 return EOK; 839 835 } 840 836 841 #endif /* CONFIG_NET IF_NIL_BUNDLE*/837 #endif /* CONFIG_NETWORKING_modular */ 842 838 843 839 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.