Subversion Repositories HelenOS

Rev

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

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