[21580dd] | 1 | /*
|
---|
| 2 | * Copyright (c) 2009 Lukas Mejdrech
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup arp
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | #ifndef __NET_ARP_INTERFACE_H__
|
---|
| 34 | #define __NET_ARP_INTERFACE_H__
|
---|
| 35 |
|
---|
[849ed54] | 36 | #include <adt/measured_strings.h>
|
---|
[514ee46] | 37 | #include <task.h>
|
---|
| 38 |
|
---|
| 39 | #include <ipc/services.h>
|
---|
| 40 |
|
---|
[e526f08] | 41 | #include <net/device.h>
|
---|
[514ee46] | 42 | #include <net/socket.h>
|
---|
[21580dd] | 43 |
|
---|
| 44 | /** @name ARP module interface
|
---|
| 45 | * This interface is used by other modules.
|
---|
| 46 | */
|
---|
| 47 | /*@{*/
|
---|
| 48 |
|
---|
| 49 | /** Registers the new device and the requesting protocol service.
|
---|
| 50 | * Connects to the network interface layer service.
|
---|
| 51 | * Determines the device broadcast address, its address lengths and packet size.
|
---|
| 52 | * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
|
---|
| 53 | * @param[in] device_id The new device identifier.
|
---|
| 54 | * @param[in] protocol The requesting protocol service.
|
---|
| 55 | * @param[in] netif The underlying device network interface layer service.
|
---|
| 56 | * @param[in] address The local requesting protocol address of the device.
|
---|
| 57 | * @returns EOK on success.
|
---|
| 58 | * @returns EEXIST if the device is already used.
|
---|
| 59 | * @returns ENOMEM if there is not enough memory left.
|
---|
| 60 | * @returns ENOENT if the network interface service is not known.
|
---|
| 61 | * @returns EREFUSED if the network interface service is not responding.
|
---|
| 62 | * @returns Other error codes as defined for the nil_packet_get_size() function.
|
---|
| 63 | * @returns Other error codes as defined for the nil_get_addr() function.
|
---|
| 64 | * @returns Other error codes as defined for the nil_get_broadcast_addr() function.
|
---|
| 65 | */
|
---|
[849ed54] | 66 | extern int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address);
|
---|
[21580dd] | 67 |
|
---|
| 68 | /** Translates the given protocol address to the network interface address.
|
---|
| 69 | * Broadcasts the ARP request if the mapping is not found.
|
---|
| 70 | * Allocates and returns the needed memory block as the data parameter.
|
---|
| 71 | * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
|
---|
| 72 | * @param[in] device_id The device identifier.
|
---|
| 73 | * @param[in] protocol The requesting protocol service.
|
---|
| 74 | * @param[in] address The local requesting protocol address.
|
---|
| 75 | * @param[out] translation The translation of the local protocol address.
|
---|
| 76 | * @param[out] data The allocated raw translation data container.
|
---|
| 77 | * @returns EOK on success.
|
---|
| 78 | * @returns EINVAL if the address parameter is NULL.
|
---|
| 79 | * @returns EBADMEM if the translation or the data parameters are NULL.
|
---|
| 80 | * @returns ENOENT if the mapping is not found.
|
---|
| 81 | */
|
---|
[849ed54] | 82 | extern 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);
|
---|
[21580dd] | 83 |
|
---|
| 84 | /** Clears the device cache.
|
---|
| 85 | * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
|
---|
| 86 | * @param[in] device_id The device identifier.
|
---|
| 87 | * @returns EOK on success.
|
---|
| 88 | * @returns ENOENT if the device is not found.
|
---|
| 89 | */
|
---|
[849ed54] | 90 | extern int arp_clear_device_req(int arp_phone, device_id_t device_id);
|
---|
[21580dd] | 91 |
|
---|
| 92 | /** Clears the given protocol address from the cache.
|
---|
| 93 | * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
|
---|
| 94 | * @param[in] device_id The device identifier.
|
---|
| 95 | * @param[in] protocol The requesting protocol service.
|
---|
| 96 | * @param[in] address The protocol address to be cleared.
|
---|
| 97 | * @returns EOK on success.
|
---|
| 98 | * @returns ENOENT if the mapping is not found.
|
---|
| 99 | */
|
---|
[849ed54] | 100 | extern int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address);
|
---|
[21580dd] | 101 |
|
---|
| 102 | /** Cleans the cache.
|
---|
| 103 | * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
|
---|
| 104 | * @returns EOK on success.
|
---|
| 105 | */
|
---|
[849ed54] | 106 | extern int arp_clean_cache_req(int arp_phone);
|
---|
[21580dd] | 107 |
|
---|
| 108 | /** Connects to the ARP module.
|
---|
| 109 | * @param service The ARP module service. Ignored parameter.
|
---|
| 110 | * @returns The ARP module phone on success.
|
---|
| 111 | */
|
---|
[849ed54] | 112 | extern int arp_connect_module(services_t service);
|
---|
[21580dd] | 113 |
|
---|
| 114 | /** Returns the ARP task identifier.
|
---|
| 115 | * @returns 0 if called by the remote module.
|
---|
| 116 | */
|
---|
[849ed54] | 117 | extern task_id_t arp_task_get_id(void);
|
---|
[21580dd] | 118 |
|
---|
| 119 | /*@}*/
|
---|
| 120 |
|
---|
| 121 | #endif
|
---|
| 122 |
|
---|
| 123 | /** @}
|
---|
| 124 | */
|
---|