Changes in uspace/lib/net/il/ip_remote.c [14f1db0:849ed54] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/il/ip_remote.c
r14f1db0 r849ed54 28 28 29 29 /** @addtogroup ip 30 * @{30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 35 * IP interface implementation for remote modules. 36 * 37 * @see ip_interface.h 38 * @see il_interface.h 39 * 34 * IP interface implementation for standalone remote modules. 35 * @see ip_interface.h 36 * @see il_interface.h 40 37 */ 41 38 … … 50 47 #include <il_messages.h> 51 48 #include <ip_messages.h> 52 #include <ip_remote.h>53 49 54 /** Add a route to the device routing table. 55 * 56 * The target network is routed using this device. 57 * 58 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 59 * @param[in] device_id The device identifier. 60 * @param[in] address The target network address. 61 * @param[in] netmask The target network mask. 62 * @param[in] gateway The target network gateway. Not used if zero. 63 * 64 */ 65 int ip_add_route_req_remote(int ip_phone, device_id_t device_id, 66 in_addr_t address, in_addr_t netmask, in_addr_t gateway) 67 { 68 return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE, 69 (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr, 70 (ipcarg_t) address.s_addr, (ipcarg_t) netmask.s_addr); 50 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){ 51 return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr, (ipcarg_t) address.s_addr, (ipcarg_t) netmask.s_addr); 71 52 } 72 53 73 int ip_bind_service(services_t service, int protocol, services_t me, 74 async_client_conn_t receiver, tl_received_msg_t tl_received_msg) 75 { 76 return (int) bind_service(service, (ipcarg_t) protocol, me, service, 77 receiver); 54 int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg){ 55 return (int) bind_service(service, (ipcarg_t) protocol, me, service, receiver); 78 56 } 79 57 80 int ip_connect_module(services_t service) 81 { 58 int ip_connect_module(services_t service){ 82 59 return connect_to_service(SERVICE_IP); 83 60 } 84 61 85 /** Register the new device. 86 * 87 * Register itself as the ip packet receiver. 88 * If the device uses ARP registers also the new ARP device. 89 * 90 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 91 * @param[in] device_id The new device identifier. 92 * @param[in] netif The underlying device network interface layer service. 93 * 94 * @return EOK on success. 95 * @return ENOMEM if there is not enough memory left. 96 * @return EINVAL if the device configuration is invalid. 97 * @return ENOTSUP if the device uses IPv6. 98 * @return ENOTSUP if the device uses DHCP. 99 * @return Other error codes as defined for the net_get_device_conf_req() 100 * function. 101 * @return Other error codes as defined for the arp_device_req() function. 102 * 103 */ 104 int ip_device_req_remote(int ip_phone, device_id_t device_id, 105 services_t service) 106 { 107 return generic_device_req_remote(ip_phone, NET_IL_DEVICE, device_id, 0, 108 service); 62 int ip_device_req(int ip_phone, device_id_t device_id, services_t service){ 63 return generic_device_req(ip_phone, NET_IL_DEVICE, device_id, 0, service); 109 64 } 110 65 111 /** Return the device identifier and the IP pseudo header based on the destination address. 112 * 113 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 114 * @param[in] protocol The transport protocol. 115 * @param[in] destination The destination address. 116 * @param[in] addrlen The destination address length. 117 * @param[out] device_id The device identifier. 118 * @param[out] header The constructed IP pseudo header. 119 * @param[out] headerlen The IP pseudo header length. 120 * 121 */ 122 int ip_get_route_req_remote(int ip_phone, ip_protocol_t protocol, 123 const struct sockaddr *destination, socklen_t addrlen, 124 device_id_t *device_id, void **header, size_t *headerlen) 125 { 126 if ((!destination) || (addrlen == 0)) 66 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){ 67 aid_t message_id; 68 ipcarg_t result; 69 ipc_call_t answer; 70 71 if(!(destination && (addrlen > 0))){ 127 72 return EINVAL; 128 129 if ((!device_id) || (header) || (headerlen))73 } 74 if(!(device_id && header && headerlen)){ 130 75 return EBADMEM; 131 76 } 77 132 78 *header = NULL; 133 134 ipc_call_t answer; 135 aid_t message_id = async_send_1(ip_phone, NET_IP_GET_ROUTE, 136 (ipcarg_t) protocol, &answer); 137 138 if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) 139 && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK) 140 && (*headerlen > 0)) { 141 *header = malloc(*headerlen); 142 if (*header) { 143 if (async_data_read_start(ip_phone, *header, *headerlen) != EOK) 79 message_id = async_send_1(ip_phone, NET_IP_GET_ROUTE, (ipcarg_t) protocol, &answer); 80 if((async_data_write_start(ip_phone, destination, addrlen) == EOK) 81 && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK) 82 && (*headerlen > 0)){ 83 *header = (ip_pseudo_header_ref) malloc(*headerlen); 84 if(*header){ 85 if(async_data_read_start(ip_phone, * header, * headerlen) != EOK){ 144 86 free(*header); 87 } 145 88 } 146 89 } 147 148 ipcarg_t result;149 90 async_wait_for(message_id, &result); 150 151 if ((result != EOK) && (*header))91 92 if((result != EOK) && (*header)){ 152 93 free(*header); 153 else94 }else{ 154 95 *device_id = IPC_GET_DEVICE(&answer); 155 96 } 156 97 return (int) result; 157 98 } 158 99 159 /** Return the device packet dimension for sending. 160 * 161 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 162 * @param[in] device_id The device identifier. 163 * @param[out] packet_dimension The packet dimension. 164 * 165 * @return EOK on success. 166 * @return ENOENT if there is no such device. 167 * @return Other error codes as defined for the 168 * generic_packet_size_req_remote() function. 169 * 170 */ 171 int ip_packet_size_req_remote(int ip_phone, device_id_t device_id, 172 packet_dimension_ref packet_dimension) 173 { 174 return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id, 175 packet_dimension); 100 int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension){ 101 return generic_packet_size_req(ip_phone, NET_IL_PACKET_SPACE, device_id, packet_dimension); 176 102 } 177 103 178 /** Notify the IP module about the received error notification packet. 179 * 180 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 181 * @param[in] device_id The device identifier. 182 * @param[in] packet The received packet or the received packet queue. 183 * @param[in] target The target internetwork module service to be 184 * delivered to. 185 * @param[in] error The packet error reporting service. Prefixes the 186 * received packet. 187 * 188 * @return EOK on success. 189 * 190 */ 191 int ip_received_error_msg_remote(int ip_phone, device_id_t device_id, 192 packet_t packet, services_t target, services_t error) 193 { 194 return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR, 195 device_id, packet_get_id(packet), target, error); 104 int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){ 105 return generic_received_msg(ip_phone, NET_IP_RECEIVED_ERROR, device_id, packet_get_id(packet), target, error); 196 106 } 197 107 198 /** Send the packet queue. 199 * 200 * The packets may get fragmented if needed. 201 * 202 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 203 * @param[in] device_id The device identifier. 204 * @param[in] packet The packet fragments as a packet queue. All the 205 * packets have to have the same destination address. 206 * @param[in] sender The sending module service. 207 * @param[in] error The packet error reporting service. Prefixes the 208 * received packet. 209 * 210 * @return EOK on success. 211 * @return Other error codes as defined for the generic_send_msg() function. 212 * 213 */ 214 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t packet, 215 services_t sender, services_t error) 216 { 217 return generic_send_msg_remote(ip_phone, NET_IL_SEND, device_id, 218 packet_get_id(packet), sender, error); 108 int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){ 109 return generic_send_msg(ip_phone, NET_IL_SEND, device_id, packet_get_id(packet), sender, error); 219 110 } 220 111 221 /** Set the default gateway. 222 * 223 * This gateway is used if no other route is found. 224 * 225 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 226 * @param[in] device_id The device identifier. 227 * @param[in] gateway The default gateway. 228 * 229 */ 230 int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id, 231 in_addr_t gateway) 232 { 233 return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY, 234 (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr); 112 int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway){ 113 return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr); 235 114 } 236 115
Note:
See TracChangeset
for help on using the changeset viewer.