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 9#ifndef __AFIUCV_H 10#define __AFIUCV_H 11 12#include <asm/types.h> 13#include <asm/byteorder.h> 14#include <linux/list.h> 15#include <linux/poll.h> 16#include <linux/socket.h> 17 18#ifndef AF_IUCV 19#define AF_IUCV 32 20#define PF_IUCV AF_IUCV 21#endif 22 23/* Connection and socket states */ 24enum { 25 IUCV_CONNECTED = 1, 26 IUCV_OPEN, 27 IUCV_BOUND, 28 IUCV_LISTEN, 29 IUCV_SEVERED, 30 IUCV_DISCONN, 31 IUCV_CLOSING, 32 IUCV_CLOSED 33}; 34 35#define IUCV_QUEUELEN_DEFAULT 65535 36#define IUCV_CONN_TIMEOUT (HZ * 40) 37#define IUCV_DISCONN_TIMEOUT (HZ * 2) 38#define IUCV_CONN_IDLE_TIMEOUT (HZ * 60) 39#define IUCV_BUFSIZE_DEFAULT 32768 40 41/* IUCV socket address */ 42struct sockaddr_iucv { 43 sa_family_t siucv_family; 44 unsigned short siucv_port; /* Reserved */ 45 unsigned int siucv_addr; /* Reserved */ 46 char siucv_nodeid[8]; /* Reserved */ 47 char siucv_user_id[8]; /* Guest User Id */ 48 char siucv_name[8]; /* Application Name */ 49}; 50 51 52/* Common socket structures and functions */ 53 54#define iucv_sk(__sk) ((struct iucv_sock *) __sk) 55 56struct iucv_sock { 57 struct sock sk; 58 char src_user_id[8]; 59 char src_name[8]; 60 char dst_user_id[8]; 61 char dst_name[8]; 62 struct list_head accept_q; 63 struct sock *parent; 64 struct iucv_path *path; 65 struct sk_buff_head send_skb_q; 66 struct sk_buff_head backlog_skb_q; 67 unsigned int send_tag; 68}; 69 70struct iucv_sock_list { 71 struct hlist_head head; 72 rwlock_t lock; 73 atomic_t autobind_name; 74}; 75 76static void iucv_sock_destruct(struct sock *sk); 77static void iucv_sock_cleanup_listen(struct sock *parent); 78static void iucv_sock_kill(struct sock *sk); 79static void iucv_sock_close(struct sock *sk); 80static int iucv_sock_create(struct socket *sock, int proto); 81static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr, 82 int addr_len); 83static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr, 84 int alen, int flags); 85static int iucv_sock_listen(struct socket *sock, int backlog); 86static int iucv_sock_accept(struct socket *sock, struct socket *newsock, 87 int flags); 88static int iucv_sock_getname(struct socket *sock, struct sockaddr *addr, 89 int *len, int peer); 90static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, 91 struct msghdr *msg, size_t len); 92static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, 93 struct msghdr *msg, size_t len, int flags); 94unsigned int iucv_sock_poll(struct file *file, struct socket *sock, 95 poll_table *wait); 96static int iucv_sock_release(struct socket *sock); 97static int iucv_sock_shutdown(struct socket *sock, int how); 98 99void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); 100void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); 101int iucv_sock_wait_state(struct sock *sk, int state, int state2, 102 unsigned long timeo); 103int iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo); 104void iucv_accept_enqueue(struct sock *parent, struct sock *sk); 105void iucv_accept_unlink(struct sock *sk); 106struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); 107 108#endif /* __IUCV_H */ 109