Deleted Added
sdiff udiff text old ( 52153 ) new ( 52704 )
full compact
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: head/sys/netncp/ncp_lib.h 52704 1999-10-31 03:39:03Z bp $
33 */
34
35#ifndef _NETNCP_NCP_LIB_H_
36#define _NETNCP_NCP_LIB_H_
37
38#define IPX
39#define INET
40
41#include <netncp/ncp.h>
42#include <netncp/ncp_conn.h>
43#include <netncp/ncp_user.h>
44#include <netncp/ncp_rq.h>
45
46#define ncp_printf printf
47
48#define sipx_cnetwork sipx_addr.x_net.c_net
49#define sipx_node sipx_addr.x_host.c_host
50#define ipx_netlong(iaddr) (((union ipx_net_u *)(&((iaddr).x_net)))->long_e)
51
52#define STDPARAM_ARGS 'A':case 'B':case 'C':case 'I':case 'M': \
53 case 'N':case 'U':case 'R':case 'S':case 'T': \
54 case 'W':case 'O':case 'P'
55
56#define STDPARAM_OPT "A:BCI:M:N:O:P:U:R:S:T:W:"
57
58#ifndef min
59#define min(a,b) (((a)<(b)) ? (a) : (b))
60#endif
61
62
63/*
64 * An attempt to do a unified options parser
65 */
66enum ncp_argtype {NCA_STR,NCA_INT,NCA_BOOL};
67
68struct ncp_args;
69
70typedef int ncp_setopt_t (struct ncp_args*);
71
72#define NAFL_NONE 0x0000
73#define NAFL_HAVEMIN 0x0001
74#define NAFL_HAVEMAX 0x0002
75#define NAFL_MINMAX NAFL_HAVEMIN | NAFL_HAVEMAX
76
77struct ncp_args {
78 enum ncp_argtype at;
79 int opt; /* command line option */
80 char *name; /* rc file equiv */
81 int flag; /* NAFL_* */
82 int ival; /* int/bool values, or max len for str value */
83 char *str; /* string value */
84 int min; /* min for ival */
85 int max; /* max for ival */
86 ncp_setopt_t *fn;/* call back to validate */
87};
88
89typedef struct {
90 nuint8 day;
91 nuint8 month;
92 nuint16 year;
93} NW_DATE;
94
95/* hours is a nuint16 so that this structure will be the same length as a dword */
96typedef struct {
97 nuint8 seconds;
98 nuint8 minutes;
99 nuint16 hours;
100} NW_TIME;
101
102struct ncp_bitname {
103 u_int bn_bit;
104 char *bn_name;
105};
106
107__BEGIN_DECLS
108
109int ncp_args_parserc(struct ncp_args *, char *, ncp_setopt_t *);
110int ncp_args_parseopt(struct ncp_args *, int, char *, ncp_setopt_t *);
111
112
113struct sockaddr_ipx;
114struct ipx_addr;
115struct sockaddr;
116struct ncp_buf;
117struct rcfile;
118
119int ncp_initlib(void);
120int ncp_connect(struct ncp_conn_args *, int *);
121int ncp_connect_addr(struct sockaddr *, NWCONN_HANDLE *);
122int ncp_disconnect(int);
123int ncp_request(int, int, struct ncp_buf *);
124int ncp_conn_request(int, struct ncp_buf *);
125int ncp_login(int, const char *, int, const char *);
126int ncp_conn_scan(struct ncp_conn_loginfo *, int *);
127int ncp_conn_cnt(void);
128void *ncp_conn_list(void);
129int ncp_conn_getinfo(int, struct ncp_conn_stat *);
130int ncp_conn_getuser(int, char **);
131int ncp_conn2ref(int, int *);
132int ncp_conn_dup(NWCONN_HANDLE, NWCONN_HANDLE *);
133int ncp_path2conn(char *, int *);
134int ncp_li_init(struct ncp_conn_loginfo *, int, char *[]);
135void ncp_li_done(struct ncp_conn_loginfo *);
136int ncp_li_login(struct ncp_conn_loginfo *, int *);
137int ncp_li_readrc(struct ncp_conn_loginfo *);
138int ncp_li_check(struct ncp_conn_loginfo *);
139int ncp_li_arg(struct ncp_conn_loginfo *, int, char *);
140int ncp_li_setserver(struct ncp_conn_loginfo *, const char *);
141int ncp_li_setuser(struct ncp_conn_loginfo *, char *);
142int ncp_li_setpassword(struct ncp_conn_loginfo *, const char *);
143int ncp_conn_setflags(int, u_int16_t, u_int16_t);
144int ncp_conn_find(char *, char *);
145NWCCODE NWRequest(NWCONN_HANDLE, nuint16, nuint16, NW_FRAGMENT *,
146 nuint16, NW_FRAGMENT *);
147
148#define ncp_setpermanent(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PERMANENT, (on) ? NCPFL_PERMANENT : 0)
149#define ncp_setprimary(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PRIMARY, (on) ? NCPFL_PRIMARY : 0)
150
151int ncp_find_fileserver(struct ncp_conn_loginfo *, int, char *);
152int ncp_find_server(struct ncp_conn_loginfo *, int, int, char *);
153
154/* misc rotines */
155char* ncp_str_upper(char *);
156int ncp_open_rcfile(void);
157int ncp_getopt(int, char * const *, const char *);
158void NWUnpackDateTime(nuint32, NW_DATE *, NW_TIME *);
159void NWUnpackDate(nuint16, NW_DATE *);
160void NWUnpackTime(nuint16, NW_TIME *);
161time_t ncp_UnpackDateTime(nuint32);
162int ncp_GetFileServerDateAndTime(NWCONN_HANDLE, time_t *);
163int ncp_SetFileServerDateAndTime(NWCONN_HANDLE, time_t *);
164NWCCODE NWDownFileServer(NWCONN_HANDLE, int);
165NWCCODE NWCloseBindery(NWCONN_HANDLE);
166NWCCODE NWOpenBindery(NWCONN_HANDLE);
167NWCCODE NWDisableTTS(NWCONN_HANDLE);
168NWCCODE NWEnableTTS(NWCONN_HANDLE);
169NWCCODE NWDisableFileServerLogin(NWCONN_HANDLE);
170NWCCODE NWEnableFileServerLogin(NWCONN_HANDLE);
171void ncp_error(char *, int,...);
172char *ncp_printb(char *, int, const struct ncp_bitname *);
173void nw_keyhash(const u_char *, const u_char *, int, u_char *);
174void nw_encrypt(const u_char *, const u_char *, u_char *);
175void ipx_print_addr(struct ipx_addr *);
176
177/* bindery calls */
178int ncp_get_bindery_object_id(NWCONN_HANDLE, u_int16_t, const char *,
179 struct ncp_bindery_object *);
180int ncp_get_bindery_object_name(NWCONN_HANDLE, u_int32_t,
181 struct ncp_bindery_object *);
182int ncp_scan_bindery_object(NWCONN_HANDLE, u_int32_t, u_int16_t,
183 char *, struct ncp_bindery_object *);
184int ncp_read_property_value(NWCONN_HANDLE, int object_type, const char *,
185 int, const char *, struct nw_property *);
186int ncp_get_encryption_key(NWCONN_HANDLE, char *);
187int ncp_change_obj_passwd(NWCONN_HANDLE,
188 const struct ncp_bindery_object *, const u_char *,
189 const u_char *, const u_char *);
190int ncp_keyed_verify_password(NWCONN_HANDLE, char *, char *,
191 struct ncp_bindery_object *);
192
193/* queue calls */
194int ncp_create_queue_job_and_file(NWCONN_HANDLE, u_int32_t, struct queue_job *);
195int ncp_close_file_and_start_job(NWCONN_HANDLE, u_int32_t, struct queue_job *);
196int ncp_attach_to_queue(NWCONN_HANDLE, u_int32_t);
197int ncp_detach_from_queue(NWCONN_HANDLE, u_int32_t);
198int ncp_service_queue_job(NWCONN_HANDLE, u_int32_t, u_int16_t,
199 struct queue_job *);
200int ncp_finish_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t, u_int32_t);
201int ncp_abort_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t);
202int ncp_get_queue_length(NWCONN_HANDLE, u_int32_t, u_int32_t *);
203int ncp_get_queue_job_ids(NWCONN_HANDLE, u_int32_t, u_int32_t,
204 u_int32_t *, u_int32_t *, u_int32_t []);
205int ncp_get_queue_job_info(NWCONN_HANDLE, u_int32_t, u_int32_t,
206 struct nw_queue_job_entry *);
207/*
208 * file system and volume calls
209 */
210int ncp_read(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *);
211int ncp_write(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *);
212int ncp_geteinfo(char *, struct nw_entry_info *);
213int ncp_NSEntryInfo(NWCONN_HANDLE, nuint8, nuint8, nuint32, NW_ENTRY_INFO *);
214
215NWCCODE NWGetVolumeName(NWCONN_HANDLE, u_char, char *);
216
217/* misc ncp calls */
218int ncp_get_file_server_information(NWCONN_HANDLE, struct ncp_file_server_info *);
219int ncp_get_stations_logged_info(NWCONN_HANDLE, u_int32_t,
220 struct ncp_bindery_object *, time_t *);
221int ncp_get_internet_address(NWCONN_HANDLE, u_int32_t, struct ipx_addr *,
222 u_int8_t *);
223NWCCODE NWGetObjectConnectionNumbers(NWCONN_HANDLE, pnstr8, nuint16,
224 pnuint16, pnuint16, nuint16);
225/*
226 * Message broadcast
227 */
228NWCCODE NWDisableBroadcasts(NWCONN_HANDLE);
229NWCCODE NWEnableBroadcasts(NWCONN_HANDLE);
230NWCCODE NWBroadcastToConsole(NWCONN_HANDLE, pnstr8);
231NWCCODE NWSendBroadcastMessage(NWCONN_HANDLE, pnstr8, nuint16, pnuint16, pnuint8);
232NWCCODE NWGetBroadcastMessage(NWCONN_HANDLE, pnstr8);
233
234/*
235 * RPC calls
236 */
237NWCCODE NWSMExecuteNCFFile(NWCONN_HANDLE, pnstr8);
238NWCCODE NWSMLoadNLM(NWCONN_HANDLE, pnstr8);
239NWCCODE NWSMUnloadNLM(NWCONN_HANDLE, pnstr8);
240NWCCODE NWSMMountVolume(NWCONN_HANDLE, pnstr8, nuint32 *);
241NWCCODE NWSMDismountVolumeByName(NWCONN_HANDLE, pnstr8);
242NWCCODE NWSMSetDynamicCmdIntValue(NWCONN_HANDLE, pnstr8, nuint32);
243NWCCODE NWSMSetDynamicCmdStrValue(NWCONN_HANDLE, pnstr8, pnstr8);
244
245__END_DECLS
246
247extern int ncp_opterr, ncp_optind, ncp_optopt, ncp_optreset;
248extern char *ncp_optarg;
249
250extern struct rcfile *ncp_rc;
251extern int sysentoffset;
252#endif /* _NETNCP_NCP_LIB_H_ */