ReactOS 0.4.15-dev-7961-gdcf9eb0
netconfig.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  netconfig
 
struct  NCONF_HANDLE
 

Macros

#define NETCONFIG   "C:\\ReactOS\\System32\\drivers\\etc\\netconfig"
 
#define NETPATH   "NETPATH"
 
#define NC_TPI_CLTS   1
 
#define NC_TPI_COTS   2
 
#define NC_TPI_COTS_ORD   3
 
#define NC_TPI_RAW   4
 
#define NC_NOFLAG   0x00
 
#define NC_VISIBLE   0x01
 
#define NC_BROADCAST   0x02
 
#define NC_NOPROTOFMLY   "-"
 
#define NC_LOOPBACK   "loopback"
 
#define NC_INET   "inet"
 
#define NC_INET6   "inet6"
 
#define NC_IMPLINK   "implink"
 
#define NC_PUP   "pup"
 
#define NC_CHAOS   "chaos"
 
#define NC_NS   "ns"
 
#define NC_NBS   "nbs"
 
#define NC_ECMA   "ecma"
 
#define NC_DATAKIT   "datakit"
 
#define NC_CCITT   "ccitt"
 
#define NC_SNA   "sna"
 
#define NC_DECNET   "decnet"
 
#define NC_DLI   "dli"
 
#define NC_LAT   "lat"
 
#define NC_HYLINK   "hylink"
 
#define NC_APPLETALK   "appletalk"
 
#define NC_NIT   "nit"
 
#define NC_IEEE802   "ieee802"
 
#define NC_OSI   "osi"
 
#define NC_X25   "x25"
 
#define NC_OSINET   "osinet"
 
#define NC_GOSIP   "gosip"
 
#define NC_NOPROTO   "-"
 
#define NC_TCP   "tcp"
 
#define NC_UDP   "udp"
 
#define NC_ICMP   "icmp"
 

Functions

__BEGIN_DECLS voidsetnetconfig (void)
 
struct netconfiggetnetconfig (void *)
 
struct netconfiggetnetconfigent (const char *)
 
void freenetconfigent (struct netconfig *)
 
int endnetconfig (void *)
 
voidsetnetpath (void)
 
struct netconfiggetnetpath (void *)
 
int endnetpath (void *)
 
void nc_perror (const char *)
 
charnc_sperror (void)
 

Macro Definition Documentation

◆ NC_APPLETALK

#define NC_APPLETALK   "appletalk"

Definition at line 67 of file netconfig.h.

◆ NC_BROADCAST

#define NC_BROADCAST   0x02

Definition at line 45 of file netconfig.h.

◆ NC_CCITT

#define NC_CCITT   "ccitt"

Definition at line 61 of file netconfig.h.

◆ NC_CHAOS

#define NC_CHAOS   "chaos"

Definition at line 56 of file netconfig.h.

◆ NC_DATAKIT

#define NC_DATAKIT   "datakit"

Definition at line 60 of file netconfig.h.

◆ NC_DECNET

#define NC_DECNET   "decnet"

Definition at line 63 of file netconfig.h.

◆ NC_DLI

#define NC_DLI   "dli"

Definition at line 64 of file netconfig.h.

◆ NC_ECMA

#define NC_ECMA   "ecma"

Definition at line 59 of file netconfig.h.

◆ NC_GOSIP

#define NC_GOSIP   "gosip"

Definition at line 73 of file netconfig.h.

◆ NC_HYLINK

#define NC_HYLINK   "hylink"

Definition at line 66 of file netconfig.h.

◆ NC_ICMP

#define NC_ICMP   "icmp"

Definition at line 81 of file netconfig.h.

◆ NC_IEEE802

#define NC_IEEE802   "ieee802"

Definition at line 69 of file netconfig.h.

◆ NC_IMPLINK

#define NC_IMPLINK   "implink"

Definition at line 54 of file netconfig.h.

◆ NC_INET

#define NC_INET   "inet"

Definition at line 52 of file netconfig.h.

◆ NC_INET6

#define NC_INET6   "inet6"

Definition at line 53 of file netconfig.h.

◆ NC_LAT

#define NC_LAT   "lat"

Definition at line 65 of file netconfig.h.

◆ NC_LOOPBACK

#define NC_LOOPBACK   "loopback"

Definition at line 51 of file netconfig.h.

◆ NC_NBS

#define NC_NBS   "nbs"

