source: mainline/uspace/lib/net/il/arp_remote.c@ 10e4cd7

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 10e4cd7 was 609243f4, checked in by Martin Decky <martin@…>, 14 years ago

cherrypick general networking improvements from lp:~helenos-nicf/helenos/nicf (after sanitization)
remove obsolete networking drivers
this renders the networking non-functional for the time being

  • Property mode set to 100644
File size: 6.0 KB
RevLine 
[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
[faa3588]29/** @addtogroup libnet
30 * @{
[21580dd]31 */
32
33/** @file
[faa3588]34 * ARP interface implementation for remote modules.
35 * @see arp_interface.h
[21580dd]36 */
37
[514ee46]38#include <arp_interface.h>
39#include <generic.h>
[21580dd]40#include <ipc/services.h>
[f87ec535]41#include <ipc/arp.h>
[c7a8442]42#include <net/modules.h>
[e526f08]43#include <net/device.h>
[849ed54]44#include <adt/measured_strings.h>
[6b82009]45#include <async.h>
46#include <errno.h>
[21580dd]47
[6b82009]48/** Connect to the ARP module.
49 *
50 * @return ARP module session on success.
[faa3588]51 *
52 */
[6b82009]53async_sess_t *arp_connect_module(services_t service)
[faa3588]54{
[6b82009]55 // FIXME: Get rid of the useless argument
[a64c64d]56 return connect_to_service(SERVICE_ARP);
57}
58
[faa3588]59/** Cleans the cache.
60 *
[6b82009]61 * @param[in] sess ARP module session.
62 *
63 * @return EOK on success.
64 *
[faa3588]65 */
[6b82009]66int arp_clean_cache_req(async_sess_t *sess)
[faa3588]67{
[6b82009]68 async_exch_t *exch = async_exchange_begin(sess);
69 int rc = async_req_0_0(exch, NET_ARP_CLEAN_CACHE);
70 async_exchange_end(exch);
71
72 return rc;
[a64c64d]73}
74
[6b82009]75/** Clear the given protocol address from the cache.
76 *
77 * @param[in] sess ARP module session.
78 * @param[in] device_id Device identifier.
79 * @param[in] protocol Requesting protocol service.
80 * @param[in] address Protocol address to be cleared.
81 *
82 * @return EOK on success.
83 * @return ENOENT if the mapping is not found.
84 *
[faa3588]85 */
[609243f4]86int arp_clear_address_req(async_sess_t *sess, nic_device_id_t device_id,
[6b82009]87 services_t protocol, measured_string_t *address)
[faa3588]88{
[6b82009]89 async_exch_t *exch = async_exchange_begin(sess);
90 aid_t message_id = async_send_2(exch, NET_ARP_CLEAR_ADDRESS,
[96b02eb9]91 (sysarg_t) device_id, protocol, NULL);
[6b82009]92 measured_strings_send(exch, address, 1);
93 async_exchange_end(exch);
94
95 sysarg_t result;
[aadf01e]96 async_wait_for(message_id, &result);
[6b82009]97
[aadf01e]98 return (int) result;
[21580dd]99}
100
[6b82009]101/** Clear the device cache.
102 *
103 * @param[in] sess ARP module session.
104 * @param[in] device_id Device identifier.
105 *
106 * @return EOK on success.
107 * @return ENOENT if the device is not found.
[faa3588]108 *
109 */
[609243f4]110int arp_clear_device_req(async_sess_t *sess, nic_device_id_t device_id)
[faa3588]111{
[6b82009]112 async_exch_t *exch = async_exchange_begin(sess);
113 int rc = async_req_1_0(exch, NET_ARP_CLEAR_DEVICE,
[96b02eb9]114 (sysarg_t) device_id);
[6b82009]115 async_exchange_end(exch);
116
117 return rc;
[21580dd]118}
119
[6b82009]120/** Register new device and the requesting protocol service.
121 *
122 * Connect to the network interface layer service.
123 * Determine the device broadcast address, its address lengths and packet size.
124 *
125 * @param[in] sess ARP module session.
126 * @param[in] device_id New device identifier.
127 * @param[in] protocol Requesting protocol service.
128 * @param[in] netif Underlying device network interface layer service.
129 * @param[in] address Local requesting protocol address of the device.
130 *
131 * @return EOK on success.
132 * @return EEXIST if the device is already used.
133 * @return ENOMEM if there is not enough memory left.
134 * @return ENOENT if the network interface service is not known.
135 * @return EREFUSED if the network interface service is not
136 * responding.
137 * @return Other error codes as defined for the
138 * nil_packet_get_size() function.
139 * @return Other error codes as defined for the nil_get_addr()
140 * function.
141 * @return Other error codes as defined for the
142 * nil_get_broadcast_addr() function.
143 *
[faa3588]144 */
[609243f4]145int arp_device_req(async_sess_t *sess, nic_device_id_t device_id,
[6b82009]146 services_t protocol, services_t netif, measured_string_t *address)
[faa3588]147{
[6b82009]148 async_exch_t *exch = async_exchange_begin(sess);
149 aid_t message_id = async_send_3(exch, NET_ARP_DEVICE,
[96b02eb9]150 (sysarg_t) device_id, protocol, netif, NULL);
[6b82009]151 measured_strings_send(exch, address, 1);
152 async_exchange_end(exch);
153
154 sysarg_t result;
[aadf01e]155 async_wait_for(message_id, &result);
[faa3588]156
[aadf01e]157 return (int) result;
[21580dd]158}
159
[6b82009]160/** Translate the given protocol address to the network interface address.
161 *
162 * Broadcast the ARP request if the mapping is not found.
163 * Allocate and returns the needed memory block as the data parameter.
164 *
165 * @param[in] sess ARP module session.
166 * @param[in] device_id Device identifier.
167 * @param[in] protocol Requesting protocol service.
168 * @param[in] address Local requesting protocol address.
169 * @param[out] translation Translation of the local protocol address.
170 * @param[out] data Allocated raw translation data container.
171 *
172 * @return EOK on success.
173 * @return EINVAL if the address parameter is NULL.
174 * @return EBADMEM if the translation or the data parameters are
175 * NULL.
176 * @return ENOENT if the mapping is not found.
177 *
[faa3588]178 */
[609243f4]179int arp_translate_req(async_sess_t *sess, nic_device_id_t device_id,
[6b82009]180 services_t protocol, measured_string_t *address,
181 measured_string_t **translation, uint8_t **data)
[faa3588]182{
[6b82009]183 return generic_translate_req(sess, NET_ARP_TRANSLATE, device_id,
[faa3588]184 protocol, address, 1, translation, data);
[a64c64d]185}
186
[21580dd]187/** @}
188 */
Note: See TracBrowser for help on using the repository browser.