Blame view

include/net/dn_nsp.h 5.97 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #ifndef _NET_DN_NSP_H
  #define _NET_DN_NSP_H
  /******************************************************************************
      (c) 1995-1998 E.M. Serrat		emserrat@geocities.com
      
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation; either version 2 of the License, or
      any later version.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  *******************************************************************************/
  /* dn_nsp.c functions prototyping */
  
  extern void dn_nsp_send_data_ack(struct sock *sk);
  extern void dn_nsp_send_oth_ack(struct sock *sk);
  extern void dn_nsp_delayed_ack(struct sock *sk);
  extern void dn_send_conn_ack(struct sock *sk);
dd0fc66fb   Al Viro   [PATCH] gfp flags...
22
  extern void dn_send_conn_conf(struct sock *sk, gfp_t gfp);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
  extern void dn_nsp_send_disc(struct sock *sk, unsigned char type, 
dd0fc66fb   Al Viro   [PATCH] gfp flags...
24
  			unsigned short reason, gfp_t gfp);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
28
29
30
31
  extern void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type,
  				unsigned short reason);
  extern void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval);
  extern void dn_nsp_send_conninit(struct sock *sk, unsigned char flags);
  
  extern void dn_nsp_output(struct sock *sk);
  extern int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum);
dd0fc66fb   Al Viro   [PATCH] gfp flags...
32
  extern void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, gfp_t gfp, int oob);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
34
35
36
37
  extern unsigned long dn_nsp_persist(struct sock *sk);
  extern int dn_nsp_xmit_timeout(struct sock *sk);
  
  extern int dn_nsp_rx(struct sk_buff *);
  extern int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
dd0fc66fb   Al Viro   [PATCH] gfp flags...
38
  extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err);
  
  #define NSP_REASON_OK 0		/* No error */
  #define NSP_REASON_NR 1		/* No resources */
  #define NSP_REASON_UN 2		/* Unrecognised node name */
  #define NSP_REASON_SD 3		/* Node shutting down */
  #define NSP_REASON_ID 4		/* Invalid destination end user */
  #define NSP_REASON_ER 5		/* End user lacks resources */
  #define NSP_REASON_OB 6		/* Object too busy */
  #define NSP_REASON_US 7		/* Unspecified error */
  #define NSP_REASON_TP 8		/* Third-Party abort */
  #define NSP_REASON_EA 9		/* End user has aborted the link */
  #define NSP_REASON_IF 10	/* Invalid node name format */
  #define NSP_REASON_LS 11	/* Local node shutdown */
  #define NSP_REASON_LL 32	/* Node lacks logical-link resources */
  #define NSP_REASON_LE 33	/* End user lacks logical-link resources */
  #define NSP_REASON_UR 34	/* Unacceptable RQSTRID or PASSWORD field */
  #define NSP_REASON_UA 36	/* Unacceptable ACCOUNT field */
  #define NSP_REASON_TM 38	/* End user timed out logical link */
  #define NSP_REASON_NU 39	/* Node unreachable */
  #define NSP_REASON_NL 41	/* No-link message */
  #define NSP_REASON_DC 42	/* Disconnect confirm */
  #define NSP_REASON_IO 43	/* Image data field overflow */
  
  #define NSP_DISCINIT 0x38
  #define NSP_DISCCONF 0x48
  
  /*------------------------- NSP - messages ------------------------------*/
  /* Data Messages */
  /*---------------*/
  
  /* Data Messages    (data segment/interrupt/link service)               */