Definition at line 58 of file netconfig.h.

◆ NC_NIT

#define NC_NIT   "nit"

Definition at line 68 of file netconfig.h.

◆ NC_NOFLAG

#define NC_NOFLAG   0x00

Definition at line 43 of file netconfig.h.

◆ NC_NOPROTO

#define NC_NOPROTO   "-"

Definition at line 78 of file netconfig.h.

◆ NC_NOPROTOFMLY

#define NC_NOPROTOFMLY   "-"

Definition at line 50 of file netconfig.h.

◆ NC_NS

#define NC_NS   "ns"

Definition at line 57 of file netconfig.h.

◆ NC_OSI

#define NC_OSI   "osi"

Definition at line 70 of file netconfig.h.

◆ NC_OSINET

#define NC_OSINET   "osinet"

Definition at line 72 of file netconfig.h.

◆ NC_PUP

#define NC_PUP   "pup"

Definition at line 55 of file netconfig.h.

◆ NC_SNA

#define NC_SNA   "sna"

Definition at line 62 of file netconfig.h.

◆ NC_TCP

#define NC_TCP   "tcp"

Definition at line 79 of file netconfig.h.

◆ NC_TPI_CLTS

#define NC_TPI_CLTS   1

Definition at line 35 of file netconfig.h.

◆ NC_TPI_COTS

#define NC_TPI_COTS   2

Definition at line 36 of file netconfig.h.

◆ NC_TPI_COTS_ORD

#define NC_TPI_COTS_ORD   3

Definition at line 37 of file netconfig.h.

◆ NC_TPI_RAW

#define NC_TPI_RAW   4

Definition at line 38 of file netconfig.h.

◆ NC_UDP

#define NC_UDP   "udp"

Definition at line 80 of file netconfig.h.

◆ NC_VISIBLE

#define NC_VISIBLE   0x01

Definition at line 44 of file netconfig.h.

◆ NC_X25

#define NC_X25   "x25"

Definition at line 71 of file netconfig.h.

◆ NETCONFIG

#define NETCONFIG   "C:\\ReactOS\\System32\\drivers\\etc\\netconfig"

Definition at line 11 of file netconfig.h.

◆ NETPATH

#define NETPATH   "NETPATH"

Definition at line 13 of file netconfig.h.

Function Documentation

◆ endnetconfig()

int endnetconfig ( void handlep)

Definition at line 373 of file getnetconfig.c.

375{
376 struct netconfig_vars *nc_handlep = (struct netconfig_vars *)handlep;
377
378 struct netconfig_list *q, *p;
379
380 /*
381 * Verify that handle is valid
382 */
383 if (nc_handlep == NULL || (nc_handlep->valid != NC_VALID &&
384 nc_handlep->valid != NC_STORAGE)) {
386 return (-1);
387 }
388
389 /*
390 * Return 0 if anyone still needs it.
391 */
392 nc_handlep->valid = NC_INVALID;
393 nc_handlep->flag = 0;
394 nc_handlep->nc_configs = NULL;
395 if (--ni.ref > 0) {
396 free(nc_handlep);
397 return(0);
398 }
399
400 /*
401 * Noone needs these entries anymore, then frees them.
402 * Make sure all info in netconfig_info structure has been reinitialized.
403 */
404 q = p = ni.head;
405 ni.eof = ni.ref = 0;
406 ni.head = NULL;
407 ni.tail = NULL;
408 while (q) {
409 p = q->next;
410 if (q->ncp->nc_lookups != NULL) free(q->ncp->nc_lookups);
411 free(q->ncp);
412 free(q->linep);
413 free(q);
414 q = p;
415 }
416 free(nc_handlep);
417
419 nc_file = NULL;
420 return (0);
421}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define NC_VALID
Definition: getnetconfig.c:147
#define NC_STORAGE
Definition: getnetconfig.c:148
#define NC_NOTINIT
Definition: getnetconfig.c:96
#define nc_error
Definition: getnetconfig.c:196
static FILE * nc_file
Definition: getnetconfig.c:157
#define NC_INVALID
Definition: getnetconfig.c:149
static struct netconfig_info ni
Definition: getnetconfig.c:158
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
struct define * next
Definition: compiler.c:65
struct netconfig_list * nc_configs
Definition: getnetconfig.c:144

Referenced by __rpc_endconf(), __rpc_getconfip(), __rpcbind_is_up(), _des_crypt_call(), endnetpath(), getkeyserv_handle(), local_rpcb(), and setnetpath().

