Network Developers Kit API  3.76.00.05
netcfg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2019, Texas Instruments Incorporated
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  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * */
32 /*
33  * ======== netcfg.h ========
34  *
35  * Standard Configuration Structures
36  *
37  * Although the Configuration functions are generic, NETTOOLS expects
38  * to be able to access a configuration with certain pre-defined
39  * configuration tags.
40  *
41  * If a system needs to use the Service functions of NetTools, it must
42  * provide service providers to implement the configuration specification
43  * defined here.
44  *
45  */
52 #ifndef _C_NETCFG_INC
53 #define _C_NETCFG_INC
54 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /* Note: *** Default Configuration Handle Required *** */
63 /* NetTools uses the default configuration handle for things like */
64 /* DHCP client, DHCP server, DNS, etc.. This handle should be */
65 /* set by calling CfgSetDefault() before using NetTools */
66 
67 /*--------------------------------------------------------------------------- */
68 /* Defined Configuration Tags */
69 /*--------------------------------------------------------------------------- */
70 #define CFGTAG_OS 0x0001
71 #define CFGTAG_IP 0x0002
72 #define CFGTAG_SERVICE 0x0003
73 #define CFGTAG_IPNET 0x0004
74 #define CFGTAG_ROUTE 0x0005
75 #define CFGTAG_CLIENT 0x0006
76 #define CFGTAG_SYSINFO 0x0007
77 #define CFGTAG_ACCT 0x0008
86 #define CFGTAG_MAX 0x0010
87 
88 /*--------------------------------------------------------------------------- */
89 /* Configuration Item Values and Entry Data by Tag Value */
90 /*--------------------------------------------------------------------------- */
91 
92 /*--------------------------------------------------------------------------- */
93 /* Config Tag: CFGTAG_SERVICE */
94 /* List of active services */
95 /* Item = Service Type */
96 /* Instance = Service Instance (1 to max) */
97 /* *** USERS CAN ADD THEIR OWN SERVICE ITEM VALUES *** */
98 #define CFGITEM_SERVICE_TELNET 0x0001
99 #define CFGITEM_SERVICE_RESERVED1 0x0002 /* was HTTP */
100 #define CFGITEM_SERVICE_NAT 0x0003
101 #define CFGITEM_SERVICE_DHCPSERVER 0x0004
102 #define CFGITEM_SERVICE_DHCPCLIENT 0x0005
103 #define CFGITEM_SERVICE_DNSSERVER 0x0006
104 #define CFGITEM_SERVICE_MAX 0x0006
105 
111 typedef struct _ci_srvargs {
119  uint32_t Item;
120 
129  void *hService;
130 
152  uint32_t Mode;
153 #define CIS_FLG_IFIDXVALID 0x0001 /* IfIdx field is supplied to CONFIG */
154 #define CIS_FLG_RESOLVEIP 0x0002 /* Resolve If to IP before execution */
155 #define CIS_FLG_CALLBYIP 0x0004 /* Call using IP (set w/RESOLVEIP) */
156 #define CIS_FLG_RESTARTIPTERM 0x0008 /* Restart serivce on IPTERM */
157 
172  uint32_t Status;
173 #define CIS_SRV_STATUS_DISABLED 0x0000 /* Config not active */
174 #define CIS_SRV_STATUS_WAIT 0x0001 /* Waiting on IP resolve */
175 #define CIS_SRV_STATUS_IPTERM 0x0002 /* Service terminated via IP synch */
176 #define CIS_SRV_STATUS_FAILED 0x0003 /* Service failed to initialize */
177 #define CIS_SRV_STATUS_ENABLED 0x0004 /* Service enabled */
178 
188  uint32_t ReportCode;
189 
200  uint32_t IfIdx;
201 
211  uint32_t IPAddr;
212 
228  void(*pCbSrv)(uint32_t Item, uint32_t Status, uint32_t Code,
229  void *hCfgEntry);
230 } CISARGS;
235 typedef struct _ci_service_telnet {
243 typedef struct _ci_service_nat {
245  NTPARAM_NAT param;
251 typedef struct _ci_service_dhcps {
252  CISARGS cisargs; /* Common arguments */
253  NTPARAM_DHCPS param; /* DHCPS parameters */
259 typedef struct _ci_service_dhcpc {
260  CISARGS cisargs; /* Common arguments */
261  NTPARAM_DHCP param; /* DHCP parameters */
267 typedef struct _ci_service_dnss {
268  CISARGS cisargs; /* Common arguments */
275 /*--------------------------------------------------------------------------- */
276 /* Config Tag: CFGTAG_IPNET */
277 /* IP networks assigned to physical devices */
278 /* Item = Physical Interface Idx (1 to n) */
279 /* Instance = Address Instance (1 to n) */
280 
281 /* Max IPNet Domain name Length - Change requires NETTOOLS rebuild */
282 #define CFG_DOMAIN_MAX 64
283 
284 /* IPNet Instance */
285 typedef struct _ci_ipnet {
286  uint32_t NetType; /* Network address type flags */
287  uint32_t IPAddr; /* IP Address */
288  uint32_t IPMask; /* Subnet Mask */
289  void *hBind; /* Binding handle (resets to NULL) */
290  char Domain[CFG_DOMAIN_MAX]; /* IPNet Domain Name */
291  } CI_IPNET;
292 
293 /* NetType consists of flags. One or more of the following can be set... */
294 /* Note: VIRTUAL and non-VIRTUAL networks can not appear on the same interface */
295 #define CFG_NETTYPE_DYNAMIC 0x0001 /* Address created by DHCP CLIENT */
296 #define CFG_NETTYPE_VIRTUAL 0x0002 /* Virtual (one per IF) */
297 #define CFG_NETTYPE_DHCPS 0x0004 /* DHCPS Server IP */
298 
299 /*--------------------------------------------------------------------------- */
300 /* Config Tag: CFGTAG_ROUTE */
301 /* Static Gateway routes for hosts and networks */
302 /* Item = 0 */
303 /* Instance = Route instance index (1 to n) */
304 
305 /* Route Instance */
306 typedef struct _ci_route {
307  uint32_t IPDestAddr; /* Destination Network Address */
308  uint32_t IPDestMask; /* Subnet Mask of Destination */
309  uint32_t IPGateAddr; /* Gateway IP Address */
310  void *hRoute; /* Route handle (resets to NULL) */
311  } CI_ROUTE;
312 
313 /*--------------------------------------------------------------------------- */
314 /* Config Tag: CFGTAG_CLIENT */
315 /* List of DHCPS clients by manual entry or allocation from pool */
316 /* Item = Physical Interface Idx (1 to n) */
317 /* Instance = Client Address Instance (1 to n) */
318 /* Used by DHCPS and DNS server for local name resolution */
319 
320 /* Client Instance */
321 
322 /*
323  * Maximum size for DHCP client host name.
324  *
325  * *** NOTE: changing this value requires a rebuild of NETTOOLS! ***
326  *
327  * NOTE: The client hostname size is actually governed by 2 definitions:
328  * 1) CFG_HOSTNAME_MAX (defined in netcfg.h)
329  * 2) HOSTNAME_LENGTH (defined in dhcp.h)
330  * These two values must be consistent! If one is changed, both must be
331  * changed.
332  *
333  * RFC 2131 and 2132 do not clearly specify what the maximum size for this
334  * value should be. 255 was determined based on MSDN "Host Name Resolution for
335  * IPv4" on Microsoft's website (the size is 255 + 1 to make room for "\0").
336  * See notes for fix of CQ15114 for more details.
337  *
338  */
339 #define CFG_HOSTNAME_MAX 256
340 
341 typedef struct _ci_client {
342  uint32_t ClientType; /* Entry Status */
343  uint32_t Status; /* DHCPS Status (init to ZERO) */
344  uint32_t IPAddr; /* Client IP Address */
345  char MacAddr[6]; /* Client Physical Address */
346  char Hostname[CFG_HOSTNAME_MAX]; /* Client Hostname */
347  uint32_t TimeStatus; /* Time of last status msg (REQ/DEC/INF) */
348  uint32_t TimeExpire; /* Expiration Time from TimeStatus */
349  } CI_CLIENT;
350 
351 /* ClientType and ClientStatus are values and can be one of the following... */
352 #define CFG_CLIENTTYPE_DYNAMIC 1 /* Entry created via DHCPS */
353 #define CFG_CLIENTTYPE_STATIC 2 /* Create manually */
354 
355 #define CFG_CLIENTSTATUS_PENDING 1 /* Supplied by OFFER */
356 #define CFG_CLIENTSTATUS_VALID 2 /* Validated by REQUEST */
357 #define CFG_CLIENTSTATUS_STATIC 3 /* Given by a INFORM */
358 #define CFG_CLIENTSTATUS_INVALID 4 /* Invalidated by DECLINE */
359 
360 /*--------------------------------------------------------------------------- */
361 /* Config Tag: CFGTAG_ACCT */
362 /* List of user accounts for PPP or similar login */
363 /* Item = 1 for PPP or REALM */
364 /* Instance = Client Address Instance (1 to n) */
365 /* Used by PPP in server mode for authentication */
366 /* Used by file system for REALM authentication */
367 /* * Note all NDK accounts use the the same "item" value * */
368 
369 /* Account Item Types */
370 #define CFGITEM_ACCT_SYSTEM 1
371 #define CFGITEM_ACCT_PPP 1
372 #define CFGITEM_ACCT_REALM 1
373 
374 #define CFG_ACCTSTR_MAX 32
375 
376 /* Account Instance */
377 typedef struct _ci_acct {
378  uint32_t Flags; /* Account Flags */
379  char Username[CFG_ACCTSTR_MAX]; /* Username */
380  char Password[CFG_ACCTSTR_MAX]; /* Password */
381  } CI_ACCT;
382 
383 /* Authority consists of flags. One or more of the following can be set... */
384 #define CFG_ACCTFLG_CH1 0x1000
385 #define CFG_ACCTFLG_CH2 0x2000
386 #define CFG_ACCTFLG_CH3 0x4000
387 #define CFG_ACCTFLG_CH4 0x8000
388 #define CFG_ACCTFLG_CHALL 0xF000
389 
390 /*--------------------------------------------------------------------------- */
391 /* Config Tag: CFGTAG_SYSINFO */
392 /* System information */
393 /* This tag is for system information that is common for all system */
394 /* tasks (DNS server, hostname, domainname, etc.). */
395 /* Tag values less than 256 are reserved for DHCP */
396 /* ( Item < 256 ) */
397 /* (DHCP Info: Item numbers are reserved to match DHCP info tags) */
398 /* Item = DHCP Compatible Tag */
399 /* Instance = Data Item Instance (1-n) */
400 /* ( Item >= 256 ) */
401 /* Item = System Info Tag */
402 /* Instance = Data Item Instance (1-n) */
403 /* *** USERS CAN ADD THEIR OWN ITEM VALUES *** */
404 /* For information, there is no structure - purely data */
405 
406 /* Currently Used DHCP Compatible Items */
407 /* Multiple instances are always to be stored as multiple */
408 /* config entries, not a concatenated byte string in a */
409 /* single config entry. */
410 #define CFGITEM_DHCP_DOMAINNAMESERVER 6 /* Stack's DNS servers */
411 #define CFGITEM_DHCP_HOSTNAME 12 /* Stack's host name */
412 #define CFGITEM_DHCP_NBNS 44 /* Stack's NBNS servers */
413 #define CFGITEM_DHCP_CLIENT_OPTION 61 /* Stack DHCP Client Identifier */
414 
415 #define CFGITEM_SYSINFO_REALM1 256 /* Realm Name 1 (max 31 chars) */
416 #define CFGITEM_SYSINFO_REALM2 257 /* Realm Name 2 (max 31 chars) */
417 #define CFGITEM_SYSINFO_REALM3 258 /* Realm Name 3 (max 31 chars) */
418 #define CFGITEM_SYSINFO_REALM4 259 /* Realm Name 4 (max 31 chars) */
419 #define CFGITEM_SYSINFO_REALMPPP 260 /* Realm Name PPP (max 31 chars) */
420 
421 /*--------------------------------------------------------------------------- */
422 /* Config Tag: CFGTAG_IP, CFGTAG_OS */
423 /* IP Stack Configuration / OS Configuration */
424 /* The CFGTAG_IP tag is for setting configuration values in the */
425 /* TCP/IP stack. */
426 /* The CFGTAG_OS tag is for setting configuration values in the */
427 /* system OS (or OS shell). */
428 /* Write to either tag results in writes the the internal configuration */
429 /* structure of the stack or OS, but being part of the configuration, the */
430 /* entry can be stored off in as part of the CfgSave() functionality. */
431 /* Removing an entry restores the default value to the configuration. */
432 /* Entries that are not present can not be read, but an error on */
433 /* read implies the entry is in its default state. */
434 /* All items are of type "int" or "uint". */
435 
436 /* When Tag = CFGTAG_IP, Item values are */
437 #define CFGITEM_IP_ICMPDOREDIRECT 1 /* Add route on ICMP redirect (1=Yes) */
438 #define CFGITEM_IP_ICMPTTL 2 /* TTL for ICMP msgs (RFC1700 says 64) */
439 #define CFGITEM_IP_ICMPTTLECHO 3 /* TTL for ICMP echo (RFC1700 says 64) */
440 #define CFGITEM_IP_IPINDEXSTART 4 /* IP Protocol Start Index */
441 #define CFGITEM_IP_IPFORWARDING 5 /* IP Forwarding Enable (1=Yes) */
442 #define CFGITEM_IP_IPNATENABLE 6 /* IP NAT Translation Enable (1=Yes) */
443 #define CFGITEM_IP_IPFILTERENABLE 7 /* IP Filtering Enable (1=Yes) */
444 #define CFGITEM_IP_IPREASMMAXTIME 8 /* Max IP reassembly time in seconds */
445 #define CFGITEM_IP_IPREASMMAXSIZE 9 /* Max IP reassembly packet size */
446 #define CFGITEM_IP_DIRECTEDBCAST 10 /* Directed BCast IP addresses (1=Yes) */
447 #define CFGITEM_IP_TCPREASMMAXPKT 11 /* Out of order pkts held by TCP socket */
448 #define CFGITEM_IP_RTCENABLEDEBUG 12 /* Route control dbg messages (1=Yes) */
449 #define CFGITEM_IP_RTCADVTIME 13 /* Seconds to send Router Adv. (0=don't) */
450 #define CFGITEM_IP_RTCADVLIFE 14 /* Lifetime of route in RtAdv if active */
451 #define CFGITEM_IP_RTCADVPREF 15 /* Preference of route in RvAdv if active */
452 #define CFGITEM_IP_RTARPDOWNTIME 16 /* Time 5 failed ARPs keeps route down */
453 #define CFGITEM_IP_RTKEEPALIVETIME 17 /* Timeout of validated route in seconds */
454 #define CFGITEM_IP_RTARPINACTIVITY 18 /* Time in seconds beyond which a route if */
455  /* unused considered "inactive" and is cleaned up. */
456 #define CFGITEM_IP_RTCLONETIMEOUT 19 /* Timeout of new cloned route in seconds */
457 #define CFGITEM_IP_RTDEFAULTMTU 20 /* MTU for internal routes */
458 #define CFGITEM_IP_SOCKTTLDEFAULT 21 /* Default IP TTL for Sockets */
459 #define CFGITEM_IP_SOCKTOSDEFAULT 22 /* Default IP TOS for Sockets */
460 #define CFGITEM_IP_SOCKMAXCONNECT 23 /* Max connections on listening socket */
461 #define CFGITEM_IP_SOCKTIMECONNECT 24 /* Max time for connect socket */
462 #define CFGITEM_IP_SOCKTIMEIO 25 /* Default Max time for socket send/rcv */
463 #define CFGITEM_IP_SOCKTCPTXBUF 26 /* TCP Transmit buffer size */
464 #define CFGITEM_IP_SOCKTCPRXBUF 27 /* TCP Receive buffer size (copy mode) */
465 #define CFGITEM_IP_SOCKTCPRXLIMIT 28 /* TCP Receive limit (non-copy mode) */
466 #define CFGITEM_IP_SOCKUDPRXLIMIT 29 /* UDP Receive limit */
467 #define CFGITEM_IP_SOCKMINTX 30 /* Default min space for "able to write" */
468 #define CFGITEM_IP_SOCKMINRX 31 /* Default min data for "able to read" */
469 #define CFGITEM_IP_PIPETIMEIO 32 /* Max time for pipe send/rcv call */
470 #define CFGITEM_IP_PIPEBUFMAX 33 /* Pipe internal buffer size */
471 #define CFGITEM_IP_PIPEMINTX 34 /* Pipe min tx space for "able to write" */
472 #define CFGITEM_IP_PIPEMINRX 35 /* Pipe min rx data for "able to read" */
473 #define CFGITEM_IP_TCPKEEPIDLE 36 /* Idle time before 1st TCP keep probe */
474 #define CFGITEM_IP_TCPKEEPINTVL 37 /* TCP keep probe interval */
475 #define CFGITEM_IP_TCPKEEPMAXIDLE 38 /* Max TCP keep probing time before drop */
476 #define CFGITEM_IP_ICMPDONTREPLYBCAST 39 /* Dont Reply To ICMP ECHO REQ */
477  /* packets sent to BCast/Directed BCast */
478 #define CFGITEM_IP_ICMPDONTREPLYMCAST 40 /* Dont Reply To ICMP ECHO REQ */
479  /* packets sent to Multi-Cast */
480 
481 #define CFGITEM_IP_RTGARP 41 /* How to handle received gratuitous ARP */
482  /* 0 : discard them. (Default) */
483  /* 1 : update MAC address of HOST, if it */
484  /* is already in the routing table. */
485  /* 2 : add HOST to routing table, if it */
486  /* does NOT exist. If exists, update */
487  /* MAC address. */
488 
489 #define CFGITEM_IP_ICMPDONTREPLYECHO 42 /* Don't Reply To ICMP ECHO REQ */
490 #define CFGITEM_IP_UDPSENDICMPPORTUNREACH 43 /* Send ICMP Port Unreachable */
491  /* packet if UDP port is opened or not */
492 #define CFGITEM_IP_TCPSENDRST 44 /* Send RST if TCP port is not */
493  /* opened or not. */
494 #define CFGITEM_IP_SOCKRAWETHRXLIMIT 45 /* Raw Eth Receive limit */
495 
496 #define CFGITEM_IP_MAX 46 /* Max CFGTAG_IP item */
497 
498 
499 /* When Tag = CFGTAG_OS, Item values are */
500 #define CFGITEM_OS_DBGPRINTLEVEL 1 /* Debug msg print threshhold */
501 #define CFGITEM_OS_DBGABORTLEVEL 2 /* Debug msg sys abort theshhold */
502 #define CFGITEM_OS_TASKPRILOW 3 /* Lowest priority for stack task */
503 #define CFGITEM_OS_TASKPRINORM 4 /* Normal priority for stack task */
504 #define CFGITEM_OS_TASKPRIHIGH 5 /* High priority for stack task */
505 #define CFGITEM_OS_TASKPRIKERN 6 /* Kernel-level priority (highest) */
506 #define CFGITEM_OS_TASKSTKLOW 7 /* Minimum stack size */
507 #define CFGITEM_OS_TASKSTKNORM 8 /* Normal stack size */
508 #define CFGITEM_OS_TASKSTKHIGH 9 /* Stack size for high volume tasks */
509 #define CFGITEM_OS_TASKSTKBOOT 10 /* Stack size for NS_BootTask */
510 #define CFGITEM_OS_MAX 10 /* Max CFGTAG_OS item */
511 
513 #ifdef __cplusplus
514 }
515 #endif /* extern "C" */
516 
517 #endif
CISARGS cisargs
Definition: netcfg.h:244
void * hRoute
Definition: netcfg.h:310
uint32_t TimeExpire
Definition: netcfg.h:348
struct _ci_acct CI_ACCT
CISARGS cisargs
Definition: netcfg.h:252
struct _ci_route CI_ROUTE
Definition: netcfg.h:341
Definition: netcfg.h:243
#define CFG_HOSTNAME_MAX
Definition: netcfg.h:339
uint32_t IPDestAddr
Definition: netcfg.h:307
uint32_t NetType
Definition: netcfg.h:286
void * hBind
Definition: netcfg.h:289
uint32_t IPAddr
Definition: netcfg.h:287
Definition: netcfg.h:251
uint32_t IPDestMask
Definition: netcfg.h:308
Common service arguments.
Definition: netcfg.h:111
struct _ci_srvargs CISARGS
Common service arguments.
uint32_t Status
Definition: netcfg.h:343
struct _ci_service_nat CI_SERVICE_NAT
uint32_t IfIdx
Definition: netcfg.h:200
uint32_t Mode
Definition: netcfg.h:152
NTPARAM_DHCPS param
Definition: netcfg.h:253
CISARGS cisargs
Definition: netcfg.h:260
Definition: telnetif.h:60
NTPARAM_NAT param
Definition: netcfg.h:245
uint32_t ClientType
Definition: netcfg.h:342
uint32_t Flags
Definition: netcfg.h:378
uint32_t IPGateAddr
Definition: netcfg.h:309
uint32_t Item
Definition: netcfg.h:119
#define CFG_ACCTSTR_MAX
Definition: netcfg.h:374
void(* pCbSrv)(uint32_t Item, uint32_t Status, uint32_t Code, void *hCfgEntry)
Definition: netcfg.h:228
CISARGS cisargs
Definition: netcfg.h:236
Definition: netcfg.h:377
NTPARAM_TELNET param
Definition: netcfg.h:237
uint32_t TimeStatus
Definition: netcfg.h:347
struct _ci_service_dnss CI_SERVICE_DNSSERVER
void * hService
Definition: netcfg.h:129
uint32_t ReportCode
Definition: netcfg.h:188
Definition: netcfg.h:235
struct _ci_ipnet CI_IPNET
Definition: netcfg.h:285
CISARGS cisargs
Definition: netcfg.h:268
Definition: netcfg.h:259
uint32_t Status
Definition: netcfg.h:172
NTPARAM_DHCP param
Definition: netcfg.h:261
Definition: netcfg.h:267
struct _ci_service_dhcps CI_SERVICE_DHCPS
Definition: netcfg.h:306
uint32_t IPAddr
Definition: netcfg.h:211
uint32_t IPAddr
Definition: netcfg.h:344
uint32_t IPMask
Definition: netcfg.h:288
struct _ci_service_dhcpc CI_SERVICE_DHCPC
struct _ci_client CI_CLIENT
#define CFG_DOMAIN_MAX
Definition: netcfg.h:282
struct _ci_service_telnet CI_SERVICE_TELNET
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale