Subversion Repositories HelenOS

Rev

Rev 4582 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4582 Rev 4704
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 arp
29
/** @addtogroup arp
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 *  ARP module.
34
 *  ARP module.
35
 */
35
 */
36
 
36
 
37
#ifndef __NET_ARP_H__
37
#ifndef __NET_ARP_H__
38
#define __NET_ARP_H__
38
#define __NET_ARP_H__
39
 
39
 
40
#include <fibril_sync.h>
40
#include <fibril_sync.h>
41
 
41
 
42
#include <ipc/ipc.h>
42
#include <ipc/ipc.h>
43
#include <ipc/services.h>
43
#include <ipc/services.h>
44
 
44
 
45
#include "../../include/device.h"
45
#include "../../include/device.h"
46
#include "../../include/hardware.h"
46
#include "../../include/hardware.h"
47
 
47
 
48
#include "../../structures/generic_char_map.h"
48
#include "../../structures/generic_char_map.h"
49
#include "../../structures/int_map.h"
49
#include "../../structures/int_map.h"
50
#include "../../structures/measured_strings.h"
50
#include "../../structures/measured_strings.h"
51
 
51
 
52
 
52
 
53
/** Type definition of the ARP global data.
53
/** Type definition of the ARP global data.
54
 *  @see arp_globals
54
 *  @see arp_globals
55
 */
55
 */
56
typedef struct arp_globals  arp_globals_t;
56
typedef struct arp_globals  arp_globals_t;
57
 
57
 
58
/** Type definition of the ARP device specific data.
58
/** Type definition of the ARP device specific data.
59
 *  @see arp_device
59
 *  @see arp_device
60
 */
60
 */
61
typedef struct arp_device   arp_device_t;
61
typedef struct arp_device   arp_device_t;
62
 
62
 
63
/** Type definition of the ARP device specific data pointer.
63
/** Type definition of the ARP device specific data pointer.
64
 *  @see arp_device
64
 *  @see arp_device
65
 */
65
 */
66
typedef arp_device_t *      arp_device_ref;
66
typedef arp_device_t *      arp_device_ref;
67
 
67
 
68
/** Type definition of the ARP protocol specific data.
68
/** Type definition of the ARP protocol specific data.
69
 *  @see arp_proto
69
 *  @see arp_proto
70
 */
70
 */
71
typedef struct arp_proto    arp_proto_t;
71
typedef struct arp_proto    arp_proto_t;
72
 
72
 
73
/** Type definition of the ARP protocol specific data pointer.
73
/** Type definition of the ARP protocol specific data pointer.
74
 *  @see arp_proto
74
 *  @see arp_proto
75
 */
75
 */
76
typedef arp_proto_t *       arp_proto_ref;
76
typedef arp_proto_t *       arp_proto_ref;
77
 
77
 
78
/** ARP address cache.
78
/** ARP address cache.
79
 *  Maps devices to the ARP device specific data.
79
 *  Maps devices to the ARP device specific data.
80
 *  @see device.h
80
 *  @see device.h
81
 */
81
 */
82
DEVICE_MAP_DECLARE( arp_cache, arp_device_t )
82
DEVICE_MAP_DECLARE( arp_cache, arp_device_t )
83
 
83
 
84
/** ARP protocol map.
84
/** ARP protocol map.
85
 *  Maps protocol identifiers to the ARP protocol specific data.
85
 *  Maps protocol identifiers to the ARP protocol specific data.
86
 *  @see int_map.h
86
 *  @see int_map.h
87
 */
87
 */
88
INT_MAP_DECLARE( arp_protos, arp_proto_t )
88
INT_MAP_DECLARE( arp_protos, arp_proto_t )
89
 
89
 
90
/** ARP address map.
90
/** ARP address map.
91
 *  Translates addresses.
91
 *  Translates addresses.
92
 *  @see generic_char_map.h
92
 *  @see generic_char_map.h
93
 */
93
 */
94
GENERIC_CHAR_MAP_DECLARE( arp_addr, measured_string_t )
94
GENERIC_CHAR_MAP_DECLARE( arp_addr, measured_string_t )
95
 
95
 
96
/** ARP device specific data.
96
/** ARP device specific data.
97
 */
97
 */
