Subversion Repositories HelenOS

Rev

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

Rev 3992 Rev 4075
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 eth
29
/** @addtogroup eth
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 *  Ethernet protocol header definitions.
34
 *  Ethernet protocol header definitions.
35
 *  Names according to the linux src/include/linux/ip.h header file.
35
 *  Names according to the linux src/include/linux/ip.h header file.
36
 */
36
 */
37
 
37
 
38
#ifndef __NET_ETH_HEADER_H__
38
#ifndef __NET_ETH_HEADER_H__
39
#define __NET_ETH_HEADER_H__
39
#define __NET_ETH_HEADER_H__
40
 
40
 
41
#include <sys/types.h>
41
#include <sys/types.h>
42
 
42
 
43
#define ETH_ADDR        6
43
#define ETH_ADDR        6
44
 
44
 
45
#define ETH_PREAMBLE    0x55
45
#define ETH_PREAMBLE    0x55
46
 
46
 
47
#define ETH_SFD         0xF5
47
#define ETH_SFD         0xD5
48
 
-
 
49
#define ETH_LSAP_SNAP   0xAA
-
 
50
 
-
 
51
#define ETH_RAW         0xFF
-
 
52
 
48
 
53
/** Type definition of the Ethernet header with all the extensions.
49
/** Type definition of the Ethernet header with all the extensions.
54
 *  @see eth_header_ex
50
 *  @see eth_header_ex
55
 */
51
 */
56
typedef struct eth_header_ex    eth_header_ex_t;
52
typedef struct eth_header_ex    eth_header_ex_t;
57
 
53
 
58
/** Type definition of the Ethernet header with all the extensions pointer.
54
/** Type definition of the Ethernet header with all the extensions pointer.
59
 *  @see eth_header
55
 *  @see eth_header
60
 */
56
 */
61
typedef eth_header_ex_t *       eth_header_ex_ref;
57
typedef eth_header_ex_t *       eth_header_ex_ref;
62
 
58
 
63
/** Type definition of the Ethernet header LSAP extension.
59
/** Type definition of the Ethernet header LSAP extension.
64
 *  @see eth_header_lsap
60
 *  @see eth_header_lsap
65
 */
61
 */
66
typedef struct eth_header_lsap  eth_header_lsap_t;
62
typedef struct eth_header_lsap  eth_header_lsap_t;
67
 
63
 
68
/** Type definition of the Ethernet header LSAP extension pointer.
64
/** Type definition of the Ethernet header LSAP extension pointer.
69
 *  @see eth_header_lsap
65
 *  @see eth_header_lsap
70
 */
66
 */
71
typedef eth_header_lsap_t *     eth_header_lsap_ref;
67
typedef eth_header_lsap_t *     eth_header_lsap_ref;
72
 
68
 
73
/** Type definition of the Ethernet header SNAP extension.
69
/** Type definition of the Ethernet header SNAP extension.
74
 *  @see eth_header_snap
70
 *  @see eth_header_snap
75
 */
71
 */
76
typedef struct eth_header_snap  eth_header_snap_t;
72
typedef struct eth_header_snap  eth_header_snap_t;
77
 
73
 
78
/** Type definition of the Ethernet header SNAP extension pointer.
74
/** Type definition of the Ethernet header SNAP extension pointer.
79
 *  @see eth_header_snap
75
 *  @see eth_header_snap
80
 */
76
 */
81
typedef eth_header_snap_t *     eth_header_snap_ref;
77
typedef eth_header_snap_t *     eth_header_snap_ref;
82
 
78
 
83
/** Type definition of the Ethernet header.
79
/** Type definition of the Ethernet header.
84
 *  @see eth_header
80
 *  @see eth_header
85
 */
81
 */
86
typedef struct eth_header   eth_header_t;
82
typedef struct eth_header   eth_header_t;
87
 
83
 
88
/** Type definition of the Ethernet header pointer.
84
/** Type definition of the Ethernet header pointer.
89
 *  @see eth_header
85
 *  @see eth_header
90
 */
86
 */
91
typedef eth_header_t *      eth_header_ref;
87
typedef eth_header_t *      eth_header_ref;
92
 
88
 
93
/** Ethernet header Link Service Access Point extension.
89
/** Ethernet header Link Service Access Point extension.
94
 */
90
 */
