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 52153 1999-10-12 11:56:41Z bp $
33 */
34
35#ifndef _NCP_LIB_H_
36#define _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
107int ncp_args_parserc(struct ncp_args *na, char *sect, ncp_setopt_t *set_callback);
108int ncp_args_parseopt(struct ncp_args *na, int opt, char *optarg, ncp_setopt_t *set_callback);
109
110
111struct sockaddr_ipx;
112struct ipx_addr;
113struct sockaddr;
114struct ncp_buf;
115struct rcfile;
116
117int ncp_initlib(void);
118int ncp_connect(struct ncp_conn_args *li, int *connHandle);
119int ncp_connect_addr(struct sockaddr *sa, NWCONN_HANDLE *chp);
120int ncp_disconnect(int connHandle);
121int ncp_request(int connHandle,int function, struct ncp_buf *ncpbuf);
122int ncp_conn_request(int connHandle, struct ncp_buf *ncpbuf);
123int ncp_login(int connHandle, const char *user, int objtype, const char *password);
124int ncp_conn_scan(struct ncp_conn_loginfo *li, int *connHandle);
125int ncp_conn_cnt(void);
126void *ncp_conn_list(void);
127int ncp_conn_getinfo(int connHandle, struct ncp_conn_stat *ps);
128int ncp_conn_getuser(int connHandle, char **user);
129int ncp_conn2ref(int connHandle, int *connRef);
130int ncp_conn_dup(NWCONN_HANDLE org, NWCONN_HANDLE *res);
131int ncp_path2conn(char *path, int *connHandle);
132int ncp_li_init(struct ncp_conn_loginfo *li, int argc, char *argv[]);
133void ncp_li_done(struct ncp_conn_loginfo *li);
134int ncp_li_login(struct ncp_conn_loginfo *li, int *aconnHandle);
135int ncp_li_readrc(struct ncp_conn_loginfo *li);
136int ncp_li_check(struct ncp_conn_loginfo *li);
137int ncp_li_arg(struct ncp_conn_loginfo *li, int opt, char *arg);
138int ncp_li_setserver(struct ncp_conn_loginfo *li, const char *arg);
139int ncp_li_setuser(struct ncp_conn_loginfo *li, char *arg);
140int ncp_li_setpassword(struct ncp_conn_loginfo *li, const char *passwd);
141int ncp_conn_setflags(int connHandle, u_int16_t mask, u_int16_t flags);
142int ncp_conn_find(char *server, char *user);
143NWCCODE NWRequest(NWCONN_HANDLE cH, nuint16 fn,
144 nuint16 nrq, NW_FRAGMENT* rq,
145 nuint16 nrp, NW_FRAGMENT* rp) ;
146
147#define ncp_setpermanent(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PERMANENT, (on) ? NCPFL_PERMANENT : 0)
148#define ncp_setprimary(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PRIMARY, (on) ? NCPFL_PRIMARY : 0)
149
150int ncp_find_fileserver(struct ncp_conn_loginfo *li, int af,char *name);
151int ncp_find_server(struct ncp_conn_loginfo *li, int type, int af,char *name);
152
153/* misc rotines */
154char* ncp_str_upper(char *name);
155int ncp_open_rcfile(void);
156int ncp_getopt(int nargc, char * const *nargv, const char *ostr);
157void NWUnpackDateTime(nuint32 dateTime, NW_DATE *sDate, NW_TIME *sTime);
158void NWUnpackDate(nuint16 date, NW_DATE *sDate);
159void NWUnpackTime(nuint16 time, NW_TIME *sTime);
160time_t ncp_UnpackDateTime(nuint32 dateTime);
161int ncp_GetFileServerDateAndTime(NWCONN_HANDLE cH, time_t *target);
162int ncp_SetFileServerDateAndTime(NWCONN_HANDLE cH, time_t * source);
163NWCCODE NWDownFileServer(NWCONN_HANDLE cH, int force);
164NWCCODE NWCloseBindery(NWCONN_HANDLE cH);
165NWCCODE NWOpenBindery(NWCONN_HANDLE cH);
166NWCCODE NWDisableTTS(NWCONN_HANDLE cH);
167NWCCODE NWEnableTTS(NWCONN_HANDLE cH);
168NWCCODE NWDisableFileServerLogin(NWCONN_HANDLE cH);
169NWCCODE NWEnableFileServerLogin(NWCONN_HANDLE cH);
170void ncp_error(char *fmt, int error,...);
171char *ncp_printb(char *dest, int flags, const struct ncp_bitname *bnp);
172void nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
173void nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
174void ipx_print_addr(struct ipx_addr *ipx);
175
176/* bindery calls */
177int ncp_get_bindery_object_id(int connHandle, u_int16_t object_type, const char *object_name,
178 struct ncp_bindery_object *target);
179int ncp_get_bindery_object_name(int connHandle, u_int32_t object_id,
180 struct ncp_bindery_object *target);
181int ncp_scan_bindery_object(int connHandle, u_int32_t last_id, u_int16_t object_type,
182 char *search_string, struct ncp_bindery_object *target);
183int ncp_read_property_value(int connHandle,int object_type, const char *object_name,
184 int segment, const char *prop_name, struct nw_property *target);
185void shuffle(const u_char *lon, const u_char *buf, int buflen, u_char *target);
186int ncp_get_encryption_key(NWCONN_HANDLE cH, char *target);
187int ncp_change_obj_passwd(NWCONN_HANDLE connid,
188 const struct ncp_bindery_object *object,
189 const u_char *key,
190 const u_char *oldpasswd, const u_char *newpasswd);
191int ncp_keyed_verify_password(NWCONN_HANDLE cH, char *key, char *passwd,
192 struct ncp_bindery_object *objinfo);
193
194/* queue calls */
195int ncp_create_queue_job_and_file(int connHandle, u_int32_t queue_id, struct queue_job *job);
196int ncp_close_file_and_start_job(int connHandle, u_int32_t queue_id, struct queue_job *job);
197int ncp_attach_to_queue(int connHandle, u_int32_t queue_id);
198int ncp_detach_from_queue(int connHandle, u_int32_t queue_id);
199int ncp_service_queue_job(int connHandle, u_int32_t queue_id, u_int16_t job_type,
200 struct queue_job *job);
201int ncp_finish_servicing_job(int connHandle, u_int32_t queue_id, u_int32_t job_number,
202 u_int32_t charge_info);
203int ncp_abort_servicing_job(int connHandle, u_int32_t queue_id, u_int32_t job_number);
204int ncp_get_queue_length(int connHandle, u_int32_t queue_id, u_int32_t *queue_length);
205int ncp_get_queue_job_ids(int connHandle, u_int32_t queue_id, u_int32_t queue_section,
206 u_int32_t *length1, u_int32_t *length2, u_int32_t ids[]);
207int ncp_get_queue_job_info(int connHandle, u_int32_t queue_id, u_int32_t job_id,
208 struct nw_queue_job_entry *jobdata);
209/*
210 * file system and volume calls
211 */
212int ncp_read(int connHandle, ncp_fh *fh, off_t offset, size_t count, char *target);
213int ncp_write(int connHandle, ncp_fh *fh, off_t offset, size_t count, char *source);
214int ncp_geteinfo(char *path, struct nw_entry_info *fi);
215int ncp_NSEntryInfo(NWCONN_HANDLE cH, nuint8 ns, nuint8 vol, nuint32 dirent,
216 NW_ENTRY_INFO *entryInfo);
217
218NWCCODE NWGetVolumeName(NWCONN_HANDLE cH, u_char volume, char *name);
219
220/* misc ncp calls */
221int ncp_get_file_server_information(int connHandle, struct ncp_file_server_info *target);
222int ncp_get_stations_logged_info(int connHandle, u_int32_t connection,
223 struct ncp_bindery_object *target, time_t *login_time);
224int ncp_get_internet_address(int connHandle, u_int32_t connection, struct ipx_addr *target,
225 u_int8_t * conn_type);
226NWCCODE NWGetObjectConnectionNumbers(NWCONN_HANDLE connHandle,
227 pnstr8 pObjName, nuint16 objType,
228 pnuint16 pNumConns, pnuint16 pConnHandleList,
229 nuint16 maxConns);
230/*
231 * Message broadcast
232 */
233NWCCODE NWDisableBroadcasts(NWCONN_HANDLE connHandle);
234NWCCODE NWEnableBroadcasts(NWCONN_HANDLE connHandle);
235NWCCODE NWBroadcastToConsole(NWCONN_HANDLE connHandle, pnstr8 message);
236NWCCODE NWSendBroadcastMessage(NWCONN_HANDLE connHandle, pnstr8 message,
237 nuint16 connCount, pnuint16 connList, pnuint8 resultList);
238NWCCODE NWGetBroadcastMessage(NWCONN_HANDLE connHandle, pnstr8 message);
239
240/*
241 * RPC calls
242 */
243NWCCODE NWSMExecuteNCFFile(NWCONN_HANDLE cH, pnstr8 NCFFileName);
244NWCCODE NWSMLoadNLM(NWCONN_HANDLE cH, pnstr8 cmd);
245NWCCODE NWSMUnloadNLM(NWCONN_HANDLE cH, pnstr8 cmd);
246NWCCODE NWSMMountVolume(NWCONN_HANDLE cH, pnstr8 volName, nuint32* volnum);
247NWCCODE NWSMDismountVolumeByName(NWCONN_HANDLE cH, pnstr8 vol);
248NWCCODE NWSMSetDynamicCmdIntValue(NWCONN_HANDLE cH, pnstr8 setCommandName, nuint32 cmdValue);
249NWCCODE NWSMSetDynamicCmdStrValue(NWCONN_HANDLE cH, pnstr8 setCommandName, pnstr8 cmdValue);
250
251int dostat(int modnum, char *modname, int *offset);
252
253extern int ncp_opterr, ncp_optind, ncp_optopt, ncp_optreset;
254extern char *ncp_optarg;
255
256extern struct rcfile *ncp_rc;
257extern int sysentoffset;
258#endif /* _NCP_LIB_H_ */