usrNetDhcpsCfg.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usrNetDhcpsCfg.c - Initialization routine for the DHCP server */
  2. /* Copyright 1992 - 2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01f,14may02,wap  Initialize structures to eliminate diab error (SPR #76331,
  7.                  SPR #76377)
  8. 01e,26oct01,vvv  allow DHCP server to start when target not booted from 
  9.  network device (SPR #64898)
  10. 01d,09oct01,rae  merge from truestack
  11. 01c,25jun01,ppp  fixed the problem involving the dhcp server and client to be
  12.                  built together (SPR #64194)
  13. 01b,13dec00,spm  updated DHCP startup for latest version (from tor3_x branch)
  14. 01a,18aug98,ann  created this configlette from usrNetwork.c
  15. */
  16. /*
  17. DESCRIPTION
  18. This configlette contains the initialization routine for the
  19. INCLUDE_DHCPS component.
  20. NOMANUAL
  21. */
  22. #include <dhcpsLib.h>
  23. IMPORT STATUS dhcpsLeaseHookAdd (FUNCPTR);
  24. IMPORT STATUS dhcpsAddressHookAdd (FUNCPTR);
  25. /* Include these declarations if hooks are defined. */
  26. /* IMPORT STATUS DHCPS_LEASE_HOOK (int, char *, int); */
  27. /* IMPORT STATUS DHCPS_ADDRESS_HOOK (int, char *, int); */
  28. /*
  29.  * The following table lists the IP addresses which will receive DHCP
  30.  * messages forwarded across network boundaries by a DHCP server or
  31.  * relay agent.
  32.  */
  33. DHCP_TARGET_DESC dhcpTargetTbl [] =
  34.     {
  35.     /*
  36.      IP address of DHCP target servers
  37.      ---------------------------------
  38.      */
  39.      /* {"90.11.42.2"}, */
  40.      { NULL } /* List terminator, must be last */
  41.      };
  42. /*
  43.  * Example cache routine - should store records of active leases
  44.  *                         across reboots.
  45.  */
  46. /*
  47. #ifdef INCLUDE_DHCPS
  48. STATUS dhcpsDummyCache (int, char *, int);
  49. STATUS dhcpsDummyCache (int op, char *name, int length)
  50.     {
  51.     printf("Cache called with op %d on %d bytes.n", op, length);
  52.     if (op == DHCPS_STORAGE_READ)
  53.         return (ERROR);          /@ Simulated end-of-file. @/
  54.     return (OK);
  55.     }
  56. #endif
  57. */
  58. /* 
  59.  * This table contains a list of interfaces that the server
  60.  * will listen to. The boot device is used when the table's
  61.  * first entry is the null string.
  62.  */
  63. DHCPS_IF_DESC dhcpsIfTbl [] =
  64.     {
  65.     {""} /* Use primary interface */
  66. /* Sample interface entries. */
  67. /*  {"fei1"}, */
  68. /*  {"ln0"} */
  69.     };
  70. DHCPS_LEASE_DESC dhcpsLeaseTbl [] =
  71.     {
  72.     /*
  73.     Name        Start IP      End IP          Parameters
  74.     ----        ----------    ------          -----------
  75.                                      see man pages
  76.                                 (timers, bootfile, etc.)
  77.     */
  78.     /*
  79.      * Host requirements defaults needed for RFC compliance - DO NOT REMOVE!!
  80.      */
  81.    {"dflt",    NULL, NULL, DHCPS_DEFAULT_ENTRY},
  82.     /* Sample database entries. */
  83. /* {"ent1", "90.11.42.24", "90.11.42.24", "clid="1:0x08003D21FE90":maxl=90:dfll=6
  84. 0"},   */
  85. /* {"ent2", "90.11.42.25", "90.11.42.26", "snmk=255.255.255.0:maxl=90:dfll=70:file=
  86. /vxWorks"}, */
  87. /* {"ent3", "90.11.42.27", "90.11.42.27", "maxl=0xffffffff:file=/vxWorks"}, */
  88. /* {"entry4", "90.11.42.28", "90.11.42.29", "albp=true:file=/vxWorks"}      */
  89.     };
  90. /*
  91.  * If the DHCP server will receive messages from relay agents,
  92.  * the following table must be filled in by the user.
  93.  */
  94. DHCPS_RELAY_DESC dhcpsRelayTbl [] =
  95.     {
  96.     /*
  97.      IP address of agent              Subnet Number
  98.      --------------------             -------------
  99.      */
  100.     /* {"90.11.42.254",               "90.11.42.0"}, */
  101.     { NULL,                           NULL } /* List terminator, must be last */
  102.     };
  103. LOCAL int dhcpsTaskPriority  = 56;      /* Priority level of DHCP server */
  104. LOCAL int dhcpsTaskOptions   = 0;       /* Option settings for DHCP server */
  105. LOCAL int dhcpsTaskStackSize = 5000;    /* Stack size for DHCP server task */
  106. #ifndef INCLUDE_VIRTUAL_STACK
  107. IMPORT void dhcpsStart (void);
  108. #else 
  109. IMPORT void dhcpsStart (int);
  110. IMPORT int myStackNum;
  111. #endif /* INCLUDE_VIRTUAL_STACK */
  112. /* Default configurations parameters for dhcps, definitions are in h/dhcpsLib.h */
  113. DHCPS_CFG_PARAMS dhcpsDfltCfgParams =
  114.     {
  115.     DHCP_MAX_HOPS,
  116.     DHCPS_SPORT,
  117.     DHCPS_CPORT,
  118.     DHCPS_MAX_MSGSIZE,
  119.     DHCPS_DEFAULT_LEASE,
  120.     DHCPS_MAX_LEASE,
  121.     DHCPS_LEASE_HOOK,
  122.     DHCPS_ADDRESS_HOOK,
  123.     dhcpsIfTbl,
  124.     NELEMENTS(dhcpsIfTbl),
  125.     dhcpsLeaseTbl,
  126.     NELEMENTS(dhcpsLeaseTbl),
  127.     dhcpTargetTbl,
  128.     NELEMENTS(dhcpTargetTbl),
  129.     dhcpsRelayTbl,
  130.     NELEMENTS(dhcpsRelayTbl),
  131.     };
  132. void usrDhcpsStart 
  133.     (
  134.     DHCPS_CFG_PARAMS *pDhcpsCfg /* Configuration parameters */
  135.     )
  136.     {
  137.     STATUS      dhcpsResult; 
  138.     if (pDhcpsCfg == (DHCPS_CFG_PARAMS *)NULL)
  139. {
  140. errnoSet (S_dhcpsLib_NOT_INITIALIZED);
  141. return;
  142. }
  143.     if (pDhcpsCfg->pDhcpsIfTbl[0].ifName[0] == EOS)
  144.         {
  145. sprintf (pDhcpsCfg->pDhcpsIfTbl[0].ifName, "%s%d",
  146.  pDevName, sysBootParams.unitNum);
  147. pDhcpsCfg->numDev = 1;
  148.         }
  149.     dhcpsResult = dhcpsInit (pDhcpsCfg);
  150.     if (dhcpsResult == ERROR)
  151. {
  152. errnoSet (S_dhcpsLib_NOT_INITIALIZED);
  153. return;
  154. }
  155.     dhcpsResult = taskSpawn ("tDhcpsTask", dhcpsTaskPriority,
  156.                                  dhcpsTaskOptions, dhcpsTaskStackSize,
  157.                                  (FUNCPTR) dhcpsStart,
  158. #ifndef INCLUDE_VIRTUAL_STACK
  159.                                  0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  160. #else
  161.                  myStackNum, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  162. #endif /* INCLUDE_VIRTUAL_STACK */
  163.     if (dhcpsResult == ERROR)
  164. {
  165. errnoSet (S_dhcpsLib_NOT_INITIALIZED);
  166. }
  167.     return;
  168.     }