1 | /*
|
---|
2 | * Copyright (c) 2009 Lukas Mejdrech
|
---|
3 | * Copyright (c) 2011 Radim Vansa
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @addtogroup nildummy
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 |
|
---|
34 | /** @file
|
---|
35 | * Dummy network interface layer module.
|
---|
36 | */
|
---|
37 |
|
---|
38 | #ifndef NET_NILDUMMY_H_
|
---|
39 | #define NET_NILDUMMY_H_
|
---|
40 |
|
---|
41 | #include <async.h>
|
---|
42 | #include <fibril_synch.h>
|
---|
43 | #include <ipc/services.h>
|
---|
44 | #include <ipc/devman.h>
|
---|
45 | #include <net/device.h>
|
---|
46 | #include <adt/measured_strings.h>
|
---|
47 |
|
---|
48 | /** Type definition of the dummy nil global data.
|
---|
49 | *
|
---|
50 | * @see nildummy_globals
|
---|
51 | *
|
---|
52 | */
|
---|
53 | typedef struct nildummy_globals nildummy_globals_t;
|
---|
54 |
|
---|
55 | /** Type definition of the dummy nil device specific data.
|
---|
56 | *
|
---|
57 | * @see nildummy_device
|
---|
58 | *
|
---|
59 | */
|
---|
60 | typedef struct nildummy_device nildummy_device_t;
|
---|
61 |
|
---|
62 | /** Type definition of the dummy nil protocol specific data.
|
---|
63 | *
|
---|
64 | * @see nildummy_proto
|
---|
65 | *
|
---|
66 | */
|
---|
67 | typedef struct nildummy_proto nildummy_proto_t;
|
---|
68 |
|
---|
69 | /** Dummy nil device map.
|
---|
70 | *
|
---|
71 | * Map devices to the dummy nil device specific data.
|
---|
72 | * @see device.h
|
---|
73 | *
|
---|
74 | */
|
---|
75 | DEVICE_MAP_DECLARE(nildummy_devices, nildummy_device_t);
|
---|
76 |
|
---|
77 | /** Dummy nil device specific data. */
|
---|
78 | struct nildummy_device {
|
---|
79 | /** Device identifier. */
|
---|
80 | nic_device_id_t device_id;
|
---|
81 | /** Device driver handle. */
|
---|
82 | devman_handle_t handle;
|
---|
83 | /** Driver session. */
|
---|
84 | async_sess_t *sess;
|
---|
85 |
|
---|
86 | /** Maximal transmission unit. */
|
---|
87 | size_t mtu;
|
---|
88 |
|
---|
89 | /** Actual device hardware address. */
|
---|
90 | nic_address_t addr;
|
---|
91 | /** Actual device hardware address length. */
|
---|
92 | size_t addr_len;
|
---|
93 | };
|
---|
94 |
|
---|
95 | /** Dummy nil protocol specific data. */
|
---|
96 | struct nildummy_proto {
|
---|
97 | /** Protocol service. */
|
---|
98 | services_t service;
|
---|
99 |
|
---|
100 | /** Protocol module session. */
|
---|
101 | async_sess_t *sess;
|
---|
102 | };
|
---|
103 |
|
---|
104 | /** Dummy nil global data. */
|
---|
105 | struct nildummy_globals {
|
---|
106 | /** Networking module session. */
|
---|
107 | async_sess_t *net_sess;
|
---|
108 |
|
---|
109 | /** Lock for devices. */
|
---|
110 | fibril_rwlock_t devices_lock;
|
---|
111 |
|
---|
112 | /** All known Ethernet devices. */
|
---|
113 | nildummy_devices_t devices;
|
---|
114 |
|
---|
115 | /** Safety lock for protocols. */
|
---|
116 | fibril_rwlock_t protos_lock;
|
---|
117 |
|
---|
118 | /** Default protocol. */
|
---|
119 | nildummy_proto_t proto;
|
---|
120 | };
|
---|
121 |
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | /** @}
|
---|
125 | */
|
---|