Remove usage of NTOHS / NTOHL / HTONS / HTONL.
[dragonfly.git] / sys / netproto / ncp / ncp_ncp.h
1 /*
2  * Copyright (c) 1999, Boris Popov
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *    This product includes software developed by Boris Popov.
16  * 4. Neither the name of the author nor the names of any co-contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  * $FreeBSD: src/sys/netncp/ncp_ncp.h,v 1.3 2000/01/14 19:54:38 bde Exp $
33  * $DragonFly: src/sys/netproto/ncp/ncp_ncp.h,v 1.3 2003/06/25 03:56:05 dillon Exp $
34  */
35 #ifndef _NETNCP_NCP_NCP_H_
36 #define _NETNCP_NCP_NCP_H_
37
38 #define NCP_ALLOC_SLOT          0x1111
39 #define NCP_REQUEST             0x2222
40 #define NCP_REPLY               0x3333
41 #define NCP_FREE_SLOT           0x5555
42 #define NCP_PACKET_BURST        0x7777
43 #define NCP_POSITIVE_ACK        0x9999
44
45 /*
46  * Bits for connection state field in ncp_rphdr
47  */
48 #define NCP_CS_BAD_CONN         0x01    /* no such connection */
49 #define NCP_CS_NO_SLOTS         0x04    /* no connection slots available */
50 #define NCP_CS_SERVER_DOWN      0x10    /* server in down state */
51 #define NCP_CS_HAVE_BROADCAST   0x40    /* server holds broadcast for us */
52
53 #define NCP_RETRY_COUNT         5
54 #define NCP_RETRY_TIMEOUT       10
55 #define NCP_RESTORE_COUNT       2       /* how many times try to restore per 
56                                          * single request, should be an _even_ */
57
58 struct ncp_rqhdr {
59         u_int16_t type;
60         u_int8_t  seq;
61         u_int8_t  conn_low;
62         u_int8_t  task;
63         u_int8_t  conn_high;
64         u_int8_t  fn;
65         u_int8_t  data[0];
66 } __attribute__((packed));
67
68
69 struct ncp_rphdr {
70         u_int16_t       type;
71         u_int8_t        seq;
72         u_int8_t        conn_low;
73         u_int8_t        task;
74         u_int8_t        conn_high;
75         u_int8_t        completion_code;
76         u_int8_t        connection_state;
77         u_int8_t        data[0];
78 }__attribute__((packed));
79
80 #define BFL_ABT         0x04
81 #define BFL_EOB         0x10
82 #define BFL_SYS         0x80
83
84 #define BOP_READ        1L
85 #define BOP_WRITE       2L
86
87 #define BERR_NONE       0
88 #define BERR_INIT       1
89 #define BERR_IO         2
90 #define BERR_NODATA     3
91 #define BERR_WRITE      4
92
93 struct ncp_bursthdr {
94         u_short bh_type;
95         u_char  bh_flags;
96         u_char  bh_streamtype;
97         u_long  bh_srcid;
98         u_long  bh_dstid;
99         u_long  bh_seq;                 /* HL */
100         u_long  bh_send_delay;          /* HL */
101         u_short bh_bseq;                /* HL */
102         u_short bh_aseq;                /* HL */
103         u_long  bh_blen;                /* HL */
104         u_long  bh_dofs;                /* HL */
105         u_short bh_dlen;                /* HL */
106         u_short bh_misfrags;            /* HL */
107 } __attribute__((packed));
108
109 struct ncp_conn;
110 struct ncp_conn_args;
111 struct ncp_rq;
112 struct proc;
113 struct thread;
114 struct ucred;
115
116 int  ncp_request(struct ncp_conn *conn,struct ncp_rq *rqp);
117 int  ncp_ncp_connect(struct ncp_conn *conn);
118 int  ncp_ncp_disconnect(struct ncp_conn *conn);
119 int  ncp_reconnect(struct ncp_conn *conn);
120 int  ncp_connect(struct ncp_conn_args *li,struct thread *td, struct ucred *cred,struct ncp_conn **aconn);
121 int  ncp_disconnect(struct ncp_conn *conn);
122 int  ncp_login(struct ncp_conn *conn, char *user, int objtype, char *password,
123           struct thread *td, struct ucred *cred);
124
125 #endif /* _NCP_NCP_H_ */