af_iucv.h 4.1 KB

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