Subversion Repositories HelenOS

Rev

Rev 3991 | Rev 4261 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3991 Rev 4243
1
/*
1
/*
2
 * Copyright (c) 2009 Lukas Mejdrech
2
 * Copyright (c) 2009 Lukas Mejdrech
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
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
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.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
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
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
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.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup net
29
/** @addtogroup net
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 */
34
 */
35
 
35
 
36
#ifndef __NET_MESSAGES_H__
36
#ifndef __NET_MESSAGES_H__
37
#define __NET_MESSAGES_H__
37
#define __NET_MESSAGES_H__
38
 
38
 
39
#define NET_NETIF_COUNT     8
39
#define NET_NETIF_COUNT     8
40
#define NET_NET_COUNT       9
40
#define NET_NET_COUNT       9
41
#define NET_NIL_COUNT       8
41
#define NET_NIL_COUNT       8
42
#define NET_ETH_COUNT       0
42
#define NET_ETH_COUNT       0
43
#define NET_IL_COUNT        3
43
#define NET_IL_COUNT        3
44
#define NET_IP_COUNT        2
44
#define NET_IP_COUNT        2
45
#define NET_ARP_COUNT       4
45
#define NET_ARP_COUNT       4
46
#define NET_RARP_COUNT      0
46
#define NET_RARP_COUNT      0
47
#define NET_ICMP_COUNT      0
47
#define NET_ICMP_COUNT      0
48
#define NET_UDP_COUNT       0
48
#define NET_UDP_COUNT       0
49
#define NET_TCP_COUNT       0
49
#define NET_TCP_COUNT       0
50
#define NET_PACKET_COUNT    5
50
#define NET_PACKET_COUNT    5
51
#define NET_SOCKET_COUNT    0
51
#define NET_SOCKET_COUNT    0
52
 
52
 
53
#define NET_FIRST       2000
53
#define NET_FIRST       2000
54
 
54
 
55
#define NET_NETIF_FIRST     NET_FIRST
55
#define NET_NETIF_FIRST     NET_FIRST
56
#define NET_NETIF_LAST      ( NET_NETIF_FIRST + NET_NETIF_COUNT )
56
#define NET_NETIF_LAST      ( NET_NETIF_FIRST + NET_NETIF_COUNT )
57
 
57
 
58
#define NET_NET_FIRST       ( NET_NETIF_LAST + 0 )
58
#define NET_NET_FIRST       ( NET_NETIF_LAST + 0 )
59
#define NET_NET_LAST        ( NET_NET_FIRST + NET_NET_COUNT )
59
#define NET_NET_LAST        ( NET_NET_FIRST + NET_NET_COUNT )
60
 
60
 
61
#define NET_NIL_FIRST       ( NET_NET_LAST + 0 )
61
#define NET_NIL_FIRST       ( NET_NET_LAST + 0 )
62
#define NET_NIL_LAST        ( NET_NIL_FIRST + NET_NIL_COUNT )
62
#define NET_NIL_LAST        ( NET_NIL_FIRST + NET_NIL_COUNT )
63
#define NET_ETH_FIRST       ( NET_NIL_LAST + 0 )
63
#define NET_ETH_FIRST       ( NET_NIL_LAST + 0 )
64
#define NET_ETH_LAST        ( NET_ETH_FIRST + NET_ETH_COUNT )
64
#define NET_ETH_LAST        ( NET_ETH_FIRST + NET_ETH_COUNT )
65
 
65
 
66
#define NET_IL_FIRST        ( NET_ETH_LAST + 0 )
66
#define NET_IL_FIRST        ( NET_ETH_LAST + 0 )
67
#define NET_IL_LAST     ( NET_IL_FIRST + NET_IL_COUNT )
67
#define NET_IL_LAST     ( NET_IL_FIRST + NET_IL_COUNT )
68
#define NET_IP_FIRST        ( NET_IL_LAST + 0 )
68
#define NET_IP_FIRST        ( NET_IL_LAST + 0 )
69
#define NET_IP_LAST     ( NET_IP_FIRST + NET_IP_COUNT )
69
#define NET_IP_LAST     ( NET_IP_FIRST + NET_IP_COUNT )
70
 