98
struct arp_device{
98
struct arp_device{
99
    /** Device identifier.
99
    /** Device identifier.
100
     */
100
     */
101
    device_id_t         device_id;
101
    device_id_t         device_id;
102
    /** Hardware type.
102
    /** Hardware type.
103
     */
103
     */
104
    hw_type_t           hardware;
104
    hw_type_t           hardware;
105
    /** Reserved packet prefix length.
105
    /** Reserved packet prefix length.
106
     */
106
     */
107
    size_t              prefix;
107
    size_t              prefix;
108
    /** Maximal packet content length.
108
    /** Maximal packet content length.
109
     */
109
     */
110
    size_t              content;
110
    size_t              content;
111
    /** Reserved packet suffix length.
111
    /** Reserved packet suffix length.
112
     */
112
     */
113
    size_t              suffix;
113
    size_t              suffix;
114
    /** Packet address length.
114
    /** Packet address length.
115
     *  The hardware address length is used.
115
     *  The hardware address length is used.
116
     */
116
     */
117
    size_t              addr_len;
117
    size_t              addr_len;
118
    /** Actual device hardware address.
118
    /** Actual device hardware address.
119
     */
119
     */
120
    measured_string_ref addr;
120
    measured_string_ref addr;
121
    /** Actual device hardware address data.
121
    /** Actual device hardware address data.
122
     */
122
     */
123
    char *              addr_data;
123
    char *              addr_data;
124
    /** Broadcast device hardware address.
124
    /** Broadcast device hardware address.
125
     */
125
     */
126
    measured_string_ref broadcast_addr;
126
    measured_string_ref broadcast_addr;
127
    /** Broadcast device hardware address data.
127
    /** Broadcast device hardware address data.
128
     */
128
     */
129
    char *              broadcast_data;
129
    char *              broadcast_data;
130
    /** Device driver service.
130
    /** Device module service.
131
     */
131
     */
132
    services_t          service;
132
    services_t          service;
133
    /** Driver phone.
133
    /** Device module phone.
134
     */
134
     */
135
    int                 phone;
135
    int                 phone;
136
    /** Protocol map.
136
    /** Protocol map.
137
     *  Address map for each protocol.
137
     *  Address map for each protocol.
138
     */
138
     */
139
    arp_protos_t        protos;
139
    arp_protos_t        protos;
140
};
140
};
141
 
141
 
142
/** ARP protocol specific data.
142
/** ARP protocol specific data.
143
 */
143
 */
144
struct arp_proto{
144
struct arp_proto{
145
    /** Protocol service.
145
    /** Protocol service.
146
     */
146
     */
147
    services_t          service;
147
    services_t          service;
148
    /** Actual device protocol address.
148
    /** Actual device protocol address.
149
     */
149
     */
150
    measured_string_ref addr;
150
    measured_string_ref addr;
151
    /** Actual device protocol address data.
151
    /** Actual device protocol address data.
152
     */
152
     */
153
    char *              addr_data;
153
    char *              addr_data;
154
    /** Address map.
154
    /** Address map.
155
     */
155
     */
156
    arp_addr_t          addresses;
156
    arp_addr_t          addresses;
157
};
157
};
158
 
158
 
159
/** ARP global data.
159
/** ARP global data.
160
 */
160
 */
161
struct  arp_globals{
161
struct  arp_globals{
162
    /** Networking module phone.
162
    /** Networking module phone.
163
     */
163
     */
164
    int         net_phone;
164
    int         net_phone;
165
    /** Safety lock.
165
    /** Safety lock.
166
     */
166
     */
167
    fibril_rwlock_t     lock;
167
    fibril_rwlock_t     lock;
168
    /** ARP address cache.
168
    /** ARP address cache.
169
     */
169
     */
170
    arp_cache_t cache;
170
    arp_cache_t cache;
171
    /** The client connection processing function.
171
    /** The client connection processing function.
172
     *  The module skeleton propagates its own one.
172
     *  The module skeleton propagates its own one.
173
     */
173
     */
174
    async_client_conn_t client_connection;
174
    async_client_conn_t client_connection;
175
};
175
};
176
 
176
 
177
#endif
177
#endif
178
 
178
 
179
/** @}
179
/** @}
180
 */
180
 */
181
 
181