source: mainline/uspace/lib/net/include/nil_interface.h@ 24ab58b3

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 24ab58b3 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: 6.8 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 net_nil
30 * @{
31 */
32
33/** @file
34 * Network interface layer module interface.
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.
39 */
40
41#ifndef __NET_NIL_INTERFACE_H__
42#define __NET_NIL_INTERFACE_H__
43
44#include <async.h>
45#include <errno.h>
46
47#include <ipc/ipc.h>
48
49#include <net_messages.h>
50#include <adt/measured_strings.h>
51#include <packet/packet.h>
52#include <nil_messages.h>
53#include <net_device.h>
54
55/** @name Network interface layer module interface
56 * This interface is used by other modules.
57 */
58/*@{*/
59
60/** Returns the device local hardware address.
61 * @param[in] nil_phone The network interface layer phone.
62 * @param[in] device_id The device identifier.
63 * @param[out] address The device local hardware address.
64 * @param[out] data The address data.
65 * @returns EOK on success.
66 * @returns EBADMEM if the address parameter and/or the data parameter is NULL.
67 * @returns ENOENT if there no such device.
68 * @returns Other error codes as defined for the generic_get_addr_req() function.
69 */
70#define nil_get_addr_req(nil_phone, device_id, address, data) \
71 generic_get_addr_req(nil_phone, NET_NIL_ADDR, device_id, address, data)
72
73/** Returns the device broadcast hardware address.
74 * @param[in] nil_phone The network interface layer phone.
75 * @param[in] device_id The device identifier.
76 * @param[out] address The device broadcast hardware address.
77 * @param[out] data The address data.
78 * @returns EOK on success.
79 * @returns EBADMEM if the address parameter is NULL.
80 * @returns ENOENT if there no such device.
81 * @returns Other error codes as defined for the generic_get_addr_req() function.
82 */
83#define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \
84 generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data)
85
86/** Sends the packet queue.
87 * @param[in] nil_phone The network interface layer phone.
88 * @param[in] device_id The device identifier.
89 * @param[in] packet The packet queue.
90 * @param[in] sender The sending module service.
91 * @returns EOK on success.
92 * @returns Other error codes as defined for the generic_send_msg() function.
93 */
94#define nil_send_msg(nil_phone, device_id, packet, sender) \
95 generic_send_msg(nil_phone, NET_NIL_SEND, device_id, packet_get_id(packet), sender, 0)
96
97/** Returns the device packet dimension for sending.
98 * @param[in] nil_phone The network interface layer phone.
99 * @param[in] device_id The device identifier.
100 * @param[out] packet_dimension The packet dimensions.
101 * @returns EOK on success.
102 * @returns ENOENT if there is no such device.
103 * @returns Other error codes as defined for the generic_packet_size_req() function.
104 */
105#define nil_packet_size_req(nil_phone, device_id, packet_dimension) \
106 generic_packet_size_req(nil_phone, NET_NIL_PACKET_SPACE, device_id, packet_dimension)
107
108/** Registers new device or updates the MTU of an existing one.
109 * @param[in] nil_phone The network interface layer phone.
110 * @param[in] device_id The new device identifier.
111 * @param[in] mtu The device maximum transmission unit.
112 * @param[in] netif_service The device driver service.
113 * @returns EOK on success.
114 * @returns EEXIST if the device with the different service exists.
115 * @returns ENOMEM if there is not enough memory left.
116 * @returns Other error codes as defined for the generic_device_req() function.
117 */
118#define nil_device_req(nil_phone, device_id, mtu, netif_service) \
119 generic_device_req(nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service)
120
121/** Notifies the network interface layer about the device state change.
122 * @param[in] nil_phone The network interface layer phone.
123 * @param[in] device_id The device identifier.
124 * @param[in] state The new device state.
125 * @returns EOK on success.
126 * @returns Other error codes as defined for each specific module device state function.
127 */
128extern int nil_device_state_msg(int nil_phone, device_id_t device_id, int state);
129
130/** Passes the packet queue to the network interface layer.
131 * Processes and redistributes the received packet queue to the registered upper layers.
132 * @param[in] nil_phone The network interface layer phone.
133 * @param[in] device_id The source device identifier.
134 * @param[in] packet The received packet or the received packet queue.
135 * @param target The target service. Ignored parameter.
136 * @returns EOK on success.
137 * @returns Other error codes as defined for each specific module received function.
138 */
139extern int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target);
140
141/** Creates bidirectional connection with the network interface layer module and registers the message receiver.
142 * @param[in] service The network interface layer module service.
143 * @param[in] device_id The device identifier.
144 * @param[in] me The requesting module service.
145 * @param[in] receiver The message receiver.
146 * @returns The phone of the needed service.
147 * @returns EOK on success.
148 * @returns Other error codes as defined for the bind_service() function.
149 */
150#define nil_bind_service(service, device_id, me, receiver) \
151 bind_service(service, device_id, me, 0, receiver);
152/*@}*/
153
154#endif
155
156/** @}
157 */
Note: See TracBrowser for help on using the repository browser.