Move around some #ifdefs to silence warnings.
[dragonfly.git] / sys / netproto / ipx / spx.h
1 /*
2  * Copyright (c) 1995, Mike Mitchell
3  * Copyright (c) 1984, 1985, 1986, 1987, 1993
4  *      The Regents of the University of California.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *      This product includes software developed by the University of
17  *      California, Berkeley and its contributors.
18  * 4. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *      @(#)spx.h
35  *
36  * $FreeBSD: src/sys/netipx/spx.h,v 1.16 1999/12/29 04:46:09 peter Exp $
37  * $DragonFly: src/sys/netproto/ipx/spx.h,v 1.3 2003/08/23 10:06:23 rob Exp $
38  */
39
40 #ifndef _NETIPX_SPX_H_
41 #define _NETIPX_SPX_H_
42
43 /*
44  * Definitions for IPX style Sequenced Packet Protocol
45  */
46
47 struct spxhdr {
48         u_char  spx_cc;         /* connection control */
49         u_char  spx_dt;         /* datastream type */
50 #define SPX_SP  0x80            /* system packet */
51 #define SPX_SA  0x40            /* send acknowledgement */
52 #define SPX_OB  0x20            /* attention (out of band data) */
53 #define SPX_EM  0x10            /* end of message */
54         u_short spx_sid;        /* source connection identifier */
55         u_short spx_did;        /* destination connection identifier */
56         u_short spx_seq;        /* sequence number */
57         u_short spx_ack;        /* acknowledge number */
58         u_short spx_alo;        /* allocation number */
59 };
60
61 /*
62  * Definitions for NS(tm) Internet Datagram Protocol
63  * containing a Sequenced Packet Protocol packet.
64  */
65 struct spx {
66         struct ipx      si_i;
67         struct spxhdr   si_s;
68 };
69 struct spx_q {
70         struct spx_q    *si_next;
71         struct spx_q    *si_prev;
72 };
73 #define SI(x)   ((struct spx *)x)
74 #define si_sum  si_i.ipx_sum
75 #define si_len  si_i.ipx_len
76 #define si_tc   si_i.ipx_tc
77 #define si_pt   si_i.ipx_pt
78 #define si_dna  si_i.ipx_dna
79 #define si_sna  si_i.ipx_sna
80 #define si_sport        si_i.ipx_sna.x_port
81 #define si_cc   si_s.spx_cc
82 #define si_dt   si_s.spx_dt
83 #define si_sid  si_s.spx_sid
84 #define si_did  si_s.spx_did
85 #define si_seq  si_s.spx_seq
86 #define si_ack  si_s.spx_ack
87 #define si_alo  si_s.spx_alo
88
89 /*
90  * SPX control block, one per connection
91  */
92 struct spxpcb {
93         struct  spx_q   s_q;            /* queue for out-of-order receipt */
94         struct  ipxpcb  *s_ipxpcb;      /* backpointer to internet pcb */
95         u_char  s_state;
96         u_char  s_flags;
97 #define SF_ACKNOW       0x01            /* Ack peer immediately */
98 #define SF_DELACK       0x02            /* Ack, but try to delay it */
99 #define SF_HI   0x04                    /* Show headers on input */
100 #define SF_HO   0x08                    /* Show headers on output */
101 #define SF_PI   0x10                    /* Packet (datagram) interface */
102 #define SF_WIN  0x20                    /* Window info changed */
103 #define SF_RXT  0x40                    /* Rxt info changed */
104 #define SF_RVD  0x80                    /* Calling from read usrreq routine */
105         u_short s_mtu;                  /* Max packet size for this stream */
106 /* use sequence fields in headers to store sequence numbers for this
107    connection */
108         struct  ipx     *s_ipx;
109         struct  spxhdr  s_shdr;         /* prototype header to transmit */
110 #define s_cc s_shdr.spx_cc              /* connection control (for EM bit) */
111 #define s_dt s_shdr.spx_dt              /* datastream type */
112 #define s_sid s_shdr.spx_sid            /* source connection identifier */
113 #define s_did s_shdr.spx_did            /* destination connection identifier */
114 #define s_seq s_shdr.spx_seq            /* sequence number */
115 #define s_ack s_shdr.spx_ack            /* acknowledge number */
116 #define s_alo s_shdr.spx_alo            /* allocation number */
117 #define s_dport s_ipx->ipx_dna.x_port   /* where we are sending */
118         struct spxhdr s_rhdr;           /* last received header (in effect!)*/
119         u_short s_rack;                 /* their acknowledge number */
120         u_short s_ralo;                 /* their allocation number */
121         u_short s_smax;                 /* highest packet # we have sent */
122         u_short s_snxt;                 /* which packet to send next */
123
124 /* congestion control */
125 #define CUNIT   1024                    /* scaling for ... */
126         int     s_cwnd;                 /* Congestion-controlled window */
127                                         /* in packets * CUNIT */
128         short   s_swnd;                 /* == tcp snd_wnd, in packets */
129         short   s_smxw;                 /* == tcp max_sndwnd */
130                                         /* difference of two spx_seq's can be
131                                            no bigger than a short */
132         u_short s_swl1;                 /* == tcp snd_wl1 */
133         u_short s_swl2;                 /* == tcp snd_wl2 */
134         int     s_cwmx;                 /* max allowable cwnd */
135         int     s_ssthresh;             /* s_cwnd size threshold for
136                                          * slow start exponential-to-
137                                          * linear switch */
138 /* transmit timing stuff
139  * srtt and rttvar are stored as fixed point, for convenience in smoothing.
140  * srtt has 3 bits to the right of the binary point, rttvar has 2.
141  */
142         short   s_idle;                 /* time idle */
143 #define SPXT_NTIMERS    4
144         short   s_timer[SPXT_NTIMERS];  /* timers */
145         short   s_rxtshift;             /* log(2) of rexmt exp. backoff */
146         short   s_rxtcur;               /* current retransmit value */
147         u_short s_rtseq;                /* packet being timed */
148         short   s_rtt;                  /* timer for round trips */
149         short   s_srtt;                 /* averaged timer */
150         short   s_rttvar;               /* variance in round trip time */
151         char    s_force;                /* which timer expired */
152         char    s_dupacks;              /* counter to intuit xmt loss */
153
154 /* out of band data */
155         char    s_oobflags;
156 #define SF_SOOB 0x08                    /* sending out of band data */
157 #define SF_IOOB 0x10                    /* receiving out of band data */
158         char    s_iobc;                 /* input characters */
159 /* debug stuff */
160         u_short s_want;                 /* Last candidate for sending */
161         char    s_outx;                 /* exit taken from spx_output */
162         char    s_inx;                  /* exit taken from spx_input */
163         u_short s_flags2;               /* more flags for testing */
164 #define SF_NEWCALL      0x100           /* for new_recvmsg */
165 #define SO_NEWCALL      10              /* for new_recvmsg */
166 };
167
168 #define ipxtospxpcb(np) ((struct spxpcb *)(np)->ipxp_pcb)
169 #define sotospxpcb(so)  (ipxtospxpcb(sotoipxpcb(so)))
170
171 #ifdef _KERNEL
172
173 extern struct pr_usrreqs spx_usrreqs;
174 extern struct pr_usrreqs spx_usrreq_sps;
175
176 void    spx_ctlinput (int cmd, struct sockaddr *arg_as_sa, void *dummy);
177 int     spx_ctloutput (struct socket *so, struct sockopt *sopt);
178 void    spx_fasttimo (void);
179 void    spx_init (void);
180 void    spx_input (struct mbuf *m, struct ipxpcb *ipxp);
181 void    spx_slowtimo (void);
182
183 #endif /* _KERNEL */
184
185 #endif /* !_NETIPX_SPX_H_ */