original files of m241
This commit is contained in:
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcps6_option.h,v $ $Revision: 1.18.42.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipdhcps6/include/ipdhcps6_option.h,v $
|
||||
* $Author: ulf $ $Date: 2011-11-16 10:33:28 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPDHCPS6_OPTION_H
|
||||
#define IPDHCPS6_OPTION_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipdhcps6_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_type.h>
|
||||
|
||||
#include "ipdhcps6_duid.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* DHCP Options */
|
||||
#define IPDHCPS6_OPTION_CLIENTID 1
|
||||
#define IPDHCPS6_OPTION_SERVERID 2
|
||||
#define IPDHCPS6_OPTION_IA_NA 3
|
||||
#define IPDHCPS6_OPTION_IA_TA 4
|
||||
#define IPDHCPS6_OPTION_IAADDR 5
|
||||
#define IPDHCPS6_OPTION_ORO 6
|
||||
#define IPDHCPS6_OPTION_PREFERENCE 7
|
||||
#define IPDHCPS6_OPTION_ELAPSED_TIME 8
|
||||
#define IPDHCPS6_OPTION_RELAY_MSG 9
|
||||
#define IPDHCPS6_OPTION_AUTH 11
|
||||
#define IPDHCPS6_OPTION_UNICAST 12
|
||||
#define IPDHCPS6_OPTION_STATUS_CODE 13
|
||||
#define IPDHCPS6_OPTION_RAPID_COMMIT 14
|
||||
#define IPDHCPS6_OPTION_USER_CLASS 15
|
||||
#define IPDHCPS6_OPTION_VENDOR_CLASS 16
|
||||
#define IPDHCPS6_OPTION_VENDOR_OPTS 17
|
||||
#define IPDHCPS6_OPTION_INTERFACE_ID 18
|
||||
#define IPDHCPS6_OPTION_RECONF_MSG 19
|
||||
#define IPDHCPS6_OPTION_RECONF_ACCEPT 20
|
||||
#define IPDHCPS6_OPTION_SIP_SERVER_D 21
|
||||
#define IPDHCPS6_OPTION_SIP_SERVER_A 22
|
||||
#define IPDHCPS6_OPTION_DNS_SERVERS 23
|
||||
#define IPDHCPS6_OPTION_DOMAIN_LIST 24
|
||||
#define IPDHCPS6_OPTION_IA_PD 25
|
||||
#define IPDHCPS6_OPTION_IAPREFIX 26
|
||||
|
||||
#define IPDHCPS6_OPTION_SNTP_SERVERS 31
|
||||
#define IPDHCPS6_OPTION_INFORMATION_REFRESH_TIME 32
|
||||
#define IPDHCPS6_OPTION_FQDN 39
|
||||
|
||||
/* local options, ONLY used for configuration */
|
||||
#define IPDHCPS6_OPTION_CONF_BASE 0xf000
|
||||
#define IPDHCPS6_OPTION_CONF_RENEW_TIME (IPDHCPS6_OPTION_CONF_BASE)
|
||||
#define IPDHCPS6_OPTION_CONF_REBIND_TIME (IPDHCPS6_OPTION_CONF_BASE + 1)
|
||||
|
||||
#define IPDHCPS6_OPTION_HDR_LEN 4
|
||||
|
||||
/** OBSOLETE: DEAD DRAFTS; MAINTAINED FOR BACKWARDS COMPATIBILITY FOR NOW
|
||||
* WILL BE REMOVED EVENTUALLY */
|
||||
|
||||
#define IPDHCPS6_OPTION_TIME_ZONE 60003 /* OLD VALUE: 28 */
|
||||
#define IPDHCPS6_OPTION_NTP_SERVERS 60004 /* OLD VALUE: 33 */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipdhcps6_authtrans_dbentry;
|
||||
struct Ipdhcps6_message_struct;
|
||||
|
||||
/* start-of packed structures */
|
||||
#include "ipcom_align16.h"
|
||||
/* Forward declarations */
|
||||
struct Ipdhcps6_prefix_struct;
|
||||
|
||||
IP_PACKED1 struct Ipdhcps6_option_status_code_data
|
||||
{
|
||||
/* The numeric code for the status encoded in this option
|
||||
(IPDHCPS6_CODE_xxx). */
|
||||
Ip_u16 code;
|
||||
/* A UTF-8 encoded text string suitable for
|
||||
display to an end user, which MUST NOT be null-terminated. */
|
||||
char message[1];
|
||||
} IP_PACKED2;
|
||||
|
||||
typedef IP_PACKED1 struct Ipdhcps6_option_ia_xx_struct
|
||||
{
|
||||
/* Must be IPDHCPS6_OPTION_IA_XX */
|
||||
Ip_u16 code;
|
||||
/* len is 12 + options */
|
||||
Ip_u16 len;
|
||||
/* The unique identifier for this IA_XX */
|
||||
Ip_u32 iaid;
|
||||
/* The time (in seconds) at which the client contacts the
|
||||
server from which the addresses in the IA_XX
|
||||
were obtained to extend the lifetimes of the
|
||||
addresses assigned to the IA_XX */
|
||||
Ip_u32 t1;
|
||||
/* The time (in seconds) at which the client contacts any
|
||||
available server to extend the lifetimes of
|
||||
the addresses assigned to the IA_XX */
|
||||
Ip_u32 t2;
|
||||
/* Options associated with this IA_XX */
|
||||
Ip_u8 options[1];
|
||||
}
|
||||
IP_PACKED2 Ipdhcps6_option_ia_xx;
|
||||
|
||||
typedef IP_PACKED1 struct Ipdhcps6_option_iaaddr_struct
|
||||
{
|
||||
/* Must be IPDHCPS6_OPTION_IAADDR */
|
||||
Ip_u16 code;
|
||||
/* len is 24 + options */
|
||||
Ip_u16 len;
|
||||
/* An IPv6 address */
|
||||
struct Ip_in6_addr ipv6_address;
|
||||
/* The preferred lifetime for the IPv6 address in
|
||||
the option, expressed in units of seconds. */
|
||||
Ip_u32 preferred_lifetime;
|
||||
/* The valid lifetime for the IPv6 address in the
|
||||
option, expressed in units of seconds. */
|
||||
Ip_u32 valid_lifetime;
|
||||
/* IAaddr-options Options associated with this address. */
|
||||
Ip_u8 options[1];
|
||||
}
|
||||
IP_PACKED2 Ipdhcps6_option_iaaddr;
|
||||
|
||||
|
||||
/* Prefix deligation options (draft-ietf-dhc-dhcpv6-opt-prefix-delegation-05.txt) */
|
||||
|
||||
/* Prefix option */
|
||||
typedef IP_PACKED1 struct Ipdhcps6_option_iaprefix_struct
|
||||
{
|
||||
/* Must be IPDHCPS6_OPTION_IAPREFIX */
|
||||
Ip_u16 code;
|
||||
/* len is 25 + length of IAprefix-options field */
|
||||
Ip_u16 len;
|
||||
/* The recommended preferred lifetime for the IPv6
|
||||
prefix in the option, expressed in units of
|
||||
seconds. A value of 0xFFFFFFFF represents
|
||||
infinity.*/
|
||||
Ip_u32 preferred_lifetime;
|
||||
/* The valid lifetime for the IPv6 prefix in the
|
||||
option, expressed in units of seconds. A value of
|
||||
0xFFFFFFFF represents infinity. */
|
||||
Ip_u32 valid_lifetime;
|
||||
/* 1 byte prefix len and 16 byte prefix */
|
||||
Ip_u8 prefix_buf[1 + sizeof(struct Ip_in6_addr) + IPDHCPS6_OPTION_HDR_LEN];
|
||||
}
|
||||
IP_PACKED2 Ipdhcps6_option_iaprefix;
|
||||
|
||||
#define IPDHCPS6_OPTION_IAPREFIX_SET_LEN(opt, len) \
|
||||
((opt)->prefix_buf[0] = len)
|
||||
|
||||
#define IPDHCPS6_OPTION_IAPREFIX_GET_LEN(opt) \
|
||||
((opt)->prefix_buf[0])
|
||||
|
||||
#define IPDHCPS6_OPTION_IAPREFIX_GET_PREFIX_PTR(opt) \
|
||||
((struct Ip_in6_addr *) &(opt)->prefix_buf[1])
|
||||
|
||||
#define IPDHCPS6_OPTION_IAPREFIX_GET_OPTIONS_PTR(opt) \
|
||||
((Ipdhcps6_option *) &(opt)->prefix_buf[1 + sizeof(struct Ip_in6_addr)])
|
||||
|
||||
/* Prefix deligation data */
|
||||
IP_PACKED1 struct Ipdhcps6_option_prefix_delegation_data
|
||||
{
|
||||
/* The unique identifier for this IA_PD; the IAID must
|
||||
be unique among the identifiers for all of this
|
||||
requesting router's IA_PDs. */
|
||||
Ip_u8 iaid[4];
|
||||
/* The time at which the requesting router contacts
|
||||
the delegating router from which the prefixes in
|
||||
the IA_PD were obtained to extend the lifetimes of
|
||||
the prefixes delegated to the IA_PD; T1 is a time
|
||||
duration relative to the current time expressed in
|
||||
units of seconds. */
|
||||
Ip_u32 t1;
|
||||
/* The time at which the requesting router contacts
|
||||
any available delegating router to extend the
|
||||
lifetimes of the prefixes assigned to the IA_PD; T2
|
||||
is a time duration relative to the current time
|
||||
expressed in units of seconds. */
|
||||
Ip_u32 t2;
|
||||
/* Options associated with this IA_PD */
|
||||
Ipdhcps6_option_iaprefix options[1];
|
||||
} IP_PACKED2;
|
||||
|
||||
|
||||
union Ipdhcps6_option_data
|
||||
{
|
||||
Ip_u8 generic[1];
|
||||
/* IPDHCPS6_OPTION_CLIENTID */
|
||||
union Ipdhcps6_duid_data clientid;
|
||||
/* IPDHCPS6_OPTION_SERVERID */
|
||||
union Ipdhcps6_duid_data serverid;
|
||||
/* IPDHCPS6_OPTION_ORO (one or more options) */
|
||||
Ip_u16 request_oro[1];
|
||||
/* IPDHCPS6_OPTION_STATUS_CODE */
|
||||
struct Ipdhcps6_option_status_code_data status_code;
|
||||
/* IPDHCPS6_OPTION_DNS_SERVERS (one or more IPv6 addresses) */
|
||||
struct Ip_in6_addr dns_servers[1];
|
||||
/* IPDHCPS6_OPTION_IA_PD */
|
||||
struct Ipdhcps6_option_prefix_delegation_data ia_pd;
|
||||
/* IPDHCPS6_OPTION_RECONF_MSG */
|
||||
Ip_u8 reconf_msg_type;
|
||||
/* IPDHCPS6_OPTION_TIME_ZONE */
|
||||
char time_zone[1];
|
||||
};
|
||||
|
||||
/*
|
||||
The format of DHCP options is:
|
||||
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| option-code | option-len |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| option-data |
|
||||
| (option-len octets) |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
|
||||
|
||||
option-code An unsigned integer identifying the specific option
|
||||
type carried in this option.
|
||||
|
||||
option-len An unsigned integer giving the length of the
|
||||
option-data field in this option in octets.
|
||||
|
||||
option-data The data for the option; the format of this data
|
||||
depends on the definition of the option.
|
||||
*/
|
||||
typedef struct Ipdhcps6_option_struct
|
||||
{
|
||||
Ip_u16 code;
|
||||
Ip_u16 len;
|
||||
union Ipdhcps6_option_data data;
|
||||
}
|
||||
Ipdhcps6_option;
|
||||
|
||||
/* end-of packed structures */
|
||||
#include "ipcom_align16.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_check(Ipdhcps6_option *options, Ip_u16 optlen);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_exist(Ipdhcps6_option *opts, Ip_u16 optslen,
|
||||
Ip_u16 code);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_get(Ipdhcps6_option *opts, Ip_u16 optslen,
|
||||
Ip_u16 code,
|
||||
Ipdhcps6_option *opt, Ip_u16 optlen, Ip_u16 *bytes_written);
|
||||
|
||||
IP_GLOBAL Ipdhcps6_option *
|
||||
ipdhcps6_option_get_ptr(Ipdhcps6_option *opts, Ip_u16 optslen,
|
||||
Ip_u16 code);
|
||||
|
||||
IP_GLOBAL Ipdhcps6_option *
|
||||
ipdhcps6_option_next(Ipdhcps6_option *options, Ip_u16 *optlen);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_merge(Ipcom_hash *result_opts, Ipcom_hash *opts);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_add_server_id(Ipdhcps6_option *opt, Ip_u16 optlen, Ip_u16 *bytes_written);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_add_status_code(Ipdhcps6_option *opt, Ip_u16 optlen, Ip_u16 *bytes_written,
|
||||
Ip_u16 code, const char *message);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_add_auth (struct Ipdhcps6_authtrans_dbentry *db,
|
||||
Ip_u8 *authKey,
|
||||
Ip_size_t authKeyLen,
|
||||
Ip_u8 *authrealm,
|
||||
Ip_size_t authrealm_len,
|
||||
struct Ipdhcps6_message_struct *msg,
|
||||
Ipdhcps6_option *opt,
|
||||
Ip_u16 optlen,
|
||||
Ip_u16 *bytes_written);
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_verify_auth_option (struct Ipdhcps6_authtrans_dbentry *db,
|
||||
Ip_u8 *authKey,
|
||||
Ip_size_t authKeyLen,
|
||||
Ip_u8 *authrealm,
|
||||
Ip_size_t authrealm_len,
|
||||
struct Ipdhcps6_message_struct *msg,
|
||||
Ipdhcps6_option *opt,
|
||||
Ip_u16 optlen);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_add_iaprefix(Ipdhcps6_option_iaprefix *opt, Ip_u16 optlen, Ip_u16 *bytes_written,
|
||||
struct Ipdhcps6_prefix_struct *prefix);
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_add_relay_message(Ipdhcps6_option *dhcp_relay_opt,
|
||||
Ip_u16 optlen,
|
||||
Ip_u16 *bytes_written,
|
||||
void *relayed_msg,
|
||||
Ip_u16 relayed_msg_len);
|
||||
IP_GLOBAL Ip_err
|
||||
ipdhcps6_option_add_interface_id(Ipdhcps6_option *opt,
|
||||
Ip_u16 optlen,
|
||||
Ip_u16 *bytes_written,
|
||||
Ip_u32 interface_id);
|
||||
|
||||
IP_GLOBAL Ipcom_hash *
|
||||
ipdhcps6_option_new_db(void);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipdhcps6_option_delete_db(Ipcom_hash *options);
|
||||
|
||||
IP_GLOBAL Ipdhcps6_option_ia_xx *
|
||||
ipdhcps6_option_add_ia_xx_start(Ipdhcps6_option *opt,
|
||||
Ip_u16 code,
|
||||
Ip_u16 opt_buf_len,
|
||||
Ip_u16 *bytes_written);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipdhcps6_option_add_ia_xx_finish(Ipdhcps6_option_ia_xx *ia_na,
|
||||
Ip_u16 opt_buf_len,
|
||||
Ip_u32 iaid,
|
||||
Ip_u32 t1,
|
||||
Ip_u32 t2);
|
||||
|
||||
IP_GLOBAL Ipdhcps6_option_iaaddr *
|
||||
ipdhcps6_option_add_iaaddr_start(Ipdhcps6_option *opt,
|
||||
Ip_u16 opt_buf_len,
|
||||
Ip_u16 *bytes_written);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipdhcps6_option_add_iaaddr_finish(Ipdhcps6_option_iaaddr *iaddr,
|
||||
Ip_u16 opt_buf_len,
|
||||
IP_CONST struct Ip_in6_addr *addr,
|
||||
Ip_u32 preferred_lifetime,
|
||||
Ip_u32 valid_lifetime);
|
||||
|
||||
IP_GLOBAL Ipdhcps6_option_iaprefix *
|
||||
ipdhcps6_option_add_iaprefix_start(Ipdhcps6_option *opt,
|
||||
Ip_u16 opt_buf_len,
|
||||
Ip_u16 *bytes_written);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipdhcps6_option_add_iaprefix_finish(Ipdhcps6_option_iaprefix *iaprefix,
|
||||
Ip_u16 opt_buf_len,
|
||||
IP_CONST struct Ip_in6_addr *prefix,
|
||||
Ip_u8 prefix_len,
|
||||
Ip_u32 preferred_lifetime,
|
||||
Ip_u32 valid_lifetime);
|
||||
struct Ipdhcps6_host_struct;
|
||||
struct Ipdhcps6_subnet_entry_struct;
|
||||
|
||||
IP_GLOBAL Ipdhcps6_option *
|
||||
ipdhcps6_option_get_configured(struct Ipdhcps6_host_struct *host,
|
||||
struct Ipdhcps6_subnet_entry_struct *subnet,
|
||||
Ip_u16 ocode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user