af_iucv.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. struct af_iucv_trans_hdr {
  57. u16 magic;
  58. u8 version;
  59. u8 flags;
  60. u16 window;
  61. char destNodeID[8];
  62. char destUserID[8];
  63. char destAppName[16];
  64. char srcNodeID[8];
  65. char srcUserID[8];
  66. char srcAppName[16]; /* => 70 bytes */
  67. struct iucv_message iucv_hdr; /* => 33 bytes */
  68. u8 pad; /* total 104 bytes */
  69. } __packed;
  70. enum iucv_tx_notify {
  71. /* transmission of skb is completed and was successful */
  72. TX_NOTIFY_OK = 0,
  73. /* target is unreachable */
  74. TX_NOTIFY_UNREACHABLE = 1,
  75. /* transfer pending queue full */
  76. TX_NOTIFY_TPQFULL = 2,
  77. /* general error */
  78. TX_NOTIFY_GENERALERROR = 3,
  79. /* transmission of skb is pending - may interleave
  80. * with TX_NOTIFY_DELAYED_* */
  81. TX_NOTIFY_PENDING = 4,
  82. /* transmission of skb was done successfully (delayed) */
  83. TX_NOTIFY_DELAYED_OK = 5,
  84. /* target unreachable (detected delayed) */
  85. TX_NOTIFY_DELAYED_UNREACHABLE = 6,
  86. /* general error (detected delayed) */
  87. TX_NOTIFY_DELAYED_GENERALERROR = 7,
  88. };
  89. #define iucv_sk(__sk) ((struct iucv_sock *) __sk)
  90. #define AF_IUCV_TRANS_IUCV 0
  91. #define AF_IUCV_TRANS_HIPER 1
  92. struct iucv_sock {
  93. struct sock sk;
  94. char src_user_id[8];
  95. char src_name[8];
  96. char dst_user_id[8];
  97. char dst_name[8];
  98. struct list_head accept_q;
  99. spinlock_t accept_q_lock;
  100. struct sock *parent;
  101. struct iucv_path *path;
  102. struct sk_buff_head send_skb_q;
  103. struct sk_buff_head backlog_skb_q;
  104. struct sock_msg_q message_q;
  105. unsigned int send_tag;
  106. u8 flags;
  107. u16 msglimit;
  108. u16 msglimit_peer;
  109. atomic_t msg_sent;
  110. atomic_t msg_recv;
  111. atomic_t pendings;
  112. int transport;
  113. void (*sk_txnotify)(struct sk_buff *skb,
  114. enum iucv_tx_notify n);
  115. };
  116. /* iucv socket options (SOL_IUCV) */
  117. #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */
  118. #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */
  119. /* iucv related control messages (scm) */
  120. #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */
  121. struct iucv_sock_list {
  122. struct hlist_head head;
  123. rwlock_t lock;
  124. atomic_t autobind_name;
  125. };
  126. unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
  127. poll_table *wait);
  128. void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
  129. void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
  130. void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
  131. void iucv_accept_unlink(struct sock *sk);
  132. struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock);
  133. #endif /* __IUCV_H */