Rev 4307 | Go to most recent revision | Details | 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 |
||
34 | */ |
||
35 | |||
36 | #ifndef __NET_ARP_MESSAGES_H__ |
||
37 | #define __NET_ARP_MESSAGES_H__ |
||
38 | |||
39 | #include <async.h> |
||
40 | #include <errno.h> |
||
41 | |||
42 | #include <ipc/ipc.h> |
||
43 | |||
44 | #include "../messages.h" |
||
45 | |||
46 | #include "../structures/measured_strings.h" |
||
47 | |||
48 | #include "device.h" |
||
49 | |||
50 | typedef enum{ |
||
51 | /* ( device_id, nil_service, proto ), measured_strings_send( proto_addr ) */ |
||
52 | NET_ARP_DEVICE = NET_ARP_FIRST, |
||
53 | /* ( device_id, protocol ), measured_strings_send( target ), measured_strings_return( translation ) */ |
||
54 | NET_ARP_TRANSLATE, |
||
55 | /* ( device_id ) */ |
||
56 | NET_ARP_CLEAR_DEVICE, |
||
57 | /* () */ |
||
58 | NET_ARP_CLEAN_CACHE, |
||
59 | } arp_messages; |
||
60 | |||
61 | static inline int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ); |
||
62 | static inline 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 ); |
||
63 | static inline int arp_clear_device_req( int arp_phone, device_id_t device_id ); |
||
64 | static inline int arp_clean_cache_req( int arp_phone ); |
||
65 | |||
66 | #if ARP_BUNDLE |
||
67 | |||
68 | #include "../il/arp/arp_wrappers.h" |
||
69 | |||
70 | /** Returns the protocol service message parameter. |
||
71 | */ |
||
72 | #define ARP_GET_PROTO( call ) ( services_t ) IPC_GET_ARG2( * call ) |
||
73 | |||
74 | static inline int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){ |
||
75 | return arp_device_wrapper( device_id, netif, protocol, address ); |
||
76 | } |
||
77 | |||
78 | static inline 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 ){ |
||
79 | return arp_translate_wrapper( device_id, protocol, address, translation, data ); |
||
80 | } |
||
81 | |||
82 | static inline int arp_clear_device_req( int arp_phone, device_id_t device_id ){ |
||
83 | return arp_clear_device_wrapper( device_id ); |
||
84 | } |
||
85 | |||
86 | static inline int arp_clean_cache_req( int arp_phone ){ |
||
87 | return arp_clean_cache_wrapper(); |
||
88 | } |
||
89 | |||
90 | #else |
||
91 | |||
92 | static inline int arp_device_req( int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address ){ |
||
93 | aid_t message_id; |
||
94 | ipcarg_t result; |
||
95 | |||
96 | message_id = async_send_3( arp_phone, NET_ARP_DEVICE, device_id, protocol, netif, NULL ); |
||
97 | measured_strings_send( arp_phone, address, 1 ); |
||
98 | async_wait_for( message_id, & result ); |
||
99 | return result; |
||
100 | } |
||
101 | |||
102 | static inline 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 ){ |
||
103 | aid_t message_id; |
||
104 | ipcarg_t result; |
||
105 | int string; |
||
106 | |||
107 | if( !( address && data )) return EBADMEM; |
||
108 | message_id = async_send_2( arp_phone, NET_ARP_TRANSLATE, device_id, protocol, NULL ); |
||
109 | measured_strings_send( arp_phone, address, 1 ); |
||
110 | string = measured_strings_return( arp_phone, translation, data, 1 ); |
||
111 | async_wait_for( message_id, & result ); |
||
112 | if(( string == EOK ) && ( result != EOK )){ |
||
113 | free( * translation ); |
||
114 | free( * data ); |
||
115 | } |
||
116 | return result; |
||
117 | } |
||
118 | |||
119 | static inline int arp_clear_device_req( int arp_phone, device_id_t device_id ){ |
||
120 | return async_req_1_0( arp_phone, NET_ARP_CLEAR_DEVICE, device_id ); |
||
121 | } |
||
122 | |||
123 | static inline int arp_clean_cache_req( int arp_phone ){ |
||
124 | return async_req_0_0( arp_phone, NET_ARP_CLEAN_CACHE ); |
||
125 | } |
||
126 | |||
127 | #endif |
||
128 | |||
129 | #endif |
||
130 | |||
131 | /** @} |
||
132 | */ |