Subversion Repositories HelenOS

Rev

Rev 4723 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4271 mejdrech 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
/** @file
4350 mejdrech 34
 *  ARP module interface.
35
 *  The same interface is used for standalone remote modules as well as for bundle modules.
36
 *  The standalone remote modules have to be compiled with the arp_remote.c source file.
37
 *  The bundle modules with the arp.c source file.
4271 mejdrech 38
 */
39
 
4307 mejdrech 40
#ifndef __NET_ARP_INTERFACE_H__
41
#define __NET_ARP_INTERFACE_H__
4271 mejdrech 42
 
43
#include "../structures/measured_strings.h"
44
 
45
#include "device.h"
46
 
4704 mejdrech 47
/** @name ARP module interface
48
 *  This interface is used by other modules.
49
 */
50
/*@{*/
51
 
4350 mejdrech 52
/** Registers the new device and the requesting protocol service.
4723 mejdrech 53
 *  Connects to the network interface layer service.
4350 mejdrech 54
 *  Determines the device broadcast address, its address lengths and packet size.
4756 mejdrech 55
 *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
56
 *  @param[in] device_id The new device identifier.
57
 *  @param[in] protocol The requesting protocol service.
58
 *  @param[in] netif The underlying device network interface layer service.
59
 *  @param[in] address The local requesting protocol address of the device.
4350 mejdrech 60
 *  @returns EOK on success.
61
 *  @returns EEXIST if the device is already used.
62
 *  @returns ENOMEM if there is not enough memory left.
63
 *  @returns ENOENT if the network interface service is not known.
64
 *  @returns EREFUSED if the network interface service is not responding.
65
 *  @returns Other error codes as defined for the nil_packet_get_size() function.
66
 *  @returns Other error codes as defined for the nil_get_addr() function.
67
 *  @returns Other error codes as defined for the nil_get_broadcast_addr() function.
68
 */
4307 mejdrech 69
int	arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address );
4350 mejdrech 70
 
71
/** Translates the given protocol address to the network interface address.
72
 *  Broadcasts the ARP request if the mapping is not found.
4723 mejdrech 73
 *  Allocates and returns the needed memory block as the data parameter.
4756 mejdrech 74
 *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
75
 *  @param[in] device_id The device identifier.
76
 *  @param[in] protocol The requesting protocol service.
77
 *  @param[in] address The local requesting protocol address.
78
 *  @param[out] translation The translation of the local protocol address.
79
 *  @param[out] data The allocated raw translation data container.
4350 mejdrech 80
 *  @returns EOK on success.
4756 mejdrech 81
 *  @returns EINVAL if the address parameter is NULL.
4350 mejdrech 82
 *  @returns EBADMEM if the translation or the data parameters are NULL.
83
 *  @returns ENOENT if the mapping is not found.
84
 */
4307 mejdrech 85
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 );
4350 mejdrech 86
 
87
/** Clears the device cache.
4756 mejdrech 88
 *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
89
 *  @param[in] device_id The device identifier.
4350 mejdrech 90
 *  @returns EOK on success.
91
 *  @returns ENOENT if the device is not found.
92
 */
4307 mejdrech 93
int	arp_clear_device_req( int arp_phone, device_id_t device_id );
4350 mejdrech 94
 
4695 mejdrech 95
/** Clears the given protocol address from the cache.
4756 mejdrech 96
 *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
97
 *  @param[in] device_id The device identifier.
98
 *  @param[in] protocol The requesting protocol service.
99
 *  @param[in] address The protocol address to be cleared.
4695 mejdrech 100
 *  @returns EOK on success.
101
 *  @returns ENOENT if the mapping is not found.
102
 */
103
int	arp_clear_address_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address );
104
 
4350 mejdrech 105
/** Cleans the cache.
4756 mejdrech 106
 *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
4350 mejdrech 107
 *  @returns EOK on success.
108
 */
4307 mejdrech 109
int	arp_clean_cache_req( int arp_phone );
4350 mejdrech 110
 
111
/** Connects to the ARP module.
112
 *  @param service The ARP module service. Ignored parameter.
113
 *  @returns The ARP module phone on success.
114
 *  @returns 0 if called by the bundle module.
115
 */
4307 mejdrech 116
int	arp_connect_module( services_t service );
4350 mejdrech 117
 
118
/** Returns the ARP task identifier.
119
 *  @returns The current task identifier if called by the bundle module.
120
 *  @returns 0 if called by the remote module.
121
 */
4503 mejdrech 122
task_id_t	arp_task_get_id( void );
4271 mejdrech 123
 
4704 mejdrech 124
/*@}*/
125
 
4271 mejdrech 126
#endif
127
 
128
/** @}
129
 */