af_iucv.h 4.1 KB

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