70
 
71
#define NET_ARP_FIRST       ( NET_IP_LAST + 0 )
71
#define NET_ARP_FIRST       ( NET_IP_LAST + 0 )
72
#define NET_ARP_LAST        ( NET_ARP_FIRST + NET_ARP_COUNT )
72
#define NET_ARP_LAST        ( NET_ARP_FIRST + NET_ARP_COUNT )
73
#define NET_RARP_FIRST      ( NET_ARP_LAST + 0 )
73
#define NET_RARP_FIRST      ( NET_ARP_LAST + 0 )
74
#define NET_RARP_LAST       ( NET_RARP_FIRST + NET_RARP_COUNT )
74
#define NET_RARP_LAST       ( NET_RARP_FIRST + NET_RARP_COUNT )
75
#define NET_ICMP_FIRST      ( NET_RARP_LAST + 0 )
75
#define NET_ICMP_FIRST      ( NET_RARP_LAST + 0 )
76
#define NET_ICMP_LAST       ( NET_ICMP_FIRST + NET_ICMP_COUNT )
76
#define NET_ICMP_LAST       ( NET_ICMP_FIRST + NET_ICMP_COUNT )
77
#define NET_UDP_FIRST       ( NET_ICMP_LAST + 0 )
77
#define NET_UDP_FIRST       ( NET_ICMP_LAST + 0 )
78
#define NET_UDP_LAST        ( NET_UDP_FIRST + NET_UDP_COUNT )
78
#define NET_UDP_LAST        ( NET_UDP_FIRST + NET_UDP_COUNT )
79
#define NET_TCP_FIRST       ( NET_UDP_LAST + 0 )
79
#define NET_TCP_FIRST       ( NET_UDP_LAST + 0 )
80
#define NET_TCP_LAST        ( NET_TCP_FIRST + NET_TCP_COUNT )
80
#define NET_TCP_LAST        ( NET_TCP_FIRST + NET_TCP_COUNT )
81
 
81
 
82
#define NET_SOCKET_FIRST    ( NET_TCP_LAST + 0 )
82
#define NET_SOCKET_FIRST    ( NET_TCP_LAST + 0 )
83
#define NET_SOCKET_LAST     ( NET_SOCKET_FIRST + NET_SOCKET_COUNT )
83
#define NET_SOCKET_LAST     ( NET_SOCKET_FIRST + NET_SOCKET_COUNT )
84
 
84
 
85
#define NET_PACKET_FIRST    ( NET_SOCKET_LAST + 0 )
85
#define NET_PACKET_FIRST    ( NET_SOCKET_LAST + 0 )
86
#define NET_PACKET_LAST     ( NET_PACKET_FIRST + NET_PACKET_COUNT )
86
#define NET_PACKET_LAST     ( NET_PACKET_FIRST + NET_PACKET_COUNT )
87
 
87
 
88
#define NET_LAST        NET_PACKET_LAST
88
#define NET_LAST        NET_PACKET_LAST
89
 
89
 
90
#define NET_COUNT       ( NET_LAST - NET_FIRST )
90
#define NET_COUNT       ( NET_LAST - NET_FIRST )
91
 
91
 
92
#define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive )))
92
#define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive )))
93
 
93
 