95
struct eth_header_lsap{
91
struct eth_header_lsap{
96
    /** Destination Service Access Point identifier.
92
    /** Destination Service Access Point identifier.
97
     *  The possible values are assigned by an IEEE committee.
93
     *  The possible values are assigned by an IEEE committee.
98
     */
94
     */
99
    uint8_t     dsap;
95
    uint8_t     dsap;
100
    /** Source Service Access Point identifier.
96
    /** Source Service Access Point identifier.
101
     *  The possible values are assigned by an IEEE committee.
97
     *  The possible values are assigned by an IEEE committee.
102
     */
98
     */
103
    uint8_t     ssap;
99
    uint8_t     ssap;
104
    /** Control parameter.
100
    /** Control parameter.
105
     *  The possible values are assigned by an IEEE committee.
101
     *  The possible values are assigned by an IEEE committee.
106
     */
102
     */
107
    uint8_t     ctrl;
103
    uint8_t     ctrl;
108
};
104
};
109
 
105
 
110
/** Ethernet header SNAP extension.
106
/** Ethernet header SNAP extension.
111
 */
107
 */
112
struct eth_header_snap{
108
struct eth_header_snap{
113
    /** Protocol identifier or organization code.
109
    /** Protocol identifier or organization code.
114
     */
110
     */
115
    uint8_t     proto[ 3 ];
111
    uint8_t     proto[ 3 ];
116
    /** Ethernet protocol identifier in the network byte order (big endian).
112
    /** Ethernet protocol identifier in the network byte order (big endian).
117
     *  @see ethernet_protocols.h
113
     *  @see ethernet_protocols.h
118
     */
114
     */
119
    uint16_t    ethertype;
115
    uint16_t    ethertype;
120
};
116
};
121
 
117
 
122
/** Ethernet header.
118
/** Ethernet header.
123
 */
119
 */
124
struct eth_header{
120
struct eth_header{
125
    /** Controlling preamble used for the frame transmission synchronization.
121
    /** Controlling preamble used for the frame transmission synchronization.
126
     *  All should be set to ETH_PREAMBLE.
122
     *  All should be set to ETH_PREAMBLE.
127
     */
123
     */
128
    uint8_t     preamble[ 7 ];
124
    uint8_t     preamble[ 7 ];
129
    /** Start of Frame Delimiter used for the frame transmission synchronization.
125
    /** Start of Frame Delimiter used for the frame transmission synchronization.
130
     *  Should be set to ETH_SFD.
126
     *  Should be set to ETH_SFD.
131
     */
127
     */
132
    uint8_t     sfd;
128
    uint8_t     sfd;
133
    /** Destination host Ethernet address (MAC address).
129
    /** Destination host Ethernet address (MAC address).
134
     */
130
     */
135
    uint8_t     dest[ ETH_ADDR ];
131
    uint8_t     dest[ ETH_ADDR ];
136
    /** Source host Ethernet address (MAC address).
132
    /** Source host Ethernet address (MAC address).
137
     */
133
     */
138
    uint8_t     src[ ETH_ADDR ];
134
    uint8_t     src[ ETH_ADDR ];
139
    /** Ethernet protocol identifier in the network byte order (big endian).
135
    /** Ethernet protocol identifier in the network byte order (big endian).
140
     *  @see ethernet_protocols.h
136
     *  @see ethernet_protocols.h
141
     */
137
     */
142
    uint16_t    ethertype;
138
    uint16_t    ethertype;
143
};
139
};
144
 
140
 
145
/** Ethernet header with all the extensions.
141
/** Ethernet header with all the extensions.
146
 */
142
 */
147
struct eth_header_ex{
143
struct eth_header_ex{
148
    /** Ethernet header.
144
    /** Ethernet header.
149
     */
145
     */
150
    eth_header_t        header;
146
    eth_header_t        header;
151
    /** LSAP extension.
147
    /** LSAP extension.
152
     *  If DSAP and SSAP are set to ETH_LSAP_SNAP the SNAP extension is being used.
148
     *  If DSAP and SSAP are set to ETH_LSAP_SNAP the SNAP extension is being used.
153
     *  If DSAP and SSAP fields are equal to ETH_RAW the raw Ethernet packet without any extensions is being used and the frame content starts rigth after the two fields.
149
     *  If DSAP and SSAP fields are equal to ETH_RAW the raw Ethernet packet without any extensions is being used and the frame content starts rigth after the two fields.
154
     */
150
     */
155
    eth_header_lsap_t   lsap;
151
    eth_header_lsap_t   lsap;
156
    /** SNAP extension.
152
    /** SNAP extension.
157
     */
153
     */
158
    eth_header_snap_t   snap;
154
    eth_header_snap_t   snap;
159
};
155
};
160
 
156
 
-
 
157
/** Ethernet Frame Check Sequence.
-
 
158
 */
-
 
159
typedef uint32_t        eth_fcs_t;
-
 
160
 
-
 
161
/** Ethernet Frame Check Sequence pointer.
-
 
162
 */
-
 
163
typedef eth_fcs_t *     eth_fcs_ref;
-
 
164
 
161
#endif
165
#endif
162
 
166
 
163
/** @}
167
/** @}
164
 */
168
 */
165
 
169