Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _NET_DN_NSP_H |
| 2 | #define _NET_DN_NSP_H |
| 3 | /****************************************************************************** |
| 4 | (c) 1995-1998 E.M. Serrat emserrat@geocities.com |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | *******************************************************************************/ |
| 16 | /* dn_nsp.c functions prototyping */ |
| 17 | |
Joe Perches | 59ddd96 | 2013-09-20 11:23:20 -0700 | [diff] [blame] | 18 | void dn_nsp_send_data_ack(struct sock *sk); |
| 19 | void dn_nsp_send_oth_ack(struct sock *sk); |
| 20 | void dn_nsp_delayed_ack(struct sock *sk); |
| 21 | void dn_send_conn_ack(struct sock *sk); |
| 22 | void dn_send_conn_conf(struct sock *sk, gfp_t gfp); |
| 23 | void dn_nsp_send_disc(struct sock *sk, unsigned char type, |
| 24 | unsigned short reason, gfp_t gfp); |
| 25 | void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type, |
| 26 | unsigned short reason); |
| 27 | void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval); |
| 28 | void dn_nsp_send_conninit(struct sock *sk, unsigned char flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Joe Perches | 59ddd96 | 2013-09-20 11:23:20 -0700 | [diff] [blame] | 30 | void dn_nsp_output(struct sock *sk); |
| 31 | int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, |
| 32 | struct sk_buff_head *q, unsigned short acknum); |
| 33 | void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, gfp_t gfp, |
| 34 | int oob); |
| 35 | unsigned long dn_nsp_persist(struct sock *sk); |
| 36 | int dn_nsp_xmit_timeout(struct sock *sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Joe Perches | 59ddd96 | 2013-09-20 11:23:20 -0700 | [diff] [blame] | 38 | int dn_nsp_rx(struct sk_buff *); |
| 39 | int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Joe Perches | 59ddd96 | 2013-09-20 11:23:20 -0700 | [diff] [blame] | 41 | struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); |
| 42 | struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, |
| 43 | long timeo, int *err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #define NSP_REASON_OK 0 /* No error */ |
| 46 | #define NSP_REASON_NR 1 /* No resources */ |
| 47 | #define NSP_REASON_UN 2 /* Unrecognised node name */ |
| 48 | #define NSP_REASON_SD 3 /* Node shutting down */ |
| 49 | #define NSP_REASON_ID 4 /* Invalid destination end user */ |
| 50 | #define NSP_REASON_ER 5 /* End user lacks resources */ |
| 51 | #define NSP_REASON_OB 6 /* Object too busy */ |
| 52 | #define NSP_REASON_US 7 /* Unspecified error */ |
| 53 | #define NSP_REASON_TP 8 /* Third-Party abort */ |
| 54 | #define NSP_REASON_EA 9 /* End user has aborted the link */ |
| 55 | #define NSP_REASON_IF 10 /* Invalid node name format */ |
| 56 | #define NSP_REASON_LS 11 /* Local node shutdown */ |
| 57 | #define NSP_REASON_LL 32 /* Node lacks logical-link resources */ |
| 58 | #define NSP_REASON_LE 33 /* End user lacks logical-link resources */ |
| 59 | #define NSP_REASON_UR 34 /* Unacceptable RQSTRID or PASSWORD field */ |
| 60 | #define NSP_REASON_UA 36 /* Unacceptable ACCOUNT field */ |
| 61 | #define NSP_REASON_TM 38 /* End user timed out logical link */ |
| 62 | #define NSP_REASON_NU 39 /* Node unreachable */ |
| 63 | #define NSP_REASON_NL 41 /* No-link message */ |
| 64 | #define NSP_REASON_DC 42 /* Disconnect confirm */ |
| 65 | #define NSP_REASON_IO 43 /* Image data field overflow */ |
| 66 | |
| 67 | #define NSP_DISCINIT 0x38 |
| 68 | #define NSP_DISCCONF 0x48 |
| 69 | |
| 70 | /*------------------------- NSP - messages ------------------------------*/ |
| 71 | /* Data Messages */ |
| 72 | /*---------------*/ |
| 73 | |
| 74 | /* Data Messages (data segment/interrupt/link service) */ |
| 75 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 76 | struct nsp_data_seg_msg { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 77 | __u8 msgflg; |
| 78 | __le16 dstaddr; |
| 79 | __le16 srcaddr; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 80 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 82 | struct nsp_data_opt_msg { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 83 | __le16 acknum; |
| 84 | __le16 segnum; |
| 85 | __le16 lsflgs; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 86 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 88 | struct nsp_data_opt_msg1 { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 89 | __le16 acknum; |
| 90 | __le16 segnum; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 91 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
| 93 | |
| 94 | /* Acknowledgment Message (data/other data) */ |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 95 | struct nsp_data_ack_msg { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 96 | __u8 msgflg; |
| 97 | __le16 dstaddr; |
| 98 | __le16 srcaddr; |
| 99 | __le16 acknum; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 100 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
| 102 | /* Connect Acknowledgment Message */ |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 103 | struct nsp_conn_ack_msg { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 104 | __u8 msgflg; |
| 105 | __le16 dstaddr; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 106 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | |
| 109 | /* Connect Initiate/Retransmit Initiate/Connect Confirm */ |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 110 | struct nsp_conn_init_msg { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 111 | __u8 msgflg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #define NSP_CI 0x18 /* Connect Initiate */ |
| 113 | #define NSP_RCI 0x68 /* Retrans. Conn Init */ |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 114 | __le16 dstaddr; |
| 115 | __le16 srcaddr; |
| 116 | __u8 services; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | #define NSP_FC_NONE 0x00 /* Flow Control None */ |
| 118 | #define NSP_FC_SRC 0x04 /* Seg Req. Count */ |
| 119 | #define NSP_FC_SCMC 0x08 /* Sess. Control Mess */ |
| 120 | #define NSP_FC_MASK 0x0c /* FC type mask */ |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 121 | __u8 info; |
| 122 | __le16 segsize; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 123 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | /* Disconnect Initiate/Disconnect Confirm */ |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 126 | struct nsp_disconn_init_msg { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 127 | __u8 msgflg; |
| 128 | __le16 dstaddr; |
| 129 | __le16 srcaddr; |
| 130 | __le16 reason; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 131 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | |
| 134 | |
Eric Dumazet | fd2c3ef | 2009-11-03 03:26:03 +0000 | [diff] [blame] | 135 | struct srcobj_fmt { |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 136 | __u8 format; |
| 137 | __u8 task; |
| 138 | __le16 grpcode; |
| 139 | __le16 usrcode; |
| 140 | __u8 dlen; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 141 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | /* |
| 144 | * A collection of functions for manipulating the sequence |
| 145 | * numbers used in NSP. Similar in operation to the functions |
| 146 | * of the same name in TCP. |
| 147 | */ |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 148 | static __inline__ int dn_before(__u16 seq1, __u16 seq2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | { |
| 150 | seq1 &= 0x0fff; |
| 151 | seq2 &= 0x0fff; |
| 152 | |
| 153 | return (int)((seq1 - seq2) & 0x0fff) > 2048; |
| 154 | } |
| 155 | |
| 156 | |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 157 | static __inline__ int dn_after(__u16 seq1, __u16 seq2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | { |
| 159 | seq1 &= 0x0fff; |
| 160 | seq2 &= 0x0fff; |
| 161 | |
| 162 | return (int)((seq2 - seq1) & 0x0fff) > 2048; |
| 163 | } |
| 164 | |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 165 | static __inline__ int dn_equal(__u16 seq1, __u16 seq2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
| 167 | return ((seq1 ^ seq2) & 0x0fff) == 0; |
| 168 | } |
| 169 | |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 170 | static __inline__ int dn_before_or_equal(__u16 seq1, __u16 seq2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | { |
| 172 | return (dn_before(seq1, seq2) || dn_equal(seq1, seq2)); |
| 173 | } |
| 174 | |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 175 | static __inline__ void seq_add(__u16 *seq, __u16 off) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
| 177 | (*seq) += off; |
| 178 | (*seq) &= 0x0fff; |
| 179 | } |
| 180 | |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 181 | static __inline__ int seq_next(__u16 seq1, __u16 seq2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | { |
| 183 | return dn_equal(seq1 + 1, seq2); |
| 184 | } |
| 185 | |
| 186 | /* |
| 187 | * Can we delay the ack ? |
| 188 | */ |
Steven Whitehouse | c4ea94a | 2006-03-20 22:42:39 -0800 | [diff] [blame] | 189 | static __inline__ int sendack(__u16 seq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | { |
| 191 | return (int)((seq & 0x1000) ? 0 : 1); |
| 192 | } |
| 193 | |
| 194 | /* |
| 195 | * Is socket congested ? |
| 196 | */ |
| 197 | static __inline__ int dn_congested(struct sock *sk) |
| 198 | { |
| 199 | return atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1); |
| 200 | } |
| 201 | |
| 202 | #define DN_MAX_NSP_DATA_HEADER (11) |
| 203 | |
| 204 | #endif /* _NET_DN_NSP_H */ |