◆ endnetpath()

int endnetpath ( void handlep)

Definition at line 191 of file getnetpath.c.

193{
194 struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep;
195 struct netpath_chain *chainp, *lastp;
196
197 if (np_sessionp == NULL || np_sessionp->valid != NP_VALID) {
198 errno = EINVAL;
199 return (-1);
200 }
201 if (np_sessionp->nc_handlep != NULL)
202 endnetconfig(np_sessionp->nc_handlep);
203 if (np_sessionp->netpath_start != NULL)
204 free(np_sessionp->netpath_start);
205 for (chainp = np_sessionp->ncp_list; chainp != NULL;
206 lastp=chainp, chainp=chainp->nchain_next, free(lastp)) {
207 freenetconfigent(chainp->ncp);
208 }
209 free(np_sessionp);
210#ifdef MEM_CHK
211 if (malloc_verify() == 0) {
212 fprintf(stderr, "memory heap corrupted in endnetpath\n");
213 exit(1);
214 }
215#endif
216 return (0);
217}
#define EINVAL
Definition: acclib.h:90
void freenetconfigent(struct netconfig *netconfigp)
Definition: getnetconfig.c:530
int endnetconfig(void *handlep)
Definition: getnetconfig.c:373
#define NP_VALID
Definition: getnetpath.c:60
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define errno
Definition: errno.h:18
#define exit(n)
Definition: config.h:202
struct netconfig * ncp
Definition: getnetpath.c:47
struct netpath_chain * nchain_next
Definition: getnetpath.c:48
char * netpath_start
Definition: getnetpath.c:56
struct netpath_chain * ncp_list
Definition: getnetpath.c:57
void * nc_handlep
Definition: getnetpath.c:54

Referenced by __rpc_endconf().

◆ freenetconfigent()

void freenetconfigent ( struct netconfig netconfigp)

Definition at line 530 of file getnetconfig.c.

532{
533 if (netconfigp != NULL) {
534 free(netconfigp->nc_netid); /* holds all netconfigp's strings */
535 if (netconfigp->nc_lookups != NULL)
536 free(netconfigp->nc_lookups);
537 free(netconfigp);
538 }
539 return;
540}
char * nc_netid
Definition: netconfig.h:16
char ** nc_lookups
Definition: netconfig.h:23

Referenced by __rpc_sockinfo2netid(), __rpcb_findaddr_timed(), cache_get(), cache_set(), endnetpath(), get_client_for_netaddr(), nfs41_server_resolve(), pmap_set(), pmap_unset(), and svc_reg().

◆ getnetconfig()

struct netconfig * getnetconfig ( void handlep)

Definition at line 253 of file getnetconfig.c.

