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

VxWorks

开发平台:

C/C++

  1. /* bootpLib.h - BOOTP client include file */
  2. /* Copyright 1990 - 2000 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01n,14jun00,spm  upgraded to RFC 1542 and removed direct link-level access;
  7.                  changed interface to isolate message body values from options
  8. 01m,07apr97,spm  changed BOOTP interface to DHCP style: all options supported
  9. 01l,26sep96,spm  fixed SPR 7120: added parameter for gateway to bootpParamsGet
  10. 01k,22sep92,rrr  added support for c++
  11. 01j,04jul92,jcf  cleaned up.
  12. 01i,11jun92,elh  modified parameters to bootpParamsGet.
  13. 01h,26may92,rrr  the tree shuffle
  14.   -changed includes to have absolute path from h/
  15. 01g,17apr92,elh  moved prototypes icmpLib.
  16. 01f,28feb92,elh  ansified.
  17. 01e,27aug91,elh  added RFC 1048 stuff, and added errors.
  18. 01d,12aug90,dnw  changed retransmission delay parameters
  19. 01c,12aug90,hjb  major revision
  20. 01b,19apr90,hjb  added VX_LOG_FILE definition
  21. 01a,11mar90,hjb  written
  22. */
  23. #ifndef __INCbootpLibh
  24. #define __INCbootpLibh
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* includes */
  29. #include "vwModNum.h"
  30. #include "netinet/in.h"
  31. /* defines */
  32. /* BOOTP reserved ports */
  33. #define _BOOTP_SPORT            67
  34. #define _BOOTP_CPORT            68
  35. #define BOOTREQUEST             1 /* BOOTP operations */
  36. #define BOOTREPLY               2
  37. #define SIZE_HLEN  16
  38. #define SIZE_SNAME  64
  39. #define SIZE_VEND 64
  40. #define SIZE_FILE 128
  41. #define UDPHL  sizeof (struct udphdr)  /* UDP header length */
  42. #define IPHL  sizeof (struct ip)  /* IP header length */
  43. /* retransmission delay parameters */
  44. #define INIT_BOOTP_DELAY 4 /* initial retransmit delay (secs) */
  45. #define MAX_BOOTP_DELAY 64  /* maximum retransmit delay (secs) */
  46. /* Hardware type values from the arp section of the assigned numbers RFC. */
  47. #define ETHER           1       /* Ethernet (10Mb) */
  48. #define EXPETHER        2       /* Experimental Ethernet (3Mb) */
  49. #define AX25            3       /* Amateur Radio AX.25 */
  50. #define PRONET          4       /* Proteon ProNET Token Ring */
  51. #define CHAOS           5       /* Chaos */
  52. #define IEEE802         6       /* IEEE 802 Networks */
  53. #define ARCNET          7       /* ARCNET */
  54. #define HYPERCH         8       /* Hyperchannel */
  55. #define LANSTAR         9       /* Lanstar */
  56. #define AUTONET         10      /* Autonet Short Address */
  57. #define LOCALTALK       11      /* LocalTalk */
  58. #define LOCALNET        12      /* LocalNet */
  59. #define ULTRALINK       13      /* Ultra link */
  60. #define FRAMERELAY      15      /* Frame Relay */
  61. #define SERIAL          20      /* Serial Line */
  62. #define DNS_NAME        128     /* DNS name */
  63. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  64. #pragma align 1 /* dont optimize alignments */
  65. #endif  /* CPU_FAMILY==I960 */
  66.                                                 /* BOOTP message structure */
  67. typedef struct bootp_msg
  68.     {
  69.     unsigned char bp_op; /* packet opcode type */
  70.     unsigned char bp_htype;        /* hardware addr type */
  71.     unsigned char bp_hlen; /* hardware addr length */
  72.     unsigned char bp_hops; /* gateway hops  */
  73.     unsigned long bp_xid; /* transaction ID  */
  74.     unsigned short bp_secs; /* seconds since boot  */
  75.     unsigned short bp_unused;
  76.     struct in_addr bp_ciaddr; /* client IP address  */
  77.     struct in_addr bp_yiaddr; /* 'your' IP address  */
  78.     struct in_addr bp_siaddr; /* server IP address  */
  79.     struct in_addr bp_giaddr; /* gateway IP address  */
  80.     unsigned char bp_chaddr [SIZE_HLEN];  /* client hardware addr */
  81.     unsigned char bp_sname [SIZE_SNAME];  /* server host name  */
  82.     unsigned char bp_file [SIZE_FILE]; /* boot file name  */
  83.     unsigned char bp_vend [SIZE_VEND]; /* vendor-specific area */
  84.     } BOOTP_MSG;
  85. #define BOOTPLEN sizeof (struct bootp_msg)
  86. struct in_addr_list
  87.     {
  88.     unsigned char  num;
  89.     struct in_addr *  addrlist;
  90.     };
  91. struct ushort_list
  92.     {
  93.     unsigned char  num;
  94.     unsigned short *  shortlist;
  95.     };
  96. struct bootpParams  /* BOOTP options/vendor extensions from RFC 1533 */
  97.     {
  98.     struct in_addr *  netmask;
  99.     unsigned short * timeOffset;
  100.     struct in_addr_list *  routers;
  101.     struct in_addr_list *  timeServers;
  102.     struct in_addr_list *  nameServers;
  103.     struct in_addr_list *  dnsServers;
  104.     struct in_addr_list *  logServers;
  105.     struct in_addr_list *  cookieServers;
  106.     struct in_addr_list *  lprServers;
  107.     struct in_addr_list *  impressServers;
  108.     struct in_addr_list *  rlpServers;
  109.     char *  clientName;
  110.     unsigned short * filesize;
  111.     char *  dumpfile; 
  112.     char *  domainName;
  113.     struct in_addr *  swapServer;
  114.     char *  rootPath;
  115.     char *  extoptPath;
  116.     unsigned char * ipForward;
  117.     unsigned char * nonlocalSourceRoute;
  118.     struct in_addr_list *  policyFilter;
  119.     unsigned short * maxDgramSize;
  120.     unsigned char * ipTTL;
  121.     unsigned long * mtuTimeout;
  122.     struct ushort_list *  mtuTable;
  123.     unsigned short *  intfaceMTU;
  124.     unsigned char *  allSubnetsLocal;
  125.     struct in_addr *  broadcastAddr;
  126.     unsigned char *  maskDiscover;
  127.     unsigned char *  maskSupplier;
  128.     unsigned char *  routerDiscover;
  129.     struct in_addr *  routerDiscAddr;
  130.     struct in_addr_list *  staticRoutes;
  131.     unsigned char *  arpTrailers;
  132.     unsigned long *  arpTimeout;
  133.     unsigned char *  etherPacketType;
  134.     unsigned char *  tcpTTL;
  135.     unsigned long *  tcpInterval;
  136.     unsigned char *  tcpGarbage;
  137.     char *  nisDomain;
  138.     struct in_addr_list *  nisServers;
  139.     struct in_addr_list *  ntpServers;
  140.     char *  vendString;
  141.     struct in_addr_list *  nbnServers;
  142.     struct in_addr_list *  nbddServers;
  143.     unsigned char *  nbNodeType;
  144.     char *  nbScope;
  145.     struct in_addr_list *  xFontServers;
  146.     struct in_addr_list *  xDisplayManagers; 
  147.     char *  nispDomain;
  148.     struct in_addr_list *  nispServers;
  149.     struct in_addr_list *  ipAgents;
  150.     struct in_addr_list *  smtpServers;
  151.     struct in_addr_list *  pop3Servers;
  152.     struct in_addr_list *  nntpServers;
  153.     struct in_addr_list *  wwwServers;
  154.     struct in_addr_list *  fingerServers;
  155.     struct in_addr_list *  ircServers;
  156.     struct in_addr_list *  stServers;
  157.     struct in_addr_list *  stdaServers;
  158.     };
  159. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  160. #pragma align 0 /* turn off */
  161. #endif  /* CPU_FAMILY==I960 */
  162. #define VM_RFC1048       { 99, 130, 83, 99 }
  163. #define TAG_PAD  0  /* RFC 1048 vendor tags */
  164. #define TAG_SUBNET_MASK  1
  165. #define TAG_TIME_OFFSET  2
  166. #define TAG_GATEWAY  3
  167. #define TAG_TIME_SERVER  4
  168. #define TAG_NAME_SERVER  5
  169. #define TAG_DNS_SERVER  6
  170. #define TAG_LOG_SERVER  7
  171. #define TAG_COOKIE_SERVER  8
  172. #define TAG_LPR_SERVER  9
  173. #define TAG_IMPRESS_SERVER  10
  174. #define TAG_RLP_SERVER  11
  175. #define TAG_HOSTNAME  12
  176. #define TAG_END                  255
  177. #define TAG_BOOTSIZE  13  /* RFC 1084 vendor tags */
  178. #define TAG_MERIT_DUMP  14  /* RFC 1395 vendor tags */
  179. #define TAG_DNS_DOMAIN  15
  180. #define TAG_SWAP_SERVER  16
  181. #define TAG_ROOT_PATH  17
  182. #define TAG_EXTENSIONS_PATH  18  /* RFC 1497 vendor tags */
  183. #define TAG_IP_FORWARD  19  /* RFC 1533 vendor tags */
  184. #define TAG_NONLOCAL_SRCROUTE  20
  185. #define TAG_POLICY_FILTER  21
  186. #define TAG_MAX_DGRAM_SIZE  22
  187. #define TAG_DEFAULT_IP_TTL  23
  188. #define TAG_MTU_AGING_TIMEOUT  24
  189. #define TAG_MTU_PLATEAU_TABLE  25
  190. #define TAG_IF_MTU  26
  191. #define TAG_ALL_SUBNET_LOCAL  27
  192. #define TAG_BRDCAST_ADDR  28
  193. #define TAG_MASK_DISCOVER  29
  194. #define TAG_MASK_SUPPLIER  30
  195. #define TAG_ROUTER_DISCOVER  31
  196. #define TAG_ROUTER_SOLICIT  32
  197. #define TAG_STATIC_ROUTE  33
  198. #define TAG_TRAILER  34
  199. #define TAG_ARP_CACHE_TIMEOUT  35
  200. #define TAG_ETHER_ENCAP  36
  201. #define TAG_DEFAULT_TCP_TTL  37
  202. #define TAG_KEEPALIVE_INTER  38
  203. #define TAG_KEEPALIVE_GARBA  39
  204. #define TAG_NIS_DOMAIN  40
  205. #define TAG_NIS_SERVER  41
  206. #define TAG_NTP_SERVER  42
  207. #define TAG_VENDOR_SPEC  43
  208. #define TAG_NBN_SERVER  44
  209. #define TAG_NBDD_SERVER  45
  210. #define TAG_NB_NODETYPE  46
  211. #define TAG_NB_SCOPE  47
  212. #define TAG_XFONT_SERVER  48
  213. #define TAG_XDISPLAY_MANAGER  49
  214. #define TAG_NISP_DOMAIN  64
  215. #define TAG_NISP_SERVER  65
  216. #define TAG_MOBILEIP_HA  68
  217. #define TAG_SMTP_SERVER  69
  218. #define TAG_POP3_SERVER  70
  219. #define TAG_NNTP_SERVER  71
  220. #define TAG_WWW_SERVER  72
  221. #define TAG_FINGER_SERVER  73
  222. #define TAG_IRC_SERVER  74
  223. #define TAG_ST_SERVER  75
  224. #define TAG_STDA_SERVER  76
  225. /* error values */
  226. #define S_bootpLib_INVALID_ARGUMENT (M_bootpLib | 1)
  227. #define S_bootpLib_INVALID_COOKIE (M_bootpLib | 2)
  228. #define S_bootpLib_NO_BROADCASTS (M_bootpLib | 3)
  229. #define S_bootpLib_PARSE_ERROR (M_bootpLib | 4)
  230. #define S_bootpLib_INVALID_TAG (M_bootpLib | 5)
  231. #define S_bootpLib_TIME_OUT (M_bootpLib | 6)
  232. #define S_bootpLib_MEM_ERROR (M_bootpLib | 7)
  233. #define S_bootpLib_NOT_INITIALIZED  (M_bootpLib | 8)
  234. #define S_bootpLib_BAD_DEVICE  (M_bootpLib | 9)
  235. /* function prototypes */
  236. #if defined(__STDC__) || defined(__cplusplus)
  237. STATUS  bootpLibInit (int);
  238. STATUS  bootpParamsGet (struct ifnet *, u_int, struct in_addr *,
  239.                         struct in_addr *, char *, char *,
  240.                         struct bootpParams *);
  241. STATUS  bootpMsgGet (struct ifnet *, struct in_addr *, USHORT, USHORT,
  242.                      BOOTP_MSG *, u_int);
  243. #else  /* __STDC__ */
  244. STATUS  bootpLibInit ();
  245. STATUS bootpParamsGet ();
  246. STATUS bootpMsgGet ();
  247. #endif  /* __STDC__ */
  248. #ifdef __cplusplus
  249. }
  250. #endif
  251. #endif /* __INCbootpLibh */