FreeBSD/Linux Kernel Cross Reference
sys/netncp/ncp_lib.h
1 /*-
2 * Copyright (c) 1999, 2000, 2001 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 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: releng/9.2/sys/netncp/ncp_lib.h 206361 2010-04-07 16:50:38Z joel $
27 */
28
29 #ifndef _NETNCP_NCP_LIB_H_
30 #define _NETNCP_NCP_LIB_H_
31
32 #define IPX
33 #define INET
34
35 #include <netncp/ncp.h>
36 #include <netncp/ncp_conn.h>
37 #include <netncp/ncp_user.h>
38 #include <netncp/ncp_rq.h>
39
40 #define ncp_printf printf
41
42 #define sipx_cnetwork sipx_addr.x_net.c_net
43 #define sipx_node sipx_addr.x_host.c_host
44 #define ipx_netlong(iaddr) (((union ipx_net_u *)(&((iaddr).x_net)))->long_e)
45
46 #define STDPARAM_ARGS 'A':case 'B':case 'C':case 'I':case 'M': \
47 case 'N':case 'U':case 'R':case 'S':case 'T': \
48 case 'W':case 'O':case 'P'
49
50 #define STDPARAM_OPT "A:BCI:M:NO:P:U:R:S:T:W:"
51
52 #ifndef min
53 #define min(a,b) (((a)<(b)) ? (a) : (b))
54 #endif
55
56
57 /*
58 * An attempt to do a unified options parser
59 */
60 enum ncp_argtype {NCA_STR,NCA_INT,NCA_BOOL};
61
62 struct ncp_args;
63
64 typedef int ncp_setopt_t (struct ncp_args*);
65
66 #define NAFL_NONE 0x0000
67 #define NAFL_HAVEMIN 0x0001
68 #define NAFL_HAVEMAX 0x0002
69 #define NAFL_MINMAX NAFL_HAVEMIN | NAFL_HAVEMAX
70
71 struct ncp_args {
72 enum ncp_argtype at;
73 int opt; /* command line option */
74 char *name; /* rc file equiv */
75 int flag; /* NAFL_* */
76 int ival; /* int/bool values, or max len for str value */
77 char *str; /* string value */
78 int min; /* min for ival */
79 int max; /* max for ival */
80 ncp_setopt_t *fn;/* call back to validate */
81 };
82
83 typedef struct {
84 nuint8 day;
85 nuint8 month;
86 nuint16 year;
87 } NW_DATE;
88
89 /* hours is a nuint16 so that this structure will be the same length as a dword */
90 typedef struct {
91 nuint8 seconds;
92 nuint8 minutes;
93 nuint16 hours;
94 } NW_TIME;
95
96 struct ncp_bitname {
97 u_int bn_bit;
98 const char *bn_name;
99 };
100
101 __BEGIN_DECLS
102
103 int ncp_args_parserc(struct ncp_args *, char *, ncp_setopt_t *);
104 int ncp_args_parseopt(struct ncp_args *, int, char *, ncp_setopt_t *);
105
106
107 struct sockaddr_ipx;
108 struct ipx_addr;
109 struct sockaddr;
110 struct ncp_buf;
111 struct rcfile;
112
113 int ncp_initlib(void);
114 int ncp_connect(struct ncp_conn_args *, int *);
115 int ncp_connect_addr(struct sockaddr *, NWCONN_HANDLE *);
116 int ncp_disconnect(int);
117 int ncp_request(int, int, struct ncp_buf *);
118 int ncp_conn_request(int, struct ncp_buf *);
119 int ncp_login(int, const char *, int, const char *);
120 int ncp_conn_scan(struct ncp_conn_loginfo *, int *);
121 int ncp_conn_cnt(void);
122 void *ncp_conn_list(void);
123 int ncp_conn_getinfo(int, struct ncp_conn_stat *);
124 int ncp_conn_getuser(int, char **);
125 int ncp_conn2ref(int, int *);
126 int ncp_conn_dup(NWCONN_HANDLE, NWCONN_HANDLE *);
127 int ncp_path2conn(char *, int *);
128 int ncp_li_init(struct ncp_conn_loginfo *, int, char *[]);
129 void ncp_li_done(struct ncp_conn_loginfo *);
130 int ncp_li_login(struct ncp_conn_loginfo *, int *);
131 int ncp_li_readrc(struct ncp_conn_loginfo *);
132 int ncp_li_check(struct ncp_conn_loginfo *);
133 int ncp_li_arg(struct ncp_conn_loginfo *, int, char *);
134 int ncp_li_setserver(struct ncp_conn_loginfo *, const char *);
135 int ncp_li_setuser(struct ncp_conn_loginfo *, char *);
136 int ncp_li_setpassword(struct ncp_conn_loginfo *, const char *);
137 int ncp_conn_setflags(int, u_int16_t, u_int16_t);
138 int ncp_conn_find(char *, char *);
139 NWCCODE NWRequest(NWCONN_HANDLE, nuint16, nuint16, NW_FRAGMENT *,
140 nuint16, NW_FRAGMENT *);
141
142 #define ncp_setpermanent(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PERMANENT, (on) ? NCPFL_PERMANENT : 0)
143 #define ncp_setprimary(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PRIMARY, (on) ? NCPFL_PRIMARY : 0)
144
145 int ncp_find_fileserver(struct ncp_conn_loginfo *, int, char *);
146 int ncp_find_server(struct ncp_conn_loginfo *, int, int, char *);
147
148 /* misc rotines */
149 char* ncp_str_upper(char *);
150 int ncp_open_rcfile(void);
151 int ncp_getopt(int, char * const *, const char *);
152 void NWUnpackDateTime(nuint32, NW_DATE *, NW_TIME *);
153 void NWUnpackDate(nuint16, NW_DATE *);
154 void NWUnpackTime(nuint16, NW_TIME *);
155 time_t ncp_UnpackDateTime(nuint32);
156 int ncp_GetFileServerDateAndTime(NWCONN_HANDLE, time_t *);
157 int ncp_SetFileServerDateAndTime(NWCONN_HANDLE, time_t *);
158 NWCCODE NWDownFileServer(NWCONN_HANDLE, int);
159 NWCCODE NWCloseBindery(NWCONN_HANDLE);
160 NWCCODE NWOpenBindery(NWCONN_HANDLE);
161 NWCCODE NWDisableTTS(NWCONN_HANDLE);
162 NWCCODE NWEnableTTS(NWCONN_HANDLE);
163 NWCCODE NWDisableFileServerLogin(NWCONN_HANDLE);
164 NWCCODE NWEnableFileServerLogin(NWCONN_HANDLE);
165 void ncp_error(const char *, int, ...) __printf0like(1, 3);
166 char *ncp_printb(char *, int, const struct ncp_bitname *);
167 void nw_keyhash(const u_char *, const u_char *, int, u_char *);
168 void nw_encrypt(const u_char *, const u_char *, u_char *);
169 void ipx_print_addr(struct ipx_addr *);
170
171 /* bindery calls */
172 int ncp_get_bindery_object_id(NWCONN_HANDLE, u_int16_t, const char *,
173 struct ncp_bindery_object *);
174 int ncp_get_bindery_object_name(NWCONN_HANDLE, u_int32_t,
175 struct ncp_bindery_object *);
176 int ncp_scan_bindery_object(NWCONN_HANDLE, u_int32_t, u_int16_t,
177 char *, struct ncp_bindery_object *);
178 int ncp_read_property_value(NWCONN_HANDLE, int object_type, const char *,
179 int, const char *, struct nw_property *);
180 int ncp_get_encryption_key(NWCONN_HANDLE, char *);
181 int ncp_change_obj_passwd(NWCONN_HANDLE,
182 const struct ncp_bindery_object *, const u_char *,
183 const u_char *, const u_char *);
184 int ncp_keyed_verify_password(NWCONN_HANDLE, char *, char *,
185 struct ncp_bindery_object *);
186
187 /* queue calls */
188 int ncp_create_queue_job_and_file(NWCONN_HANDLE, u_int32_t, struct queue_job *);
189 int ncp_close_file_and_start_job(NWCONN_HANDLE, u_int32_t, struct queue_job *);
190 int ncp_attach_to_queue(NWCONN_HANDLE, u_int32_t);
191 int ncp_detach_from_queue(NWCONN_HANDLE, u_int32_t);
192 int ncp_service_queue_job(NWCONN_HANDLE, u_int32_t, u_int16_t,
193 struct queue_job *);
194 int ncp_finish_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t, u_int32_t);
195 int ncp_abort_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t);
196 int ncp_get_queue_length(NWCONN_HANDLE, u_int32_t, u_int32_t *);
197 int ncp_get_queue_job_ids(NWCONN_HANDLE, u_int32_t, u_int32_t,
198 u_int32_t *, u_int32_t *, u_int32_t []);
199 int ncp_get_queue_job_info(NWCONN_HANDLE, u_int32_t, u_int32_t,
200 struct nw_queue_job_entry *);
201 /*
202 * filesystem and volume calls
203 */
204 int ncp_read(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *);
205 int ncp_write(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *);
206 int ncp_geteinfo(char *, struct nw_entry_info *);
207 int ncp_NSEntryInfo(NWCONN_HANDLE, nuint8, nuint8, nuint32, NW_ENTRY_INFO *);
208
209 NWCCODE NWGetVolumeName(NWCONN_HANDLE, u_char, char *);
210
211 /* misc ncp calls */
212 int ncp_get_file_server_information(NWCONN_HANDLE, struct ncp_file_server_info *);
213 int ncp_get_stations_logged_info(NWCONN_HANDLE, u_int32_t,
214 struct ncp_bindery_object *, time_t *);
215 int ncp_get_internet_address(NWCONN_HANDLE, u_int32_t, struct ipx_addr *,
216 u_int8_t *);
217 NWCCODE NWGetObjectConnectionNumbers(NWCONN_HANDLE, pnstr8, nuint16,
218 pnuint16, pnuint16, nuint16);
219 /*
220 * Message broadcast
221 */
222 NWCCODE NWDisableBroadcasts(NWCONN_HANDLE);
223 NWCCODE NWEnableBroadcasts(NWCONN_HANDLE);
224 NWCCODE NWBroadcastToConsole(NWCONN_HANDLE, pnstr8);
225 NWCCODE NWSendBroadcastMessage(NWCONN_HANDLE, pnstr8, nuint16, pnuint16, pnuint8);
226 NWCCODE NWGetBroadcastMessage(NWCONN_HANDLE, pnstr8);
227
228 /*
229 * RPC calls
230 */
231 NWCCODE NWSMExecuteNCFFile(NWCONN_HANDLE, pnstr8);
232 NWCCODE NWSMLoadNLM(NWCONN_HANDLE, pnstr8);
233 NWCCODE NWSMUnloadNLM(NWCONN_HANDLE, pnstr8);
234 NWCCODE NWSMMountVolume(NWCONN_HANDLE, pnstr8, nuint32 *);
235 NWCCODE NWSMDismountVolumeByName(NWCONN_HANDLE, pnstr8);
236 NWCCODE NWSMSetDynamicCmdIntValue(NWCONN_HANDLE, pnstr8, nuint32);
237 NWCCODE NWSMSetDynamicCmdStrValue(NWCONN_HANDLE, pnstr8, pnstr8);
238
239 __END_DECLS
240
241 extern int ncp_opterr, ncp_optind, ncp_optopt, ncp_optreset;
242 extern char *ncp_optarg;
243
244 extern struct rcfile *ncp_rc;
245 extern int sysentoffset;
246 #endif /* _NETNCP_NCP_LIB_H_ */
Cache object: 382883e912df865f5b270c73b57d7dfb
|