fd2c3ef76   Eric Dumazet   net: cleanup incl...
71
  struct nsp_data_seg_msg {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
72
73
74
  	__u8   msgflg;
  	__le16 dstaddr;
  	__le16 srcaddr;
bc10502db   Eric Dumazet   net: use __packed...
75
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76

fd2c3ef76   Eric Dumazet   net: cleanup incl...
77
  struct nsp_data_opt_msg {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
78
79
80
  	__le16 acknum;
  	__le16 segnum;
  	__le16 lsflgs;
bc10502db   Eric Dumazet   net: use __packed...
81
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82

fd2c3ef76   Eric Dumazet   net: cleanup incl...
83
  struct nsp_data_opt_msg1 {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
84
85
  	__le16 acknum;
  	__le16 segnum;
bc10502db   Eric Dumazet   net: use __packed...
86
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
87
88
89
  
  
  /* Acknowledgment Message (data/other data)                             */
fd2c3ef76   Eric Dumazet   net: cleanup incl...
90
  struct nsp_data_ack_msg {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
91
92
93
94
  	__u8   msgflg;
  	__le16 dstaddr;
  	__le16 srcaddr;
  	__le16 acknum;
bc10502db   Eric Dumazet   net: use __packed...
95
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
97
  
  /* Connect Acknowledgment Message */
fd2c3ef76   Eric Dumazet   net: cleanup incl...
98
  struct  nsp_conn_ack_msg {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
99
100
  	__u8 msgflg;
  	__le16 dstaddr;
bc10502db   Eric Dumazet   net: use __packed...
101
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
103
104
  
  
  /* Connect Initiate/Retransmit Initiate/Connect Confirm */
fd2c3ef76   Eric Dumazet   net: cleanup incl...
105
  struct  nsp_conn_init_msg {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
106
  	__u8   msgflg;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
108
  #define NSP_CI      0x18            /* Connect Initiate     */
  #define NSP_RCI     0x68            /* Retrans. Conn Init   */
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
109
110
111
  	__le16 dstaddr;
  	__le16 srcaddr;
  	__u8   services;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
113
114
115
  #define NSP_FC_NONE   0x00            /* Flow Control None    */
  #define NSP_FC_SRC    0x04            /* Seg Req. Count       */
  #define NSP_FC_SCMC   0x08            /* Sess. Control Mess   */
  #define NSP_FC_MASK   0x0c            /* FC type mask         */
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
116
117
  	__u8   info;
  	__le16 segsize;
bc10502db   Eric Dumazet   net: use __packed...
118
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
120
  
  /* Disconnect Initiate/Disconnect Confirm */
fd2c3ef76   Eric Dumazet   net: cleanup incl...
121
  struct  nsp_disconn_init_msg {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
122
123
124
125
  	__u8   msgflg;
  	__le16 dstaddr;
  	__le16 srcaddr;
  	__le16 reason;
bc10502db   Eric Dumazet   net: use __packed...
126
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127

fd2c3ef76   Eric Dumazet   net: cleanup incl...
128
  struct  srcobj_fmt {
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
129
130
131
132
133
  	__u8   format;
  	__u8   task;
  	__le16 grpcode;
  	__le16 usrcode;
  	__u8   dlen;
bc10502db   Eric Dumazet   net: use __packed...
134
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
135
136
137
138
139
140
  
  /*
   * A collection of functions for manipulating the sequence
   * numbers used in NSP. Similar in operation to the functions
   * of the same name in TCP.
   */
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
141
  static __inline__ int dn_before(__u16 seq1, __u16 seq2)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142
143
144
145
146
147
  {
          seq1 &= 0x0fff;
          seq2 &= 0x0fff;
  
          return (int)((seq1 - seq2) & 0x0fff) > 2048;
  }
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
148
  static __inline__ int dn_after(__u16 seq1, __u16 seq2)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
150
151
152
153
154
  {
          seq1 &= 0x0fff;
          seq2 &= 0x0fff;
  
          return (int)((seq2 - seq1) & 0x0fff) > 2048;
  }
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
155
  static __inline__ int dn_equal(__u16 seq1, __u16 seq2)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
156
157
158
  {
          return ((seq1 ^ seq2) & 0x0fff) == 0;
  }
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
159
  static __inline__ int dn_before_or_equal(__u16 seq1, __u16 seq2)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
160
161
162
  {
  	return (dn_before(seq1, seq2) || dn_equal(seq1, seq2));
  }
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
163
  static __inline__ void seq_add(__u16 *seq, __u16 off)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
164
165
166
167
  {
          (*seq) += off;
          (*seq) &= 0x0fff;
  }
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
168
  static __inline__ int seq_next(__u16 seq1, __u16 seq2)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
169
170
171
172
173
174
175
  {
  	return dn_equal(seq1 + 1, seq2);
  }
  
  /*
   * Can we delay the ack ?
   */
c4ea94ab3   Steven Whitehouse   [DECnet]: Endian ...
176
  static __inline__ int sendack(__u16 seq)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
  {
          return (int)((seq & 0x1000) ? 0 : 1);
  }
  
  /*
   * Is socket congested ?
   */
  static __inline__ int dn_congested(struct sock *sk)
  {
          return atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1);
  }
  
  #define DN_MAX_NSP_DATA_HEADER (11)
  
  #endif /* _NET_DN_NSP_H */