| [21580dd] | 1 | /*
|
|---|
| 2 | * Copyright (c) 2009 Lukas Mejdrech
|
|---|
| [609243f4] | 3 | * Copyright (c) 2011 Radim Vansa
|
|---|
| [21580dd] | 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
|
|---|
| [30b2d02] | 31 | * @{
|
|---|
| [21580dd] | 32 | */
|
|---|
| 33 |
|
|---|
| 34 | /** @file
|
|---|
| [30b2d02] | 35 | * Dummy network interface layer module.
|
|---|
| [21580dd] | 36 | */
|
|---|
| 37 |
|
|---|
| [30b2d02] | 38 | #ifndef NET_NILDUMMY_H_
|
|---|
| 39 | #define NET_NILDUMMY_H_
|
|---|
| [21580dd] | 40 |
|
|---|
| [6b82009] | 41 | #include <async.h>
|
|---|
| [21580dd] | 42 | #include <fibril_synch.h>
|
|---|
| 43 | #include <ipc/services.h>
|
|---|
| [609243f4] | 44 | #include <ipc/devman.h>
|
|---|
| [e526f08] | 45 | #include <net/device.h>
|
|---|
| [849ed54] | 46 | #include <adt/measured_strings.h>
|
|---|
| [21580dd] | 47 |
|
|---|
| 48 | /** Type definition of the dummy nil global data.
|
|---|
| [fe8dfa6] | 49 | *
|
|---|
| [30b2d02] | 50 | * @see nildummy_globals
|
|---|
| [fe8dfa6] | 51 | *
|
|---|
| [21580dd] | 52 | */
|
|---|
| [30b2d02] | 53 | typedef struct nildummy_globals nildummy_globals_t;
|
|---|
| [21580dd] | 54 |
|
|---|
| 55 | /** Type definition of the dummy nil device specific data.
|
|---|
| [fe8dfa6] | 56 | *
|
|---|
| [30b2d02] | 57 | * @see nildummy_device
|
|---|
| [fe8dfa6] | 58 | *
|
|---|
| [21580dd] | 59 | */
|
|---|
| [30b2d02] | 60 | typedef struct nildummy_device nildummy_device_t;
|
|---|
| [21580dd] | 61 |
|
|---|
| 62 | /** Type definition of the dummy nil protocol specific data.
|
|---|
| [fe8dfa6] | 63 | *
|
|---|
| [30b2d02] | 64 | * @see nildummy_proto
|
|---|
| [fe8dfa6] | 65 | *
|
|---|
| [21580dd] | 66 | */
|
|---|
| [5e9e8b7] | 67 | typedef struct nildummy_proto nildummy_proto_t;
|
|---|
| [21580dd] | 68 |
|
|---|
| 69 | /** Dummy nil device map.
|
|---|
| [fe8dfa6] | 70 | *
|
|---|
| 71 | * Map devices to the dummy nil device specific data.
|
|---|
| [30b2d02] | 72 | * @see device.h
|
|---|
| [fe8dfa6] | 73 | *
|
|---|
| [21580dd] | 74 | */
|
|---|
| [30b2d02] | 75 | DEVICE_MAP_DECLARE(nildummy_devices, nildummy_device_t);
|
|---|
| [21580dd] | 76 |
|
|---|
| [30b2d02] | 77 | /** Dummy nil device specific data. */
|
|---|
| 78 | struct nildummy_device {
|
|---|
| 79 | /** Device identifier. */
|
|---|
| [609243f4] | 80 | nic_device_id_t device_id;
|
|---|
| 81 | /** Device driver handle. */
|
|---|
| 82 | devman_handle_t handle;
|
|---|
| [6b82009] | 83 | /** Driver session. */
|
|---|
| 84 | async_sess_t *sess;
|
|---|
| [fe8dfa6] | 85 |
|
|---|
| [30b2d02] | 86 | /** Maximal transmission unit. */
|
|---|
| [aadf01e] | 87 | size_t mtu;
|
|---|
| [fe8dfa6] | 88 |
|
|---|
| [30b2d02] | 89 | /** Actual device hardware address. */
|
|---|
| [609243f4] | 90 | nic_address_t addr;
|
|---|
| 91 | /** Actual device hardware address length. */
|
|---|
| 92 | size_t addr_len;
|
|---|
| [21580dd] | 93 | };
|
|---|
| 94 |
|
|---|
| [30b2d02] | 95 | /** Dummy nil protocol specific data. */
|
|---|
| 96 | struct nildummy_proto {
|
|---|
| 97 | /** Protocol service. */
|
|---|
| [aadf01e] | 98 | services_t service;
|
|---|
| [fe8dfa6] | 99 |
|
|---|
| [6b82009] | 100 | /** Protocol module session. */
|
|---|
| 101 | async_sess_t *sess;
|
|---|
| [21580dd] | 102 | };
|
|---|
| 103 |
|
|---|
| [30b2d02] | 104 | /** Dummy nil global data. */
|
|---|
| [5e9e8b7] | 105 | struct nildummy_globals {
|
|---|
| [6b82009] | 106 | /** Networking module session. */
|
|---|
| 107 | async_sess_t *net_sess;
|
|---|
| [fe8dfa6] | 108 |
|
|---|
| 109 | /** Lock for devices. */
|
|---|
| [aadf01e] | 110 | fibril_rwlock_t devices_lock;
|
|---|
| [fe8dfa6] | 111 |
|
|---|
| [30b2d02] | 112 | /** All known Ethernet devices. */
|
|---|
| [aadf01e] | 113 | nildummy_devices_t devices;
|
|---|
| [fe8dfa6] | 114 |
|
|---|
| [30b2d02] | 115 | /** Safety lock for protocols. */
|
|---|
| [aadf01e] | 116 | fibril_rwlock_t protos_lock;
|
|---|
| [fe8dfa6] | 117 |
|
|---|
| [30b2d02] | 118 | /** Default protocol. */
|
|---|
| [aadf01e] | 119 | nildummy_proto_t proto;
|
|---|
| [21580dd] | 120 | };
|
|---|
| 121 |
|
|---|
| 122 | #endif
|
|---|
| 123 |
|
|---|
| 124 | /** @}
|
|---|
| 125 | */
|
|---|