af_iucv.c (af88b52def76679c8c5bcdbed199fbe62b6a16d4) af_iucv.c (9d5c5d8f4105dc56ec10864b195dd1714f282c22)
1/*
2 * linux/net/iucv/af_iucv.c
3 *
4 * IUCV protocol stack for Linux on zSeries
5 *
6 * Copyright 2006 IBM Corporation
7 *
8 * Author(s): Jennifer Hunt <jenhunt@us.ibm.com>

--- 18 unchanged lines hidden (view full) ---

27#include <linux/kmod.h>
28
29#include <net/iucv/iucv.h>
30#include <net/iucv/af_iucv.h>
31
32#define CONFIG_IUCV_SOCK_DEBUG 1
33
34#define IPRMDATA 0x80
1/*
2 * linux/net/iucv/af_iucv.c
3 *
4 * IUCV protocol stack for Linux on zSeries
5 *
6 * Copyright 2006 IBM Corporation
7 *
8 * Author(s): Jennifer Hunt <jenhunt@us.ibm.com>

--- 18 unchanged lines hidden (view full) ---

27#include <linux/kmod.h>
28
29#include <net/iucv/iucv.h>
30#include <net/iucv/af_iucv.h>
31
32#define CONFIG_IUCV_SOCK_DEBUG 1
33
34#define IPRMDATA 0x80
35#define VERSION "1.0"
35#define VERSION "1.1"
36
37static char iucv_userid[80];
38
39static struct proto_ops iucv_sock_ops;
40
41static struct proto iucv_proto = {
42 .name = "AF_IUCV",
43 .owner = THIS_MODULE,

--- 177 unchanged lines hidden (view full) ---

221 sock_init_data(sock, sk);
222 INIT_LIST_HEAD(&iucv_sk(sk)->accept_q);
223 spin_lock_init(&iucv_sk(sk)->accept_q_lock);
224 skb_queue_head_init(&iucv_sk(sk)->send_skb_q);
225 INIT_LIST_HEAD(&iucv_sk(sk)->message_q.list);
226 spin_lock_init(&iucv_sk(sk)->message_q.lock);
227 skb_queue_head_init(&iucv_sk(sk)->backlog_skb_q);
228 iucv_sk(sk)->send_tag = 0;
36
37static char iucv_userid[80];
38
39static struct proto_ops iucv_sock_ops;
40
41static struct proto iucv_proto = {
42 .name = "AF_IUCV",
43 .owner = THIS_MODULE,

--- 177 unchanged lines hidden (view full) ---

221 sock_init_data(sock, sk);
222 INIT_LIST_HEAD(&iucv_sk(sk)->accept_q);
223 spin_lock_init(&iucv_sk(sk)->accept_q_lock);
224 skb_queue_head_init(&iucv_sk(sk)->send_skb_q);
225 INIT_LIST_HEAD(&iucv_sk(sk)->message_q.list);
226 spin_lock_init(&iucv_sk(sk)->message_q.lock);
227 skb_queue_head_init(&iucv_sk(sk)->backlog_skb_q);
228 iucv_sk(sk)->send_tag = 0;
229 iucv_sk(sk)->flags = 0;
229
230 sk->sk_destruct = iucv_sock_destruct;
231 sk->sk_sndtimeo = IUCV_CONN_TIMEOUT;
232 sk->sk_allocation = GFP_DMA;
233
234 sock_reset_flag(sk, SOCK_ZAPPED);
235
236 sk->sk_protocol = proto;

--- 761 unchanged lines hidden (view full) ---

998 iucv_sk(sk)->path = NULL;
999 }
1000
1001 sock_orphan(sk);
1002 iucv_sock_kill(sk);
1003 return err;
1004}
1005
230
231 sk->sk_destruct = iucv_sock_destruct;
232 sk->sk_sndtimeo = IUCV_CONN_TIMEOUT;
233 sk->sk_allocation = GFP_DMA;
234
235 sock_reset_flag(sk, SOCK_ZAPPED);
236
237 sk->sk_protocol = proto;

--- 761 unchanged lines hidden (view full) ---

999 iucv_sk(sk)->path = NULL;
1000 }
1001
1002 sock_orphan(sk);
1003 iucv_sock_kill(sk);
1004 return err;
1005}
1006
1007/* getsockopt and setsockopt */
1008static int iucv_sock_setsockopt(struct socket *sock, int level, int optname,
1009 char __user *optval, int optlen)
1010{
1011 struct sock *sk = sock->sk;
1012 struct iucv_sock *iucv = iucv_sk(sk);
1013 int val;
1014 int rc;
1015
1016 if (level != SOL_IUCV)
1017 return -ENOPROTOOPT;
1018
1019 if (optlen < sizeof(int))
1020 return -EINVAL;
1021
1022 if (get_user(val, (int __user *) optval))
1023 return -EFAULT;
1024
1025 rc = 0;
1026
1027 lock_sock(sk);
1028 switch (optname) {
1029 case SO_IPRMDATA_MSG:
1030 if (val)
1031 iucv->flags |= IUCV_IPRMDATA;
1032 else
1033 iucv->flags &= ~IUCV_IPRMDATA;
1034 break;
1035 default:
1036 rc = -ENOPROTOOPT;
1037 break;
1038 }
1039 release_sock(sk);
1040
1041 return rc;
1042}
1043
1044static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
1045 char __user *optval, int __user *optlen)
1046{
1047 struct sock *sk = sock->sk;
1048 struct iucv_sock *iucv = iucv_sk(sk);
1049 int val, len;
1050
1051 if (level != SOL_IUCV)
1052 return -ENOPROTOOPT;
1053
1054 if (get_user(len, optlen))
1055 return -EFAULT;
1056
1057 if (len < 0)
1058 return -EINVAL;
1059
1060 len = min_t(unsigned int, len, sizeof(int));
1061
1062 switch (optname) {
1063 case SO_IPRMDATA_MSG:
1064 val = (iucv->flags & IUCV_IPRMDATA) ? 1 : 0;
1065 break;
1066 default:
1067 return -ENOPROTOOPT;
1068 }
1069
1070 if (put_user(len, optlen))
1071 return -EFAULT;
1072 if (copy_to_user(optval, &val, len))
1073 return -EFAULT;
1074
1075 return 0;
1076}
1077
1078
1006/* Callback wrappers - called from iucv base support */
1007static int iucv_callback_connreq(struct iucv_path *path,
1008 u8 ipvmid[8], u8 ipuser[16])
1009{
1010 unsigned char user_data[16];
1011 unsigned char nuser_data[16];
1012 unsigned char src_name[8];
1013 struct hlist_node *node;

--- 210 unchanged lines hidden (view full) ---

1224 .getname = iucv_sock_getname,
1225 .sendmsg = iucv_sock_sendmsg,
1226 .recvmsg = iucv_sock_recvmsg,
1227 .poll = iucv_sock_poll,
1228 .ioctl = sock_no_ioctl,
1229 .mmap = sock_no_mmap,
1230 .socketpair = sock_no_socketpair,
1231 .shutdown = iucv_sock_shutdown,
1079/* Callback wrappers - called from iucv base support */
1080static int iucv_callback_connreq(struct iucv_path *path,
1081 u8 ipvmid[8], u8 ipuser[16])
1082{
1083 unsigned char user_data[16];
1084 unsigned char nuser_data[16];
1085 unsigned char src_name[8];
1086 struct hlist_node *node;

--- 210 unchanged lines hidden (view full) ---

1297 .getname = iucv_sock_getname,
1298 .sendmsg = iucv_sock_sendmsg,
1299 .recvmsg = iucv_sock_recvmsg,
1300 .poll = iucv_sock_poll,
1301 .ioctl = sock_no_ioctl,
1302 .mmap = sock_no_mmap,
1303 .socketpair = sock_no_socketpair,
1304 .shutdown = iucv_sock_shutdown,
1232 .setsockopt = sock_no_setsockopt,
1233 .getsockopt = sock_no_getsockopt
1305 .setsockopt = iucv_sock_setsockopt,
1306 .getsockopt = iucv_sock_getsockopt,
1234};
1235
1236static struct net_proto_family iucv_sock_family_ops = {
1237 .family = AF_IUCV,
1238 .owner = THIS_MODULE,
1239 .create = iucv_sock_create,
1240};
1241

--- 51 unchanged lines hidden ---
1307};
1308
1309static struct net_proto_family iucv_sock_family_ops = {
1310 .family = AF_IUCV,
1311 .owner = THIS_MODULE,
1312 .create = iucv_sock_create,
1313};
1314

--- 51 unchanged lines hidden ---