1 #ifndef __LINUX_NET_AFIPN_H
2 #define __LINUX_NET_AFIPN_H
7 #define IPN_HASH_SIZE 256
9 #define IPN_BROADCAST 1
11 #define IPN_VDESWITCH 2
12 #define IPN_VDESWITCH_L3 3
14 #define IPN_SO_PREBIND 0x80
16 #define IPN_SO_DESCR 1
17 #define IPN_SO_MTU (IPN_SO_PREBIND | 0)
18 #define IPN_SO_NUMNODES (IPN_SO_PREBIND | 1)
19 #define IPN_SO_MSGPOOLSIZE (IPN_SO_PREBIND | 2)
20 #define IPN_SO_FLAGS (IPN_SO_PREBIND | 3)
21 #define IPN_SO_MODE (IPN_SO_PREBIND | 4)
23 #define IPN_PORTNO_ANY -1
25 #define IPN_DESCRLEN 128
27 #define IPN_FLAG_LOSSLESS 1
30 #define IPN_SETPERSIST_NETDEV _IOW('I', 200, int)
31 #define IPN_CLRPERSIST_NETDEV _IOW('I', 201, int)
32 #define IPN_CONN_NETDEV _IOW('I', 202, int)
33 #define IPN_JOIN_NETDEV _IOW('I', 203, int)
34 #define IPN_SETPERSIST _IOW('I', 204, int)
37 #include <linux/socket.h>
38 #include <linux/mutex.h>
42 /* The AF_IPN socket */
45 struct pre_bind_parms
;
50 * @protocol=kind of service 0->standard broadcast
51 * @flags= see IPN_NODEFLAG_xxx
52 * @descr=description of this port
53 * @portno=when connected: port of the netowrk (<0 means unconnected)
54 * @msglock=mutex on the msg queue
55 * @msgcount=# of pending msgs
56 * @msgqueue=queue of messages
57 * @ipn=network we are connected to
58 * @pbp=temporary storage for parms that must be set prior to bind
62 volatile unsigned char flags
;
63 unsigned char shutdown
;
64 char descr
[IPN_DESCRLEN
];
67 unsigned short msgcount
;
68 struct list_head msgqueue
;
69 wait_queue_head_t read_wait
;
70 struct net_device
*dev
;
71 struct ipn_network
*ipn
;
72 struct pre_bind_parms
*pbp
;
75 #define IPN_NODEFLAG_BOUND 0x1 /* bind succeeded */
76 #define IPN_NODEFLAG_INUSE 0x2 /* is currently "used" (0 for persistent, unbound interfaces) */
77 #define IPN_NODEFLAG_PERSIST 0x4 /* if persist does not disappear on close (net interfaces) */
78 #define IPN_NODEFLAG_TAP 0x10 /* This is a tap interface */
79 #define IPN_NODEFLAG_GRAB 0x20 /* This is a grab of a real interface */
80 #define IPN_NODEFLAG_DEVMASK 0x30 /* True if this is a device */
85 * unfortunately we must use a struct sock (most of the fields are useless) as
86 * this is the standard "agnostic" structure for socket implementation.
87 * This proofs that it is not "agnostic" enough!
92 struct ipn_node
*node
;
96 * ipn_network network descriptor
98 * @hnode=hash to find this entry (looking for i-node)
99 * @refcnt=reference count (bound or connected sockets)
100 * @dentry/@mnt=to keep the file system descriptor into memory
101 * @ipnn_lock=lock for protocol functions
102 * @protocol=kind of service
103 * @flags=flags (IPN_FLAG_LOSSLESS)
104 * @maxports=number of ports available in this network
105 * @msgpool_nelem=number of pending messages
106 * @msgpool_size=max number of pending messages *per net* when IPN_FLAG_LOSSLESS
107 * @msgpool_size=max number of pending messages *per port*when LOSSY
109 * @send_wait=wait queue waiting for a message in the msgpool (IPN_FLAG_LOSSLESS)
110 * @msgpool_cache=slab for msgpool (unused yet)
111 * @connports=array of connected sockets
114 struct hlist_node hnode
;
116 struct dentry
*dentry
;
117 struct vfsmount
*mnt
;
118 struct semaphore ipnn_mutex
;
120 struct sockaddr_un sunaddr
;
121 unsigned int protocol
;
123 atomic_t msgpool_nelem
;
124 unsigned short maxports
;
125 unsigned short msgpool_size
;
127 wait_queue_head_t send_wait
;
128 struct kmem_cache
*msgpool_cache
;
130 struct ipn_node
*connport
[0];
133 /* struct msgpool_item
134 * the local copy of the message for dispatching
139 struct msgpool_item
{
142 unsigned char data
[0];
145 struct msgpool_item
*ipn_msgpool_alloc(struct ipn_network
*ipnn
);
146 void ipn_msgpool_put(struct msgpool_item
*old
, struct ipn_network
*ipnn
);
151 * @newport=upcall for reporting a new port. returns the portno, -1=error
152 * @handlemsg=dispatch a message.
153 * should call ipn_proto_sendmsg for each desctination
154 * can allocate other msgitems using ipn_msgpool_alloc to send
155 * different messages to different destinations;
156 * @delport=(may be null) reports the terminatio of a port
159 * @ipn_p_ioctl=(may be null) upcall to manage specific options or ctls.
161 struct ipn_protocol
{
163 int (*ipn_p_newport
)(struct ipn_node
*newport
);
164 int (*ipn_p_handlemsg
)(struct ipn_node
*from
,struct msgpool_item
*msgitem
, int depth
);
165 void (*ipn_p_delport
)(struct ipn_node
*oldport
);
166 void (*ipn_p_postnewport
)(struct ipn_node
*newport
);
167 void (*ipn_p_predelport
)(struct ipn_node
*oldport
);
168 int (*ipn_p_newnet
)(struct ipn_network
*newnet
);
169 void (*ipn_p_delnet
)(struct ipn_network
*oldnet
);
170 int (*ipn_p_setsockopt
)(struct ipn_node
*port
,int optname
,
171 char __user
*optval
, int optlen
);
172 int (*ipn_p_getsockopt
)(struct ipn_node
*port
,int optname
,
173 char __user
*optval
, int *optlen
);
174 int (*ipn_p_ioctl
)(struct ipn_node
*port
,unsigned int request
,
178 int ipn_proto_register(int protocol
,struct ipn_protocol
*ipn_service
);
179 int ipn_proto_deregister(int protocol
);
181 int ipn_proto_injectmsg(struct ipn_node
*from
, struct msgpool_item
*msg
,
183 void ipn_proto_sendmsg(struct ipn_node
*to
, struct msgpool_item
*msg
,