Changeset f4f866c in mainline for uspace/srv/net/nil/eth/eth.c
- Timestamp:
- 2010-04-23T21:42:26Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c39a907
- Parents:
- 38aaacc2 (diff), 80badbe (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
r38aaacc2 rf4f866c 60 60 #include <adt/measured_strings.h> 61 61 #include <packet/packet_client.h> 62 #include <packet_remote.h> 63 #include <nil_local.h> 62 64 63 65 #include "eth.h" … … 66 68 /** The module name. 67 69 */ 68 #define NAME "Ethernet protocol"70 #define NAME "eth" 69 71 70 72 /** Reserved packet prefix length. … … 270 272 INT_MAP_IMPLEMENT(eth_protos, eth_proto_t) 271 273 272 int nil_device_state_msg (int nil_phone, device_id_t device_id, int state){274 int nil_device_state_msg_local(int nil_phone, device_id_t device_id, int state){ 273 275 int index; 274 276 eth_proto_ref proto; … … 401 403 return index; 402 404 } 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); 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); 404 411 } 405 412 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 469 476 } 470 477 471 int nil_received_msg (int nil_phone, device_id_t device_id, packet_t packet, services_t target){478 int nil_received_msg_local(int nil_phone, device_id_t device_id, packet_t packet, services_t target){ 472 479 eth_proto_ref proto; 473 480 packet_t next; … … 491 498 }else{ 492 499 // drop invalid/unknown 493 pq_release (eth_globals.net_phone, packet_get_id(packet));500 pq_release_remote(eth_globals.net_phone, packet_get_id(packet)); 494 501 } 495 502 packet = next; … … 571 578 } 572 579 } 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); 580 581 printf("%s: Protocol registered (protocol: %d, service: %d, phone: %d)\n", 582 NAME, proto->protocol, proto->service, proto->phone); 583 574 584 fibril_rwlock_write_unlock(ð_globals.protos_lock); 575 585 return EOK; … … 672 682 ethertype = htons(protocol_map(SERVICE_ETHERNET, sender)); 673 683 if(! ethertype){ 674 pq_release (eth_globals.net_phone, packet_get_id(packet));684 pq_release_remote(eth_globals.net_phone, packet_get_id(packet)); 675 685 return EINVAL; 676 686 } … … 690 700 packet = tmp; 691 701 } 692 pq_release (eth_globals.net_phone, packet_get_id(next));702 pq_release_remote(eth_globals.net_phone, packet_get_id(next)); 693 703 next = tmp; 694 704 }else{ … … 704 714 } 705 715 706 int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 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 { 707 719 ERROR_DECLARE; 708 720 709 721 measured_string_ref address; 710 722 packet_t packet; … … 713 725 size_t suffix; 714 726 size_t content; 715 716 // printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_NIL_FIRST); 727 717 728 *answer_count = 0; 718 switch (IPC_GET_METHOD(*call)){729 switch (IPC_GET_METHOD(*call)) { 719 730 case IPC_M_PHONE_HUNGUP: 720 731 return EOK; 721 732 case NET_NIL_DEVICE: 722 return eth_device_message(IPC_GET_DEVICE(call), IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 733 return eth_device_message(IPC_GET_DEVICE(call), 734 IPC_GET_SERVICE(call), IPC_GET_MTU(call)); 723 735 case NET_NIL_SEND: 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)); 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)); 726 740 case NET_NIL_PACKET_SPACE: 727 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix)); 741 ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call), 742 &addrlen, &prefix, &content, &suffix)); 728 743 IPC_SET_ADDR(answer, addrlen); 729 744 IPC_SET_PREFIX(answer, prefix); … … 733 748 return EOK; 734 749 case NET_NIL_ADDR: 735 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR, &address)); 750 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 751 ETH_LOCAL_ADDR, &address)); 736 752 return measured_strings_reply(address, 1); 737 753 case NET_NIL_BROADCAST_ADDR: 738 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR, &address)); 754 ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call), 755 ETH_BROADCAST_ADDR, &address)); 739 756 return measured_strings_reply(address, 1); 740 757 case IPC_M_CONNECT_TO_ME: 741 return eth_register_message(NIL_GET_PROTO(call), IPC_GET_PHONE(call)); 742 } 758 return eth_register_message(NIL_GET_PROTO(call), 759 IPC_GET_PHONE(call)); 760 } 761 743 762 return ENOTSUP; 744 763 } … … 753 772 switch(IPC_GET_METHOD(*icall)){ 754 773 case NET_NIL_DEVICE_STATE: 755 nil_device_state_msg (0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall));774 nil_device_state_msg_local(0, IPC_GET_DEVICE(icall), IPC_GET_STATE(icall)); 756 775 ipc_answer_0(iid, EOK); 757 776 break; 758 777 case NET_NIL_RECEIVED: 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);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); 761 780 } 762 781 ipc_answer_0(iid, (ipcarg_t) ERROR_CODE); … … 769 788 } 770 789 771 #ifdef CONFIG_NETWORKING_modular 772 773 #include <nil_standalone.h> 790 #ifndef CONFIG_NETIF_NIL_BUNDLE 774 791 775 792 /** Default thread for new connections. 776 793 * 777 * 778 * 794 * @param[in] iid The initial message identifier. 795 * @param[in] icall The initial message call structure. 779 796 * 780 797 */ 781 static void nil_client_connection(ipc_callid_t iid, ipc_call_t * 798 static void nil_client_connection(ipc_callid_t iid, ipc_call_t *icall) 782 799 { 783 800 /* … … 799 816 800 817 /* Process the message */ 801 int res = nil_module_message(callid, &call, &answer, &answer_count); 818 int res = nil_module_message_standalone(NAME, callid, &call, &answer, 819 &answer_count); 802 820 803 821 /* End if said to either by the message or the processing result */ … … 810 828 } 811 829 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 */821 830 int main(int argc, char *argv[]) 822 831 { 823 832 ERROR_DECLARE; 824 833 825 /* Print the module label */826 printf("Task %d - %s\n", task_get_id(), NAME);827 828 834 /* Start the module */ 829 if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) { 830 printf(" - ERROR %i\n", ERROR_CODE); 835 if (ERROR_OCCURRED(nil_module_start_standalone(nil_client_connection))) 831 836 return ERROR_CODE; 832 }833 837 834 838 return EOK; 835 839 } 836 840 837 #endif /* CONFIG_NET WORKING_modular*/841 #endif /* CONFIG_NETIF_NIL_BUNDLE */ 838 842 839 843 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.