source: mainline/uspace/lib/socket/include/net_device.h@ 849ed54

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

Networking work:
Split the networking stack into end-user library (libsocket) and two helper libraries (libnet and libnetif).
Don't use over-the-hand compiling and linking, but rather separation of conserns.
There might be still some issues and the non-modular networking architecture is currently broken, but this will be fixed soon.

  • Property mode set to 100644
File size: 4.4 KB
Line 
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 netif
30 * @{
31 */
32
33/** @file
34 * Device identifier, state and usage statistics.
35 */
36
37#ifndef __NET_DEVICE_ID_TYPE_H__
38#define __NET_DEVICE_ID_TYPE_H__
39
40#include <adt/int_map.h>
41
42/** Device identifier to generic type map declaration.
43 */
44#define DEVICE_MAP_DECLARE INT_MAP_DECLARE
45
46/** Device identifier to generic type map implementation.
47 */
48#define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT
49
50/** Invalid device identifier.
51 */
52#define DEVICE_INVALID_ID (-1)
53
54/** Device identifier type.
55 */
56typedef int device_id_t;
57
58/** Device state type.
59 */
60typedef enum device_state device_state_t;
61
62/** Type definition of the device usage statistics.
63 * @see device_stats
64 */
65typedef struct device_stats device_stats_t;
66
67/** Type definition of the device usage statistics pointer.
68 * @see device_stats
69 */
70typedef device_stats_t * device_stats_ref;
71
72/** Device state.
73 */
74enum device_state{
75 /** Device not present or not initialized.
76 */
77 NETIF_NULL = 0,
78 /** Device present and stopped.
79 */
80 NETIF_STOPPED,
81 /** Device present and active.
82 */
83 NETIF_ACTIVE,
84 /** Device present but unable to transmit.
85 */
86 NETIF_CARRIER_LOST
87};
88
89/** Device usage statistics.
90 */
91struct device_stats{
92 /** Total packets received.
93 */
94 unsigned long receive_packets;
95 /** Total packets transmitted.
96 */
97 unsigned long send_packets;
98 /** Total bytes received.
99 */
100 unsigned long receive_bytes;
101 /** Total bytes transmitted.
102 */
103 unsigned long send_bytes;
104 /** Bad packets received counter.
105 */
106 unsigned long receive_errors;
107 /** Packet transmition problems counter.
108 */
109 unsigned long send_errors;
110 /** No space in buffers counter.
111 */
112 unsigned long receive_dropped;
113 /** No space available counter.
114 */
115 unsigned long send_dropped;
116 /** Total multicast packets received.
117 */
118 unsigned long multicast;
119 /** The number of collisions due to congestion on the medium.
120 */
121 unsigned long collisions;
122
123 /* detailed receive_errors: */
124 /** Received packet length error counter.
125 */
126 unsigned long receive_length_errors;
127 /** Receiver buffer overflow counter.
128 */
129 unsigned long receive_over_errors;
130 /** Received packet with crc error counter.
131 */
132 unsigned long receive_crc_errors;
133 /** Received frame alignment error counter.
134 */
135 unsigned long receive_frame_errors;
136 /** Receiver fifo overrun counter.
137 */
138 unsigned long receive_fifo_errors;
139 /** Receiver missed packet counter.
140 */
141 unsigned long receive_missed_errors;
142
143 /* detailed send_errors */
144 /** Transmitter aborted counter.
145 */
146 unsigned long send_aborted_errors;
147 /** Transmitter carrier errors counter.
148 */
149 unsigned long send_carrier_errors;
150 /** Transmitter fifo overrun counter.
151 */
152 unsigned long send_fifo_errors;
153 /** Transmitter carrier errors counter.
154 */
155 unsigned long send_heartbeat_errors;
156 /** Transmitter window errors counter.
157 */
158 unsigned long send_window_errors;
159
160 /* for cslip etc */
161 /** Total compressed packets received.
162 */
163 unsigned long receive_compressed;
164 /** Total compressed packet transmitted.
165 */
166 unsigned long send_compressed;
167};
168
169#endif
170
171/** @}
172 */
173
Note: See TracBrowser for help on using the repository browser.