Rev 4743 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 4261 | 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 net_nil |
||
| 30 | * @{ |
||
| 31 | */ |
||
| 32 | |||
| 4350 | mejdrech | 33 | /** @file |
| 4704 | mejdrech | 34 | * Network interface layer module interface. |
| 4350 | mejdrech | 35 | * The same interface is used for standalone remote device modules as well as for bundle device modules. |
| 36 | * The standalone remote device modules have to be compiled with the nil_remote.c source file. |
||
| 37 | * The bundle device modules with the appropriate network interface layer source file (eth.c etc.). |
||
| 38 | * The upper layers cannot be bundled with the network interface layer. |
||
| 4261 | mejdrech | 39 | */ |
| 40 | |||
| 4307 | mejdrech | 41 | #ifndef __NET_NIL_INTERFACE_H__ |
| 42 | #define __NET_NIL_INTERFACE_H__ |
||
| 4261 | mejdrech | 43 | |
| 44 | #include <async.h> |
||
| 45 | #include <errno.h> |
||
| 46 | |||
| 47 | #include <ipc/ipc.h> |
||
| 48 | |||
| 49 | #include "../messages.h" |
||
| 50 | |||
| 51 | #include "../structures/measured_strings.h" |
||
| 52 | #include "../structures/packet/packet.h" |
||
| 53 | |||
| 4307 | mejdrech | 54 | #include "../nil/nil_messages.h" |
| 55 | |||
| 4261 | mejdrech | 56 | #include "device.h" |
| 57 | |||
| 4704 | mejdrech | 58 | /** @name Network interface layer module interface |
| 59 | * This interface is used by other modules. |
||
| 60 | */ |
||
| 61 | /*@{*/ |
||
| 62 | |||
| 4350 | mejdrech | 63 | /** Returns the device local hardware address. |
| 4756 | mejdrech | 64 | * @param[in] nil_phone The network interface layer phone. |
| 65 | * @param[in] device_id The device identifier. |
||
| 66 | * @param[out] address The device local hardware address. |
||
| 67 | * @param[out] data The address data. |
||
| 4350 | mejdrech | 68 | * @returns EOK on success. |
| 4756 | mejdrech | 69 | * @returns EBADMEM if the address parameter and/or the data parameter is NULL. |
| 4350 | mejdrech | 70 | * @returns ENOENT if there no such device. |
| 4743 | mejdrech | 71 | * @returns Other error codes as defined for the generic_get_addr_req() function. |
| 4350 | mejdrech | 72 | */ |
| 4743 | mejdrech | 73 | #define nil_get_addr_req( nil_phone, device_id, address, data ) \ |
| 74 | generic_get_addr_req( nil_phone, NET_NIL_ADDR, device_id, address, data ) |
||
| 4261 | mejdrech | 75 | |
| 4350 | mejdrech | 76 | /** Returns the device broadcast hardware address. |
| 4756 | mejdrech | 77 | * @param[in] nil_phone The network interface layer phone. |
| 78 | * @param[in] device_id The device identifier. |
||
| 79 | * @param[out] address The device broadcast hardware address. |
||
| 80 | * @param[out] data The address data. |
||
| 4350 | mejdrech | 81 | * @returns EOK on success. |
| 82 | * @returns EBADMEM if the address parameter is NULL. |
||
| 83 | * @returns ENOENT if there no such device. |
||
| 4743 | mejdrech | 84 | * @returns Other error codes as defined for the generic_get_addr_req() function. |
| 4350 | mejdrech | 85 | */ |
| 4743 | mejdrech | 86 | #define nil_get_broadcast_addr_req( nil_phone, device_id, address, data ) \ |
| 87 | generic_get_addr_req( nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data ) |
||
| 4261 | mejdrech | 88 | |
| 4350 | mejdrech | 89 | /** Sends the packet queue. |
| 4756 | mejdrech | 90 | * @param[in] nil_phone The network interface layer phone. |
| 91 | * @param[in] device_id The device identifier. |
||
| 92 | * @param[in] packet The packet queue. |
||
| 93 | * @param[in] sender The sending module service. |
||
| 4350 | mejdrech | 94 | * @returns EOK on success. |
| 95 | * @returns Other error codes as defined for the generic_send_msg() function. |
||
| 96 | */ |
||
| 4261 | mejdrech | 97 | #define nil_send_msg( nil_phone, device_id, packet, sender ) \ |
| 4707 | mejdrech | 98 | generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender, 0 ) |
| 4261 | mejdrech | 99 | |
| 4350 | mejdrech | 100 | /** Returns the device packet dimensions for sending. |
| 4756 | mejdrech | 101 | * @param[in] nil_phone The network interface layer phone. |
| 102 | * @param[in] device_id The device identifier. |
||
| 103 | * @param[out] addr_len The minimum reserved address length. |
||
| 104 | * @param[out] prefix The minimum reserved prefix size. |
||
| 105 | * @param[out] content The maximum content size. |
||
| 106 | * @param[out] suffix The minimum reserved suffix size. |
||
| 4350 | mejdrech | 107 | * @returns EOK on success. |
| 108 | * @returns EBADMEM if either one of the parameters is NULL. |
||
| 109 | * @returns ENOENT if there is no such device. |
||
| 110 | * @returns Other error codes as defined for the generic_packet_size_req() function. |
||
| 111 | */ |
||
| 4261 | mejdrech | 112 | #define nil_packet_size_req( nil_phone, device_id, addr_len, prefix, content, suffix ) \ |
| 113 | generic_packet_size_req( nil_phone, NET_NIL_PACKET_SPACE, device_id, addr_len, prefix, content, suffix ) |
||
| 114 | |||
| 4350 | mejdrech | 115 | /** Registers new device or updates the MTU of an existing one. |
| 4756 | mejdrech | 116 | * @param[in] nil_phone The network interface layer phone. |
| 117 | * @param[in] device_id The new device identifier. |
||
| 118 | * @param[in] mtu The device maximum transmission unit. |
||
| 119 | * @param[in] netif_service The device driver service. |
||
| 4350 | mejdrech | 120 | * @returns EOK on success. |
| 121 | * @returns EEXIST if the device with the different service exists. |
||
| 122 | * @returns ENOMEM if there is not enough memory left. |
||
| 123 | * @returns Other error codes as defined for the generic_device_req() function. |
||
| 124 | */ |
||
| 4261 | mejdrech | 125 | #define nil_device_req( nil_phone, device_id, mtu, netif_service ) \ |
| 126 | generic_device_req( nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service ) |
||
| 127 | |||
| 4350 | mejdrech | 128 | /** Notifies the network interface layer about the device state change. |
| 4756 | mejdrech | 129 | * @param[in] nil_phone The network interface layer phone. |
| 130 | * @param[in] device_id The device identifier. |
||
| 131 | * @param[in] state The new device state. |
||
| 4350 | mejdrech | 132 | * @returns EOK on success. |
| 133 | * @returns Other error codes as defined for each specific module device state function. |
||
| 134 | */ |
||
| 4307 | mejdrech | 135 | int nil_device_state_msg( int nil_phone, device_id_t device_id, int state ); |
| 4261 | mejdrech | 136 | |
| 4350 | mejdrech | 137 | /** Passes the packet queue to the network interface layer. |
| 138 | * Processes and redistributes the received packet queue to the registered upper layers. |
||
| 4756 | mejdrech | 139 | * @param[in] nil_phone The network interface layer phone. |
| 140 | * @param[in] device_id The source device identifier. |
||
| 141 | * @param[in] packet The received packet or the received packet queue. |
||
| 4350 | mejdrech | 142 | * @param target The target service. Ignored parameter. |
| 143 | * @returns EOK on success. |
||
| 144 | * @returns Other error codes as defined for each specific module received function. |
||
| 145 | */ |
||
| 4307 | mejdrech | 146 | int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target ); |
| 147 | |||
| 4743 | mejdrech | 148 | /** Creates bidirectional connection with the network interface layer module and registers the message receiver. |
| 4756 | mejdrech | 149 | * @param[in] service The network interface layer module service. |
| 150 | * @param[in] device_id The device identifier. |
||
| 151 | * @param[in] me The requesting module service. |
||
| 152 | * @param[in] receiver The message receiver. |
||
| 4743 | mejdrech | 153 | * @returns The phone of the needed service. |
| 154 | * @returns EOK on success. |
||
| 155 | * @returns Other error codes as defined for the bind_service() function. |
||
| 156 | */ |
||
| 157 | #define nil_bind_service( service, device_id, me, receiver ) \ |
||
| 158 | bind_service( service, device_id, me, 0, receiver ); |
||
| 4704 | mejdrech | 159 | /*@}*/ |
| 160 | |||
| 4261 | mejdrech | 161 | #endif |
| 162 | |||
| 163 | /** @} |
||
| 164 | */ |