Subversion Repositories HelenOS

Rev

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

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