Subversion Repositories HelenOS

Rev

Rev 4350 | Rev 4707 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4350 Rev 4704
1
/*
1
/*
2
 * Copyright (c) 2009 Lukas Mejdrech
2
 * Copyright (c) 2009 Lukas Mejdrech
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
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
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.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
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
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
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.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup net_nil
29
/** @addtogroup net_nil
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 *  Network interface layer interface.
34
 *  Network interface layer module interface.
35
 *  The same interface is used for standalone remote device modules as well as for bundle device modules.
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.
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.).
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.
38
 *  The upper layers cannot be bundled with the network interface layer.
39
 */
39
 */
40
 
40
 
41
#ifndef __NET_NIL_INTERFACE_H__
41
#ifndef __NET_NIL_INTERFACE_H__
42
#define __NET_NIL_INTERFACE_H__
42
#define __NET_NIL_INTERFACE_H__
43
 
43
 
44
#include <async.h>
44
#include <async.h>
45
#include <errno.h>
45
#include <errno.h>
46
 
46
 
47
#include <ipc/ipc.h>
47
#include <ipc/ipc.h>
48
 
48
 
49
#include "../messages.h"
49
#include "../messages.h"
50
 
50
 
51
#include "../structures/measured_strings.h"
51
#include "../structures/measured_strings.h"
52
#include "../structures/packet/packet.h"
52
#include "../structures/packet/packet.h"
53
 
53
 
54
#include "../nil/nil_messages.h"
54
#include "../nil/nil_messages.h"
55
 
55
 
56
#include "device.h"
56
#include "device.h"
57
 
57
 
-
 
58
/** @name Network interface layer module interface
-
 
59
 *  This interface is used by other modules.
-
 
60
 */
-
 
61
/*@{*/
-
 
62
 
58
/** Returns the device local hardware address.
63
/** Returns the device local hardware address.
59
 *  @param nil_phone The network interface layer phone. Input parameter.
64
 *  @param nil_phone The network interface layer phone. Input parameter.
60
 *  @param device_id The device identifier. Input parameter.
65
 *  @param device_id The device identifier. Input parameter.
61
 *  @param address The device local hardware address. Output parameter.
66
 *  @param address The device local hardware address. Output parameter.
62
 *  @param data The address data. Output parameter.
67
 *  @param data The address data. Output parameter.
63
 *  @returns EOK on success.
68
 *  @returns EOK on success.
64
 *  @returns EBADMEM if the address parameter is NULL.
69
 *  @returns EBADMEM if the address parameter is NULL.
65
 *  @returns ENOENT if there no such device.
70
 *  @returns ENOENT if there no such device.
66
 *  @returns Other error codes as defined for the generic_get_addr() function.
71
 *  @returns Other error codes as defined for the generic_get_addr() function.
67
 */
72
 */
68
#define nil_get_addr( nil_phone, device_id, address, data ) \
73
#define nil_get_addr( nil_phone, device_id, address, data ) \
69
    generic_get_addr( nil_phone, NET_NIL_ADDR, device_id, address, data )
74
    generic_get_addr( nil_phone, NET_NIL_ADDR, device_id, address, data )
70
 
75
 
71
/** Returns the device broadcast hardware address.
76
/** Returns the device broadcast hardware address.
72
 *  @param nil_phone The network interface layer phone. Input parameter.
77
 *  @param nil_phone The network interface layer phone. Input parameter.
73
 *  @param device_id The device identifier. Input parameter.
78
 *  @param device_id The device identifier. Input parameter.
74
 *  @param address The device broadcast hardware address. Output parameter.
79
 *  @param address The device broadcast hardware address. Output parameter.
75
 *  @param data The address data. Output parameter.
80
 *  @param data The address data. Output parameter.
76
 *  @returns EOK on success.
81
 *  @returns EOK on success.
77
 *  @returns EBADMEM if the address parameter is NULL.
82
 *  @returns EBADMEM if the address parameter is NULL.
78
 *  @returns ENOENT if there no such device.
83
 *  @returns ENOENT if there no such device.
79
 *  @returns Other error codes as defined for the generic_get_addr() function.
84
 *  @returns Other error codes as defined for the generic_get_addr() function.
80
 */
85
 */
81
#define nil_get_broadcast_addr( nil_phone, device_id, address, data )   \
86
#define nil_get_broadcast_addr( nil_phone, device_id, address, data )   \
82
    generic_get_addr( nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data )
87
    generic_get_addr( nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data )
83
 
88
 
84
/** Sends the packet queue.
89
/** Sends the packet queue.
85
 *  @param nil_phone The network interface layer phone. Input parameter.
90
 *  @param nil_phone The network interface layer phone. Input parameter.
86
 *  @param device_id The device identifier. Input parameter.
91
 *  @param device_id The device identifier. Input parameter.
87
 *  @param packet The packet queue. Input parameter.
92
 *  @param packet The packet queue. Input parameter.
88
 *  @param sender The sending module service. Input parameter.
93
 *  @param sender The sending module service. Input parameter.
89
 *  @returns EOK on success.
94
 *  @returns EOK on success.
90
 *  @returns Other error codes as defined for the generic_send_msg() function.
95
 *  @returns Other error codes as defined for the generic_send_msg() function.
91
 */
96
 */
