Changeset 14f1db0 in mainline for uspace/srv/net/il/ip/ip.c
- Timestamp:
- 2010-04-09T12:54:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1caa3c2
- Parents:
- 24ab58b3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/ip/ip.c
r24ab58b3 r14f1db0 69 69 #include <adt/module_map.h> 70 70 #include <packet/packet_client.h> 71 #include <packet_remote.h> 71 72 #include <nil_messages.h> 72 73 #include <il_messages.h> 74 #include <il_local.h> 75 #include <ip_local.h> 73 76 74 77 #include "ip.h" … … 424 427 } 425 428 426 int ip_device_req (int il_phone, device_id_t device_id, services_t netif){429 int ip_device_req_local(int il_phone, device_id_t device_id, services_t netif){ 427 430 ERROR_DECLARE; 428 431 … … 656 659 } 657 660 658 int ip_send_msg (int il_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){661 int ip_send_msg_local(int il_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){ 659 662 ERROR_DECLARE; 660 663 … … 782 785 // sleep(1); 783 786 // ERROR_PROPAGATE(arp_translate_req(netif->arp->phone, netif->device_id, SERVICE_IP, &destination, &translation, &data)); 784 pq_release (ip_globals.net_phone, packet_get_id(packet));787 pq_release_remote(ip_globals.net_phone, packet_get_id(packet)); 785 788 return ERROR_CODE; 786 789 } … … 799 802 }else translation = NULL; 800 803 if(ERROR_OCCURRED(ip_prepare_packet(src, dest, packet, translation))){ 801 pq_release (ip_globals.net_phone, packet_get_id(packet));804 pq_release_remote(ip_globals.net_phone, packet_get_id(packet)); 802 805 }else{ 803 806 packet = ip_split_packet(packet, netif->packet_dimension.prefix, netif->packet_dimension.content, netif->packet_dimension.suffix, netif->packet_dimension.addr_len, error); … … 891 894 } 892 895 893 int ip_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 896 int ip_message_standalone(ipc_callid_t callid, ipc_call_t *call, 897 ipc_call_t *answer, int * answer_count) 898 { 894 899 ERROR_DECLARE; 895 900 896 901 packet_t packet; 897 struct sockaddr * 902 struct sockaddr *addr; 898 903 size_t addrlen; 899 904 size_t prefix; 900 905 size_t suffix; 901 906 size_t content; 902 ip_pseudo_header_refheader;907 void *header; 903 908 size_t headerlen; 904 909 device_id_t device_id; 905 910 906 911 *answer_count = 0; 907 switch (IPC_GET_METHOD(*call)){912 switch (IPC_GET_METHOD(*call)) { 908 913 case IPC_M_PHONE_HUNGUP: 909 914 return EOK; 910 915 case NET_IL_DEVICE: 911 return ip_device_req(0, IPC_GET_DEVICE(call), IPC_GET_SERVICE(call)); 916 return ip_device_req_local(0, IPC_GET_DEVICE(call), 917 IPC_GET_SERVICE(call)); 912 918 case IPC_M_CONNECT_TO_ME: 913 return ip_register(IL_GET_PROTO(call), IL_GET_SERVICE(call), IPC_GET_PHONE(call), NULL); 919 return ip_register(IL_GET_PROTO(call), IL_GET_SERVICE(call), 920 IPC_GET_PHONE(call), NULL); 914 921 case NET_IL_SEND: 915 ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call))); 916 return ip_send_msg(0, IPC_GET_DEVICE(call), packet, 0, IPC_GET_ERROR(call)); 922 ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet, 923 IPC_GET_PACKET(call))); 924 return ip_send_msg_local(0, IPC_GET_DEVICE(call), packet, 0, 925 IPC_GET_ERROR(call)); 917 926 case NET_IL_DEVICE_STATE: 918 return ip_device_state_message(IPC_GET_DEVICE(call), IPC_GET_STATE(call)); 927 return ip_device_state_message(IPC_GET_DEVICE(call), 928 IPC_GET_STATE(call)); 919 929 case NET_IL_RECEIVED: 920 ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call))); 930 ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet, 931 IPC_GET_PACKET(call))); 921 932 return ip_receive_message(IPC_GET_DEVICE(call), packet); 922 933 case NET_IP_RECEIVED_ERROR: 923 ERROR_PROPAGATE(packet_translate(ip_globals.net_phone, &packet, IPC_GET_PACKET(call))); 924 return ip_received_error_msg(0, IPC_GET_DEVICE(call), packet, IPC_GET_TARGET(call), IPC_GET_ERROR(call)); 934 ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone, &packet, 935 IPC_GET_PACKET(call))); 936 return ip_received_error_msg_local(0, IPC_GET_DEVICE(call), packet, 937 IPC_GET_TARGET(call), IPC_GET_ERROR(call)); 925 938 case NET_IP_ADD_ROUTE: 926 return ip_add_route_req(0, IPC_GET_DEVICE(call), IP_GET_ADDRESS(call), IP_GET_NETMASK(call), IP_GET_GATEWAY(call)); 939 return ip_add_route_req_local(0, IPC_GET_DEVICE(call), 940 IP_GET_ADDRESS(call), IP_GET_NETMASK(call), IP_GET_GATEWAY(call)); 927 941 case NET_IP_SET_GATEWAY: 928 return ip_set_gateway_req(0, IPC_GET_DEVICE(call), IP_GET_GATEWAY(call)); 942 return ip_set_gateway_req_local(0, IPC_GET_DEVICE(call), 943 IP_GET_GATEWAY(call)); 929 944 case NET_IP_GET_ROUTE: 930 945 ERROR_PROPAGATE(data_receive((void **) &addr, &addrlen)); 931 ERROR_PROPAGATE(ip_get_route_req (0, IP_GET_PROTOCOL(call), addr, (socklen_t) addrlen,932 &device_id, &header, &headerlen));946 ERROR_PROPAGATE(ip_get_route_req_local(0, IP_GET_PROTOCOL(call), 947 addr, (socklen_t) addrlen, &device_id, &header, &headerlen)); 933 948 IPC_SET_DEVICE(answer, device_id); 934 949 IP_SET_HEADERLEN(answer, headerlen); 950 935 951 *answer_count = 2; 936 if(! ERROR_OCCURRED(data_reply(&headerlen, sizeof(headerlen)))){ 952 953 if (!ERROR_OCCURRED(data_reply(&headerlen, sizeof(headerlen)))) 937 954 ERROR_CODE = data_reply(header, headerlen); 938 }955 939 956 free(header); 940 957 return ERROR_CODE; 941 958 case NET_IL_PACKET_SPACE: 942 ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call), &addrlen, &prefix, &content, &suffix)); 959 ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call), 960 &addrlen, &prefix, &content, &suffix)); 943 961 IPC_SET_ADDR(answer, addrlen); 944 962 IPC_SET_PREFIX(answer, prefix); … … 948 966 return EOK; 949 967 case NET_IL_MTU_CHANGED: 950 return ip_mtu_changed_message(IPC_GET_DEVICE(call), IPC_GET_MTU(call)); 951 } 968 return ip_mtu_changed_message(IPC_GET_DEVICE(call), 969 IPC_GET_MTU(call)); 970 } 971 952 972 return ENOTSUP; 953 973 } 954 974 955 int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension){ 956 if(! packet_dimension){ 975 int ip_packet_size_req_local(int ip_phone, device_id_t device_id, 976 packet_dimension_ref packet_dimension) 977 { 978 if (!packet_dimension) 957 979 return EBADMEM; 958 } 959 return ip_packet_size_message(device_id, &packet_dimension->addr_len, &packet_dimension->prefix, &packet_dimension->content, &packet_dimension->suffix); 980 981 return ip_packet_size_message(device_id, &packet_dimension->addr_len, 982 &packet_dimension->prefix, &packet_dimension->content, 983 &packet_dimension->suffix); 960 984 } 961 985 … … 1003 1027 } 1004 1028 1005 int ip_add_route_req (int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){1029 int ip_add_route_req_local(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){ 1006 1030 ip_route_ref route; 1007 1031 ip_netif_ref netif; … … 1067 1091 } 1068 1092 1069 int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway){ 1093 int ip_set_gateway_req_local(int ip_phone, device_id_t device_id, in_addr_t gateway) 1094 { 1070 1095 ip_netif_ref netif; 1071 1096 … … 1112 1137 } 1113 1138 }else{ 1114 pq_release (ip_globals.net_phone, packet_get_id(next));1139 pq_release_remote(ip_globals.net_phone, packet_get_id(next)); 1115 1140 } 1116 1141 next = new_packet; … … 1153 1178 } 1154 1179 // create the last fragment 1155 new_packet = packet_get_4 (ip_globals.net_phone, prefix, length, suffix, ((addrlen > addr_len) ? addrlen : addr_len));1180 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length, suffix, ((addrlen > addr_len) ? addrlen : addr_len)); 1156 1181 if(! new_packet){ 1157 1182 return ENOMEM; … … 1177 1202 // create middle framgents 1178 1203 while(IP_TOTAL_LENGTH(header) > length){ 1179 new_packet = packet_get_4 (ip_globals.net_phone, prefix, length, suffix, ((addrlen >= addr_len) ? addrlen : addr_len));1204 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length, suffix, ((addrlen >= addr_len) ? addrlen : addr_len)); 1180 1205 if(! new_packet){ 1181 1206 return ENOMEM; … … 1357 1382 } 1358 1383 1359 int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){ 1384 /** Notify the IP module about the received error notification packet. 1385 * 1386 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 1387 * @param[in] device_id The device identifier. 1388 * @param[in] packet The received packet or the received packet queue. 1389 * @param[in] target The target internetwork module service to be 1390 * delivered to. 1391 * @param[in] error The packet error reporting service. Prefixes the 1392 * received packet. 1393 * 1394 * @return EOK on success. 1395 * 1396 */ 1397 int ip_received_error_msg_local(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){ 1360 1398 uint8_t * data; 1361 1399 int offset; … … 1492 1530 next = pq_detach(packet); 1493 1531 if(next){ 1494 pq_release (ip_globals.net_phone, packet_get_id(next));1532 pq_release_remote(ip_globals.net_phone, packet_get_id(next)); 1495 1533 } 1496 1534 if(! header){ … … 1556 1594 1557 1595 int ip_release_and_return(packet_t packet, int result){ 1558 pq_release (ip_globals.net_phone, packet_get_id(packet));1596 pq_release_remote(ip_globals.net_phone, packet_get_id(packet)); 1559 1597 return result; 1560 1598 } 1561 1599 1562 int ip_get_route_req (int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref *header, size_t * headerlen){1600 int ip_get_route_req_local(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, void **header, size_t * headerlen){ 1563 1601 struct sockaddr_in * address_in; 1564 1602 // struct sockaddr_in6 * address_in6; … … 1624 1662 header_in->protocol = protocol; 1625 1663 header_in->data_length = 0; 1626 *header = (ip_pseudo_header_ref)header_in;1664 *header = header_in; 1627 1665 return EOK; 1628 1666 } 1629 1630 #ifdef CONFIG_NETWORKING_modular1631 1632 #include <il_standalone.h>1633 1667 1634 1668 /** Default thread for new connections. … … 1658 1692 1659 1693 /* Process the message */ 1660 int res = il_module_message(callid, &call, &answer, &answer_count); 1694 int res = il_module_message_standalone(callid, &call, &answer, 1695 &answer_count); 1661 1696 1662 1697 /* End if said to either by the message or the processing result */ … … 1683 1718 1684 1719 /* Start the module */ 1685 if (ERROR_OCCURRED(il_module_start (il_client_connection)))1720 if (ERROR_OCCURRED(il_module_start_standalone(il_client_connection))) 1686 1721 return ERROR_CODE; 1687 1722 … … 1689 1724 } 1690 1725 1691 #endif /* CONFIG_NETWORKING_modular */1692 1693 1726 /** @} 1694 1727 */
Note:
See TracChangeset
for help on using the changeset viewer.