Subversion Repositories HelenOS

Rev

Rev 4243 | Rev 4307 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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