aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/af_decnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/decnet/af_decnet.c')
-rw-r--r--net/decnet/af_decnet.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 21f20f21dd32..70061641ee59 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -45,7 +45,7 @@
45 45
46/****************************************************************************** 46/******************************************************************************
47 (c) 1995-1998 E.M. Serrat emserrat@geocities.com 47 (c) 1995-1998 E.M. Serrat emserrat@geocities.com
48 48
49 This program is free software; you can redistribute it and/or modify 49 This program is free software; you can redistribute it and/or modify
50 it under the terms of the GNU General Public License as published by 50 it under the terms of the GNU General Public License as published by
51 the Free Software Foundation; either version 2 of the License, or 51 the Free Software Foundation; either version 2 of the License, or
@@ -63,7 +63,7 @@ Version Kernel Date Author/Comments
63Version 0.0.1 2.0.30 01-dic-97 Eduardo Marcelo Serrat 63Version 0.0.1 2.0.30 01-dic-97 Eduardo Marcelo Serrat
64 (emserrat@geocities.com) 64 (emserrat@geocities.com)
65 65
66 First Development of DECnet Socket La- 66 First Development of DECnet Socket La-
67 yer for Linux. Only supports outgoing 67 yer for Linux. Only supports outgoing
68 connections. 68 connections.
69 69
@@ -75,28 +75,28 @@ Version 0.0.2 2.1.105 20-jun-98 Patrick J. Caulfield
75Version 0.0.3 2.1.106 25-jun-98 Eduardo Marcelo Serrat 75Version 0.0.3 2.1.106 25-jun-98 Eduardo Marcelo Serrat
76 (emserrat@geocities.com) 76 (emserrat@geocities.com)
77 _ 77 _
78 Added support for incoming connections 78 Added support for incoming connections
79 so we can start developing server apps 79 so we can start developing server apps
80 on Linux. 80 on Linux.
81 - 81 -
82 Module Support 82 Module Support
83Version 0.0.4 2.1.109 21-jul-98 Eduardo Marcelo Serrat 83Version 0.0.4 2.1.109 21-jul-98 Eduardo Marcelo Serrat
84 (emserrat@geocities.com) 84 (emserrat@geocities.com)
85 _ 85 _
86 Added support for X11R6.4. Now we can 86 Added support for X11R6.4. Now we can
87 use DECnet transport for X on Linux!!! 87 use DECnet transport for X on Linux!!!
88 - 88 -
89Version 0.0.5 2.1.110 01-aug-98 Eduardo Marcelo Serrat 89Version 0.0.5 2.1.110 01-aug-98 Eduardo Marcelo Serrat
90 (emserrat@geocities.com) 90 (emserrat@geocities.com)
91 Removed bugs on flow control 91 Removed bugs on flow control
92 Removed bugs on incoming accessdata 92 Removed bugs on incoming accessdata
93 order 93 order
94 - 94 -
95Version 0.0.6 2.1.110 07-aug-98 Eduardo Marcelo Serrat 95Version 0.0.6 2.1.110 07-aug-98 Eduardo Marcelo Serrat
96 dn_recvmsg fixes 96 dn_recvmsg fixes
97 97
98 Patrick J. Caulfield 98 Patrick J. Caulfield
99 dn_bind fixes 99 dn_bind fixes
100*******************************************************************************/ 100*******************************************************************************/
101 101
102#include <linux/module.h> 102#include <linux/module.h>
@@ -169,7 +169,7 @@ static struct hlist_head *dn_find_list(struct sock *sk)
169 return &dn_sk_hash[dn_ntohs(scp->addrloc) & DN_SK_HASH_MASK]; 169 return &dn_sk_hash[dn_ntohs(scp->addrloc) & DN_SK_HASH_MASK];
170} 170}
171 171
172/* 172/*
173 * Valid ports are those greater than zero and not already in use. 173 * Valid ports are those greater than zero and not already in use.
174 */ 174 */
175static int check_port(__le16 port) 175static int check_port(__le16 port)
@@ -218,7 +218,7 @@ static int dn_hash_sock(struct sock *sk)
218 BUG_ON(sk_hashed(sk)); 218 BUG_ON(sk_hashed(sk));
219 219
220 write_lock_bh(&dn_hash_lock); 220 write_lock_bh(&dn_hash_lock);
221 221
222 if (!scp->addrloc && !port_alloc(sk)) 222 if (!scp->addrloc && !port_alloc(sk))
223 goto out; 223 goto out;
224 224
@@ -400,7 +400,7 @@ struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr)
400 400
401 sk = sk_head(&dn_wild_sk); 401 sk = sk_head(&dn_wild_sk);
402 if (sk) { 402 if (sk) {
403 if (sk->sk_state == TCP_LISTEN) 403 if (sk->sk_state == TCP_LISTEN)
404 sock_hold(sk); 404 sock_hold(sk);
405 else 405 else
406 sk = NULL; 406 sk = NULL;
@@ -500,7 +500,7 @@ static struct sock *dn_alloc_sock(struct socket *sock, gfp_t gfp)
500 scp->ackxmt_oth = 0; /* Last oth data ack'ed */ 500 scp->ackxmt_oth = 0; /* Last oth data ack'ed */
501 scp->ackrcv_dat = 0; /* Highest data ack recv*/ 501 scp->ackrcv_dat = 0; /* Highest data ack recv*/
502 scp->ackrcv_oth = 0; /* Last oth data ack rec*/ 502 scp->ackrcv_oth = 0; /* Last oth data ack rec*/
503 scp->flowrem_sw = DN_SEND; 503 scp->flowrem_sw = DN_SEND;
504 scp->flowloc_sw = DN_SEND; 504 scp->flowloc_sw = DN_SEND;
505 scp->flowrem_dat = 0; 505 scp->flowrem_dat = 0;
506 scp->flowrem_oth = 1; 506 scp->flowrem_oth = 1;
@@ -690,7 +690,7 @@ static int dn_create(struct socket *sock, int protocol)
690 } 690 }
691 691
692 692
693 if ((sk = dn_alloc_sock(sock, GFP_KERNEL)) == NULL) 693 if ((sk = dn_alloc_sock(sock, GFP_KERNEL)) == NULL)
694 return -ENOBUFS; 694 return -ENOBUFS;
695 695
696 sk->sk_protocol = protocol; 696 sk->sk_protocol = protocol;
@@ -713,7 +713,7 @@ dn_release(struct socket *sock)
713 sock_put(sk); 713 sock_put(sk);
714 } 714 }
715 715
716 return 0; 716 return 0;
717} 717}
718 718
719static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) 719static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
@@ -770,7 +770,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
770 } 770 }
771 release_sock(sk); 771 release_sock(sk);
772 772
773 return rv; 773 return rv;
774} 774}
775 775
776 776
@@ -791,7 +791,7 @@ static int dn_auto_bind(struct socket *sock)
791 */ 791 */
792 if ((scp->accessdata.acc_accl != 0) && 792 if ((scp->accessdata.acc_accl != 0) &&
793 (scp->accessdata.acc_accl <= 12)) { 793 (scp->accessdata.acc_accl <= 12)) {
794 794
795 scp->addr.sdn_objnamel = dn_htons(scp->accessdata.acc_accl); 795 scp->addr.sdn_objnamel = dn_htons(scp->accessdata.acc_accl);
796 memcpy(scp->addr.sdn_objname, scp->accessdata.acc_acc, dn_ntohs(scp->addr.sdn_objnamel)); 796 memcpy(scp->addr.sdn_objname, scp->accessdata.acc_acc, dn_ntohs(scp->addr.sdn_objnamel));
797 797
@@ -997,20 +997,20 @@ static inline int dn_check_state(struct sock *sk, struct sockaddr_dn *addr, int
997 997
998static void dn_access_copy(struct sk_buff *skb, struct accessdata_dn *acc) 998static void dn_access_copy(struct sk_buff *skb, struct accessdata_dn *acc)
999{ 999{
1000 unsigned char *ptr = skb->data; 1000 unsigned char *ptr = skb->data;
1001 1001
1002 acc->acc_userl = *ptr++; 1002 acc->acc_userl = *ptr++;
1003 memcpy(&acc->acc_user, ptr, acc->acc_userl); 1003 memcpy(&acc->acc_user, ptr, acc->acc_userl);
1004 ptr += acc->acc_userl; 1004 ptr += acc->acc_userl;
1005 1005
1006 acc->acc_passl = *ptr++; 1006 acc->acc_passl = *ptr++;
1007 memcpy(&acc->acc_pass, ptr, acc->acc_passl); 1007 memcpy(&acc->acc_pass, ptr, acc->acc_passl);
1008 ptr += acc->acc_passl; 1008 ptr += acc->acc_passl;
1009 1009
1010 acc->acc_accl = *ptr++; 1010 acc->acc_accl = *ptr++;
1011 memcpy(&acc->acc_acc, ptr, acc->acc_accl); 1011 memcpy(&acc->acc_acc, ptr, acc->acc_accl);
1012 1012
1013 skb_pull(skb, acc->acc_accl + acc->acc_passl + acc->acc_userl + 3); 1013 skb_pull(skb, acc->acc_accl + acc->acc_passl + acc->acc_userl + 3);
1014 1014
1015} 1015}
1016 1016
@@ -1071,7 +1071,7 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
1071 1071
1072 lock_sock(sk); 1072 lock_sock(sk);
1073 1073
1074 if (sk->sk_state != TCP_LISTEN || DN_SK(sk)->state != DN_O) { 1074 if (sk->sk_state != TCP_LISTEN || DN_SK(sk)->state != DN_O) {
1075 release_sock(sk); 1075 release_sock(sk);
1076 return -EINVAL; 1076 return -EINVAL;
1077 } 1077 }
@@ -1098,13 +1098,13 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
1098 dst_release(xchg(&newsk->sk_dst_cache, skb->dst)); 1098 dst_release(xchg(&newsk->sk_dst_cache, skb->dst));
1099 skb->dst = NULL; 1099 skb->dst = NULL;
1100 1100
1101 DN_SK(newsk)->state = DN_CR; 1101 DN_SK(newsk)->state = DN_CR;
1102 DN_SK(newsk)->addrrem = cb->src_port; 1102 DN_SK(newsk)->addrrem = cb->src_port;
1103 DN_SK(newsk)->services_rem = cb->services; 1103 DN_SK(newsk)->services_rem = cb->services;
1104 DN_SK(newsk)->info_rem = cb->info; 1104 DN_SK(newsk)->info_rem = cb->info;
1105 DN_SK(newsk)->segsize_rem = cb->segsize; 1105 DN_SK(newsk)->segsize_rem = cb->segsize;
1106 DN_SK(newsk)->accept_mode = DN_SK(sk)->accept_mode; 1106 DN_SK(newsk)->accept_mode = DN_SK(sk)->accept_mode;
1107 1107
1108 if (DN_SK(newsk)->segsize_rem < 230) 1108 if (DN_SK(newsk)->segsize_rem < 230)
1109 DN_SK(newsk)->segsize_rem = 230; 1109 DN_SK(newsk)->segsize_rem = 230;
1110 1110
@@ -1154,15 +1154,15 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
1154 dn_send_conn_ack(newsk); 1154 dn_send_conn_ack(newsk);
1155 1155
1156 /* 1156 /*
1157 * Here we use sk->sk_allocation since although the conn conf is 1157 * Here we use sk->sk_allocation since although the conn conf is
1158 * for the newsk, the context is the old socket. 1158 * for the newsk, the context is the old socket.
1159 */ 1159 */
1160 if (DN_SK(newsk)->accept_mode == ACC_IMMED) 1160 if (DN_SK(newsk)->accept_mode == ACC_IMMED)
1161 err = dn_confirm_accept(newsk, &timeo, 1161 err = dn_confirm_accept(newsk, &timeo,
1162 sk->sk_allocation); 1162 sk->sk_allocation);
1163 } 1163 }
1164 release_sock(newsk); 1164 release_sock(newsk);
1165 return err; 1165 return err;
1166} 1166}
1167 1167
1168 1168
@@ -1177,10 +1177,10 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int *uaddr_len
1177 lock_sock(sk); 1177 lock_sock(sk);
1178 1178
1179 if (peer) { 1179 if (peer) {
1180 if ((sock->state != SS_CONNECTED && 1180 if ((sock->state != SS_CONNECTED &&
1181 sock->state != SS_CONNECTING) && 1181 sock->state != SS_CONNECTING) &&
1182 scp->accept_mode == ACC_IMMED) { 1182 scp->accept_mode == ACC_IMMED) {
1183 release_sock(sk); 1183 release_sock(sk);
1184 return -ENOTCONN; 1184 return -ENOTCONN;
1185 } 1185 }
1186 1186
@@ -1191,7 +1191,7 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int *uaddr_len
1191 1191
1192 release_sock(sk); 1192 release_sock(sk);
1193 1193
1194 return 0; 1194 return 0;
1195} 1195}
1196 1196
1197 1197
@@ -1285,7 +1285,7 @@ static int dn_listen(struct socket *sock, int backlog)
1285out: 1285out:
1286 release_sock(sk); 1286 release_sock(sk);
1287 1287
1288 return err; 1288 return err;
1289} 1289}
1290 1290
1291 1291
@@ -1333,7 +1333,7 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use
1333 return err; 1333 return err;
1334} 1334}
1335 1335
1336static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, int optlen, int flags) 1336static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, int optlen, int flags)
1337{ 1337{
1338 struct sock *sk = sock->sk; 1338 struct sock *sk = sock->sk;
1339 struct dn_scp *scp = DN_SK(sk); 1339 struct dn_scp *scp = DN_SK(sk);
@@ -1360,7 +1360,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
1360 1360
1361 switch(optname) { 1361 switch(optname) {
1362 case DSO_CONDATA: 1362 case DSO_CONDATA:
1363 if (sock->state == SS_CONNECTED) 1363 if (sock->state == SS_CONNECTED)
1364 return -EISCONN; 1364 return -EISCONN;
1365 if ((scp->state != DN_O) && (scp->state != DN_CR)) 1365 if ((scp->state != DN_O) && (scp->state != DN_CR))
1366 return -EINVAL; 1366 return -EINVAL;
@@ -1375,7 +1375,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
1375 break; 1375 break;
1376 1376
1377 case DSO_DISDATA: 1377 case DSO_DISDATA:
1378 if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED) 1378 if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED)
1379 return -ENOTCONN; 1379 return -ENOTCONN;
1380 1380
1381 if (optlen != sizeof(struct optdata_dn)) 1381 if (optlen != sizeof(struct optdata_dn))
@@ -1388,7 +1388,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
1388 break; 1388 break;
1389 1389
1390 case DSO_CONACCESS: 1390 case DSO_CONACCESS:
1391 if (sock->state == SS_CONNECTED) 1391 if (sock->state == SS_CONNECTED)
1392 return -EISCONN; 1392 return -EISCONN;
1393 if (scp->state != DN_O) 1393 if (scp->state != DN_O)
1394 return -EINVAL; 1394 return -EINVAL;
@@ -1521,7 +1521,7 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
1521 1521
1522 if(get_user(r_len , optlen)) 1522 if(get_user(r_len , optlen))
1523 return -EFAULT; 1523 return -EFAULT;
1524 1524
1525 switch(optname) { 1525 switch(optname) {
1526 case DSO_CONDATA: 1526 case DSO_CONDATA:
1527 if (r_len > sizeof(struct optdata_dn)) 1527 if (r_len > sizeof(struct optdata_dn))
@@ -1573,11 +1573,11 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
1573#ifdef CONFIG_NETFILTER 1573#ifdef CONFIG_NETFILTER
1574 { 1574 {
1575 int val, len; 1575 int val, len;
1576 1576
1577 if(get_user(len, optlen)) 1577 if(get_user(len, optlen))
1578 return -EFAULT; 1578 return -EFAULT;
1579 1579
1580 val = nf_getsockopt(sk, PF_DECnet, optname, 1580 val = nf_getsockopt(sk, PF_DECnet, optname,
1581 optval, &len); 1581 optval, &len);
1582 if (val >= 0) 1582 if (val >= 0)
1583 val = put_user(len, optlen); 1583 val = put_user(len, optlen);
@@ -1588,7 +1588,7 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
1588 case DSO_SEQPACKET: 1588 case DSO_SEQPACKET:
1589 case DSO_CONACCEPT: 1589 case DSO_CONACCEPT:
1590 case DSO_CONREJECT: 1590 case DSO_CONREJECT:
1591 return -ENOPROTOOPT; 1591 return -ENOPROTOOPT;
1592 1592
1593 case DSO_MAXWINDOW: 1593 case DSO_MAXWINDOW:
1594 if (r_len > sizeof(unsigned long)) 1594 if (r_len > sizeof(unsigned long))
@@ -1724,7 +1724,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
1724 } 1724 }
1725 } 1725 }
1726 } 1726 }
1727 1727
1728 if (scp->state != DN_RUN) 1728 if (scp->state != DN_RUN)
1729 goto out; 1729 goto out;
1730 1730
@@ -1773,7 +1773,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
1773 if (skb->len == 0) { 1773 if (skb->len == 0) {
1774 skb_unlink(skb, queue); 1774 skb_unlink(skb, queue);
1775 kfree_skb(skb); 1775 kfree_skb(skb);
1776 /* 1776 /*
1777 * N.B. Don't refer to skb or cb after this point 1777 * N.B. Don't refer to skb or cb after this point
1778 * in loop. 1778 * in loop.
1779 */ 1779 */
@@ -1783,7 +1783,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
1783 } 1783 }
1784 } 1784 }
1785 1785
1786 if (eor) { 1786 if (eor) {
1787 if (sk->sk_type == SOCK_SEQPACKET) 1787 if (sk->sk_type == SOCK_SEQPACKET)
1788 break; 1788 break;
1789 if (!(flags & MSG_WAITALL)) 1789 if (!(flags & MSG_WAITALL))
@@ -1884,7 +1884,7 @@ static inline unsigned int dn_current_mss(struct sock *sk, int flags)
1884 return mss_now; 1884 return mss_now;
1885} 1885}
1886 1886
1887/* 1887/*
1888 * N.B. We get the timeout wrong here, but then we always did get it 1888 * N.B. We get the timeout wrong here, but then we always did get it
1889 * wrong before and this is another step along the road to correcting 1889 * wrong before and this is another step along the road to correcting
1890 * it. It ought to get updated each time we pass through the routine, 1890 * it. It ought to get updated each time we pass through the routine,
@@ -2044,7 +2044,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
2044 cb->nsp_flags |= 0x20; 2044 cb->nsp_flags |= 0x20;
2045 2045
2046 scp->seg_total += len; 2046 scp->seg_total += len;
2047 2047
2048 if (((sent + len) == size) && (flags & MSG_EOR)) { 2048 if (((sent + len) == size) && (flags & MSG_EOR)) {
2049 cb->nsp_flags |= 0x40; 2049 cb->nsp_flags |= 0x40;
2050 scp->seg_total = 0; 2050 scp->seg_total = 0;
@@ -2202,7 +2202,7 @@ static void dn_socket_seq_stop(struct seq_file *seq, void *v)
2202static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf) 2202static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf)
2203{ 2203{
2204 int i; 2204 int i;
2205 2205
2206 switch (dn_ntohs(dn->sdn_objnamel)) { 2206 switch (dn_ntohs(dn->sdn_objnamel)) {
2207 case 0: 2207 case 0:
2208 sprintf(buf, "%d", dn->sdn_objnum); 2208 sprintf(buf, "%d", dn->sdn_objnum);
@@ -2214,7 +2214,7 @@ static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf)
2214 buf[i] = '.'; 2214 buf[i] = '.';
2215 } 2215 }
2216 buf[i] = 0; 2216 buf[i] = 0;
2217 } 2217 }
2218} 2218}
2219 2219
2220static char *dn_state2asc(unsigned char state) 2220static char *dn_state2asc(unsigned char state)
@@ -2381,7 +2381,7 @@ static int __init decnet_init(void)
2381{ 2381{
2382 int rc; 2382 int rc;
2383 2383
2384 printk(banner); 2384 printk(banner);
2385 2385
2386 rc = proto_register(&dn_proto, 1); 2386 rc = proto_register(&dn_proto, 1);
2387 if (rc != 0) 2387 if (rc != 0)