94
#define IS_NET_MESSAGE( call )          IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST )
94
#define IS_NET_MESSAGE( call )          IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST )
95
#define IS_NET_NET_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST )
95
#define IS_NET_NET_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST )
96
#define IS_NET_NIL_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST )
96
#define IS_NET_NIL_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST )
97
#define IS_NET_ETH_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST )
97
#define IS_NET_ETH_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST )
98
#define IS_NET_IL_MESSAGE( call )       IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST )
98
#define IS_NET_IL_MESSAGE( call )       IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST )
99
#define IS_NET_IP_MESSAGE( call )       IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST )
99
#define IS_NET_IP_MESSAGE( call )       IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST )
100
#define IS_NET_ARP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST )
100
#define IS_NET_ARP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST )
101
#define IS_NET_RARP_MESSAGE( call )     IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_RARP_FIRST, NET_RARP_LAST )
101
#define IS_NET_RARP_MESSAGE( call )     IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_RARP_FIRST, NET_RARP_LAST )
102
#define IS_NET_UDP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST )
102
#define IS_NET_UDP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST )
103
#define IS_NET_TCP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST )
103
#define IS_NET_TCP_MESSAGE( call )      IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST )
104
#define IS_NET_SOCKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST )
104
#define IS_NET_SOCKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST )
105
#define IS_NET_PACKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST )
105
#define IS_NET_PACKET_MESSAGE( call )   IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST )
106
 
106
 
-
 
107
#define IPC_GET_PHONE( call )       ( int ) IPC_GET_ARG5( * call )
-
 
108
 
