Changes in uspace/lib/net/il/arp_remote.c [1bfd3d3:14f1db0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/il/arp_remote.c
r1bfd3d3 r14f1db0 27 27 */ 28 28 29 /** @addtogroup libnet30 * @{29 /** @addtogroup arp 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ARP interface implementation for remote modules.35 * @see arp_interface.h34 * ARP interface implementation for remote modules. 35 * @see arp_interface.h 36 36 */ 37 38 #include <arp_interface.h>39 #include <generic.h>40 37 41 38 #include <async.h> … … 43 40 #include <ipc/ipc.h> 44 41 #include <ipc/services.h> 45 #include <ipc/arp.h>46 42 47 #include <net/modules.h> 48 #include <net/device.h> 43 #include <net_messages.h> 44 #include <net_modules.h> 45 #include <net_device.h> 46 #include <arp_interface.h> 49 47 #include <adt/measured_strings.h> 48 #include <arp_messages.h> 50 49 51 /** Connects to the ARP module. 52 * 53 * @param service The ARP module service. Ignored parameter. 54 * @return The ARP module phone on success. 55 */ 56 int arp_connect_module(services_t service) 57 { 58 if (service != SERVICE_ARP) 50 int arp_connect_module(services_t service){ 51 if(service != SERVICE_ARP){ 59 52 return EINVAL; 60 53 } 61 54 return connect_to_service(SERVICE_ARP); 62 55 } 63 56 64 /** Cleans the cache. 65 * 66 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 67 * @return EOK on success. 68 */ 69 int arp_clean_cache_req(int arp_phone) 70 { 57 int arp_clean_cache_req(int arp_phone){ 71 58 return (int) async_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE); 72 59 } 73 60 74 /** Clears the given protocol address from the cache. 75 * 76 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 77 * @param[in] device_id The device identifier. 78 * @param[in] protocol The requesting protocol service. 79 * @param[in] address The protocol address to be cleared. 80 * @return EOK on success. 81 * @return ENOENT if the mapping is not found. 82 */ 83 int 84 arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, 85 measured_string_t *address) 86 { 61 int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address){ 87 62 aid_t message_id; 88 63 ipcarg_t result; 89 64 90 message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, 91 (ipcarg_t) device_id, protocol, NULL); 65 message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, (ipcarg_t) device_id, protocol, NULL); 92 66 measured_strings_send(arp_phone, address, 1); 93 67 async_wait_for(message_id, &result); 94 95 68 return (int) result; 96 69 } 97 70 98 /** Clears the device cache. 99 * 100 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 101 * @param[in] device_id The device identifier. 102 * @return EOK on success. 103 * @return ENOENT if the device is not found. 104 */ 105 int arp_clear_device_req(int arp_phone, device_id_t device_id) 106 { 107 return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, 108 (ipcarg_t) device_id); 71 int arp_clear_device_req(int arp_phone, device_id_t device_id){ 72 return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, (ipcarg_t) device_id); 109 73 } 110 74 111 /** Registers the new device and the requesting protocol service. 112 * 113 * Connects to the network interface layer service. 114 * Determines the device broadcast address, its address lengths and packet size. 115 * 116 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 117 * @param[in] device_id The new device identifier. 118 * @param[in] protocol The requesting protocol service. 119 * @param[in] netif The underlying device network interface layer service. 120 * @param[in] address The local requesting protocol address of the device. 121 * @return EOK on success. 122 * @return EEXIST if the device is already used. 123 * @return ENOMEM if there is not enough memory left. 124 * @return ENOENT if the network interface service is not known. 125 * @return EREFUSED if the network interface service is not 126 * responding. 127 * @return Other error codes as defined for the 128 * nil_packet_get_size() function. 129 * @return Other error codes as defined for the nil_get_addr() 130 * function. 131 * @return Other error codes as defined for the 132 * nil_get_broadcast_addr() function. 133 */ 134 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, 135 services_t netif, measured_string_t *address) 136 { 75 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){ 137 76 aid_t message_id; 138 77 ipcarg_t result; 139 78 140 message_id = async_send_3(arp_phone, NET_ARP_DEVICE, 141 (ipcarg_t) device_id, protocol, netif, NULL); 79 message_id = async_send_3(arp_phone, NET_ARP_DEVICE, (ipcarg_t) device_id, protocol, netif, NULL); 142 80 measured_strings_send(arp_phone, address, 1); 143 81 async_wait_for(message_id, &result); 144 145 82 return (int) result; 146 83 } 147 84 148 /** Translates the given protocol address to the network interface address. 149 * 150 * Broadcasts the ARP request if the mapping is not found. 151 * Allocates and returns the needed memory block as the data parameter. 152 * 153 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 154 * @param[in] device_id The device identifier. 155 * @param[in] protocol The requesting protocol service. 156 * @param[in] address The local requesting protocol address. 157 * @param[out] translation The translation of the local protocol address. 158 * @param[out] data The allocated raw translation data container. 159 * @return EOK on success. 160 * @return EINVAL if the address parameter is NULL. 161 * @return EBADMEM if the translation or the data parameters are 162 * NULL. 163 * @return ENOENT if the mapping is not found. 164 */ 165 int 166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, 167 measured_string_t *address, measured_string_t **translation, char **data) 168 { 169 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, 170 protocol, address, 1, translation, data); 85 task_id_t arp_task_get_id(void){ 86 return 0; 87 } 88 89 int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){ 90 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data); 171 91 } 172 92
Note:
See TracChangeset
for help on using the changeset viewer.