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