]> Pileus Git - ~andy/linux/blob - include/net/iucv/af_iucv.h
Merge branch 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git...
[~andy/linux] / include / net / iucv / af_iucv.h
1 /*
2  * Copyright 2006 IBM Corporation
3  * IUCV protocol stack for Linux on zSeries
4  * Version 1.0
5  * Author(s): Jennifer Hunt <jenhunt@us.ibm.com>
6  *
7  */
8
9 #ifndef __AFIUCV_H
10 #define __AFIUCV_H
11
12 #include <asm/types.h>
13 #include <asm/byteorder.h>
14 #include <linux/list.h>
15 #include <linux/poll.h>
16 #include <linux/socket.h>
17 #include <net/iucv/iucv.h>
18
19 #ifndef AF_IUCV
20 #define AF_IUCV         32
21 #define PF_IUCV         AF_IUCV
22 #endif
23
24 /* Connection and socket states */
25 enum {
26         IUCV_CONNECTED = 1,
27         IUCV_OPEN,
28         IUCV_BOUND,
29         IUCV_LISTEN,
30         IUCV_DISCONN,
31         IUCV_CLOSING,
32         IUCV_CLOSED
33 };
34
35 #define IUCV_QUEUELEN_DEFAULT   65535
36 #define IUCV_HIPER_MSGLIM_DEFAULT       128
37 #define IUCV_CONN_TIMEOUT       (HZ * 40)
38 #define IUCV_DISCONN_TIMEOUT    (HZ * 2)
39 #define IUCV_CONN_IDLE_TIMEOUT  (HZ * 60)
40 #define IUCV_BUFSIZE_DEFAULT    32768
41
42 /* IUCV socket address */
43 struct sockaddr_iucv {
44         sa_family_t     siucv_family;
45         unsigned short  siucv_port;             /* Reserved */
46         unsigned int    siucv_addr;             /* Reserved */
47         char            siucv_nodeid[8];        /* Reserved */
48         char            siucv_user_id[8];       /* Guest User Id */
49         char            siucv_name[8];          /* Application Name */
50 };
51
52
53 /* Common socket structures and functions */
54 struct sock_msg_q {
55         struct iucv_path        *path;
56         struct iucv_message     msg;
57         struct list_head        list;
58         spinlock_t              lock;
59 };
60
61 #define AF_IUCV_FLAG_ACK 0x1
62 #define AF_IUCV_FLAG_SYN 0x2
63 #define AF_IUCV_FLAG_FIN 0x4
64 #define AF_IUCV_FLAG_WIN 0x8
65
66 struct af_iucv_trans_hdr {
67         u16 magic;
68         u8 version;
69         u8 flags;
70         u16 window;
71         char destNodeID[8];
72         char destUserID[8];
73         char destAppName[16];
74         char srcNodeID[8];
75         char srcUserID[8];
76         char srcAppName[16];             /* => 70 bytes */
77         struct iucv_message iucv_hdr;    /* => 33 bytes */
78         u8 pad;                          /* total 104 bytes */
79 } __packed;
80
81 enum iucv_tx_notify {
82         /* transmission of skb is completed and was successful */
83         TX_NOTIFY_OK = 0,
84         /* target is unreachable */
85         TX_NOTIFY_UNREACHABLE = 1,
86         /* transfer pending queue full */
87         TX_NOTIFY_TPQFULL = 2,
88         /* general error */
89         TX_NOTIFY_GENERALERROR = 3,
90         /* transmission of skb is pending - may interleave
91          * with TX_NOTIFY_DELAYED_* */
92         TX_NOTIFY_PENDING = 4,
93         /* transmission of skb was done successfully (delayed) */
94         TX_NOTIFY_DELAYED_OK = 5,
95         /* target unreachable (detected delayed) */
96         TX_NOTIFY_DELAYED_UNREACHABLE = 6,
97         /* general error (detected delayed) */
98         TX_NOTIFY_DELAYED_GENERALERROR = 7,
99 };
100
101 #define iucv_sk(__sk) ((struct iucv_sock *) __sk)
102
103 #define AF_IUCV_TRANS_IUCV 0
104 #define AF_IUCV_TRANS_HIPER 1
105
106 struct iucv_sock {
107         struct sock             sk;
108         char                    src_user_id[8];
109         char                    src_name[8];
110         char                    dst_user_id[8];
111         char                    dst_name[8];
112         struct list_head        accept_q;
113         spinlock_t              accept_q_lock;
114         struct sock             *parent;
115         struct iucv_path        *path;
116         struct sk_buff_head     send_skb_q;
117         struct sk_buff_head     backlog_skb_q;
118         struct sock_msg_q       message_q;
119         unsigned int            send_tag;
120         u8                      flags;
121         u16                     msglimit;
122         u16                     msglimit_peer;
123         atomic_t                msg_sent;
124         atomic_t                msg_recv;
125         atomic_t                pendings;
126         int                     transport;
127         void                    (*sk_txnotify)(struct sk_buff *skb,
128                                                enum iucv_tx_notify n);
129 };
130
131 /* iucv socket options (SOL_IUCV) */
132 #define SO_IPRMDATA_MSG 0x0080          /* send/recv IPRM_DATA msgs */
133 #define SO_MSGLIMIT     0x1000          /* get/set IUCV MSGLIMIT */
134
135 /* iucv related control messages (scm) */
136 #define SCM_IUCV_TRGCLS 0x0001          /* target class control message */
137
138 struct iucv_sock_list {
139         struct hlist_head head;
140         rwlock_t          lock;
141         atomic_t          autobind_name;
142 };
143
144 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
145                             poll_table *wait);
146 void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
147 void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
148 void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
149 void iucv_accept_unlink(struct sock *sk);
150 struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock);
151
152 #endif /* __IUCV_H */