]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/netncp/ncp_ncp.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / netncp / 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$
33  */
34 #ifndef _NETNCP_NCP_NCP_H_
35 #define _NETNCP_NCP_NCP_H_
36
37 #define NCP_ALLOC_SLOT          0x1111
38 #define NCP_REQUEST             0x2222
39 #define NCP_REPLY               0x3333
40 #define NCP_FREE_SLOT           0x5555
41 #define NCP_PACKET_BURST        0x7777
42 #define NCP_POSITIVE_ACK        0x9999
43
44 /*
45  * Bits for connection state field in ncp_rphdr
46  */
47 #define NCP_CS_BAD_CONN         0x01    /* no such connection */
48 #define NCP_CS_NO_SLOTS         0x04    /* no connection slots available */
49 #define NCP_CS_SERVER_DOWN      0x10    /* server in down state */
50 #define NCP_CS_HAVE_BROADCAST   0x40    /* server holds broadcast for us */
51
52 #define NCP_RETRY_COUNT         5
53 #define NCP_RETRY_TIMEOUT       10
54 #define NCP_RESTORE_COUNT       2       /* how many times try to restore per 
55                                          * single request, should be an _even_ */
56
57 struct ncp_rqhdr {
58         u_int16_t type;
59         u_int8_t  seq;
60         u_int8_t  conn_low;
61         u_int8_t  task;
62         u_int8_t  conn_high;
63         u_int8_t  fn;
64         u_int8_t  data[0];
65 } __packed;
66
67
68 struct ncp_rphdr {
69         u_int16_t       type;
70         u_int8_t        seq;
71         u_int8_t        conn_low;
72         u_int8_t        task;
73         u_int8_t        conn_high;
74         u_int8_t        completion_code;
75         u_int8_t        connection_state;
76         u_int8_t        data[0];
77 }__packed;
78
79 #define BFL_ABT         0x04
80 #define BFL_EOB         0x10
81 #define BFL_SYS         0x80
82
83 #define BOP_READ        1L
84 #define BOP_WRITE       2L
85
86 #define BERR_NONE       0
87 #define BERR_INIT       1
88 #define BERR_IO         2
89 #define BERR_NODATA     3
90 #define BERR_WRITE      4
91
92 struct ncp_bursthdr {
93         u_short bh_type;
94         u_char  bh_flags;
95         u_char  bh_streamtype;
96         u_long  bh_srcid;
97         u_long  bh_dstid;
98         u_long  bh_seq;                 /* HL */
99         u_long  bh_send_delay;          /* HL */
100         u_short bh_bseq;                /* HL */
101         u_short bh_aseq;                /* HL */
102         u_long  bh_blen;                /* HL */
103         u_long  bh_dofs;                /* HL */
104         u_short bh_dlen;                /* HL */
105         u_short bh_misfrags;            /* HL */
106 } __packed;
107
108 struct ncp_conn;
109 struct ncp_conn_args;
110 struct ncp_rq;
111 struct ucred;
112
113 int  ncp_ncp_connect(struct ncp_conn *conn);
114 int  ncp_ncp_disconnect(struct ncp_conn *conn);
115 int  ncp_negotiate_buffersize(struct ncp_conn *conn, int size, int *target);
116 int  ncp_renegotiate_connparam(struct ncp_conn *conn, int buffsize,
117         u_int8_t in_options);
118 int  ncp_get_bindery_object_id(struct ncp_conn *conn, 
119                 u_int16_t object_type, char *object_name, 
120                 struct ncp_bindery_object *target,
121                 struct thread *td,struct ucred *cred);
122 int  ncp_get_encryption_key(struct ncp_conn *conn, char *target);
123 int  ncp_login_encrypted(struct ncp_conn *conn,
124         struct ncp_bindery_object *object,
125         const u_char *key, const u_char *passwd,
126         struct thread *td, struct ucred *cred);
127 int ncp_login_unencrypted(struct ncp_conn *conn, u_int16_t object_type, 
128         const char *object_name, const u_char *passwd,
129         struct thread *td, struct ucred *cred);
130 int  ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
131 int  ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
132
133 #endif /* _NCP_NCP_H_ */