00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00042 #include <ip_remote.h>
00043 #include <ip_interface.h>
00044 #include <packet_client.h>
00045 #include <generic.h>
00046
00047 #include <ipc/services.h>
00048 #include <ipc/il.h>
00049 #include <ipc/ip.h>
00050
00051 #include <net/modules.h>
00052 #include <net/device.h>
00053 #include <net/inet.h>
00054
00065 int ip_add_route_req_remote(int ip_phone, device_id_t device_id,
00066 in_addr_t address, in_addr_t netmask, in_addr_t gateway)
00067 {
00068 return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE,
00069 (sysarg_t) device_id, (sysarg_t) gateway.s_addr,
00070 (sysarg_t) address.s_addr, (sysarg_t) netmask.s_addr);
00071 }
00072
00085 int ip_bind_service(services_t service, int protocol, services_t me,
00086 async_client_conn_t receiver)
00087 {
00088 return (int) bind_service(service, (sysarg_t) protocol, me, service,
00089 receiver);
00090 }
00091
00097 int ip_connect_module(services_t service)
00098 {
00099 return connect_to_service(SERVICE_IP);
00100 }
00101
00120 int ip_device_req_remote(int ip_phone, device_id_t device_id,
00121 services_t service)
00122 {
00123 return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0,
00124 service);
00125 }
00126
00139 int ip_get_route_req_remote(int ip_phone, ip_protocol_t protocol,
00140 const struct sockaddr *destination, socklen_t addrlen,
00141 device_id_t *device_id, void **header, size_t *headerlen)
00142 {
00143 if (!destination || (addrlen == 0))
00144 return EINVAL;
00145
00146 if (!device_id || !header || !headerlen)
00147 return EBADMEM;
00148
00149 *header = NULL;
00150
00151 ipc_call_t answer;
00152 aid_t message_id = async_send_1(ip_phone, NET_IP_GET_ROUTE,
00153 (sysarg_t) protocol, &answer);
00154
00155 if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) &&
00156 (async_data_read_start(ip_phone, headerlen,
00157 sizeof(*headerlen)) == EOK) && (*headerlen > 0)) {
00158 *header = malloc(*headerlen);
00159 if (*header) {
00160 if (async_data_read_start(ip_phone, *header,
00161 *headerlen) != EOK)
00162 free(*header);
00163 }
00164 }
00165
00166 sysarg_t result;
00167 async_wait_for(message_id, &result);
00168
00169 if ((result != EOK) && *header)
00170 free(*header);
00171 else
00172 *device_id = IPC_GET_DEVICE(answer);
00173
00174 return (int) result;
00175 }
00176
00187 int ip_packet_size_req_remote(int ip_phone, device_id_t device_id,
00188 packet_dimension_t *packet_dimension)
00189 {
00190 return generic_packet_size_req_remote(ip_phone, NET_IP_PACKET_SPACE,
00191 device_id, packet_dimension);
00192 }
00193
00205 int ip_received_error_msg_remote(int ip_phone, device_id_t device_id,
00206 packet_t *packet, services_t target, services_t error)
00207 {
00208 return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR,
00209 device_id, packet_get_id(packet), target, error);
00210 }
00211
00227 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t *packet,
00228 services_t sender, services_t error)
00229 {
00230 return generic_send_msg_remote(ip_phone, NET_IP_SEND, device_id,
00231 packet_get_id(packet), sender, error);
00232 }
00233
00242 int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id,
00243 in_addr_t gateway)
00244 {
00245 return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY,
00246 (sysarg_t) device_id, (sysarg_t) gateway.s_addr);
00247 }
00248