Xenomai  3.0.8
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 <rtdm/net.h>
35 #include <rtdm/driver.h>
36 #include <stack_mgr.h>
37 
38 
39 struct rtsocket {
40  unsigned short protocol;
41 
42  struct rtskb_pool skb_pool;
43  unsigned int pool_size;
44  struct mutex pool_nrt_lock;
45 
46  struct rtskb_queue incoming;
47 
48  rtdm_lock_t param_lock;
49 
50  unsigned int priority;
51  nanosecs_rel_t timeout; /* receive timeout, 0 for infinite */
52 
53  rtdm_sem_t pending_sem;
54 
55  void (*callback_func)(struct rtdm_fd *, void *arg);
56  void *callback_arg;
57 
58  unsigned long flags;
59 
60  union {
61  /* IP specific */
62  struct {
63  u32 saddr; /* source ip-addr (bind) */
64  u32 daddr; /* destination ip-addr */
65  u16 sport; /* source port */
66  u16 dport; /* destination port */
67 
68  int reg_index; /* index in port registry */
69  u8 tos;
70  u8 state;
71  } inet;
72 
73  /* packet socket specific */
74  struct {
75  struct rtpacket_type packet_type;
76  int ifindex;
77  } packet;
78  } prot;
79 
80  struct module *owner;
81 };
82 
83 
84 static inline struct rtdm_fd *rt_socket_fd(struct rtsocket *sock)
85 {
86  return rtdm_private_to_fd(sock);
87 }
88 
89 void *rtnet_get_arg(struct rtdm_fd *fd, void *tmp,
90  const void *src, size_t len);
91 
92 int rtnet_put_arg(struct rtdm_fd *fd, void *dst,
93  const void *src, size_t len);
94 
95 #define rt_socket_reference(sock) \
96  rtdm_fd_lock(rt_socket_fd(sock))
97 #define rt_socket_dereference(sock) \
98  rtdm_fd_unlock(rt_socket_fd(sock))
99 
100 int __rt_socket_init(struct rtdm_fd *fd, unsigned short protocol,
101  struct module *module);
102 #define rt_socket_init(fd, proto) \
103  __rt_socket_init(fd, proto, THIS_MODULE)
104 
105 void rt_socket_cleanup(struct rtdm_fd *fd);
106 int rt_socket_common_ioctl(struct rtdm_fd *fd, int request, void __user *arg);
107 int rt_socket_if_ioctl(struct rtdm_fd *fd, int request, void __user *arg);
108 int rt_socket_select_bind(struct rtdm_fd *fd,
109  rtdm_selector_t *selector,
110  enum rtdm_selecttype type,
111  unsigned fd_index);
112 
113 int __rt_bare_socket_init(struct rtdm_fd *fd, unsigned short protocol,
114  unsigned int priority, unsigned int pool_size,
115  struct module *module);
116 #define rt_bare_socket_init(fd, proto, prio, pool_sz) \
117  __rt_bare_socket_init(fd, proto, prio, pool_sz, THIS_MODULE)
118 
119 static inline void rt_bare_socket_cleanup(struct rtsocket *sock)
120 {
121  rtskb_pool_release(&sock->skb_pool);
122  module_put(sock->owner);
123 }
124 
125 #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