107
typedef enum {
109
typedef enum {
108
    /* ( device_id, irq, io ) */
-
 
109
    NET_NETIF_PROBE = NET_NETIF_FIRST,
-
 
110
    /* () not supported, should ask networking for a name and register device */
-
 
111
    NET_NETIF_PROBE_AUTO,
-
 
112
    /* ( device_id, packet_id ) */
-
 
113
    NET_NETIF_SEND,
-
 
114
    /* ( device_id ) */
-
 
115
    NET_NETIF_START,
-
 
116
    /* ( device_id ), ipc_data_read( stats ) */
-
 
117
    NET_NETIF_STATS,
-
 
118
    /* ( device_id ) */
-
 
119
    NET_NETIF_STOP,
-
 
120
    /* */
-
 
121
    NET_NETIF_SET_ADDR,
-
 
122
    /* */
-
 
123
    NET_NETIF_GET_ADDR,
-
 
124
    /* () not supported, registers new device */
110
    /* () not supported, registers new device */
125
    NET_NET_DEVICE = NET_NET_FIRST,
111
    NET_NET_DEVICE = NET_NET_FIRST,
126
    /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */
112
    /* ( NULL, count ), measured_strings_send( names ), measured_strings_return( values ) */
127
    NET_NET_GET_CONF,
113
    NET_NET_GET_CONF,
128
    /* ( device_id, count ), measured_strings_send( names ), measured_strings_return( values ) */
114
    /* ( device_id, count ), measured_strings_send( names ), measured_strings_return( values ) */
129
    NET_NET_GET_DEVICE_CONF,
115
    NET_NET_GET_DEVICE_CONF,
130
    /* () not supported, measured_strings_send( names ), measured_strings_send( values ) */
116
    /* () not supported, measured_strings_send( names ), measured_strings_send( values ) */
131
    NET_NET_SET_CONF,
117
    NET_NET_SET_CONF,
132
    /* ( device_id, count ) not supported, measured_strings_send( names ), measured_strings_send( values ) */
118
    /* ( device_id, count ) not supported, measured_strings_send( names ), measured_strings_send( values ) */
133
    NET_NET_SET_DEVICE_CONF,
119
    NET_NET_SET_DEVICE_CONF,
134
    /* () */
120
    /* () */
135
    NET_NET_STARTUP,
121
    NET_NET_STARTUP,
136
    /* ( device_id ) */
122
    /* ( device_id ) */
137
    NET_NET_START,
123
    NET_NET_START,
138
    /* ( device_id ) */
124
    /* ( device_id ) */
139
    NET_NET_STOP,
125
    NET_NET_STOP,
140
    /* ( device_id ) ipc_data_read( stats ) */
126
    /* ( device_id ) ipc_data_read( stats ) */
141
    NET_NET_STATS,
127
    NET_NET_STATS,
142
    /* ( device_id, driver_service, mtu ) */
128
    /* ( device_id, driver_service, mtu ) */
143
    NET_NIL_DEVICE = NET_NIL_FIRST,
129
    NET_NIL_DEVICE = NET_NIL_FIRST,
144
    /* ( device_id, state ) */
130
    /* ( device_id, state ) */
145
    NET_NIL_DEVICE_STATE,
131
    NET_NIL_DEVICE_STATE,
146
    /* ( device_id ), packet_send */
132
    /* ( device_id ), packet_send */
147
    NET_NIL_RECEIVED,
133
    NET_NIL_RECEIVED,
148
    /* ( device_id ), packet_send */
134
    /* ( device_id ), packet_send */
149
    NET_NIL_SEND,
135
    NET_NIL_SEND,
150
    /* ( device_id ) -> addr, prefix, content, suffix */
136
    /* ( device_id ) -> addr, prefix, content, suffix */
151
    NET_NIL_PACKET_SPACE,
137
    NET_NIL_PACKET_SPACE,
152
    /* ( device_id ), measured_strings_return( hardware address ) */
138
    /* ( device_id ), measured_strings_return( hardware address ) */
153
    NET_NIL_ADDR,
139
    NET_NIL_ADDR,
154
    /* ( device_id ), measured_strings_return( broadcast address ) */
140
    /* ( device_id ), measured_strings_return( broadcast address ) */
155
    NET_NIL_BROADCAST_ADDR,
141
    NET_NIL_BROADCAST_ADDR,
156
    /* ( device_id, nil_service ) */
142
    /* ( device_id, nil_service ) */
157
    NET_IL_DEVICE = NET_IL_FIRST,
143
    NET_IL_DEVICE = NET_IL_FIRST,
158
    /* ( device_id, state ) */
144
    /* ( device_id, state ) */
159
    NET_IL_DEVICE_STATE,
145
    NET_IL_DEVICE_STATE,
160
    /* ( device_id ), packet_send */
146
    /* ( device_id ), packet_send */
161
    NET_IL_RECEIVED,
147
    NET_IL_RECEIVED,
162
    /* ( device_id ), measured_strings_send( address ) */
148
    /* ( device_id ), measured_strings_send( address ) */
163
//  NET_IL_MY_ADDR,
149
//  NET_IL_MY_ADDR,
164
    NET_IP_ECHO = NET_IP_FIRST,
150
    NET_IP_ECHO = NET_IP_FIRST,
165
    /* ( packet_id ) */
151
    /* ( packet_id ) */
166
    NET_IP_SEND,
152
    NET_IP_SEND,
167
    /* ( device_id, nil_service, proto ), measured_strings_send( proto_addr ) */
153
    /* ( device_id, nil_service, proto ), measured_strings_send( proto_addr ) */
168
    NET_ARP_DEVICE = NET_ARP_FIRST,
154
    NET_ARP_DEVICE = NET_ARP_FIRST,
169
    /* ( device_id, protocol ), measured_strings_send( target ), measured_strings_return( translation ) */
155
    /* ( device_id, protocol ), measured_strings_send( target ), measured_strings_return( translation ) */
170
    NET_ARP_TRANSLATE,
156
    NET_ARP_TRANSLATE,
171
    /* ( device_id ) */
157
    /* ( device_id ) */
172
    NET_ARP_CLEAR_DEVICE,
158
    NET_ARP_CLEAR_DEVICE,
173
    /* () */
159
    /* () */
174
    NET_ARP_CLEAN_CACHE,
160
    NET_ARP_CLEAN_CACHE,
175
    NET_PACKET_CREATE_1 = NET_PACKET_FIRST,
161
    NET_PACKET_CREATE_1 = NET_PACKET_FIRST,
176
    NET_PACKET_CREATE_4,
162
    NET_PACKET_CREATE_4,
177
    NET_PACKET_GET,
163
    NET_PACKET_GET,
178
    NET_PACKET_GET_SIZE,
164
    NET_PACKET_GET_SIZE,
179
    NET_PACKET_RELEASE
165
    NET_PACKET_RELEASE
180
} net_messages;
166
} net_messages;
181
 
167
 
182
#endif
168
#endif
183
 
169
 
184
/** @}
170
/** @}
185
 */
171
 */
186
 
172