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