92
#define nil_send_msg( nil_phone, device_id, packet, sender )    \
97
#define nil_send_msg( nil_phone, device_id, packet, sender )    \
93
    generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender )
98
    generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender )
94
 
99
 
95
/** Returns the device packet dimensions for sending.
100
/** Returns the device packet dimensions for sending.
96
 *  @param nil_phone The network interface layer phone. Input parameter.
101
 *  @param nil_phone The network interface layer phone. Input parameter.
97
 *  @param device_id The device identifier. Input parameter.
102
 *  @param device_id The device identifier. Input parameter.
98
 *  @param addr_len The minimum reserved address length. Output parameter.
103
 *  @param addr_len The minimum reserved address length. Output parameter.
99
 *  @param prefix The minimum reserved prefix size. Output parameter.
104
 *  @param prefix The minimum reserved prefix size. Output parameter.
100
 *  @param content The maximum content size. Output parameter.
105
 *  @param content The maximum content size. Output parameter.
101
 *  @param suffix The minimum reserved suffix size. Output parameter.
106
 *  @param suffix The minimum reserved suffix size. Output parameter.
102
 *  @returns EOK on success.
107
 *  @returns EOK on success.
103
 *  @returns EBADMEM if either one of the parameters is NULL.
108
 *  @returns EBADMEM if either one of the parameters is NULL.
104
 *  @returns ENOENT if there is no such device.
109
 *  @returns ENOENT if there is no such device.
105
 *  @returns Other error codes as defined for the generic_packet_size_req() function.
110
 *  @returns Other error codes as defined for the generic_packet_size_req() function.
106
 */
111
 */
107
#define nil_packet_size_req( nil_phone, device_id, addr_len, prefix, content, suffix )  \
112
#define nil_packet_size_req( nil_phone, device_id, addr_len, prefix, content, suffix )  \
108
    generic_packet_size_req( nil_phone, NET_NIL_PACKET_SPACE, 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 )
109
 
114
 
110
/** Registers new device or updates the MTU of an existing one.
115
/** Registers new device or updates the MTU of an existing one.
111
 *  @param nil_phone The network interface layer phone. Input parameter.
116
 *  @param nil_phone The network interface layer phone. Input parameter.
112
 *  @param device_id The new device identifier. Input parameter.
117
 *  @param device_id The new device identifier. Input parameter.
113
 *  @param mtu The device maximum transmission unit. Input parameter.
118
 *  @param mtu The device maximum transmission unit. Input parameter.
114
 *  @param netif_service The device driver service. Input parameter.
119
 *  @param netif_service The device driver service. Input parameter.
115
 *  @returns EOK on success.
120
 *  @returns EOK on success.
116
 *  @returns EEXIST if the device with the different service exists.
121
 *  @returns EEXIST if the device with the different service exists.
117
 *  @returns ENOMEM if there is not enough memory left.
122
 *  @returns ENOMEM if there is not enough memory left.
118
 *  @returns Other error codes as defined for the generic_device_req() function.
123
 *  @returns Other error codes as defined for the generic_device_req() function.
119
 */
124
 */
120
#define nil_device_req( nil_phone, device_id, mtu, netif_service )  \
125
#define nil_device_req( nil_phone, device_id, mtu, netif_service )  \
121
    generic_device_req( nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service )
126
    generic_device_req( nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service )
122
 
127
 
123
/** Notifies the network interface layer about the device state change.
128
/** Notifies the network interface layer about the device state change.
124
 *  @param nil_phone The network interface layer phone. Input parameter.
129
 *  @param nil_phone The network interface layer phone. Input parameter.
125
 *  @param device_id The device identifier. Input parameter.
130
 *  @param device_id The device identifier. Input parameter.
126
 *  @param state The new device state. Input parameter.
131
 *  @param state The new device state. Input parameter.
127
 *  @returns EOK on success.
132
 *  @returns EOK on success.
128
 *  @returns Other error codes as defined for each specific module device state function.
133
 *  @returns Other error codes as defined for each specific module device state function.
129
 */
134
 */
130
int nil_device_state_msg( int nil_phone, device_id_t device_id, int state );
135
int nil_device_state_msg( int nil_phone, device_id_t device_id, int state );
131
 
136
 
132
/** Passes the packet queue to the network interface layer.
137
/** Passes the packet queue to the network interface layer.
133
 *  Processes and redistributes the received packet queue to the registered upper layers.
138
 *  Processes and redistributes the received packet queue to the registered upper layers.
134
 *  @param nil_phone The network interface layer phone. Input parameter.
139
 *  @param nil_phone The network interface layer phone. Input parameter.
135
 *  @param device_id The source device identifier. Input parameter.
140
 *  @param device_id The source device identifier. Input parameter.
136
 *  @param packet The received packet or the received packet queue. Input parameter.
141
 *  @param packet The received packet or the received packet queue. Input parameter.
137
 *  @param target The target service. Ignored parameter.
142
 *  @param target The target service. Ignored parameter.
138
 *  @returns EOK on success.
143
 *  @returns EOK on success.
139
 *  @returns Other error codes as defined for each specific module received function.
144
 *  @returns Other error codes as defined for each specific module received function.
140
 */
145
 */
141
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target );
146
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target );
142
 
147
 
-
 
148
/*@}*/
-
 
149
 
143
#endif
150
#endif
144
 
151
 
145
/** @}
152
/** @}
146
 */
153
 */
147
 
154