Xenomai  3.1-devel
rtnet_socket.h
1 /***
2  *
3  * include/rtnet_socket.h
4  *
5  * RTnet - real-time networking subsystem
6  * Copyright (C) 1999 Lineo, Inc
7  * 1999, 2002 David A. Schleef <ds@schleef.org>
8  * 2002 Ulrich Marx <marx@kammer.uni-hannover.de>
9  * 2003-2005 Jan Kiszka <jan.kiszka@web.de>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  */
26 
27 #ifndef __RTNET_SOCKET_H_
28 #define __RTNET_SOCKET_H_
29 
30 #include <asm/atomic.h>
31 #include <linux/list.h>
32 
33 #include <rtdev.h>
34 #include <rtnet.h>
35 #include <rtdm/driver.h>
36 #include <stack_mgr.h>
37 
38 #include <rtdm/driver.h>
39 
40 
41 struct rtsocket {
42  unsigned short protocol;
43 
44  struct rtskb_pool skb_pool;
45  unsigned int pool_size;
46  struct mutex pool_nrt_lock;
47 
48  struct rtskb_queue incoming;
49 
50  rtdm_lock_t param_lock;
51 
52  unsigned int priority;
53  nanosecs_rel_t timeout; /* receive timeout, 0 for infinite */
54 
55  rtdm_sem_t pending_sem;
56 
57  void (*callback_func)(struct rtdm_fd *, void *arg);
58  void *callback_arg;
59 
60  unsigned long flags;
61 
62  union {
63  /* IP specific */
64  struct {
65  u32 saddr; /* source ip-addr (bind) */
66  u32 daddr; /* destination ip-addr */
67  u16 sport; /* source port */
68  u16 dport; /* destination port */
69 
70  int reg_index; /* index in port registry */
71  u8 tos;
72  u8 state;
73  } inet;
74 
75  /* packet socket specific */
76  struct {
77  struct rtpacket_type packet_type;
78  int ifindex;
79  } packet;
80  } prot;
81 
82  struct module *owner;
83 };
84 
85 
86 static inline struct rtdm_fd *rt_socket_fd(struct rtsocket *sock)
87 {
88  return rtdm_private_to_fd(sock);
89 }
90 
91 void *rtnet_get_arg(struct rtdm_fd *fd, void *tmp,
92  const void *src, size_t len);
93 
94 int rtnet_put_arg(struct rtdm_fd *fd, void *dst,
95  const void *src, size_t len);
96 
97 #define rt_socket_reference(sock) \
98  rtdm_fd_lock(rt_socket_fd(sock))
99 #define rt_socket_dereference(sock) \
100  rtdm_fd_unlock(rt_socket_fd(sock))
101 
102 int __rt_socket_init(struct rtdm_fd *fd, unsigned short protocol,
103  struct module *module);
104 #define rt_socket_init(fd, proto) \
105  __rt_socket_init(fd, proto, THIS_MODULE)
106 
107 void rt_socket_cleanup(struct rtdm_fd *fd);
108 int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, void __user *arg);
109 int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, void __user *arg);
110 int rt_socket_select_bind(struct rtdm_fd *fd,
111  rtdm_selector_t *selector,
112  enum rtdm_selecttype type,
113  unsigned fd_index);
114 
115 int __rt_bare_socket_init(struct rtdm_fd *fd, unsigned short protocol,
116  unsigned int priority, unsigned int pool_size,
117  struct module *module);
118 #define rt_bare_socket_init(fd, proto, prio, pool_sz) \
119  __rt_bare_socket_init(fd, proto, prio, pool_sz, THIS_MODULE)
120 
121 static inline void rt_bare_socket_cleanup(struct rtsocket *sock)
122 {
123  rtskb_pool_release(&sock->skb_pool);
124  module_put(sock->owner);
125 }
126 
127 #endif /* __RTNET_SOCKET_H_ */
ipipe_spinlock_t rtdm_lock_t
Lock variable.
Definition: driver.h:551
int64_t nanosecs_rel_t
RTDM type for representing relative intervals.
Definition: rtdm.h:49
Real-Time Driver Model for Xenomai, driver API header.
rtdm_selecttype
Definition: driver.h:111
static struct rtdm_fd * rtdm_private_to_fd(void *dev_private)
Locate a device file descriptor structure from its driver private area.
Definition: driver.h:174