source: mainline/uspace/srv/net/nil/eth/eth_header.h@ 774e6d1a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 774e6d1a was 774e6d1a, checked in by martin@…>, 15 years ago

partial networking stack overhaul

  • a lot of coding style changes (comments, indentation, etc.)
  • convert several ints to unsigned ints or size_t values
  • streamline many of the IPC-related macros (they no longer dereference the call structure by themselves)
  • get rid of netif_interface.h (containing only aliases for remote functions and not serving any purpose)
  • rename netif_local.{c|h} to netif_skel.{c|h} (it is really just a skeleton)
  • drop the "_remote" and "_standalone" suffixes from most of the netif_ functions (they do not serve any purpose anymore)
  • implement netif_client_connection() as a common framework function for all netif modules
    • update the lo module accordingly
  • ip module now reports the default gateway to the user whenever it is being set
  • Property mode set to 100644
File size: 5.2 KB
RevLine 
[21580dd]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
[6067284]34 * Ethernet protocol header definitions.
35 * Based on the IEEE 802.3-2005
[21580dd]36 */
37
[6067284]38#ifndef NET_ETH_HEADER_H_
39#define NET_ETH_HEADER_H_
[21580dd]40
41#include <sys/types.h>
42
[6067284]43/** Ethernet address length. */
[774e6d1a]44#define ETH_ADDR 6
[21580dd]45
[6067284]46/** Ethernet header preamble value. */
[774e6d1a]47#define ETH_PREAMBLE 0x55
[21580dd]48
[6067284]49/** Ethernet header start of frame value. */
[774e6d1a]50#define ETH_SFD 0xD5
[21580dd]51
[6067284]52/** IEEE 802.2 unordered information control field. */
[774e6d1a]53#define IEEE_8023_2_UI 0x03
[21580dd]54
55/** Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions.
[6067284]56 * @see eth_header_snap
[21580dd]57 */
[6067284]58typedef struct eth_header_snap eth_header_snap_t;
[21580dd]59
60/** Type definition of the Ethernet header IEEE 802.3 + 802.2 + SNAP extensions.
[6067284]61 * @see eth_header_lsap
[21580dd]62 */
[6067284]63typedef struct eth_header_lsap eth_header_lsap_t;
[21580dd]64
65/** Type definition of the Ethernet header LSAP extension.
[6067284]66 * @see eth_ieee_lsap
[21580dd]67 */
[6067284]68typedef struct eth_ieee_lsap eth_ieee_lsap_t;
[21580dd]69
70/** Type definition of the Ethernet header SNAP extension.
[6067284]71 * @see eth_snap
[21580dd]72 */
[6067284]73typedef struct eth_snap eth_snap_t;
[21580dd]74
75/** Type definition of the Ethernet header preamble.
[6067284]76 * @see preamble
[21580dd]77 */
[6067284]78typedef struct eth_preamble eth_preamble_t;
[21580dd]79
80/** Type definition of the Ethernet header.
[6067284]81 * @see eth_header
[21580dd]82 */
[6067284]83typedef struct eth_header eth_header_t;
[21580dd]84
[6067284]85/** Ethernet header Link Service Access Point extension. */
86struct eth_ieee_lsap {
87 /**
88 * Destination Service Access Point identifier.
[aadf01e]89 * The possible values are assigned by an IEEE committee.
[21580dd]90 */
[aadf01e]91 uint8_t dsap;
[6067284]92
93 /**
94 * Source Service Access Point identifier.
[aadf01e]95 * The possible values are assigned by an IEEE committee.
[21580dd]96 */
[aadf01e]97 uint8_t ssap;
[6067284]98
99 /**
100 * Control parameter.
[aadf01e]101 * The possible values are assigned by an IEEE committee.
[21580dd]102 */
[aadf01e]103 uint8_t ctrl;
[21580dd]104} __attribute__ ((packed));
105
[6067284]106/** Ethernet header SNAP extension. */
107struct eth_snap {
108 /** Protocol identifier or organization code. */
[aadf01e]109 uint8_t protocol[3];
[6067284]110
111 /**
112 * Ethernet protocol identifier in the network byte order (big endian).
113 * @see ethernet_protocols.h
[21580dd]114 */
[aadf01e]115 uint16_t ethertype;
[21580dd]116} __attribute__ ((packed));
117
118/** Ethernet header preamble.
[6067284]119 *
120 * Used for dummy devices.
[21580dd]121 */
[6067284]122struct eth_preamble {
123 /**
124 * Controlling preamble used for the frame transmission synchronization.
125 * All should be set to ETH_PREAMBLE.
[21580dd]126 */
[aadf01e]127 uint8_t preamble[7];
[6067284]128
129 /**
130 * Start of Frame Delimiter used for the frame transmission
131 * synchronization.
132 * Should be set to ETH_SFD.
[21580dd]133 */
[aadf01e]134 uint8_t sfd;
[21580dd]135} __attribute__ ((packed));
136
[6067284]137/** Ethernet header. */
138struct eth_header {
139 /** Destination host Ethernet address (MAC address). */
[aadf01e]140 uint8_t destination_address[ETH_ADDR];
[6067284]141 /** Source host Ethernet address (MAC address). */
[aadf01e]142 uint8_t source_address[ETH_ADDR];
[6067284]143
144 /**
145 * Ethernet protocol identifier in the network byte order (big endian).
146 * @see ethernet_protocols.h
[21580dd]147 */
[aadf01e]148 uint16_t ethertype;
[21580dd]149} __attribute__ ((packed));
150
[6067284]151/** Ethernet header IEEE 802.3 + 802.2 extension. */
152struct eth_header_lsap {
153 /** Ethernet header. */
[aadf01e]154 eth_header_t header;
[6067284]155
156 /**
157 * LSAP extension.
158 * If DSAP and SSAP are set to ETH_LSAP_SNAP the SNAP extension is being
159 * used.
160 * If DSAP and SSAP fields are equal to ETH_RAW the raw Ethernet packet
161 * without any extensions is being used and the frame content starts
162 * rigth after the two fields.
[21580dd]163 */
[aadf01e]164 eth_ieee_lsap_t lsap;
[21580dd]165} __attribute__ ((packed));
166
[6067284]167/** Ethernet header IEEE 802.3 + 802.2 + SNAP extensions. */
168struct eth_header_snap {
169 /** Ethernet header. */
[aadf01e]170 eth_header_t header;
[6067284]171
172 /**
173 * LSAP extension.
174 * If DSAP and SSAP are set to ETH_LSAP_SNAP the SNAP extension is being
175 * used.
176 * If DSAP and SSAP fields are equal to ETH_RAW the raw Ethernet packet
177 * without any extensions is being used and the frame content starts
178 * rigth after the two fields.
[21580dd]179 */
[aadf01e]180 eth_ieee_lsap_t lsap;
[6067284]181
182 /** SNAP extension. */
[aadf01e]183 eth_snap_t snap;
[21580dd]184} __attribute__ ((packed));
185
[6067284]186/** Ethernet Frame Check Sequence. */
187typedef uint32_t eth_fcs_t;
[21580dd]188
189#endif
190
191/** @}
192 */
Note: See TracBrowser for help on using the repository browser.