Xenomai  3.0.5
rtnet.h
1 /***
2  *
3  * rtnet.h
4  *
5  * RTnet - real-time networking subsystem
6  * Copyright (C) 2005-2011 Jan Kiszka <jan.kiszka@web.de>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * As a special exception to the GNU General Public license, the RTnet
23  * project allows you to use this header file in unmodified form to produce
24  * application programs executing in user-space which use RTnet services by
25  * normal system calls. The resulting executable will not be covered by the
26  * GNU General Public License merely as a result of this header file use.
27  * Instead, this header file use will be considered normal use of RTnet and
28  * not a "derived work" in the sense of the GNU General Public License.
29  *
30  * This exception does not apply when the application code is built as a
31  * static or dynamically loadable portion of the Linux kernel nor does the
32  * exception override other reasons justifying application of the GNU General
33  * Public License.
34  *
35  * This exception applies only to the code released by the RTnet project
36  * under the name RTnet and bearing this exception notice. If you copy code
37  * from other sources into a copy of RTnet, the exception does not apply to
38  * the code that you add in this way.
39  *
40  */
41 
42 #ifndef __RTNET_H_
43 #define __RTNET_H_
44 
45 #include <rtdm/rtdm.h>
46 
47 
48 /* RTDM_API_VER < 5 is lacking generic time types */
49 #if !(defined RTDM_API_VER) || (RTDM_API_VER < 5)
50 
51 #ifndef __KERNEL__
52 #include <stdint.h>
53 #endif /* !__KERNEL__ */
54 
55 typedef uint64_t nanosecs_abs_t;
56 typedef int64_t nanosecs_rel_t;
57 
58 #define RTDM_TIMEOUT_INFINITE 0
59 #define RTDM_TIMEOUT_NONE (-1)
60 
61 #endif /* !RTDM_API_VER */
62 
63 
64 /* sub-classes: RTDM_CLASS_NETWORK */
65 #define RTDM_SUBCLASS_RTNET 0
66 
67 #define RTIOC_TYPE_NETWORK RTDM_CLASS_NETWORK
68 
69 /* RTnet-specific IOCTLs */
70 #define RTNET_RTIOC_XMITPARAMS _IOW(RTIOC_TYPE_NETWORK, 0x10, unsigned int)
71 #define RTNET_RTIOC_PRIORITY RTNET_RTIOC_XMITPARAMS /* legacy */
72 #define RTNET_RTIOC_TIMEOUT _IOW(RTIOC_TYPE_NETWORK, 0x11, int64_t)
73 /* RTNET_RTIOC_CALLBACK _IOW(RTIOC_TYPE_NETWORK, 0x12, ...
74  * IOCTL only usable inside the kernel. */
75 /* RTNET_RTIOC_NONBLOCK _IOW(RTIOC_TYPE_NETWORK, 0x13, unsigned int)
76  * This IOCTL is no longer supported (and it was buggy anyway).
77  * Use RTNET_RTIOC_TIMEOUT with any negative timeout value instead. */
78 #define RTNET_RTIOC_EXTPOOL _IOW(RTIOC_TYPE_NETWORK, 0x14, unsigned int)
79 #define RTNET_RTIOC_SHRPOOL _IOW(RTIOC_TYPE_NETWORK, 0x15, unsigned int)
80 
81 /* socket transmission priorities */
82 #define SOCK_MAX_PRIO 0
83 #define SOCK_DEF_PRIO SOCK_MAX_PRIO + \
84  (SOCK_MIN_PRIO-SOCK_MAX_PRIO+1)/2
85 #define SOCK_MIN_PRIO SOCK_NRT_PRIO - 1
86 #define SOCK_NRT_PRIO 31
87 
88 /* socket transmission channels */
89 #define SOCK_DEF_RT_CHANNEL 0 /* default rt xmit channel */
90 #define SOCK_DEF_NRT_CHANNEL 1 /* default non-rt xmit channel */
91 #define SOCK_USER_CHANNEL 2 /* first user-defined channel */
92 
93 /* argument construction for RTNET_RTIOC_XMITPARAMS */
94 #define SOCK_XMIT_PARAMS(priority, channel) ((priority) | ((channel) << 16))
95 
96 
97 #ifdef __KERNEL__
98 
99 #include <rtdm/driver.h>
100 
101 struct rtnet_callback {
102  void (*func)(struct rtdm_fd *, void *);
103  void *arg;
104 };
105 
106 #define RTNET_RTIOC_CALLBACK _IOW(RTIOC_TYPE_NETWORK, 0x12, \
107  struct rtnet_callback)
108 
109 /* utility functions */
110 
111 /* provided by rt_ipv4 */
112 unsigned long rt_inet_aton(const char *ip);
113 
114 /* provided by rt_packet */
115 int rt_eth_aton(unsigned char *addr_buf, const char *mac);
116 
117 #define RTNET_RTDM_VER 914
118 
119 #endif /* __KERNEL__ */
120 
121 #endif /* __RTNET_H_ */
int64_t nanosecs_rel_t
RTDM type for representing relative intervals.
Definition: rtdm.h:49
Real-Time Driver Model for Xenomai, driver API header.
uint64_t nanosecs_abs_t
RTDM type for representing absolute dates.
Definition: rtdm.h:43