255{
256 struct netconfig_vars *ncp = (struct netconfig_vars *)handlep;
257 char *stringp; /* tmp string pointer */
258 struct netconfig_list *list;
259 struct netconfig *np;
260
261 /*
262 * Verify that handle is valid
263 */
264 if (ncp == NULL || nc_file == NULL) {
266 return (NULL);
267 }
268
269 switch (ncp->valid) {
270 case NC_VALID:
271 /*
272 * If entry has already been read into the list,
273 * we return the entry in the linked list.
274 * If this is the first time call, check if there are any entries in
275 * linked list. If no entries, we need to read the netconfig db.
276 * If we have been here and the next entry is there, we just return
277 * it.
278 */
279 if (ncp->flag == 0) { /* first time */
280 ncp->flag = 1;
281 ncp->nc_configs = ni.head;
282 if (ncp->nc_configs != NULL) /* entry already exist */
283 return(ncp->nc_configs->ncp);
284 }
285 else if (ncp->nc_configs != NULL && ncp->nc_configs->next != NULL) {
286 ncp->nc_configs = ncp->nc_configs->next;
287 return(ncp->nc_configs->ncp);
288 }
289
290 /*
291 * If we cannot find the entry in the list and is end of file,
292 * we give up.
293 */
294 if (ni.eof == 1)
295 return(NULL);
296 break;
297 default:
299 return (NULL);
300 }
301
302 stringp = (char *) malloc(MAXNETCONFIGLINE);
303 if (stringp == NULL)
304 return (NULL);
305
306#ifdef MEM_CHK
307 if (malloc_verify() == 0) {
308 fprintf(stderr, "memory heap corrupted in getnetconfig\n");
309 exit(1);
310 }
311#endif
312
313 /*
314 * Read a line from netconfig file.
315 */
316 do {
317 if (fgets(stringp, MAXNETCONFIGLINE, nc_file) == NULL) {
318 free(stringp);
319 ni.eof = 1;
320 return (NULL);
321 }
322 } while (*stringp == '#');
323
324 list = (struct netconfig_list *) malloc(sizeof (struct netconfig_list));
325 if (list == NULL) {
326 free(stringp);
327 return(NULL);
328 }
329 np = (struct netconfig *) malloc(sizeof (struct netconfig));
330 if (np == NULL) {
331 free(stringp);
332 free(list);
333 return(NULL);
334 }
335 list->ncp = np;
336 list->next = NULL;
337 list->ncp->nc_lookups = NULL;
338 list->linep = stringp;
339 wintirpc_debug("%s: before parse: &list->linep %p, list->linep %p, stringp %p\n", __FUNCTION__, &list->linep, list->linep, stringp);
340 if (parse_ncp(stringp, list->ncp) == -1) {
341 free(stringp);
342 free(np);
343 free(list);
344 return (NULL);
345 } else {
346 wintirpc_debug("%s: after parse: list->linep %p, stringp %p\n", __FUNCTION__, list->linep, stringp);
347 /*
348 * If this is the first entry that's been read, it is the head of
349 * the list. If not, put the entry at the end of the list.
350 * Reposition the current pointer of the handle to the last entry
351 * in the list.
352 */
353 if (ni.head == NULL) { /* first entry */
354 ni.head = ni.tail = list;
355 }
356 else {
357 ni.tail->next = list;
358 ni.tail = ni.tail->next;
359 }
360 ncp->nc_configs = ni.tail;
361 return(ni.tail->ncp);
362 }
363}
Definition: list.h:37
struct list * next
Definition: list.h:38
#define malloc
Definition: debug_ros.c:4
#define __FUNCTION__
Definition: types.h:116
#define MAXNETCONFIGLINE
Definition: getnetconfig.c:160
static void wintirpc_debug(char *fmt,...)
Definition: getnetconfig.c:49
static int parse_ncp(char *, struct netconfig *)
Definition: getnetconfig.c:555
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
#define list
Definition: rosglue.h:35

Referenced by __rpc_getconf(), __rpc_getconfip(), __rpcbind_is_up(), _des_crypt_call(), getkeyserv_handle(), getnetpath(), and local_rpcb().

◆ getnetconfigent()

struct netconfig * getnetconfigent ( const char )

◆ getnetpath()

struct netconfig * getnetpath ( void handlep)

Definition at line 134 of file getnetpath.c.

136{
137 struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep;
138 struct netconfig *ncp = NULL; /* temp. holds a netconfig session */
139 struct netpath_chain *chainp; /* holds chain of ncp's we alloc */
140 char *npp; /* holds current NETPATH */
141
142 if (np_sessionp == NULL || np_sessionp->valid != NP_VALID) {
143 errno = EINVAL;
144 return (NULL);
145 }
146 if (np_sessionp->netpath_start == NULL) { /* NETPATH was not set */
147 do { /* select next visible network */
148 if (np_sessionp->nc_handlep == NULL) {
149 np_sessionp->nc_handlep = setnetconfig();
150 if (np_sessionp->nc_handlep == NULL) {
151 //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
152 }
153 }
154 if ((ncp = getnetconfig(np_sessionp->nc_handlep)) == NULL) {
155 return(NULL);
156 }
157 } while ((ncp->nc_flag & NC_VISIBLE) == 0);
158 return (ncp);
159 }
160 /*
161 * Find first valid network ID in netpath.
162 */
163 while ((npp = np_sessionp->netpath) != NULL && strlen(npp) != 0) {
164 np_sessionp->netpath = _get_next_token(npp, ':');
165 /*
166 * npp is a network identifier.
167 */
168 if ((ncp = getnetconfigent(npp)) != NULL) {
169 chainp = (struct netpath_chain *) /* cobble alloc chain entry */
170 malloc(sizeof (struct netpath_chain));
171 chainp->ncp = ncp;
172 chainp->nchain_next = NULL;
173 if (np_sessionp->ncp_list == NULL) {
174 np_sessionp->ncp_list = chainp;
175 } else {
176 np_sessionp->ncp_list->nchain_next = chainp;
177 }
178 return (ncp);
179 }
180 /* couldn't find this token in the database; go to next one. */
181 }
182 return (NULL);
183}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct netconfig * getnetconfigent(char *netid) const
Definition: getnetconfig.c:432
struct netconfig * getnetconfig(void *handlep)
Definition: getnetconfig.c:253
void * setnetconfig()
Definition: getnetconfig.c:217
char * _get_next_token(char *, int)
Definition: getnetpath.c:228
#define NC_VISIBLE
Definition: netconfig.h:44
char * netpath
Definition: getnetpath.c:55

