Subversion Repositories HelenOS

Rev

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

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