Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 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 | |
| 18 | #ifndef AF_IUCV |
| 19 | #define AF_IUCV 32 |
| 20 | #define PF_IUCV AF_IUCV |
| 21 | #endif |
| 22 | |
| 23 | /* Connection and socket states */ |
| 24 | enum { |
| 25 | IUCV_CONNECTED = 1, |
| 26 | IUCV_OPEN, |
| 27 | IUCV_BOUND, |
| 28 | IUCV_LISTEN, |
| 29 | IUCV_SEVERED, |
| 30 | IUCV_DISCONN, |
Jennifer Hunt | 561e036 | 2007-05-04 12:22:07 -0700 | [diff] [blame] | 31 | IUCV_CLOSING, |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 32 | IUCV_CLOSED |
| 33 | }; |
| 34 | |
| 35 | #define IUCV_QUEUELEN_DEFAULT 65535 |
| 36 | #define IUCV_CONN_TIMEOUT (HZ * 40) |
| 37 | #define IUCV_DISCONN_TIMEOUT (HZ * 2) |
| 38 | #define IUCV_CONN_IDLE_TIMEOUT (HZ * 60) |
| 39 | #define IUCV_BUFSIZE_DEFAULT 32768 |
| 40 | |
| 41 | /* IUCV socket address */ |
| 42 | struct sockaddr_iucv { |
| 43 | sa_family_t siucv_family; |
| 44 | unsigned short siucv_port; /* Reserved */ |
| 45 | unsigned int siucv_addr; /* Reserved */ |
| 46 | char siucv_nodeid[8]; /* Reserved */ |
| 47 | char siucv_user_id[8]; /* Guest User Id */ |
| 48 | char siucv_name[8]; /* Application Name */ |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | /* Common socket structures and functions */ |
Ursula Braun | f0703c8 | 2007-10-08 02:03:31 -0700 | [diff] [blame] | 53 | struct sock_msg_q { |
| 54 | struct iucv_path *path; |
| 55 | struct iucv_message msg; |
| 56 | struct list_head list; |
| 57 | spinlock_t lock; |
| 58 | }; |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 59 | |
| 60 | #define iucv_sk(__sk) ((struct iucv_sock *) __sk) |
| 61 | |
| 62 | struct iucv_sock { |
| 63 | struct sock sk; |
| 64 | char src_user_id[8]; |
| 65 | char src_name[8]; |
| 66 | char dst_user_id[8]; |
| 67 | char dst_name[8]; |
| 68 | struct list_head accept_q; |
Ursula Braun | febca28 | 2007-07-14 19:04:25 -0700 | [diff] [blame] | 69 | spinlock_t accept_q_lock; |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 70 | struct sock *parent; |
| 71 | struct iucv_path *path; |
| 72 | struct sk_buff_head send_skb_q; |
Jennifer Hunt | 561e036 | 2007-05-04 12:22:07 -0700 | [diff] [blame] | 73 | struct sk_buff_head backlog_skb_q; |
Ursula Braun | f0703c8 | 2007-10-08 02:03:31 -0700 | [diff] [blame] | 74 | struct sock_msg_q message_q; |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 75 | unsigned int send_tag; |
Hendrik Brueckner | 9d5c5d8 | 2009-04-21 23:26:22 +0000 | [diff] [blame] | 76 | u8 flags; |
Hendrik Brueckner | 09488e2 | 2009-04-21 23:26:27 +0000 | [diff] [blame] | 77 | u16 msglimit; |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
Hendrik Brueckner | 9d5c5d8 | 2009-04-21 23:26:22 +0000 | [diff] [blame] | 80 | /* iucv socket options (SOL_IUCV) */ |
| 81 | #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ |
Hendrik Brueckner | 09488e2 | 2009-04-21 23:26:27 +0000 | [diff] [blame] | 82 | #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ |
Hendrik Brueckner | 9d5c5d8 | 2009-04-21 23:26:22 +0000 | [diff] [blame] | 83 | |
Hendrik Brueckner | 44b1e6b | 2009-04-21 23:26:24 +0000 | [diff] [blame] | 84 | /* iucv related control messages (scm) */ |
| 85 | #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ |
| 86 | |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 87 | struct iucv_sock_list { |
| 88 | struct hlist_head head; |
| 89 | rwlock_t lock; |
| 90 | atomic_t autobind_name; |
| 91 | }; |
| 92 | |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 93 | unsigned int iucv_sock_poll(struct file *file, struct socket *sock, |
| 94 | poll_table *wait); |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 95 | void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); |
| 96 | void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); |
Jennifer Hunt | eac3731 | 2007-02-08 13:51:54 -0800 | [diff] [blame] | 97 | int iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo); |
| 98 | void iucv_accept_enqueue(struct sock *parent, struct sock *sk); |
| 99 | void iucv_accept_unlink(struct sock *sk); |
| 100 | struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); |
| 101 | |
| 102 | #endif /* __IUCV_H */ |