Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright 2006 IBM Corporation
0004  * IUCV protocol stack for Linux on zSeries
0005  * Version 1.0
0006  * Author(s): Jennifer Hunt <jenhunt@us.ibm.com>
0007  *
0008  */
0009 
0010 #ifndef __AFIUCV_H
0011 #define __AFIUCV_H
0012 
0013 #include <asm/types.h>
0014 #include <asm/byteorder.h>
0015 #include <linux/list.h>
0016 #include <linux/poll.h>
0017 #include <linux/socket.h>
0018 #include <net/iucv/iucv.h>
0019 
0020 #ifndef AF_IUCV
0021 #define AF_IUCV     32
0022 #define PF_IUCV     AF_IUCV
0023 #endif
0024 
0025 /* Connection and socket states */
0026 enum {
0027     IUCV_CONNECTED = 1,
0028     IUCV_OPEN,
0029     IUCV_BOUND,
0030     IUCV_LISTEN,
0031     IUCV_DISCONN,
0032     IUCV_CLOSING,
0033     IUCV_CLOSED
0034 };
0035 
0036 #define IUCV_QUEUELEN_DEFAULT   65535
0037 #define IUCV_HIPER_MSGLIM_DEFAULT   128
0038 #define IUCV_CONN_TIMEOUT   (HZ * 40)
0039 #define IUCV_DISCONN_TIMEOUT    (HZ * 2)
0040 #define IUCV_CONN_IDLE_TIMEOUT  (HZ * 60)
0041 #define IUCV_BUFSIZE_DEFAULT    32768
0042 
0043 /* IUCV socket address */
0044 struct sockaddr_iucv {
0045     sa_family_t siucv_family;
0046     unsigned short  siucv_port;     /* Reserved */
0047     unsigned int    siucv_addr;     /* Reserved */
0048     char        siucv_nodeid[8];    /* Reserved */
0049     char        siucv_user_id[8];   /* Guest User Id */
0050     char        siucv_name[8];      /* Application Name */
0051 };
0052 
0053 
0054 /* Common socket structures and functions */
0055 struct sock_msg_q {
0056     struct iucv_path    *path;
0057     struct iucv_message msg;
0058     struct list_head    list;
0059     spinlock_t      lock;
0060 };
0061 
0062 #define AF_IUCV_FLAG_ACK 0x1
0063 #define AF_IUCV_FLAG_SYN 0x2
0064 #define AF_IUCV_FLAG_FIN 0x4
0065 #define AF_IUCV_FLAG_WIN 0x8
0066 #define AF_IUCV_FLAG_SHT 0x10
0067 
0068 struct af_iucv_trans_hdr {
0069     u16 magic;
0070     u8 version;
0071     u8 flags;
0072     u16 window;
0073     char destNodeID[8];
0074     char destUserID[8];
0075     char destAppName[16];
0076     char srcNodeID[8];
0077     char srcUserID[8];
0078     char srcAppName[16];             /* => 70 bytes */
0079     struct iucv_message iucv_hdr;    /* => 33 bytes */
0080     u8 pad;                          /* total 104 bytes */
0081 } __packed;
0082 
0083 static inline struct af_iucv_trans_hdr *iucv_trans_hdr(struct sk_buff *skb)
0084 {
0085     return (struct af_iucv_trans_hdr *)skb_network_header(skb);
0086 }
0087 
0088 enum iucv_tx_notify {
0089     /* transmission of skb is completed and was successful */
0090     TX_NOTIFY_OK = 0,
0091     /* target is unreachable */
0092     TX_NOTIFY_UNREACHABLE = 1,
0093     /* transfer pending queue full */
0094     TX_NOTIFY_TPQFULL = 2,
0095     /* general error */
0096     TX_NOTIFY_GENERALERROR = 3,
0097     /* transmission of skb is pending - may interleave
0098      * with TX_NOTIFY_DELAYED_* */
0099     TX_NOTIFY_PENDING = 4,
0100     /* transmission of skb was done successfully (delayed) */
0101     TX_NOTIFY_DELAYED_OK = 5,
0102     /* target unreachable (detected delayed) */
0103     TX_NOTIFY_DELAYED_UNREACHABLE = 6,
0104     /* general error (detected delayed) */
0105     TX_NOTIFY_DELAYED_GENERALERROR = 7,
0106 };
0107 
0108 #define iucv_sk(__sk) ((struct iucv_sock *) __sk)
0109 
0110 #define AF_IUCV_TRANS_IUCV 0
0111 #define AF_IUCV_TRANS_HIPER 1
0112 
0113 struct iucv_sock {
0114     struct sock     sk;
0115     struct_group(init,
0116         char        src_user_id[8];
0117         char        src_name[8];
0118         char        dst_user_id[8];
0119         char        dst_name[8];
0120     );
0121     struct list_head    accept_q;
0122     spinlock_t      accept_q_lock;
0123     struct sock     *parent;
0124     struct iucv_path    *path;
0125     struct net_device   *hs_dev;
0126     struct sk_buff_head send_skb_q;
0127     struct sk_buff_head backlog_skb_q;
0128     struct sock_msg_q   message_q;
0129     unsigned int        send_tag;
0130     u8          flags;
0131     u16         msglimit;
0132     u16         msglimit_peer;
0133     atomic_t        skbs_in_xmit;
0134     atomic_t        msg_sent;
0135     atomic_t        msg_recv;
0136     atomic_t        pendings;
0137     int         transport;
0138     void            (*sk_txnotify)(struct sock *sk,
0139                            enum iucv_tx_notify n);
0140 };
0141 
0142 struct iucv_skb_cb {
0143     u32 class;      /* target class of message */
0144     u32 tag;        /* tag associated with message */
0145     u32 offset;     /* offset for skb receival */
0146 };
0147 
0148 #define IUCV_SKB_CB(__skb)  ((struct iucv_skb_cb *)&((__skb)->cb[0]))
0149 
0150 /* iucv socket options (SOL_IUCV) */
0151 #define SO_IPRMDATA_MSG 0x0080      /* send/recv IPRM_DATA msgs */
0152 #define SO_MSGLIMIT 0x1000      /* get/set IUCV MSGLIMIT */
0153 #define SO_MSGSIZE  0x0800      /* get maximum msgsize */
0154 
0155 /* iucv related control messages (scm) */
0156 #define SCM_IUCV_TRGCLS 0x0001      /* target class control message */
0157 
0158 struct iucv_sock_list {
0159     struct hlist_head head;
0160     rwlock_t      lock;
0161     atomic_t      autobind_name;
0162 };
0163 
0164 #endif /* __IUCV_H */