364 lines
14 KiB
C
364 lines
14 KiB
C
/*
|
|
******************************************************************************
|
|
* INTERPEAK API HEADER FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcps6_msg.h,v $ $Revision: 1.9.16.1 $
|
|
* $Source: /home/interpeak/CVSRoot/ipdhcps6/src/ipdhcps6_msg.h,v $
|
|
* $Author: ulf $ $Date: 2011-11-16 10:33:28 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* Copyright Interpeak AB 2000-2004 <www.interpeak.se>. All rights reserved.
|
|
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
#ifndef IPDHCPS6_MSG_H
|
|
#define IPDHCPS6_MSG_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipdhcps6_config.h"
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include <ipcom_type.h>
|
|
#include <ipcom_cstyle.h>
|
|
|
|
#include "ipdhcps6_option.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
|
|
/* DHCP Message Types */
|
|
|
|
/* A client sends a Solicit message to locate servers. */
|
|
#define IPDHCPS6_MSG_SOLICIT 1
|
|
/* A server sends an Advertise message to indicate
|
|
that it is available for DHCP service, in
|
|
response to a Solicit message received from a
|
|
client. */
|
|
#define IPDHCPS6_MSG_ADVERTISE 2
|
|
/* A client sends a Request message to request
|
|
configuration parameters, including IP
|
|
addresses, from a specific server. */
|
|
#define IPDHCPS6_MSG_REQUEST 3
|
|
/* A client sends a Confirm message to any
|
|
available server to determine whether the
|
|
addresses it was assigned are still appropriate
|
|
to the link to which the client is connected. */
|
|
#define IPDHCPS6_MSG_CONFIRM 4
|
|
/* A client sends a Renew message to the server
|
|
that originally provided the client's addresses
|
|
and configuration parameters to extend the
|
|
lifetimes on the addresses assigned to the
|
|
client and to update other configuration
|
|
parameters. */
|
|
#define IPDHCPS6_MSG_RENEW 5
|
|
/* A client sends a Rebind message to any
|
|
available server to extend the lifetimes on the
|
|
addresses assigned to the client and to update
|
|
other configuration parameters; this message is
|
|
sent after a client receives no response to a
|
|
Renew message. */
|
|
#define IPDHCPS6_MSG_REBIND 6
|
|
/* A server sends a Reply message containing
|
|
assigned addresses and configuration parameters
|
|
in response to a Solicit, Request, Renew,
|
|
Rebind message received from a client. A
|
|
server sends a Reply message containing
|
|
configuration parameters in response to an
|
|
Information-request message. A server sends a
|
|
Reply message in response to a Confirm message
|
|
confirming or denying that the addresses
|
|
assigned to the client are appropriate to the
|
|
link to which the client is connected. A
|
|
server sends a Reply message to acknowledge
|
|
receipt of a Release or Decline message. */
|
|
#define IPDHCPS6_MSG_REPLY 7
|
|
/* A client sends a Release message to the server
|
|
that assigned addresses to the client to
|
|
indicate that the client will no longer use one
|
|
or more of the assigned addresses. */
|
|
#define IPDHCPS6_MSG_RELEASE 8
|
|
/* A client sends a Decline message to a server to
|
|
indicate that the client has determined that
|
|
one or more addresses assigned by the server
|
|
are already in use on the link to which the
|
|
client is connected. */
|
|
#define IPDHCPS6_MSG_DECLINE 9
|
|
/* A server sends a Reconfigure message to a
|
|
client to inform the client that the server has
|
|
new or updated configuration parameters, and
|
|
that the client is to initiate a Renew/Reply
|
|
or Information-request/Reply transaction with
|
|
the server in order to receive the updated
|
|
information. */
|
|
#define IPDHCPS6_MSG_RECONFIGURE 10
|
|
/* A client sends an Information-request
|
|
message to a server to request configuration
|
|
parameters without the assignment of any IP
|
|
addresses to the client. */
|
|
#define IPDHCPS6_MSG_INFORMATION_REQUEST 11
|
|
/* A relay agent sends a Relay-forward message
|
|
to relay messages to servers, either directly
|
|
or through another relay agent. The received
|
|
message, either a client message or a
|
|
Relay-forward message from another relay
|
|
agent, is encapsulated in an option in the
|
|
Relay-forward message. */
|
|
#define IPDHCPS6_MSG_RELAY_FORW 12
|
|
/* A server sends a Relay-reply message to a relay
|
|
agent containing a message that the relay
|
|
agent delivers to a client. The Relay-reply
|
|
message may be relayed by other relay agents
|
|
for delivery to the destination relay agent.
|
|
The server encapsulates the client message as
|
|
an option in the Relay-reply message, which the
|
|
relay agent extracts and relays to the client. */
|
|
#define IPDHCPS6_MSG_RELAY_REPL 13
|
|
|
|
|
|
|
|
/* Status Codes */
|
|
|
|
/* Success */
|
|
#define IPDHCPS6_CODE_SUCCESS 0
|
|
/* Failure, reason unspecified; this status code is sent by either a client
|
|
or a server to indicate a failure not explicitly specified in the DHCPv6
|
|
protocol specification */
|
|
#define IPDHCPS6_CODE_UNSPEC_FAIL 1
|
|
/* Server has no addresses available to assign to the IA(s) */
|
|
#define IPDHCPS6_CODE_NO_ADDRS_AVAIL 2
|
|
/* Client record (binding) unavailable */
|
|
#define IPDHCPS6_CODE_NO_BINDING 3
|
|
/* The prefix for the address is not appropriate to the link to which the
|
|
client is attached */
|
|
#define IPDHCPS6_CODE_NOT_ON_LINK 4
|
|
/* Sent by a server to a client to force the client to send messages to the
|
|
server using the All_DHCP_Relay_Agents_and_Servers address */
|
|
#define IPDHCPS6_CODE_USE_MULTICAST 5
|
|
/* The deligating server (this DHCPv6 server) will not give any prefixes
|
|
to the requesting router */
|
|
#define IPDHCPS6_CODE_NO_PREFIX_AVAIL 6
|
|
|
|
/*FLAGS used for FQDN*/
|
|
|
|
#define IPDHCPS6_DNS_AAAA 0
|
|
#define IPDHCPS6_DNS_PTR 1
|
|
#define IPDHCPS6_DNS_MAX_NAME_LEN 255
|
|
|
|
#define IPDHCPS6_DNS_DEFAULT_TTL 3600
|
|
#define IPDHCPS6_DNS_MIN_TTL 60*10
|
|
#define IPDHCPS6_FQDN_FLAG_S 0x01
|
|
#define IPDHCPS6_FQDN_FLAG_O 0x02
|
|
#define IPDHCPS6_FQDN_FLAG_N 0x04
|
|
#define IPDHCPS6_DNS_MD5_VALUE_LEN 16
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
struct Ipdhcps6_subnet_entry_struct;
|
|
|
|
typedef struct Ipdhcps6_message_struct
|
|
{
|
|
/* The interface to use for send response,
|
|
also the interface the request was received on */
|
|
Ip_u32 ifindex;
|
|
/* The address the request was sent to */
|
|
struct Ip_sockaddr_in6 local_addr;
|
|
/* The address the request was sent from */
|
|
struct Ip_sockaddr_in6 peer_addr;
|
|
/* The address the response should be sent to */
|
|
struct Ip_sockaddr_in6 response_addr;
|
|
/* Will be != if the response must be sent on a specific interface */
|
|
Ip_u32 response_ifindex;
|
|
/* The subnet that maches this message */
|
|
struct Ipdhcps6_subnet_entry_struct *subnet;
|
|
|
|
/* The length of the received message */
|
|
Ip_u16 recv_buf_len;
|
|
/* Pointer to the recieved message */
|
|
Ip_u8 *recv_buf;
|
|
|
|
/* Set to IP_TRUE if a response should be sent */
|
|
Ip_bool send_response;
|
|
/* The maximum length of the send buffer */
|
|
Ip_u16 send_buf_maxlen;
|
|
/* The actual length of data written to the send buffer */
|
|
Ip_u16 send_buf_len;
|
|
/* The send buffer */
|
|
Ip_u8 *send_buf;
|
|
|
|
/* Set to IP_TRUE if hop limit field should be set when
|
|
* relay agent relays messages to the All_DHCP_Servers multicast
|
|
* address or other multicast addresses. Fix for WIND00195425.
|
|
*/
|
|
Ip_bool mhop_limit;
|
|
}
|
|
Ipdhcps6_message;
|
|
|
|
|
|
/*
|
|
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
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
| msg-type | transaction-id |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
| |
|
|
. options .
|
|
. (variable) .
|
|
| |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
|
|
|
msg-type Identifies the DHCP message type; the
|
|
available message types are listed in
|
|
section 5.3.
|
|
|
|
transaction-id The transaction ID for this message exchange.
|
|
|
|
options Options carried in this message.
|
|
*/
|
|
#include "ipcom_align16.h"
|
|
typedef IP_PACKED1 struct Ipdhcps6_msg_hdr_struct
|
|
{
|
|
Ip_u8 type;
|
|
Ip_u8 transaction_id_1;
|
|
Ip_u8 transaction_id_2;
|
|
Ip_u8 transaction_id_3;
|
|
/* The options (header is 4 bytes so the this is the smallest possible size) */
|
|
Ip_u8 options[4];
|
|
}
|
|
IP_PACKED2 Ipdhcps6_msg_hdr;
|
|
#include "ipcom_align16.h"
|
|
|
|
|
|
/*
|
|
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
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
| msg-type | hop-count | |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
|
| |
|
|
| link-address |
|
|
| |
|
|
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
|
|
| | |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
|
| |
|
|
| peer-address |
|
|
| |
|
|
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
|
|
| | |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
|
. .
|
|
. options (variable number and length) .... .
|
|
| |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
*/
|
|
#include "ipcom_align16.h"
|
|
typedef IP_PACKED1 struct Ipdhcps6_relay_msg_hdr_struct
|
|
{
|
|
Ip_u8 type;
|
|
Ip_u8 hop_count;
|
|
struct Ip_in6_addr link_addr;
|
|
struct Ip_in6_addr peer_addr;
|
|
Ip_u8 options[1];
|
|
}
|
|
IP_PACKED2 Ipdhcps6_relay_msg_hdr;
|
|
#include "ipcom_align16.h"
|
|
|
|
|
|
#define IPDHCPS6_MSG_HDR_LEN 4
|
|
#define IPDHCP_RELAY_MSG_HDR_LEN 34
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
IP_GLOBAL const char *
|
|
ipdhcps6_msg_type_to_string(Ip_u8 type);
|
|
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_solicit(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options, Ip_u16 optlen);
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_confirm(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options, Ip_u16 optlen);
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_request(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options, Ip_u16 optlen);
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_renew(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options, Ip_u16 optlen);
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_rebind(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options, Ip_u16 optlen);
|
|
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_release(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options, Ip_u16 optlen);
|
|
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_decline(Ipdhcps6_message * msg,
|
|
Ipdhcps6_option *options,
|
|
Ip_u16 optslen);
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_relay_forw(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options, Ip_u16 optlen);
|
|
|
|
IP_GLOBAL Ip_err
|
|
ipdhcps6_msg_process_information_request(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option *options,
|
|
Ip_u16 optlen);
|
|
|
|
IP_GLOBAL void
|
|
ipdhcps6_msg_get_first_option(Ipdhcps6_msg_hdr *msg,
|
|
Ip_u16 msg_len,
|
|
Ipdhcps6_option **poptions,
|
|
Ip_u16 *poptslen);
|
|
|
|
IP_GLOBAL void
|
|
ipdhcps6_msg_first_response_opt(Ipdhcps6_message *msg,
|
|
Ipdhcps6_option **response_opt,
|
|
Ip_u16 *optlen);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|