Referenced by __rpc_getconf().

◆ nc_perror()

void nc_perror ( const char )

◆ nc_sperror()

char * nc_sperror ( void  )

Definition at line 648 of file getnetconfig.c.

649{
650 const char *message;
651
652 switch(nc_error) {
653 case NC_NONETCONFIG:
654 message = _nc_errors[0];
655 break;
656 case NC_NOMEM:
657 message = _nc_errors[1];
658 break;
659 case NC_NOTINIT:
660 message = _nc_errors[2];
661 break;
662 case NC_BADFILE:
663 message = _nc_errors[3];
664 break;
665 case NC_NOTFOUND:
666 message = _nc_errors[4];
667 break;
668 default:
669 message = "Unknown network selection error";
670 }
671 /* LINTED const castaway */
672 return ((char *)message);
673}
#define NC_BADFILE
Definition: getnetconfig.c:97
#define NC_NONETCONFIG
Definition: getnetconfig.c:94
#define NC_NOTFOUND
Definition: getnetconfig.c:98
#define NC_NOMEM
Definition: getnetconfig.c:95
static const char *const _nc_errors[]
Definition: getnetconfig.c:120
Definition: tftpd.h:60

Referenced by nc_perror().

◆ setnetconfig()

__BEGIN_DECLS void * setnetconfig ( void  )

Definition at line 217 of file getnetconfig.c.

218{
219 struct netconfig_vars *nc_vars;
220
221 if ((nc_vars = (struct netconfig_vars *)malloc(sizeof
222 (struct netconfig_vars))) == NULL) {
223 return(NULL);
224 }
225
226 /*
227 * For multiple calls, i.e. nc_file is not NULL, we just return the
228 * handle without reopening the netconfig db.
229 */
230 ni.ref++;
231 if ((nc_file != NULL) || (nc_file = fopen(NETCONFIG, "r")) != NULL) {
232 nc_vars->valid = NC_VALID;
233 nc_vars->flag = 0;
234 nc_vars->nc_configs = ni.head;
235 return ((void *)nc_vars);
236 }
237 ni.ref--;
239 free(nc_vars);
240 return (NULL);
241}
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define NETCONFIG
Definition: netconfig.h:11

Referenced by __rpc_getconfip(), __rpc_setconf(), __rpcbind_is_up(), _des_crypt_call(), getkeyserv_handle(), getnetpath(), local_rpcb(), and setnetpath().

◆ setnetpath()

void * setnetpath ( void  )

Definition at line 78 of file getnetpath.c.

79{
80
81 struct netpath_vars *np_sessionp; /* this session's variables */
82 char *npp; /* NETPATH env variable */
83
84#ifdef MEM_CHK
85 malloc_debug(1);
86#endif
87
88 if ((np_sessionp =
89 (struct netpath_vars *)malloc(sizeof (struct netpath_vars))) == NULL) {
90 return (NULL);
91 }
92 if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) {
93 //syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
94 return (NULL);
95 }
96 np_sessionp->valid = NP_VALID;
97 np_sessionp->ncp_list = NULL;
98 if ((npp = getenv(NETPATH)) == NULL) {
99 np_sessionp->netpath = NULL;
100 } else {
101 (void) endnetconfig(np_sessionp->nc_handlep);/* won't need nc session*/
102 np_sessionp->nc_handlep = NULL;
103 if ((np_sessionp->netpath = malloc(strlen(npp)+1)) == NULL) {
104 free(np_sessionp);
105 return (NULL);
106 } else {
107 (void) strcpy(np_sessionp->netpath, npp);
108 }
109 }
110 np_sessionp->netpath_start = np_sessionp->netpath;
111 return ((void *)np_sessionp);
112}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define NETPATH
Definition: netconfig.h:13

Referenced by __rpc_setconf().