original files of m241
This commit is contained in:
@@ -0,0 +1,588 @@
|
||||
/* 00comp_ipnet_mobility_pm6.cdf - IPNet Mobility configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement. No license to Wind River intellectual property rights
|
||||
* is granted herein. All rights not licensed by Wind River are reserved
|
||||
* by Wind River.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01b,14jul08,tlu Fix a module name to fix the component greyed out in WB
|
||||
01i,11may08,jho created.
|
||||
*/
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPMIP6PM
|
||||
|
||||
|
||||
Component INCLUDE_IPMIP6PM {
|
||||
NAME IPv6 Mobility Access Gateway Agent
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Agent
|
||||
REQUIRES INCLUDE_IPCOM_USE_INET6 INCLUDE_IPMIP6 SELECT_IPMIP6PM
|
||||
MODULES ipmip6pm.o
|
||||
CONFIGLETTES ipmip6pm_config.c
|
||||
CFG_PARAMS MIP6PM_INTERFACES \
|
||||
MIP6PM_LIFETIME_ENUM \
|
||||
MIP6PM_INITIAL_REGISTRATION_TIMEOUT_ENUM \
|
||||
MIP6PM_TIMESTAMP_BASED_APPROACH_IN_USE_ENUM \
|
||||
MIP6PM_CARE_OF_ADDRESS_ENUM \
|
||||
MIP6PM_TUNNEL_IP6IP6_ENUM \
|
||||
MIP6PM_TUNNEL_GRE_ENUM \
|
||||
MIP6PM_TUNNEL_GRE_PREFERRED_ENUM \
|
||||
MIP6PM_TUNNEL_GRE_KEYED_ENUM \
|
||||
MIP6PM_HEARTBEAT_ENABLED_ENUM \
|
||||
MIP6PM_HEARTBEAT_INTERVAL_ENUM \
|
||||
MIP6PM_MISSING_HEARTBEATS_ALLOWED_ENUM \
|
||||
MIP6PM_LMA_ENUM \
|
||||
MIP6PM_BINDING_REVOCATION_MIN_DELAY_ENUM \
|
||||
MIP6PM_BINDING_REVOCATION_MAX_RETRIES_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LAYER_ADDRESS {
|
||||
NAME IPv6 Mobility Access Gateway Link Feature FixedMAGLinkLayerAddressOnAllAccessLinks
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Link Feature FixedMAGLinkLayerAddressOnAllAccessLinks
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_FIXED_MAG_LINK_LAYER_ADDRESS_ON_ALL_ACCESS_LINKS_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LOCAL_ADDRESS {
|
||||
NAME IPv6 Mobility Access Gateway Link Feature FixedMAGLinkLocalAddressOnAllAccessLinks
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Link Feature FixedMAGLinkLocalAddressOnAllAccessLinks
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_FIXED_MAG_LINK_LOCAL_ADDRESS_ON_ALL_ACCESS_LINKS_ENUM
|
||||
}
|
||||
|
||||
|
||||
Component INCLUDE_IPMIP6PM_DUAL_STACK {
|
||||
NAME IPv6 Mobility Access Gateway Agent Dual Stack Support
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Agent Dual Stack Support
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_INET_CARE_OF_ADDRESS_ENUM \
|
||||
MIP6PM_INET_USE_IPV4_UDP_ENCAP_FOR_SIGNALING_MESSAGES_ENUM \
|
||||
MIP6PM_INET_FORCE_IPV4_UDP_ENCAPSULATION_SUPPORT_ENUM \
|
||||
MIP6PM_INET_IPV4UDPENCAPSULATIONNATTIMEOUT_ENUM \
|
||||
MIP6PM_INET_TUNNEL_IPIP_ENUM \
|
||||
MIP6PM_INET_TUNNEL_GRE_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_SERVICE_FEATURE_DHCP_RELAY {
|
||||
NAME IPv6 Mobility Access Gateway Agent Service Feature DHCP Relay Support
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Agent Service Feature DHCP Relay Support
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_DHCP_RELAY_MODE_ENUM \
|
||||
MIP6PM_DHCP_RELAY_SERVER_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_SERVICE_FEATURE_RADVD {
|
||||
NAME IPv6 Mobility Access Gateway Agent Service Feature RADVD Support
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Agent Service Feature RADVD Support. \
|
||||
Will provide RADVD functionality on the access links. Unless \
|
||||
you implement another address assignment feature, this \
|
||||
service should always be included.
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_RADVD_MANAGED_ENUM \
|
||||
MIP6PM_RADVD_OTHER_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_SERVICE_FEATURE_SERVICE_SELECTION {
|
||||
NAME IPv6 Mobility Access Gateway Agent Service Feature Service Selection Support
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Agent Service Feature Service Selection Support
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_SERVICE_SELECTION_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_SERVICE_FEATURE_VENDOR_EXTENSION {
|
||||
NAME IPv6 Mobility Access Gateway Agent Service Feature Generic Vendor Extension Support
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Agent Service Feature Generic Vendor Extension Support
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_VENDOR_EXTENSION_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_RELAY_SUPPORT {
|
||||
NAME IPv6 Mobility Access Gateway Dual Stack Internal DHCP Relay Support
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Dual Stack Internal DHCP Relay includes \
|
||||
the integrated DHCP relay feature.
|
||||
REQUIRES INCLUDE_IPMIP6PM_DUAL_STACK
|
||||
CFG_PARAMS MIP6PM_INET_DHCP_RELAY_SERVER_ENUM \
|
||||
MIP6PM_INET_DHCP_RELAY_SERVER_OVERRIDE_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_SERVER_SUPPORT {
|
||||
NAME IPv6 Mobility Access Gateway Dual Stack Internal DHCP Server Support
|
||||
SYNOPSIS IPv6 Mobility Access Gateway Dual Stack Internal DHCP includes \
|
||||
the integrated DHCP server feature.
|
||||
REQUIRES INCLUDE_IPMIP6PM_DUAL_STACK
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_SERVICE_FEATURE_EXTENSION {
|
||||
NAME IPv6 Mobility Access Gateway Service Feature Extension
|
||||
SYNOPSIS This feature should be included if one wants to add \
|
||||
a new service feature to the mobility access gateway, and have the \
|
||||
feature hook being registered during initialization.
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_SERVICE_FEATURE_INITIALIZATION_HOOK
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_LINK_FEATURE_EXTENSION {
|
||||
NAME IPv6 Mobility Access Gateway Link Feature Extension
|
||||
SYNOPSIS This feature should be included if one wants to add \
|
||||
a new link feature to the mobility access gateway, and have the \
|
||||
feature hook being registered during initialization.
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
CFG_PARAMS MIP6PM_LINK_FEATURE_INITIALIZATION_HOOK
|
||||
}
|
||||
|
||||
Selection SELECT_IPMIP6PM {
|
||||
NAME Ipv6 Mobility Access Gateway Components
|
||||
SYNOPSIS Ipv6 Mobility Access Gateway Components
|
||||
COUNT 0-
|
||||
REQUIRES INCLUDE_IPMIP6PM
|
||||
_CHILDREN FOLDER_MOBILITY_V6
|
||||
CHILDREN INCLUDE_IPMIP6PM \
|
||||
INCLUDE_IPMIP6PM_CMD \
|
||||
INCLUDE_IPMIP6PM_DUAL_STACK \
|
||||
INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_RELAY_SUPPORT \
|
||||
INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_SERVER_SUPPORT \
|
||||
INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LAYER_ADDRESS \
|
||||
INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LOCAL_ADDRESS \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_DHCP_RELAY \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_RADVD \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_SERVICE_SELECTION \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_VENDOR_EXTENSION \
|
||||
INCLUDE_IPMIP6PM_LINK_FEATURE_EXTENSION \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_EXTENSION
|
||||
DEFAULTS INCLUDE_IPMIP6PM \
|
||||
INCLUDE_IPMIP6PM_CMD \
|
||||
INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LAYER_ADDRESS \
|
||||
INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LOCAL_ADDRESS \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_DHCP_RELAY \
|
||||
INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_SERVER_SUPPORT \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_RADVD \
|
||||
INCLUDE_IPMIP6PM_SERVICE_FEATURE_SERVICE_SELECTION \
|
||||
INCLUDE_IPMIP6PM_DUAL_STACK \
|
||||
INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_RELAY_SUPPORT
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIP6PM_CMD {
|
||||
NAME IPv6 Mobility Access Gateway IPCOM commands
|
||||
SYNOPSIS IPv6 Mobility Access Gateway IPCOM commands
|
||||
MODULES ipmip6pm_cmd_pm6.o
|
||||
REQUIRES INCLUDE_IPCOM_SHELL_CMD INCLUDE_IPMIP6PM
|
||||
}
|
||||
|
||||
|
||||
Parameter MIP6PM_INTERFACES {
|
||||
NAME Interface list
|
||||
SYNOPSIS The interface list specifies what interfaces \
|
||||
should be configured for ;AG operation. This \
|
||||
parameter is a comma separated list of interfaces such \
|
||||
as "<ifname1>,<ifname2>" etc.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_LIFETIME_ENUM {
|
||||
NAME Interface requested lifetime
|
||||
SYNOPSIS The lifetime in seconds that the MAG will request from the LMA. \
|
||||
This value indicates the maximum lifetime length, since the LMA \
|
||||
may lower it. The default value is "60". Format for this \
|
||||
configuration item is a semi-colon separated list of interfaces \
|
||||
and lifetime values as specified by the following format string \
|
||||
"<ifname1>=<lifetime1>;<ifnameN>=<lifetimeN>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INITIAL_REGISTRATION_TIMEOUT_ENUM {
|
||||
NAME Interface Initial Registration Timeout
|
||||
SYNOPSIS Specifies the amount of time (in milliseconds) to wait for \
|
||||
the initial binding acknowledgement from the home agent. \
|
||||
The initial binding acknowledgement may take additional time \
|
||||
compared to subsequent ones, due to the requirement to \
|
||||
verify address usability. The default value is "1500". Format for \
|
||||
this configuration item is a semi-colon separated list of \
|
||||
interfaces and lifetime values as specified by the following \
|
||||
format string "<ifname1>=<timeout1>;<ifnameN>=<timeoutN>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_TIMESTAMP_BASED_APPROACH_IN_USE_ENUM {
|
||||
NAME Interface Timestamp Based Approach In Use
|
||||
SYNOPSIS Specifies whether or not an interface should be using Timestamps \
|
||||
or Sequence numbers for replay and out-of-order protection. \
|
||||
By default the MAG will use Timestamps. The format for this \
|
||||
parameter is "<ifname1>=<enabled|disabled>;<ifnameN>=<enabled|disabled>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_CARE_OF_ADDRESS_ENUM {
|
||||
NAME Interface Care of Address
|
||||
SYNOPSIS Specifies the INET6 Care-of-address that should be used by the MAG \
|
||||
for communication with the Home Agent/LMA. If not specified, the MAG. \
|
||||
will attempt to resolve it from the interface. If no address is \
|
||||
available, the interface will be disabled.. The format for this \
|
||||
parameter is "<ifname1>=<address1>;<ifnameN>=<addressN>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_TUNNEL_IP6IP6_ENUM {
|
||||
NAME Interface IPv6 tunneling
|
||||
SYNOPSIS This configuration item specifies whether or not IPv6 tunneling \
|
||||
is allowed by the MAG. By default it is always "enabled". \
|
||||
This configuration parameter is specified by using a \
|
||||
semi-colon separated list of interface names and \
|
||||
disabled/enabled values, as specified by the format string \
|
||||
"<ifname1>=<enabled|disabled>;<ifnameN>=<enabled|disabled>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_TUNNEL_GRE_ENUM {
|
||||
NAME Interface IPv6 GRE tunneling
|
||||
SYNOPSIS This configuration item specifies whether or not IPv6 GRE tunneling \
|
||||
is allowed by the MAG. By default it is always "enabled". \
|
||||
This configuration parameter is specified by using a \
|
||||
semi-colon separated list of interface names and \
|
||||
disabled/enabled values, as specified by the format string \
|
||||
"<ifname1>=<enabled|disabled>;<ifnameN>=<enabled|disabled>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_TUNNEL_GRE_PREFERRED_ENUM {
|
||||
NAME Interface IPv6 GRE Preferred tunneling
|
||||
SYNOPSIS This configuration item specifies whether or not GRE tunneling \
|
||||
is preferred by the MAG. If preferred, the MAG will try to use \
|
||||
GRE initially, and if the LMA either forbids it or is unable \
|
||||
to handle it, revert to IPIP. By default this parameter is \
|
||||
"disabled". This configuration parameter is specified by using \
|
||||
a semi-colon separated list of interface names and \
|
||||
disabled/enabled values, as specified by the format string \
|
||||
"<ifname1>=<enabled|disabled>;<ifnameN>=<enabled|disabled>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_TUNNEL_GRE_KEYED_ENUM {
|
||||
NAME Interface IPv6 GRE Keyed tunneling
|
||||
SYNOPSIS This configuration item specifies whether or not GRE tunneling \
|
||||
is keyed. By default Keyed GRE is "enabled". This configuration \
|
||||
parameter is specified by using a semi-colon separated list of interface \
|
||||
names and disabled/enabled values, as specified by the format string \
|
||||
"<ifname1>=<enabled|disabled>;<ifnameN>=<enabled|disabled>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_HEARTBEAT_ENABLED_ENUM {
|
||||
NAME Interface Proxy Mobility HEARTBEAT
|
||||
SYNOPSIS This configuration option specifies whether or not the Heartbeat \
|
||||
feature is enabled for the specified interface. If no \
|
||||
configuration is provided, the feature is turned off. \
|
||||
The format for this configuration item is \
|
||||
a semi-colon separated list of "<ifname>=<enabled|disabled>".
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_HEARTBEAT_INTERVAL_ENUM {
|
||||
NAME Interface Proxy Mobility HEARTBEAT_INTERVAL
|
||||
SYNOPSIS This variable is used to set the time interval in seconds \
|
||||
between two consecutive Heartbeat Request messages. The \
|
||||
default value is 60 seconds. It SHOULD NOT be set to less \
|
||||
than 30 seconds.The format for this configuration item is \
|
||||
a semi-colon separated list of "<ifname>=<interval>".
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_MISSING_HEARTBEATS_ALLOWED_ENUM {
|
||||
NAME Interface Proxy Mobility MISSING_HEARTBEATS_ALLOWED
|
||||
SYNOPSIS This variable indicates the maximum number of consecutive \
|
||||
Heartbeat Request messages that a PMIPv6 node can miss before \
|
||||
concluding that the peer PMIPv6 node is not reachable. The \
|
||||
default value for this variable is 3.\
|
||||
The format for this configuration item is a semi-colon \
|
||||
separated list of "<ifname>=<misses>".
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_LMA_ENUM {
|
||||
NAME Proxy Mobility Local Mobility Anchor Definitions
|
||||
SYNOPSIS This configuration item specifies what LMAs \
|
||||
should be permanently added to the LMA database, \
|
||||
and whether or not they support HeartBeat. The MAG will \
|
||||
send an unsolicited HeartBeat response to each HeartBeat \
|
||||
enabled LMA during startup and reconfiguration. \
|
||||
The format for this configuration item is a semi-colon \
|
||||
separated list of "<LMA address>=<enabled|disabled>", where \
|
||||
<LMA Address> has the form <LMA INET6 Address>[/<LMA INET Address>]
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_FIXED_MAG_LINK_LAYER_ADDRESS_ON_ALL_ACCESS_LINKS_ENUM {
|
||||
NAME Interface Fixed MAG Link Layer Address on all Access Links
|
||||
SYNOPSIS This parameter specifies what Link Layer address should be \
|
||||
used on all access links belonging to this proxy domain. The \
|
||||
format is specified as a link layer address. For example \
|
||||
ethernet would use XX:XX:XX:XX:XX:XX. The format for this \
|
||||
configuration item is a semi-colon \
|
||||
separated list of "<ifname1>=<Link Layer Address>". For example \
|
||||
"eth0=00:00:0a:0a:0a:0a"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_FIXED_MAG_LINK_LOCAL_ADDRESS_ON_ALL_ACCESS_LINKS_ENUM {
|
||||
NAME Interface Fixed MAG Link Local Address on all Access Links
|
||||
SYNOPSIS This configuration item specifies the Link Local Address that \
|
||||
should be used on all access links in this proxy mobility \
|
||||
domain. If not specified or set to "::", the LMA will allocate \
|
||||
a link local address for each session. The format for this \
|
||||
configuration item is a semi-colon separated list of \
|
||||
"<ifname1>=<Link Local Address>". For example "eth0=fe80::1/64"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_SERVICE_FEATURE_INITIALIZATION_HOOK {
|
||||
NAME Mobility Access Gateway Service Feature Initialization Hook
|
||||
SYNOPSIS This is the function hook that you may define in order to \
|
||||
register extra functional extensions to the Mobility Access \
|
||||
Gateway. The Service Features are provided after the \
|
||||
Link Features have been completed, so that the access \
|
||||
link should be fully up and running.
|
||||
TYPE FUNCPTR
|
||||
DEFAULT your_function_here
|
||||
}
|
||||
|
||||
Parameter MIP6PM_LINK_FEATURE_INITIALIZATION_HOOK {
|
||||
NAME Mobility Access Gateway Link Feature Initialization Hook
|
||||
SYNOPSIS This is the function hook that you may define in order to \
|
||||
register extra functional extensions to the Mobility Access \
|
||||
Gateway. The Link Features are used to setup the access link \
|
||||
and will be invoked and provided prior to service features.
|
||||
TYPE FUNCPTR
|
||||
DEFAULT your_function_here
|
||||
}
|
||||
|
||||
|
||||
Parameter MIP6PM_DHCP_RELAY_MODE_ENUM {
|
||||
NAME Mobility Access Gateway Service Feature DHCP Relay Mode
|
||||
SYNOPSIS This option specifies the mode of the DHCP Relay. It may be \
|
||||
set to "disabled", "optional" or "required". If "required", \
|
||||
the relay will always be configured, if "optional" it may \
|
||||
be enabled by node specific arguments. Format for this \
|
||||
parameter is a semi-colon separated list of \
|
||||
"<ifname>=<disabled|optional|required>". Default value is \
|
||||
"optional".
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_DHCP_RELAY_SERVER_ENUM {
|
||||
NAME Mobility Access Gateway Service Feature DHCP Relay Server
|
||||
SYNOPSIS This option specifies the DHCP server to be used. It may be \
|
||||
overriden by node specific arguments. If no server has been \
|
||||
specified, the home agent address will be used. Format for this \
|
||||
parameter is a semi-colon separated list of \
|
||||
"<ifname>=<address>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_RADVD_MANAGED_ENUM {
|
||||
NAME RADVD Managed Flag
|
||||
SYNOPSIS Enable or disable the MANAGED flag for RADVD.Format for this \
|
||||
parameter is a semi-colon separated list of \
|
||||
"<ifname>=<true|false>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_RADVD_OTHER_ENUM {
|
||||
NAME RADVD Other Config Flag
|
||||
SYNOPSIS Enable or disable the Other configuration flag for RADVD.\
|
||||
Format for this parameter is a semi-colon separated list of \
|
||||
"<ifname>=<true|false>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_SERVICE_SELECTION_ENUM {
|
||||
NAME Service Selection
|
||||
SYNOPSIS Specify the Service Selection parameter. If specified, the.\
|
||||
MAG will provide the string to the LMA in order for the LMA \
|
||||
to setup the correct services. This configuration parameter \
|
||||
may be overriden by node specific arguments. Format for this \
|
||||
parameter is a semi-colon separated list of \
|
||||
"<ifname>=<service selection string>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INET_CARE_OF_ADDRESS_ENUM {
|
||||
NAME Interface INET Care of Address
|
||||
SYNOPSIS Specifies the INET Care-of-address that should be used by the MAG \
|
||||
for communication with the Home Agent/LMA. If not specified, the MAG. \
|
||||
will attempt to resolve it from the interface. The format for this \
|
||||
parameter is "<ifname1>=<address1>;<ifnameN>=<addressN>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INET_USE_IPV4_UDP_ENCAP_FOR_SIGNALING_MESSAGES_ENUM {
|
||||
NAME Interface INET UseIPv4UDPEncapForSignalingMessages
|
||||
SYNOPSIS This flag indicates whether or not the mobile access gateway \
|
||||
should use IPv4-UDP encapsulation mode for the signaling messages. \
|
||||
The default value for this flag is set to value of 0, indicating \
|
||||
that the mobile access gateway MUST NOT use IPv4-UDP encapsulation \
|
||||
mode, but MUST use native IPv4 encapsulation mode for sending the \
|
||||
Proxy Mobile IPv6 signaling messages. \
|
||||
When the value for this flag is set to value of 1, the mobile \
|
||||
access gateway MUST use IPv4-UDP encapsulation mode for sending \
|
||||
the Proxy Mobile IPv6 signaling messages. The format for this \
|
||||
parameter is "<ifname1>=<0|1>;<ifnameN>=<0|1>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
|
||||
Parameter MIP6PM_INET_FORCE_IPV4_UDP_ENCAPSULATION_SUPPORT_ENUM {
|
||||
NAME Interface INET ForceIPv4UDPEncapsulationSupport
|
||||
SYNOPSIS This flag indicates whether or not the mobile access gateway \
|
||||
should request the mobile node's local mobility anchor for forcing \
|
||||
IPv4 UDP encapsulation support for the mobile node's data traffic, \
|
||||
even when NAT is not detected in the path. \
|
||||
The default value for this flag is set to value of 0, indicating \
|
||||
that the mobile access gateway MUST NOT request the mobile node's \
|
||||
local mobility anchor for forcing IPv4 UDP encapsulation support \
|
||||
even when NAT is not detected in path. \
|
||||
When the value for this flag is set to value of 1, the mobile \
|
||||
access gateway MUST force the mobile node's local mobility anchor \
|
||||
for IPv4 UDP encapsulation support. \
|
||||
This flag is applicable only when the flag \
|
||||
UseIPv4UDPEncapForSignalingMessages is set to a value of 1. \
|
||||
The format for this parameter is "<ifname1>=<0|1>;<ifnameN>=<0|1>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INET_IPV4UDPENCAPSULATIONNATTIMEOUT_ENUM {
|
||||
NAME Interface INET UDP Encapsulation NAT Timeout
|
||||
SYNOPSIS This parameter specifies the maximum time in seconds that the \
|
||||
MAG must send BUs to a LMA in order to maintain NAT translations \
|
||||
in the path. The default value is 110. The format for this \
|
||||
parameter is "<ifname1>=<timeout1>;<ifnameN>=<timeoutN>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INET_TUNNEL_IPIP_ENUM {
|
||||
NAME INET IPIP tunneling
|
||||
SYNOPSIS This configuration item specifies whether or not v4 IPIP tunneling \
|
||||
is allowed by the MAG for proxy mobility. By default all \
|
||||
interfaces enables IPIP tunneling. This configuration parameter \
|
||||
is specified by using a semi-colon separated list of interface \
|
||||
names and disabled/enabled values, as specified by the format \
|
||||
string "<ifname1>=<enabled|disabled>;<ifnameN>=<enabled|disabled>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INET_TUNNEL_GRE_ENUM {
|
||||
NAME INET GRE tunneling
|
||||
SYNOPSIS This configuration item specifies whether v4 GRE tunneling \
|
||||
is allowed by the MAG for Proxy Mobility. By default all \
|
||||
interfaces enables GRE. This configuration parameter is \
|
||||
specified by using a semi-colon separated list of interface \
|
||||
names and disabled/enabled values, as specified by the format string \
|
||||
"<ifname1>=<enabled|disabled>;<ifnameN>=<enabled|disabled>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INET_DHCP_RELAY_SERVER_ENUM {
|
||||
NAME INET DHCP Relay Server
|
||||
SYNOPSIS This configuration item specifies the DHCP server that DHCP \
|
||||
requests should be forwarded to. If this parameter is not \
|
||||
specified, the INET home agent is used. These parameters may \
|
||||
be overriden by node specific parameters. This parameter is \
|
||||
specified by using a semi-colon separated list of interface \
|
||||
names and INET address values, as specified by the format string \
|
||||
"<ifname1>=<DHCP server1>;<ifnameN>=<DHCP serverN>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_INET_DHCP_RELAY_SERVER_OVERRIDE_ENUM {
|
||||
NAME INET DHCP Relay Server Override
|
||||
SYNOPSIS This configuration item specifies if the DHCP Relay should \
|
||||
request the use of DHCP server override. DHCP server override \
|
||||
may be required if the DHCP server is not co-located or \
|
||||
integrated with the Home Agent. This item is "true" by default. \
|
||||
This parameter is specified by using a semi-colon separated list \
|
||||
of interface names and true/false values, as specified by the \
|
||||
format string "<ifname1>=<true|false>;<ifnameN>=<true|false>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_VENDOR_EXTENSION_ENUM {
|
||||
NAME Generic Vendor Extension Configuration
|
||||
SYNOPSIS If configured, will add Vendor Extension options to the \
|
||||
registration messages. The Generic vendor extension feature \
|
||||
does not do anything beyond providing the information in the \
|
||||
binding update. Extra features or functionalities acting upon \
|
||||
the vendor extensions are beyond the current scope of this \
|
||||
product. The format of the configuration parameter is a semi-colon\
|
||||
separated list of <SMI Number>.<SubType>=<value1>[,<valueN>]. \
|
||||
SMI Number is the IANA assigned SMI number. Subtype is the \
|
||||
vendor specified subtype. Value is defined as a string, or as \
|
||||
a comma separated array of hexadecimal numbers. The number of \
|
||||
hexadecimal figures in the value will define how the value is \
|
||||
interpreted. For example 0xaa is 1 byte, 0x00aa is two bytes, \
|
||||
0x0000aa will be interpreted as a four byte value. Values \
|
||||
larger than 1 byte will be converted to network byte order.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_BINDING_REVOCATION_MIN_DELAY_ENUM {
|
||||
NAME MAG Minimum Delay Between BRI messages (MINDelayBRIs)
|
||||
SYNOPSIS This variable specifies the delay time in milliseconds before \
|
||||
the revoking mobility entity retransmits a BRI message. The \
|
||||
default is 1000 ms but not less than 500 ms.\
|
||||
This configuration parameter is specified by using a semi-colon \
|
||||
separated list of interface names and timeout values, as \
|
||||
specified by the format string \
|
||||
"<ifname1>=<milliseconds>;<ifnameN>=<milliseconds>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIP6PM_BINDING_REVOCATION_MAX_RETRIES_ENUM {
|
||||
NAME MAG BRI Maximum Number of Retries (BRIMaxRetriesNumber)
|
||||
SYNOPSIS This variable specifies the maximum Number of times a mobility \
|
||||
entity can retransmit a Binding Revocation Indication message \
|
||||
before receiving a Binding Revocation Acknowledgement message. \
|
||||
The default value for this parameter is 1. \
|
||||
This configuration parameter is specified by using a semi-colon \
|
||||
separated list of interface names and retransmit values, as \
|
||||
specified by the format string \
|
||||
"<ifname1>=<retransmits>;<ifnameN>=<retransmits>"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.6 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipmip6pm/config/common.vxconfig,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPMIP6PM
|
||||
config SUPPORTS_MIP6PM
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_config.c,v $ $Revision: 1.16 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_config.c,v $
|
||||
* $Author: jonas $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef void (*Ipmip6pm_config_func_t) (void *);
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int ipmip6pm_cmd_pm6(int argc, char **argv);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if !defined(INCLUDE_IPMIP6MN)
|
||||
|
||||
#define INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LAYER_ADDRESS 1
|
||||
#define INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LOCAL_ADDRESS 1
|
||||
#define INCLUDE_IPMIP6PM_SERVICE_FEATURE_DHCP_RELAY 1
|
||||
#define INCLUDE_IPMIP6PM_SERVICE_FEATURE_RADVD 1
|
||||
#define INCLUDE_IPMIP6PM_SERVICE_FEATURE_SERVICE_SELECTION 1
|
||||
#define INCLUDE_IPMIP6PM_SERVICE_FEATURE_VENDOR_EXTENSION 1
|
||||
#define INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_RELAY_SUPPORT 1
|
||||
#define INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_SERVER_SUPPORT 1
|
||||
#define INCLUDE_IPMIP6PM_DUAL_STACK 1
|
||||
|
||||
#define INCLUDE_IPMIP6PM_CMD
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Basic MIP6 Mobile Node(mn) sysvar Configuration
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
IP_STATIC IP_CONST Ipcom_sysvar ipmip6pm_conf_sysvar[] =
|
||||
{
|
||||
|
||||
/* Configuration delimiter - DO NOT EDIT! */
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
IP_STATIC IP_CONST Ipcom_sysvar ipmip6pm_conf_sysvar[] =
|
||||
{
|
||||
/* Basic configuration entries */
|
||||
{ "ipmip6pm.interfaces", MIP6PM_INTERFACES },
|
||||
|
||||
|
||||
/* Configuration delimiter - DO NOT EDIT! */
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
/* Interface specific list configurations */
|
||||
IP_CONST Ipcom_sysvar_ext ipmip6pm_conf_sysvar_ext[] =
|
||||
{
|
||||
/* Configuration delimiter - DO NOT EDIT! */
|
||||
{ "ipmip6pm.interface", "lifetime", MIP6PM_LIFETIME_ENUM },
|
||||
{ "ipmip6pm.interface", "InitialBindackTimeoutFirstReg", MIP6PM_INITIAL_REGISTRATION_TIMEOUT_ENUM },
|
||||
{ "ipmip6pm.interface", "TimestampBasedApproachInUse", MIP6PM_TIMESTAMP_BASED_APPROACH_IN_USE_ENUM },
|
||||
{ "ipmip6pm.interface", "care_of_address", MIP6PM_CARE_OF_ADDRESS_ENUM },
|
||||
{ "ipmip6pm.interface", "tunnel.gre", MIP6PM_TUNNEL_GRE_ENUM },
|
||||
{ "ipmip6pm.interface", "tunnel.ip6ip6", MIP6PM_TUNNEL_IP6IP6_ENUM },
|
||||
{ "ipmip6pm.interface", "tunnel.gre.Preferred", MIP6PM_TUNNEL_GRE_PREFERRED_ENUM },
|
||||
{ "ipmip6pm.interface", "tunnel.gre.UseKeys", MIP6PM_TUNNEL_GRE_KEYED_ENUM },
|
||||
{ "ipmip6pm.interface", "HeartBeatEnabled", MIP6PM_HEARTBEAT_ENABLED_ENUM },
|
||||
{ "ipmip6pm.interface", "HeartBeatInterval", MIP6PM_HEARTBEAT_INTERVAL_ENUM },
|
||||
{ "ipmip6pm.interface", "MissingHeartBeatsAllowed", MIP6PM_MISSING_HEARTBEATS_ALLOWED_ENUM },
|
||||
{ "ipmip6pm.LMA", IP_NULL, MIP6PM_LMA_ENUM },
|
||||
|
||||
{ "ipmip6pm.interface", "BRIMaxRetriesNumber", MIP6PM_BINDING_REVOCATION_MAX_RETRIES_ENUM },
|
||||
{ "ipmip6pm.interface", "MINDelayBRIs", MIP6PM_BINDING_REVOCATION_MIN_DELAY_ENUM },
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_DUAL_STACK)
|
||||
{ "ipmip6pm.interface", "inet.care_of_address", MIP6PM_INET_CARE_OF_ADDRESS_ENUM },
|
||||
{ "ipmip6pm.interface", "inet.UseIPv4UDPEncapForSignalingMessages", MIP6PM_INET_USE_IPV4_UDP_ENCAP_FOR_SIGNALING_MESSAGES_ENUM },
|
||||
{ "ipmip6pm.interface", "inet.ForceIPv4UDPEncapsulationSupport", MIP6PM_INET_FORCE_IPV4_UDP_ENCAPSULATION_SUPPORT_ENUM },
|
||||
{ "ipmip6pm.interface", "inet.IPv4UDPEncapsulationNATTimeout", MIP6PM_INET_IPV4UDPENCAPSULATIONNATTIMEOUT_ENUM },
|
||||
{ "ipmip6pm.interface", "inet.tunnel.gre", MIP6PM_INET_TUNNEL_GRE_ENUM },
|
||||
{ "ipmip6pm.interface", "inet.tunnel.ipip", MIP6PM_INET_TUNNEL_IPIP_ENUM },
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_RELAY_SUPPORT)
|
||||
{ "ipmip6pm.interface", "inet.dhcp.relay.enabled", "enabled" },
|
||||
{ "ipmip6pm.interface", "inet.dhcp.relay.server", MIP6PM_INET_DHCP_RELAY_SERVER_ENUM },
|
||||
{ "ipmip6pm.interface", "inet.dhcp.relay.server.override", MIP6PM_INET_DHCP_RELAY_SERVER_OVERRIDE_ENUM },
|
||||
#else
|
||||
{ "ipmip6pm.interface", "inet.dhcp.relay.enabled", "disabled" },
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_SERVER_SUPPORT)
|
||||
{ "ipmip6pm.interface", "inet.dhcp.server.enabled", "enabled" },
|
||||
#else
|
||||
{ "ipmip6pm.interface", "inet.dhcp.server.enabled", "disabled" },
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LAYER_ADDRESS)
|
||||
{ "ipmip6pm.interface", "FixedMAGLinkLayerAddressOnAllAccessLinks", MIP6PM_FIXED_MAG_LINK_LAYER_ADDRESS_ON_ALL_ACCESS_LINKS_ENUM },
|
||||
#endif
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LOCAL_ADDRESS)
|
||||
{ "ipmip6pm.interface", "FixedMAGLinkLayerAddressOnAllAccessLinks", MIP6PM_FIXED_MAG_LINK_LOCAL_ADDRESS_ON_ALL_ACCESS_LINKS_ENUM },
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_DHCP_RELAY)
|
||||
{ "ipmip6pm.interface", "dhcpv6_relay.mode", MIP6PM_DHCP_RELAY_MODE_ENUM },
|
||||
{ "ipmip6pm.interface", "dhcpv6_relay.server", MIP6PM_DHCP_RELAY_SERVER_ENUM },
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_RADVD)
|
||||
{ "ipmip6pm.interface", "radvd.AdvManagedFlag", MIP6PM_RADVD_MANAGED_ENUM },
|
||||
{ "ipmip6pm.interface", "radvd.AdvOtherConfigFlag", MIP6PM_RADVD_OTHER_ENUM },
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_SERVICE_SELECTION)
|
||||
{ "ipmip6pm.interface", "service_selection", MIP6PM_SERVICE_SELECTION_ENUM },
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_VENDOR_EXTENSION)
|
||||
{ "ipmip6pm.service_selection", IP_NULL, MIP6PM_VENDOR_EXTENSION_ENUM },
|
||||
#endif
|
||||
|
||||
{ IP_NULL, IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_DHCP_RELAY)
|
||||
extern void ipmip6pm_service_dhcpv6_relay_install(void *);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_RADVD)
|
||||
extern void ipmip6pm_service_radvd_install(void *);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_SERVICE_SELECTION)
|
||||
extern void ipmip6pm_service_selection_install(void *);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_VENDOR_EXTENSION)
|
||||
extern void ipmip6pm_service_vendor_extension_install(void *);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_RELAY_SUPPORT) || defined(INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_SERVER_SUPPORT)
|
||||
extern void ipmip6pm_service_dsmipv6_install(void *);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_EXTENSION)
|
||||
extern void MIP6PM_SERVICE_FEATURE_INITIALIZATION_HOOK(void *);
|
||||
#endif
|
||||
|
||||
|
||||
Ipmip6pm_config_func_t ipmip6pm_service_registrations[] =
|
||||
{
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_DHCP_RELAY)
|
||||
ipmip6pm_service_dhcpv6_relay_install,
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_RADVD)
|
||||
ipmip6pm_service_radvd_install,
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_SERVICE_SELECTION)
|
||||
ipmip6pm_service_selection_install,
|
||||
#endif
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_VENDOR_EXTENSION)
|
||||
ipmip6pm_service_vendor_extension_install,
|
||||
#endif
|
||||
#if defined(INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_RELAY_SUPPORT) || defined(INCLUDE_IPMIP6PM_DUAL_STACK_DHCP_SERVER_SUPPORT)
|
||||
ipmip6pm_service_dsmipv6_install,
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_SERVICE_FEATURE_EXTENSION)
|
||||
MIP6PM_SERVICE_FEATURE_INITIALIZATION_HOOK,
|
||||
#endif
|
||||
IP_NULL
|
||||
};
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LAYER_ADDRESS)
|
||||
extern void ipmip6pm_link_address_install(void *);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LOCAL_ADDRESS)
|
||||
extern void ipmip6pm_link_local_install(void *);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_EXTENSION)
|
||||
extern void MIP6PM_LINK_FEATURE_INITIALIZATION_HOOK(void *);
|
||||
#endif
|
||||
|
||||
|
||||
Ipmip6pm_config_func_t ipmip6pm_link_registrations[] =
|
||||
{
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LAYER_ADDRESS)
|
||||
ipmip6pm_link_address_install,
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_LINK_LOCAL_ADDRESS)
|
||||
ipmip6pm_link_local_install,
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIP6PM_LINK_FEATURE_EXTENSION)
|
||||
MIP6PM_LINK_FEATURE_INITIALIZATION_HOOK,
|
||||
#endif
|
||||
IP_NULL
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6pm_configure
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipmip6pm_configure(void);
|
||||
IP_PUBLIC Ip_err
|
||||
ipmip6pm_configure(void)
|
||||
{
|
||||
/* Initialize IPMIPMN system variables. */
|
||||
/* Initialize IPMIPMN system variables. */
|
||||
if (ipcom_sysvar_setv(ipmip6pm_conf_sysvar, 0) == IPCOM_SUCCESS)
|
||||
{
|
||||
/* now configure the interface-specific sysvars */
|
||||
#if defined(INCLUDE_IPMIP6MN)
|
||||
return ipcom_sysvar_ext_setv (ipmip6pm_conf_sysvar_ext, 0);
|
||||
#else
|
||||
return IPCOM_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
ipcom_sysvar_setv(ipmip6pm_conf_sysvar, 0);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6pm_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipmip6pm_init(void);
|
||||
IP_PUBLIC Ip_err
|
||||
ipmip6pm_init(void)
|
||||
{
|
||||
#if defined(INCLUDE_IPMIP6PM_CMD) && !defined(IP_PORT_LAS)
|
||||
ipcom_shell_add_cmd("pm6", "pm6 <command> [modifiers]", "Mobile IPv6 Proxy Mobility",
|
||||
ipmip6pm_cmd_pm6,
|
||||
IPCOM_PRIORITY_DEFAULT, IPCOM_PROC_STACK_SMALL);
|
||||
#endif
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6pm_exit
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipmip6pm_exit(void);
|
||||
IP_PUBLIC Ip_err
|
||||
ipmip6pm_exit(void)
|
||||
{
|
||||
#if defined(INCLUDE_IPMIP6PM_CMD) && !defined(IP_PORT_LAS)
|
||||
/* Remove the shell command */
|
||||
ipcom_shell_remove_cmd("pm6", ipmip6pm_cmd_pm6);
|
||||
#endif
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_config.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_config.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-03-02 11:44:40 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6PM_CONFIG_H
|
||||
#define IPMIP6PM_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef IP_DEBUG
|
||||
#define IPMIP6PM_EVENT_BACKLOG 300
|
||||
#else
|
||||
#define IPMIP6PM_EVENT_BACKLOG 100
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MULTICAST status changes over CLI sockets that has requested
|
||||
* it.
|
||||
*/
|
||||
#define IPMIP6PM_MULTICAST_STATUS 1
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6pm_context;
|
||||
struct Ipmip_proc;
|
||||
|
||||
typedef Ip_bool (*Ipmip6pm_init_func_t)
|
||||
(
|
||||
struct Ipmip6pm_context *ctx
|
||||
);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Callbacks */
|
||||
extern Ipmip6pm_init_func_t ipmip6pm_service_registrations[];
|
||||
extern Ipmip6pm_init_func_t ipmip6pm_link_registrations[];
|
||||
|
||||
IP_PUBLIC Ip_err ipmip6pm_init(void);
|
||||
IP_PUBLIC Ip_err ipmip6pm_exit(void);
|
||||
IP_PUBLIC Ip_err ipmip6pm_configure(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,370 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_link_address.c,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_link_address.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_policy_routing.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_attr_h.h"
|
||||
#include "ipmip6pm_if.h"
|
||||
#include "ipmip6pm_node.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6PM_LINK_ADDRESS_NAME "LINK-ADDRESS"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
typedef struct Ipmip6pm_link_address_config_global
|
||||
{
|
||||
Ipmip_lladdr_t *FixedMAGLinkLayerAddressOnAllAccessLinks;
|
||||
} Ipmip6pm_link_address_config_global_t;
|
||||
|
||||
typedef struct Ipmip6pm_link_address_config
|
||||
{
|
||||
Ipmip_lladdr_t *FixedMAGLinkLayerAddressOnAllAccessLinks;
|
||||
} Ipmip6pm_link_address_config_t;
|
||||
|
||||
typedef struct Ipmip6pm_link_address_node_config
|
||||
{
|
||||
Ipmip_lladdr_t *LinkLayerAddress;
|
||||
} Ipmip6pm_link_address_node_config_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_link_address_config_global(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_link_address_config_global_t *gcfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
char *dptr;
|
||||
|
||||
dptr = ipmip_sysvar("ipmip6pm.FixedMAGLinkLayerAddressOnAllAccessLinks");
|
||||
|
||||
/**/
|
||||
if (dptr != IP_NULL)
|
||||
{
|
||||
gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks = ipmip_lladdr_parse(proc, 0, 0, dptr);
|
||||
/**/
|
||||
ipcom_free(dptr);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
if (gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks)
|
||||
{
|
||||
ipcom_free(gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks);
|
||||
gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.FixedMAGLinkLayerAddressOnAllAccessLinks=%s",
|
||||
ipmip_ntop_lladdr(proc, gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_link_address_config(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6pm_if *ifp,
|
||||
Ipmip6pm_link_address_config_global_t *gcfg,
|
||||
Ipmip6pm_link_address_config_t *cfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
char *dptr;
|
||||
|
||||
dptr = ipmip_sysvar("ipmip6pm.interface.%s.FixedMAGLinkLayerAddressOnAllAccessLinks", ifp->ipmip6.iff.ifname);
|
||||
|
||||
/**/
|
||||
if (dptr != IP_NULL)
|
||||
{
|
||||
cfg->FixedMAGLinkLayerAddressOnAllAccessLinks = ipmip_lladdr_parse(proc, 0, 0, dptr);
|
||||
/**/
|
||||
ipcom_free(dptr);
|
||||
}
|
||||
else if (gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks)
|
||||
{
|
||||
cfg->FixedMAGLinkLayerAddressOnAllAccessLinks = ipmip_lladdr_dup(gcfg->FixedMAGLinkLayerAddressOnAllAccessLinks);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
if (cfg->FixedMAGLinkLayerAddressOnAllAccessLinks)
|
||||
{
|
||||
ipcom_free(cfg->FixedMAGLinkLayerAddressOnAllAccessLinks);
|
||||
cfg->FixedMAGLinkLayerAddressOnAllAccessLinks = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (cfg->FixedMAGLinkLayerAddressOnAllAccessLinks)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.FixedMAGLinkLayerAddressOnAllAccessLinks=%s",
|
||||
ifp->ipmip6.iff.ifname, ipmip_ntop_lladdr(proc, cfg->FixedMAGLinkLayerAddressOnAllAccessLinks));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_link_address_provide(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_link_address_config_global_t *gcfg,
|
||||
Ipmip6pm_link_address_config_t *ifcfg,
|
||||
Ipmip6pm_link_address_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_ENABLE)
|
||||
{
|
||||
int ret;
|
||||
Ipmip_lladdr_t *lla = nodecfg->LinkLayerAddress? nodecfg->LinkLayerAddress : ifcfg->FixedMAGLinkLayerAddressOnAllAccessLinks;
|
||||
|
||||
/* Must stop interface for assignment */
|
||||
#if 0
|
||||
ipmip_if_clear_flags(&ctx->ipmip6.ipmip, proc, &node->ifp_private.ipmip6.ifp->iff, IP_IFF_UP);
|
||||
#endif
|
||||
|
||||
/* Assign LLADDR */
|
||||
if ((ret = ipmip_netlink_link(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_RTM_SETLINK,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
0,
|
||||
0,
|
||||
IPMIP_LLADDR_DATA(lla),
|
||||
IPMIP_LLADDR_LEN_LLA(lla),
|
||||
0)) != 0)
|
||||
{
|
||||
/* Do something */
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Proxy Mobile node %s interface %s unable to assign Link-Layer address (%d)",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
node->ifp_private.ipmip6.ifp->iff.ifname,
|
||||
-ret));
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
ipmip_if_set_flags(&ctx->ipmip6.ipmip, proc, &node->ifp_private.ipmip6.ifp->iff, IP_IFF_UP);
|
||||
#endif
|
||||
/* Re-resolve LLA */
|
||||
ipmip_timer_lock_acquire(&ctx->ipmip6.ipmip, proc, node->ifp_private.ipmip6.ifp->iff_lock);
|
||||
ipmip_if_resolve_lla(&ctx->ipmip6.ipmip, proc, &node->ifp_private.ipmip6.ifp->iff);
|
||||
ipmip_timer_lock_release(&ctx->ipmip6.ipmip, proc, node->ifp_private.ipmip6.ifp->iff_lock);
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_DISABLE)
|
||||
{
|
||||
}
|
||||
|
||||
/* Don't delay */
|
||||
return IPMIP_CALLBACK_RET_SUCCESS;
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_link_address_setup(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_link_address_config_global_t *gcfg,
|
||||
Ipmip6pm_link_address_config_t *ifcfg,
|
||||
Ipmip6pm_link_address_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
const char *value,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* Turned off in configuration */
|
||||
if (value == IP_NULL)
|
||||
return ifcfg->FixedMAGLinkLayerAddressOnAllAccessLinks != IP_NULL;
|
||||
|
||||
if (nodecfg->LinkLayerAddress)
|
||||
ipcom_free(nodecfg->LinkLayerAddress);
|
||||
nodecfg->LinkLayerAddress = ipmip_lladdr_parse(proc, 0, 0, value);
|
||||
return nodecfg->LinkLayerAddress != IP_NULL;
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
if (nodecfg->LinkLayerAddress)
|
||||
{
|
||||
ipcom_free(nodecfg->LinkLayerAddress);
|
||||
nodecfg->LinkLayerAddress = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (nodecfg->LinkLayerAddress)
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_LINK);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_LINK_ADDRESS_NAME);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
ipmip_ntop_lladdr(proc, nodecfg->LinkLayerAddress));
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6pm_link_address_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_link_address_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
static Ipmip6pm_extension_t srv;
|
||||
|
||||
srv.name = IPMIP6PM_LINK_ADDRESS_NAME;
|
||||
srv.syntax = "<MAC ADDRESS>";
|
||||
srv.node_data_size = sizeof(Ipmip6pm_link_address_node_config_t);
|
||||
srv.ifp_data_size = sizeof(Ipmip6pm_link_address_config_t);
|
||||
srv.global_data_size= sizeof(Ipmip6pm_link_address_config_global_t);
|
||||
|
||||
srv.config_global = (Ipmip6pm_extension_config_global_t)ipmip6pm_link_address_config_global;
|
||||
srv.config_ifp = (Ipmip6pm_extension_config_ifp_t)ipmip6pm_link_address_config;
|
||||
srv.provide = (Ipmip6pm_extension_provide_t)ipmip6pm_link_address_provide;
|
||||
srv.setup = (Ipmip6pm_extension_setup_t)ipmip6pm_link_address_setup;
|
||||
|
||||
ipmip6pm_context_register_extension(ctx, &srv, IPMIP6PM_FUNCTION_LINK);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,440 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_link_local.c,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_link_local.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_policy_routing.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_attr_h.h"
|
||||
#include "ipmip6pm_if.h"
|
||||
#include "ipmip6pm_node.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6PM_LINK_LOCAL_NAME "LINK-LOCAL"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmip6pm_link_local_config_global
|
||||
{
|
||||
Ipmip6_address_t FixedMAGLinkLocalAddressOnAllAccessLinks;
|
||||
Ip_bool FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO;
|
||||
} Ipmip6pm_link_local_config_global_t;
|
||||
|
||||
typedef struct Ipmip6pm_link_local_config
|
||||
{
|
||||
Ipmip6_address_t FixedMAGLinkLocalAddressOnAllAccessLinks;
|
||||
Ip_bool FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO;
|
||||
} Ipmip6pm_link_local_config_t;
|
||||
|
||||
typedef struct Ipmip6pm_link_local_node_config
|
||||
{
|
||||
Ipmip6_address_t FixedMAGLinkLocalAddressOnAllAccessLinks;
|
||||
} Ipmip6pm_link_local_node_config_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_link_local_request_req_accept(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6pm_link_local_config_global_t *gcfg,
|
||||
Ipmip6pm_link_local_config_t *ifcfg,
|
||||
Ipmip6pm_link_local_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip6pm_pktbuf *pbuf,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (ifcfg->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO)
|
||||
{
|
||||
if (pbuf->ipmip6.mo.pmipv6_link_local_address != IP_NULL)
|
||||
ipcom_memcpy(&nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, &pbuf->ipmip6.mo.pmipv6_link_local_address->prefix, sizeof(struct Ip_in6_addr));
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_link_local_request_rep_apply(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6pm_link_local_config_global_t *gcfg,
|
||||
Ipmip6pm_link_local_config_t *ifcfg,
|
||||
Ipmip6pm_link_local_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip6pm_pktbuf *pbuf)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (ifcfg->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO)
|
||||
{
|
||||
Ipmip6_mh_mo_pmipv6_link_local_address_t ll;
|
||||
|
||||
ll.hdr.val = IPMIP6_MH_MO_PMIPV6_LINK_LOCAL_ADDRESS_OPTION;
|
||||
ll.hdr.len = 16;
|
||||
ipcom_memcpy(&ll.prefix, &nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, sizeof(nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix));
|
||||
|
||||
/* Refresh */
|
||||
ipmip6_mh_pkt_opt_add_mo(&ctx->ipmip6,
|
||||
proc,
|
||||
&pbuf->ipmip6,
|
||||
&ll.hdr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_link_local_config_global(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_link_local_config_global_t *gcfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* Read the prefix list allowed for this interface */
|
||||
ipmip_sysvar_inet6(&ip_in6addr_any, &gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, &gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len, "ipmip6pm.FixedMAGLinkLocalAddressOnAllAccessLinks");
|
||||
|
||||
/* Check if its unspecified */
|
||||
if (IP_IN6_IS_ADDR_UNSPECIFIED(&gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix))
|
||||
gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO = IP_TRUE;
|
||||
|
||||
/**/
|
||||
if (gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len == 0)
|
||||
gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len = 64;
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.FixedMAGLinkLocalAddressOnAllAccessLinks=%s/%d",
|
||||
ipmip_ntop_inet6(proc, &gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, IP_NULL), gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_link_local_config(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6pm_if *ifp,
|
||||
Ipmip6pm_link_local_config_global_t *gcfg,
|
||||
Ipmip6pm_link_local_config_t *cfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* Read the prefix list allowed for this interface */
|
||||
if (!ipmip_sysvar_inet6(&gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, &cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, &cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len, "ipmip6pm.interface.%s.FixedMAGLinkLocalAddressOnAllAccessLinks", ifp->ipmip6.iff.ifname))
|
||||
{
|
||||
cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len = gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len;
|
||||
cfg->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO = gcfg->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check if its unspecified */
|
||||
if (IP_IN6_IS_ADDR_UNSPECIFIED(&cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix))
|
||||
cfg->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO = IP_TRUE;
|
||||
|
||||
/**/
|
||||
if (cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len == 0)
|
||||
cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len = 64;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.FixedMAGLinkLocalAddressOnAllAccessLinks=%s/%d",
|
||||
ifp->ipmip6.iff.ifname, ipmip_ntop_inet6(proc, &cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, IP_NULL), cfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_link_local_provide(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_link_local_config_global_t *gcfg,
|
||||
Ipmip6pm_link_local_config_t *ifcfg,
|
||||
Ipmip6pm_link_local_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
IPMIP_UNUSED_PARAMETER(ifcfg);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_ENABLE)
|
||||
{
|
||||
if (!IP_IN6_IS_ADDR_UNSPECIFIED(&nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix))
|
||||
{
|
||||
Ipmip6_if_inet6_t *addr;
|
||||
|
||||
ipmip_timer_lock_acquire(&ctx->ipmip6.ipmip, proc, node->ifp_private.ipmip6.ifp->iff_lock);
|
||||
for (addr = IPCOM_LIST_FIRST(&node->ifp_private.ipmip6.ifp->inet6); addr != IP_NULL; addr = IPCOM_LIST_NEXT(&addr->ifa_next))
|
||||
{
|
||||
if (addr->ifa_scope == IP_RT_SCOPE_LINK)
|
||||
{
|
||||
int ret;
|
||||
if ((ret = ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_DELADDR,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
&addr->ifa_address.prefix,
|
||||
addr->ifa_address.len,
|
||||
0,
|
||||
0)) != 0)
|
||||
{
|
||||
/**/
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Proxy Mobile node %s interface %s unable to delete link local address %s/%d = %d",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
node->ifp_private.ipmip6.ifp->iff.ifname,
|
||||
ipmip_ntop_inet6(proc,&addr->ifa_address.prefix, IP_NULL),
|
||||
addr->ifa_address.len,
|
||||
ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_NEWADDR,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
&nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix,
|
||||
nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len,
|
||||
0,
|
||||
0) != 0)
|
||||
{
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Proxy Mobile node %s interface %s unable to add link local address %s/%d",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
node->ifp_private.ipmip6.ifp->iff.ifname,
|
||||
ipmip_ntop_inet6(proc, &nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, IP_NULL),
|
||||
nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len));
|
||||
}
|
||||
|
||||
ipmip_timer_lock_release(&ctx->ipmip6.ipmip, proc, node->ifp_private.ipmip6.ifp->iff_lock);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_DISABLE)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Don't delay */
|
||||
return IPMIP_CALLBACK_RET_SUCCESS;
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_link_local_setup(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_link_local_config_global_t *gcfg,
|
||||
Ipmip6pm_link_local_config_t *ifcfg,
|
||||
Ipmip6pm_link_local_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
const char *value,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len = 64;
|
||||
|
||||
if (value == IP_NULL)
|
||||
{
|
||||
if (!ifcfg->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO)
|
||||
ipcom_memcpy(&nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks, &ifcfg->FixedMAGLinkLocalAddressOnAllAccessLinks, sizeof(Ipmip6_address_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
ipmip_util_inet6(value, &nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, &nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len);
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do Nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (!IP_IN6_IS_ADDR_UNSPECIFIED(&nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix))
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_LINK);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_LINK_LOCAL_NAME);
|
||||
|
||||
ipcom_snprintf(proc->ntop.ntop_pbuf, sizeof(proc->ntop.ntop_pbuf), "%s/%d",
|
||||
ipmip_ntop_inet6(proc, &nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, IP_NULL),
|
||||
nodecfg->FixedMAGLinkLocalAddressOnAllAccessLinks.len);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
proc->ntop.ntop_pbuf);
|
||||
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6pm_link_local_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_link_local_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
static Ipmip6pm_extension_t srv;
|
||||
|
||||
srv.name = IPMIP6PM_LINK_LOCAL_NAME;
|
||||
srv.syntax = "<link-local address>";
|
||||
srv.node_data_size = sizeof(Ipmip6pm_link_local_node_config_t);
|
||||
srv.ifp_data_size = sizeof(Ipmip6pm_link_local_config_t);
|
||||
srv.global_data_size= sizeof(Ipmip6pm_link_local_config_global_t);
|
||||
|
||||
srv.config_global = (Ipmip6pm_extension_config_global_t)ipmip6pm_link_local_config_global;
|
||||
srv.config_ifp = (Ipmip6pm_extension_config_ifp_t)ipmip6pm_link_local_config;
|
||||
srv.provide = (Ipmip6pm_extension_provide_t)ipmip6pm_link_local_provide;
|
||||
srv.setup = (Ipmip6pm_extension_setup_t)ipmip6pm_link_local_setup;
|
||||
srv.pkt_rep_accept = (Ipmip6pm_extension_pkt_rep_accept_t)ipmip6pm_link_local_request_req_accept;
|
||||
srv.pkt_req_apply = (Ipmip6pm_extension_pkt_req_apply_t)ipmip6pm_link_local_request_rep_apply;
|
||||
|
||||
ipmip6pm_context_register_extension(ctx, &srv, IPMIP6PM_FUNCTION_LINK);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,166 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_pktbuf.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_pktbuf.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_pkt.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6pm_pktbuf_alloc
|
||||
*===========================================================================
|
||||
* Description: Allocate a packet buffer
|
||||
* Parameters:
|
||||
* Returns: A newly allocated packet buffer
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_pktbuf_t *
|
||||
ipmip6pm_pktbuf_alloc(Ipmip6pm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ip_size_t extra)
|
||||
{
|
||||
Ipmip6pm_pktbuf_t *pbuf;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
pbuf = ipcom_calloc(1, sizeof(Ipmip6pm_pktbuf_t) + extra);
|
||||
if (pbuf)
|
||||
{
|
||||
pbuf->ipmip6.ipmip.pktend = (void *) (pbuf + 1);
|
||||
return &pbuf->ipmip6.ipmip;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6pm_pktbuf_free
|
||||
*===========================================================================
|
||||
* Description: Free a packet buffer
|
||||
* Parameters: pbuf - The packet buffer
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_pktbuf_free(Ipmip6pm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6pm_pktbuf_t *pbuf)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
/* Free the data */
|
||||
ipcom_free(pbuf);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,149 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_pktbuf.h,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_pktbuf.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-12-02 15:33:30 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6PM_PKTBUF_H
|
||||
#define IPMIP6PM_PKTBUF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip6_pkt.h>
|
||||
#include <private/ipmip6_mh_pkt.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6pm_if;
|
||||
struct Ipmip6_if;
|
||||
struct Ipmip6pm_context;
|
||||
|
||||
typedef struct Ipmip6pm_pktbuf_pktinfo
|
||||
{
|
||||
struct Ip_in6_addr *src;
|
||||
struct Ip_in6_addr *home;
|
||||
|
||||
Ip_u8 iperr;
|
||||
Ip_u8 pmBindingStatus;
|
||||
Ip_u16 pmMobilityBindingTimeGranted;
|
||||
|
||||
Ip_u16 pmMobilityBindingSequenceNumber;
|
||||
Ip_u16 pmMobilityBindingFlags;
|
||||
|
||||
Ip_time_t pmBindingLastUpdated;
|
||||
|
||||
Ip_bool pmMobilityDeregistration;
|
||||
Ip_u32 pmMobilityBindingRefresh;
|
||||
Ip_u32 pmMobilityTransport;
|
||||
Ip_bool pmMobilityTransportChanged;
|
||||
Ip_u32 *pmMobilityTransportGREUplink;
|
||||
|
||||
} Ipmip6pm_pktbuf_pktinfo_t;
|
||||
|
||||
typedef struct Ipmip6pm_pktbuf
|
||||
{
|
||||
Ipmip6_pktbuf_t ipmip6;
|
||||
|
||||
Ip_u32 state;
|
||||
|
||||
Ip_u32 processed[IPMIP6PM_FUNCTION_MAX];
|
||||
|
||||
Ipmip6pm_pktbuf_pktinfo_t pktinfo;
|
||||
|
||||
union
|
||||
{
|
||||
struct Ipmip6pm_if *priv;
|
||||
struct Ipmip6_if *pub;
|
||||
} iff;
|
||||
|
||||
void **extdata[IPMIP6PM_FUNCTION_MAX];
|
||||
} Ipmip6pm_pktbuf_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6pm_pktbuf_alloc
|
||||
*===========================================================================
|
||||
* Description: Allocate a packet buffer
|
||||
* Parameters: ctx - Context
|
||||
* proc - Process
|
||||
* Returns: A newly allocated packet buffer
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_pktbuf_t *ipmip6pm_pktbuf_alloc(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_size_t extra);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6pm_pktbuf_free
|
||||
*===========================================================================
|
||||
* Description: Free a packet buffer
|
||||
* Parameters: ctx - Context
|
||||
* proc - Process
|
||||
* pbuf - The packet buffer
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip6pm_pktbuf_free(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6pm_pktbuf_t *pbuf);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,496 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_service_dhcpv6_relay.c,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_service_dhcpv6_relay.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_policy_routing.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_inet6.h>
|
||||
#include <private/ipmip_dhcp6.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_attr_h.h"
|
||||
#include "ipmip6pm_if.h"
|
||||
#include "ipmip6pm_node.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6PM_SERVICE_DHCPV6_RELAY_NAME "DHCPV6_RELAY"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmip6pm_service_dhcpv6_relay_fwd
|
||||
{
|
||||
Ip_u32 ifindex;
|
||||
struct Ip_in6_addr srv;
|
||||
} Ipmip6pm_service_dhcpv6_relay_fwd_t;
|
||||
|
||||
typedef struct Ipmip6pm_service_dhcpv6_relay_config
|
||||
{
|
||||
int mode;
|
||||
Ip_u32 ifscope;
|
||||
struct Ip_in6_addr *srv;
|
||||
} Ipmip6pm_service_dhcpv6_relay_config_t;
|
||||
|
||||
typedef struct Ipmip6pm_service_dhcpv6_relay_handle
|
||||
{
|
||||
Ipmip_dhcp6_node_t relay;
|
||||
Ip_u32 ifscope;
|
||||
struct Ip_in6_addr *srv;
|
||||
Ipmip6_address_t link_address;
|
||||
Ip_bool enabled;
|
||||
Ip_bool registered;
|
||||
} Ipmip6pm_service_dhcpv6_relay_handle_t;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_service_dhcpv6_relay(int event,
|
||||
Ipmip6pm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6pm_service_dhcpv6_relay_handle_t *dnode,
|
||||
Ipmip6pm_pktbuf_t *pbuf)
|
||||
{
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
Ipmip_dhcp6_hdr_t *pkt = (Ipmip_dhcp6_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->ipmip6.ipmip.packet);
|
||||
Ipmip_dhcp6_relay_hdr_t *rpkt = (Ipmip_dhcp6_relay_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->ipmip6.ipmip.packet);
|
||||
Ip_u8 hc = 0;
|
||||
|
||||
/* Sanity process */
|
||||
switch (pkt->msg_type)
|
||||
{
|
||||
/**/
|
||||
case IPMIP_DHCP6_MSG_RELAY_REPLY:
|
||||
/* Must forward to client */
|
||||
{
|
||||
Ipmip_dhcp6_option_hdr_t *rmsg = ipmip_dhcp6_option_buffer_find(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP6_OPTION_RELAY_MSG);
|
||||
if (rmsg == IP_NULL)
|
||||
goto done_out;
|
||||
|
||||
/* Do forward */
|
||||
ipmip_dhcp6_send_msg(&ctx->ipmip6.ipmip, proc, rmsg + 1, IP_GET_NTOHS(&rmsg->length), &rpkt->peer_addr, dnode->relay.ifindex);
|
||||
}
|
||||
break;
|
||||
case IPMIP_DHCP6_MSG_RELAY_FORWARD:
|
||||
hc = rpkt->hop_count;
|
||||
/* Fall Through */
|
||||
default:
|
||||
{
|
||||
Ipmip_pktbuf_t *rpbuf = (Ipmip_pktbuf_t *)ipmip_dhcp6_relay_msg(&ctx->ipmip6.ipmip, proc, &dnode->link_address.prefix, hc, &pbuf->ipmip6.ipmip);
|
||||
if (rpbuf)
|
||||
{
|
||||
ipmip_dhcp6_send_msg(&ctx->ipmip6.ipmip, proc, IPMIP_BUFFER_DATA(&rpbuf->packet), IPMIP_BUFFER_SIZE(&rpbuf->packet), dnode->srv, dnode->ifscope);
|
||||
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, rpbuf);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the DHCP packet */
|
||||
done_out:
|
||||
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_dhcpv6_relay_parse(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ip_in6_addr **addr,
|
||||
Ip_u32 *ifscope,
|
||||
const char *value)
|
||||
{
|
||||
/* Scope? */
|
||||
if (((*ifscope) = ipcom_if_nametoindex(value)) == 0)
|
||||
{
|
||||
*addr = ipcom_malloc(sizeof(struct Ip_in6_addr));
|
||||
if (!ipmip_util_inet6(value, *addr, IP_NULL))
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Unable to properly parse DHCPv6 Relay Destination %s",
|
||||
value));
|
||||
|
||||
ipcom_free(*addr);
|
||||
*addr = IP_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_dhcpv6_relay_config_global(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_dhcpv6_relay_config_t *gcfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
char *fwd = ipmip_sysvar("ipmip6pm.dhcpv6_relay.server");
|
||||
gcfg->mode = ipmip_sysvar_mode(IPMIP_SYSVAR_MODE_OPTIONAL, "ipmip6pm.dhcpv6_relay.mode");
|
||||
if (fwd)
|
||||
{
|
||||
ipmip6pm_service_dhcpv6_relay_parse(ctx, proc, &gcfg->srv, &gcfg->ifscope, fwd);
|
||||
ipcom_free(fwd);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
if (gcfg->srv)
|
||||
ipcom_free(gcfg->srv);
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.dhcpv6_relay.mode=%s",
|
||||
ipmip_sysvar_mode_desc[gcfg->mode]);
|
||||
|
||||
if (gcfg->ifscope)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.dhcpv6_relay.server=%s",
|
||||
ipcom_if_indextoname(gcfg->ifscope, proc->ntop.ntop_name));
|
||||
}
|
||||
else if (gcfg->srv != IP_NULL)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.dhcpv6_relay.server=%s",
|
||||
ipmip_ntop_inet6(proc, gcfg->srv, IP_NULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_dhcpv6_relay_config(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6pm_if *ifp,
|
||||
Ipmip6pm_service_dhcpv6_relay_config_t *gcfg,
|
||||
Ipmip6pm_service_dhcpv6_relay_config_t *cfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
char *fwd = ipmip_sysvar("ipmip6pm.interface.%s.dhcpv6_relay.server", ifp->ipmip6.iff.ifname);
|
||||
cfg->mode = ipmip_sysvar_mode(gcfg->mode, "ipmip6pm.interface.%s.dhcpv6_relay.mode", ifp->ipmip6.iff.ifname);
|
||||
if (fwd)
|
||||
{
|
||||
ipmip6pm_service_dhcpv6_relay_parse(ctx, proc, &cfg->srv, &cfg->ifscope, fwd);
|
||||
ipcom_free(fwd);
|
||||
}
|
||||
|
||||
if (cfg->srv == IP_NULL && cfg->ifscope == 0)
|
||||
{
|
||||
cfg->srv = gcfg->srv;
|
||||
cfg->ifscope = gcfg->ifscope;
|
||||
}
|
||||
|
||||
if (cfg->mode != IPMIP_SYSVAR_MODE_DISABLED)
|
||||
{
|
||||
/* We need the DHCP context */
|
||||
ipmip_dhcp6_context_create(&ctx->ipmip6.ipmip, proc);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
if (cfg->srv != IP_NULL && cfg->srv != gcfg->srv)
|
||||
{
|
||||
ipcom_free(cfg->srv);
|
||||
cfg->srv = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.dhcpv6_relay.mode=%s",
|
||||
ifp->ipmip6.iff.ifname, ipmip_sysvar_mode_desc[cfg->mode]);
|
||||
|
||||
if (cfg->ifscope)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.dhcpv6_relay.server=%s",
|
||||
ifp->ipmip6.iff.ifname, ipcom_if_indextoname(cfg->ifscope, proc->ntop.ntop_name));
|
||||
}
|
||||
else if (cfg->srv)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.dhcpv6_relay.server=%s",
|
||||
ifp->ipmip6.iff.ifname, ipmip_ntop_inet6(proc, cfg->srv, IP_NULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_service_dhcpv6_relay_provide(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_dhcpv6_relay_config_t *gcfg,
|
||||
Ipmip6pm_service_dhcpv6_relay_config_t *cfg,
|
||||
Ipmip6pm_service_dhcpv6_relay_handle_t *handle,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
IPMIP_UNUSED_PARAMETER(cfg);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_ENABLE)
|
||||
{
|
||||
if (handle->enabled)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* OK - MUST ASSIGN ADDRESS BASED ON ALLOCATED PREFIX */
|
||||
/* Do the prefixes */
|
||||
for (i = 0; i < node->mo_home_prefix_size; i++)
|
||||
{
|
||||
if (ipmip6_netlink_prefix_generate(&ctx->ipmip6,
|
||||
proc,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
&node->mo_home_prefix[i].prefix,
|
||||
node->mo_home_prefix[i].prefix_length,
|
||||
&handle->link_address))
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/**/
|
||||
if (i < node->mo_home_prefix_size)
|
||||
ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip, proc, IP_AF_INET6, IP_RTM_NEWADDR, node->ifp_private.ipmip6.ifp->iff.ifindex, &handle->link_address.prefix, handle->link_address.len, 0, 0);
|
||||
|
||||
handle->relay.ifindex = node->ifp_private.ipmip6.ifp->iff.ifindex;
|
||||
handle->relay.lock = node->lock;
|
||||
handle->relay.process_func = (Ipmip_timer_func_t)ipmip6pm_service_dhcpv6_relay;
|
||||
handle->registered = IP_TRUE;
|
||||
ipmip_dhcp6_register(&ctx->ipmip6.ipmip, proc, &handle->relay);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_DISABLE)
|
||||
{
|
||||
if (handle->registered)
|
||||
{
|
||||
ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip, proc, IP_AF_INET6, IP_RTM_DELADDR, node->ifp_private.ipmip6.ifp->iff.ifindex, &handle->link_address.prefix, handle->link_address.len, 0, 0);
|
||||
handle->registered = IP_FALSE;
|
||||
ipmip_dhcp6_unregister(&ctx->ipmip6.ipmip, proc, &handle->relay);
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't delay */
|
||||
return IPMIP_CALLBACK_RET_SUCCESS;
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_service_dhcpv6_relay_setup(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_dhcpv6_relay_config_t *gcfg,
|
||||
Ipmip6pm_service_dhcpv6_relay_config_t *cfg,
|
||||
Ipmip6pm_service_dhcpv6_relay_handle_t *handle,
|
||||
struct Ipmip6pm_node *node,
|
||||
const char *value,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* Turned off in configuration */
|
||||
if (cfg->mode == IPMIP_SYSVAR_MODE_DISABLED)
|
||||
return IP_FALSE;
|
||||
|
||||
/* Turned on by node */
|
||||
if (value == IP_NULL && cfg->mode == IPMIP_SYSVAR_MODE_OPTIONAL)
|
||||
return IP_FALSE;
|
||||
|
||||
handle->enabled = IP_TRUE;
|
||||
if (value && ipcom_strlen(value))
|
||||
ipmip6pm_service_dhcpv6_relay_parse(ctx, proc, &handle->srv, &handle->ifscope, value);
|
||||
|
||||
if (handle->srv == IP_NULL && handle->ifscope == 0)
|
||||
{
|
||||
handle->srv = cfg->srv;
|
||||
handle->ifscope = cfg->ifscope;
|
||||
}
|
||||
|
||||
/* Rever to home agent */
|
||||
if (handle->srv == IP_NULL && handle->ifscope == 0)
|
||||
handle->srv = &node->homeagent;
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
handle->enabled = IP_FALSE;
|
||||
if (handle->srv != IP_NULL && handle->srv != cfg->srv && handle->srv != &node->homeagent)
|
||||
{
|
||||
ipcom_free(handle->srv);
|
||||
handle->srv = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (handle->enabled)
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_SERVICE);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_SERVICE_DHCPV6_RELAY_NAME);
|
||||
|
||||
if (handle->ifscope)
|
||||
{
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
ipcom_if_indextoname(handle->ifscope, proc->ntop.ntop_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
ipmip_ntop_inet6(proc, handle->srv, IP_NULL));
|
||||
}
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6pm_service_dhcpv6_relay_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_service_dhcpv6_relay_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
static Ipmip6pm_extension_t srv;
|
||||
|
||||
srv.name = IPMIP6PM_SERVICE_DHCPV6_RELAY_NAME;
|
||||
srv.syntax = "<interface_name|dhcpv6 server address>";
|
||||
srv.node_data_size = sizeof(Ipmip6pm_service_dhcpv6_relay_handle_t);
|
||||
srv.ifp_data_size = sizeof(Ipmip6pm_service_dhcpv6_relay_config_t);
|
||||
srv.global_data_size= sizeof(Ipmip6pm_service_dhcpv6_relay_config_t);
|
||||
|
||||
srv.config_global = (Ipmip6pm_extension_config_global_t)ipmip6pm_service_dhcpv6_relay_config_global;
|
||||
srv.config_ifp = (Ipmip6pm_extension_config_ifp_t)ipmip6pm_service_dhcpv6_relay_config;
|
||||
srv.provide = (Ipmip6pm_extension_provide_t)ipmip6pm_service_dhcpv6_relay_provide;
|
||||
srv.setup = (Ipmip6pm_extension_setup_t)ipmip6pm_service_dhcpv6_relay_setup;
|
||||
|
||||
ipmip6pm_context_register_extension(ctx, &srv, IPMIP6PM_FUNCTION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,950 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_service_dsmipv6.c,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_service_dsmipv6.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_policy_routing.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_dhcp.h>
|
||||
#include <private/ipmip_inet.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_attr_h.h"
|
||||
#include "ipmip6pm_if.h"
|
||||
#include "ipmip6pm_node.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6PM_SERVICE_DSMIPV6_NAME "DSMIPV6"
|
||||
|
||||
#define IPMIP6PM_SERVICE_INSTALLED_DHCP (1 << 0)
|
||||
#define IPMIP6PM_SERVICE_INSTALLED_ARP (1 << 1)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmip6pm_service_dsmipv6_config_global
|
||||
{
|
||||
struct
|
||||
{
|
||||
Ip_bool enabled;
|
||||
} server_config;
|
||||
|
||||
struct
|
||||
{
|
||||
Ip_bool enabled;
|
||||
Ip_u32 forward;
|
||||
Ip_bool override;
|
||||
Ip_bool link_selection;
|
||||
} relay_config;
|
||||
} Ipmip6pm_service_dsmipv6_config_global_t;
|
||||
|
||||
|
||||
typedef struct Ipmip6pm_service_dsmipv6_config
|
||||
{
|
||||
struct
|
||||
{
|
||||
Ip_bool enabled;
|
||||
} server_config;
|
||||
|
||||
struct
|
||||
{
|
||||
Ip_bool enabled;
|
||||
Ip_u32 forward;
|
||||
Ip_bool override;
|
||||
Ip_bool link_selection;
|
||||
} relay_config;
|
||||
} Ipmip6pm_service_dsmipv6_config_t;
|
||||
|
||||
|
||||
typedef struct Ipmip6pm_service_dsmipv6_relay
|
||||
{
|
||||
Ip_u32 forward;
|
||||
} Ipmip6pm_service_dsmipv6_relay_t;
|
||||
|
||||
typedef struct Ipmip6pm_service_dsmipv6_node
|
||||
{
|
||||
/* MUST be first */
|
||||
Ipmip_dhcp_node_t dhcp;
|
||||
Ipmip_arp_node_t arp;
|
||||
|
||||
Ip_u32 installed;
|
||||
|
||||
Ipmip6pm_service_dsmipv6_relay_t relay_data;
|
||||
|
||||
Ip_bool relay;
|
||||
Ip_u32 gateway;
|
||||
|
||||
Ipmip6pm_service_dsmipv6_config_t *cfg;
|
||||
} Ipmip6pm_service_dsmipv6_node_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_service_dsmipv6_arp(int event,
|
||||
Ipmip6pm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_arp_node_t *arp,
|
||||
Ipmip6pm_pktbuf_t *pbuf)
|
||||
{
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
Ipmip_arp_hdr_t *pkt = (Ipmip_arp_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->ipmip6.ipmip.packet);
|
||||
Ipmip6pm_node_t *node = arp->opaque;
|
||||
|
||||
|
||||
if (pkt->op == IPMIP_ARP_OP_REQUEST)
|
||||
{
|
||||
/* Don't reply to the node's own */
|
||||
if (IP_GET_32ON8(&pkt->ip_dst[0]) != node->mo_dsmipv6_home_prefix.prefix)
|
||||
{
|
||||
IPMIP6_EVENT_IF(DEBUG2, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"ARP Request Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
|
||||
|
||||
ipmip_inet_arp_reply(&ctx->ipmip6.ipmip, proc, pkt, &node->ifp_private.ipmip6.ifp->iff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the DHCP packet */
|
||||
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_service_dsmipv6_dhcpv4_relay(int event,
|
||||
Ipmip6pm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6pm_service_dsmipv6_node_t *dnode,
|
||||
Ipmip6pm_pktbuf_t *pbuf)
|
||||
{
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
Ipmip6pm_node_t *node = dnode->dhcp.opaque;
|
||||
int ra_opt;
|
||||
Ipmip_dhcp_hdr_t *pkt = (Ipmip_dhcp_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->ipmip6.ipmip.packet);
|
||||
Ip_u8 *opt;
|
||||
|
||||
opt = ipmip_dhcp_option_buffer_find(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_OPTCODE_DHCP_MESSAGE_TYPE);
|
||||
|
||||
if (pkt->op == IPMIP_DHCP_OP_BOOTREQUEST)
|
||||
{
|
||||
if (opt == IP_NULL)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Request Received by %s contained no MESSAGE_TYPE",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
if (opt[IPMIP_DHCP_OPT_DATA] == IPMIP_DHCP_MSG_REQUEST)
|
||||
{
|
||||
Ip_u32 ciaddr = IP_GET_32ON8(&pkt->ciaddr);
|
||||
|
||||
if (ciaddr == 0)
|
||||
ciaddr = ipmip_dhcp_option_buffer_find_ip(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_OPTCODE_DHCP_REQUESTED_ADDRESS);
|
||||
|
||||
|
||||
if (ciaddr != node->mo_dsmipv6_home_prefix.prefix)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP REQUEST Received for %s CIADDR mismatch %s != %s",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
ipmip_ntop_inet(proc, ciaddr),
|
||||
ipmip_ntop_inet(proc, node->mo_dsmipv6_home_prefix.prefix)));
|
||||
goto done_out;
|
||||
}
|
||||
}
|
||||
|
||||
IPMIP6_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Request Received by %s relaying to %s",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
ipmip_ntop_inet(proc, dnode->relay_data.forward)));
|
||||
|
||||
/* */
|
||||
IP_SET_32ON8(&pkt->giaddr, node->ifp_public->ifinet);
|
||||
pkt->hops++;
|
||||
|
||||
/**/
|
||||
ipmip_dhcp_option_buffer_open(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_OPTCODE_END);
|
||||
|
||||
/**/
|
||||
ra_opt = ipmip_dhcp_option_buffer_init(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_OPTCODE_RELAY_AGENT_INFO);
|
||||
if (dnode->cfg->relay_config.link_selection)
|
||||
ipmip_dhcp_option_buffer_append(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_SUBOPTCODE_RA_LINK_SELECTION, sizeof(Ip_u32), &node->mo_dsmipv6_home_prefix.prefix);
|
||||
if (dnode->cfg->relay_config.override)
|
||||
ipmip_dhcp_option_buffer_append(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_SUBOPTCODE_RA_SERVER_OVERRIDE, sizeof(Ip_u32), &dnode->gateway);
|
||||
ipmip_dhcp_option_buffer_append(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_SUBOPTCODE_RA_REMOTE_ID, sizeof(Ip_u32), &node->mo_dsmipv6_home_prefix.prefix);
|
||||
ipmip_dhcp_option_buffer_append(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_SUBOPTCODE_RA_CIRCUIT_ID, sizeof(Ip_u32), &dnode->dhcp.ifindex);
|
||||
ipmip_dhcp_option_buffer_end(&pbuf->ipmip6.ipmip.packet, ra_opt);
|
||||
|
||||
ipmip_dhcp_option_buffer_close(&pbuf->ipmip6.ipmip.packet);
|
||||
|
||||
/* */
|
||||
ipmip_dhcp_relay_to_server(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip, node->ifp_public->ifinet, dnode->relay_data.forward);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ipmip6pm_if_priv_t *ifp = (Ipmip6pm_if_priv_t *)node->ifp_private.ipmip6.ifp;
|
||||
|
||||
if (opt == IP_NULL)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Reply Received for %s contained no MESSAGE_TYPE",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
/**/
|
||||
if (opt[IPMIP_DHCP_OPT_DATA] == IPMIP_DHCP_MSG_OFFER)
|
||||
{
|
||||
if (IP_GET_32ON8(&pkt->yiaddr) != node->mo_dsmipv6_home_prefix.prefix)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP OFFER Received for %s YIADDR mismatch %s != %s",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
ipmip_ntop_inet(proc, IP_GET_32ON8(&pkt->yiaddr)),
|
||||
ipmip_ntop_inet(proc,node->mo_dsmipv6_home_prefix.prefix)));
|
||||
goto done_out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IPMIP6_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Reply Received for %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
|
||||
ipmip_dhcp_write_to_client(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip, dnode->gateway, &ifp->ipmip6.iff, IP_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the DHCP packet */
|
||||
done_out:
|
||||
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_service_dsmipv6_dhcpv4_server(int event,
|
||||
Ipmip6pm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6pm_service_dsmipv6_node_t *dnode,
|
||||
Ipmip6pm_pktbuf_t *pbuf)
|
||||
{
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
Ipmip6pm_node_t *node = dnode->dhcp.opaque;
|
||||
Ipmip_dhcp_hdr_t *pkt = (Ipmip_dhcp_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->ipmip6.ipmip.packet);
|
||||
|
||||
if (pkt->op == IPMIP_DHCP_OP_BOOTREQUEST)
|
||||
{
|
||||
Ip_u8 *opt;
|
||||
|
||||
/**/
|
||||
if (IP_GET_32ON8(&pkt->giaddr) == 0 && ipmip_dhcp_option_buffer_find(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_OPTCODE_RELAY_AGENT_INFO) == IP_NULL)
|
||||
{
|
||||
if ((opt = ipmip_dhcp_option_buffer_find(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_OPTCODE_DHCP_MESSAGE_TYPE)) == IP_NULL)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"No MESSAGE TYPE in DHCP Request Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
goto done_out;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Ipmip6pm_pktbuf_t *rpkt = (Ipmip6pm_pktbuf_t*)ipmip_pktbuf_alloc(&ctx->ipmip6.ipmip, proc, 512);
|
||||
Ipmip_buffer_t *buf = &rpkt->ipmip6.ipmip.packet;
|
||||
Ip_u8 type;
|
||||
#if 0
|
||||
Ip_u8 *req_opt = ipmip_dhcp_option_buffer_find(&pbuf->ipmip6.ipmip.packet, IPMIP_DHCP_OPTCODE_DHCP_PARAMETER_REQUEST_LIST);
|
||||
#endif
|
||||
Ip_u32 tmp32;
|
||||
|
||||
/* Add the packet */
|
||||
ipmip_buffer_append(buf, pkt, sizeof(*pkt));
|
||||
|
||||
|
||||
switch(opt[IPMIP_DHCP_OPT_DATA])
|
||||
{
|
||||
case IPMIP_DHCP_MSG_DISCOVER:
|
||||
IPMIP6_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Discover Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
type = IPMIP_DHCP_MSG_OFFER;
|
||||
break;
|
||||
|
||||
case IPMIP_DHCP_MSG_REQUEST:
|
||||
{
|
||||
Ip_u32 sid = 0;
|
||||
Ip_u32 req_addr = 0;
|
||||
|
||||
IPMIP6_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Request Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
|
||||
sid = ipmip_dhcp_option_buffer_find_ip(&pbuf->ipmip6.ipmip.packet,
|
||||
IPMIP_DHCP_OPTCODE_DHCP_SERVER_IDENTIFIER);
|
||||
req_addr = ipmip_dhcp_option_buffer_find_ip(&pbuf->ipmip6.ipmip.packet,
|
||||
IPMIP_DHCP_OPTCODE_DHCP_REQUESTED_ADDRESS);
|
||||
|
||||
if (req_addr == 0)
|
||||
req_addr = IP_GET_32ON8(&pkt->ciaddr);
|
||||
|
||||
|
||||
if (sid != 0 && sid != dnode->gateway)
|
||||
goto done_out;
|
||||
|
||||
if (req_addr != 0 && req_addr == node->mo_dsmipv6_home_prefix.prefix)
|
||||
type = IPMIP_DHCP_MSG_ACK;
|
||||
else
|
||||
type = IPMIP_DHCP_MSG_NAK;
|
||||
}
|
||||
break;
|
||||
case IPMIP_DHCP_MSG_DECLINE:
|
||||
/* Do what? */
|
||||
IPMIP6_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Decline Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
goto done_out;
|
||||
|
||||
case IPMIP_DHCP_MSG_RELEASE:
|
||||
/* Do what? */
|
||||
IPMIP6_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Release Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
goto done_out;
|
||||
|
||||
case IPMIP_DHCP_MSG_INFORM:
|
||||
/* Do what? */
|
||||
IPMIP6_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Inform Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
if (IP_GET_32ON8(&pkt->ciaddr) == node->mo_dsmipv6_home_prefix.prefix)
|
||||
type = IPMIP_DHCP_MSG_INFORM_ACK;
|
||||
else
|
||||
type = IPMIP_DHCP_MSG_NAK;
|
||||
break;
|
||||
default:
|
||||
IPMIP6_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP unknown Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
/* Add TYPE */
|
||||
ipmip_dhcp_option_buffer_append_u8(buf, IPMIP_DHCP_OPTCODE_DHCP_MESSAGE_TYPE, type);
|
||||
ipmip_dhcp_option_buffer_append_ip(buf, IPMIP_DHCP_OPTCODE_DHCP_SERVER_IDENTIFIER, dnode->gateway);
|
||||
|
||||
if (type != IPMIP_DHCP_MSG_NAK)
|
||||
{
|
||||
/* ACK or INFORM_ACK */
|
||||
if (type != IPMIP_DHCP_MSG_INFORM_ACK)
|
||||
{
|
||||
#ifndef IPTESTENGINE
|
||||
ipmip_dhcp_option_buffer_append_u32(buf, IPMIP_DHCP_OPTCODE_DHCP_LEASE_TIME, node->remaining);
|
||||
#else
|
||||
ipmip_dhcp_option_buffer_append_u32(buf, IPMIP_DHCP_OPTCODE_DHCP_LEASE_TIME, 5);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Add the basic options */
|
||||
|
||||
/* Subnet */
|
||||
tmp32 = 0;
|
||||
ipmip_util_create_mask((Ip_u8 *)&tmp32, node->mo_dsmipv6_home_prefix.len);
|
||||
ipmip_dhcp_option_buffer_append_ip(buf, IPMIP_DHCP_OPTCODE_SUBNET_MASK, tmp32);
|
||||
|
||||
/* Gateway */
|
||||
ipmip_dhcp_option_buffer_append_ip(buf, IPMIP_DHCP_OPTCODE_ROUTERS, dnode->gateway);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* NAK */
|
||||
}
|
||||
ipmip_dhcp_option_buffer_close(buf);
|
||||
|
||||
pkt = (Ipmip_dhcp_hdr_t *)IPMIP_BUFFER_PTR(buf);
|
||||
pkt->op = IPMIP_DHCP_OP_BOOTREPLY;
|
||||
pkt->hops = 0;
|
||||
|
||||
if (type != IPMIP_DHCP_MSG_NAK && type != IPMIP_DHCP_MSG_INFORM_ACK)
|
||||
IP_SET_32ON8(&pkt->yiaddr, node->mo_dsmipv6_home_prefix.prefix);
|
||||
|
||||
/* Send */
|
||||
ipmip_dhcp_write_to_client(&ctx->ipmip6.ipmip, proc, &rpkt->ipmip6.ipmip, dnode->gateway, &node->ifp_private.ipmip6.ifp->iff, type == IPMIP_DHCP_MSG_NAK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Relayed DHCP Request Received by %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"DHCP Reply Received for %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
}
|
||||
}
|
||||
|
||||
done_out:
|
||||
/* Free the DHCP packet */
|
||||
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_service_dsmipv6_req_accept(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6pm_service_dsmipv6_config_global_t *gcfg,
|
||||
Ipmip6pm_service_dsmipv6_config_t *cfg,
|
||||
Ipmip6pm_service_dsmipv6_node_t *handle,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip6pm_pktbuf *pbuf,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(cfg);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
|
||||
if (pbuf->ipmip6.mo.pdsmipv6_default_router != IP_NULL)
|
||||
handle->gateway = IP_GET_32ON8(&pbuf->ipmip6.mo.pdsmipv6_default_router->gw);
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_dsmipv6_config_global(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_dsmipv6_config_global_t *gcfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
gcfg->relay_config.enabled = ipmip_sysvar_bool(IP_TRUE, "ipmip6pm.inet.dhcp.relay.enabled");
|
||||
|
||||
gcfg->relay_config.link_selection = ipmip_sysvar_bool(IP_FALSE, "ipmip6pm.inet.dhcp.relay.link_selection");
|
||||
gcfg->relay_config.override = ipmip_sysvar_bool(IP_TRUE, "ipmip6pm.inet.dhcp.relay.server_override");
|
||||
|
||||
ipmip_sysvar_inet(0, &gcfg->relay_config.forward, IP_NULL, "ipmip6pm.inet.dhcp.relay.server");
|
||||
gcfg->server_config.enabled = ipmip_sysvar_bool(IP_TRUE, "ipmip6pm.inet.dhcp.server.enabled");
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.inet.dhcp.server.enabled=%s",
|
||||
gcfg->server_config.enabled? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.inet.dhcp.relay.enabled=%s",
|
||||
gcfg->relay_config.enabled? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.inet.dhcp.relay.link_selection=%s",
|
||||
gcfg->relay_config.link_selection? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.inet.dhcp.relay.server_override=%s",
|
||||
gcfg->relay_config.override? "true" : "false");
|
||||
|
||||
if (gcfg->relay_config.forward)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.inet.dhcp.relay.server=%s",
|
||||
ipmip_ntop_inet(proc, gcfg->relay_config.forward));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_dsmipv6_config(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6pm_if *ifp,
|
||||
Ipmip6pm_service_dsmipv6_config_global_t *gcfg,
|
||||
Ipmip6pm_service_dsmipv6_config_t *cfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
cfg->relay_config.enabled = ipmip_sysvar_bool(gcfg->relay_config.enabled, "ipmip6pm.interface.%s.inet.dhcp.relay.enabled", ifp->ipmip6.iff.ifname);
|
||||
ipmip_sysvar_inet(gcfg->relay_config.forward, &cfg->relay_config.forward, IP_NULL, "ipmip6pm.interface.%s.inet.dhcp.relay.server", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->relay_config.link_selection = ipmip_sysvar_bool(gcfg->relay_config.link_selection, "ipmip6pm.interface.%s.inet.dhcp.relay.link_selection", ifp->ipmip6.iff.ifname);
|
||||
cfg->relay_config.override = ipmip_sysvar_bool(gcfg->relay_config.override, "ipmip6pm.interface.%s.inet.dhcp.relay.server_override", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->server_config.enabled = ipmip_sysvar_mode(gcfg->server_config.enabled, "ipmip6pm.interface.%s.inet.dhcp.server.enabled", ifp->ipmip6.iff.ifname);
|
||||
|
||||
if (cfg->relay_config.enabled || cfg->server_config.enabled)
|
||||
{
|
||||
/* We need the DHCP context */
|
||||
ipmip_dhcp_context_create(&ctx->ipmip6.ipmip, proc);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.inet.dhcp.server.enabled=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->server_config.enabled? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.inet.dhcp.relay.enabled=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->relay_config.enabled? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.inet.dhcp.relay.link_selection=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->relay_config.link_selection? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.inet.dhcp.relay.server_override=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->relay_config.override? "true" : "false");
|
||||
|
||||
if (cfg->relay_config.forward)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.inet.dhcp.relay.server=%s",
|
||||
ifp->ipmip6.iff.ifname, ipmip_ntop_inet(proc, cfg->relay_config.forward));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_service_dsmipv6_provide(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_dsmipv6_config_global_t *gcfg,
|
||||
Ipmip6pm_service_dsmipv6_config_t *cfg,
|
||||
Ipmip6pm_service_dsmipv6_node_t *handle,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
IPMIP_UNUSED_PARAMETER(cfg);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_ENABLE)
|
||||
{
|
||||
/* Assign the gateway */
|
||||
if (node->mo_dsmipv6_home_prefix.prefix != 0)
|
||||
{
|
||||
if (handle->gateway && !handle->relay)
|
||||
{
|
||||
if (ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_NEWADDR,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
&handle->gateway,
|
||||
32,
|
||||
0,
|
||||
0) != 0)
|
||||
{
|
||||
/**/
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Proxy Mobile node %s interface %s unable to add DSMIPv6 Gateway address %s",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
node->ifp_private.ipmip6.ifp->iff.ifname,
|
||||
ipmip_ntop_inet(proc, handle->gateway)));
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup the RELAY structure */
|
||||
handle->dhcp.ifindex = node->ifp_private.ipmip6.ifp->iff.ifindex;
|
||||
handle->dhcp.lock = node->lock;
|
||||
handle->dhcp.opaque = node;
|
||||
handle->cfg = cfg;
|
||||
|
||||
if (handle->relay)
|
||||
{
|
||||
if (node->ifp_public && node->ifp_public->ifinet)
|
||||
{
|
||||
/*
|
||||
* The relay agent won't work properly unless there is
|
||||
* an IPv4 address configured on the interface.
|
||||
* We can use the CoA for this purpose.
|
||||
*/
|
||||
|
||||
if (ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_NEWADDR,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
&node->ifp_public->ifinet,
|
||||
32,
|
||||
0,
|
||||
0) != 0)
|
||||
{
|
||||
/**/
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Proxy Mobile node %s interface %s unable to add DSMIPv6 CoA address %s",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
node->ifp_private.ipmip6.ifp->iff.ifname,
|
||||
ipmip_ntop_inet(proc, node->ifp_public->ifinet)));
|
||||
}
|
||||
}
|
||||
|
||||
handle->dhcp.remote_id = node->mo_dsmipv6_home_prefix.prefix;
|
||||
handle->dhcp.process_func = (Ipmip_timer_func_t)ipmip6pm_service_dsmipv6_dhcpv4_relay;
|
||||
ipmip_dhcp_register(&ctx->ipmip6.ipmip, proc, &handle->dhcp);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle->dhcp.process_func = (Ipmip_timer_func_t)ipmip6pm_service_dsmipv6_dhcpv4_server;
|
||||
ipmip_dhcp_register(&ctx->ipmip6.ipmip, proc, &handle->dhcp);
|
||||
}
|
||||
|
||||
handle->installed |= IPMIP6PM_SERVICE_INSTALLED_DHCP;
|
||||
|
||||
if (node->ifp_private.ipmip6.ifp->iff.lladdr != IP_NULL && node->ifp_private.ipmip6.ifp->iff.lladdr->type == IPMIP_LLADDR_TYPE_MAC)
|
||||
{
|
||||
handle->arp.ifindex = node->ifp_private.ipmip6.ifp->iff.ifindex;
|
||||
handle->arp.lock = node->lock;
|
||||
handle->arp.opaque = node;
|
||||
handle->arp.process_func = (Ipmip_timer_func_t)ipmip6pm_service_dsmipv6_arp;
|
||||
|
||||
ipmip_inet_arp_context_in_create(&ctx->ipmip6.ipmip, proc);
|
||||
ipmip_inet_arp_context_out_create(&ctx->ipmip6.ipmip, proc);
|
||||
ipmip_inet_arp_register(&ctx->ipmip6.ipmip, proc, &handle->arp);
|
||||
|
||||
handle->installed |= IPMIP6PM_SERVICE_INSTALLED_ARP;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_DISABLE || action == IPMIP_CALLBACK_UPDATE)
|
||||
{
|
||||
if (handle->relay
|
||||
&& node->ifp_public
|
||||
&& node->ifp_public->ifinet)
|
||||
{
|
||||
ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_DELADDR,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
&node->ifp_public->ifinet,
|
||||
32,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
else if (handle->gateway)
|
||||
{
|
||||
ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_DELADDR,
|
||||
node->ifp_private.ipmip6.ifp->iff.ifindex,
|
||||
&handle->gateway,
|
||||
32,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
if ((handle->installed & IPMIP6PM_SERVICE_INSTALLED_DHCP) != 0)
|
||||
{
|
||||
ipmip_dhcp_unregister(&ctx->ipmip6.ipmip, proc, &handle->dhcp);
|
||||
|
||||
/**/
|
||||
handle->installed &= ~IPMIP6PM_SERVICE_INSTALLED_DHCP;
|
||||
}
|
||||
|
||||
if ((handle->installed & IPMIP6PM_SERVICE_INSTALLED_ARP) != 0)
|
||||
{
|
||||
ipmip_inet_arp_unregister(&ctx->ipmip6.ipmip, proc, &handle->arp);
|
||||
|
||||
/**/
|
||||
handle->installed &= ~IPMIP6PM_SERVICE_INSTALLED_ARP;
|
||||
}
|
||||
|
||||
if (action == IPMIP_CALLBACK_UPDATE)
|
||||
return IPMIP_CALLBACK_RET_FAILED;
|
||||
}
|
||||
|
||||
/* Don't delay */
|
||||
return IPMIP_CALLBACK_RET_SUCCESS;
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_service_dsmipv6_setup(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_dsmipv6_config_global_t *gcfg,
|
||||
Ipmip6pm_service_dsmipv6_config_t *cfg,
|
||||
Ipmip6pm_service_dsmipv6_node_t *handle,
|
||||
struct Ipmip6pm_node *node,
|
||||
const char *value,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
int slen = value? ipcom_strlen(value) : 0;
|
||||
|
||||
if (ctx->ipmip6.ipmip.dhcp == IP_NULL)
|
||||
return IP_FALSE;
|
||||
|
||||
if (slen == 0 || value[0] != 'S')
|
||||
{
|
||||
if (cfg->relay_config.enabled == IP_FALSE)
|
||||
return IP_FALSE;
|
||||
|
||||
/* RELAY */
|
||||
if (slen > 2 && value[1] == '=')
|
||||
{
|
||||
ipmip_util_inet(&value[2], &handle->relay_data.forward, IP_NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cfg->relay_config.forward)
|
||||
handle->relay_data.forward = cfg->relay_config.forward;
|
||||
else
|
||||
handle->relay_data.forward = node->homeagent_inet;
|
||||
}
|
||||
|
||||
handle->relay = IP_TRUE;
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* SERVER */
|
||||
return cfg->server_config.enabled;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* No dyncamically allocated values */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (handle->relay)
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_SERVICE);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_SERVICE_DSMIPV6_NAME);
|
||||
|
||||
ipcom_snprintf(proc->ntop.ntop_pbuf, sizeof(proc->ntop.ntop_pbuf), "R=%s", ipmip_ntop_inet(proc, handle->relay_data.forward));
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
proc->ntop.ntop_pbuf);
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_SERVICE);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_SERVICE_DSMIPV6_NAME);
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
"S");
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6pm_service_dsmipv6_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_service_dsmipv6_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
static Ipmip6pm_extension_t srv;
|
||||
|
||||
srv.name = IPMIP6PM_SERVICE_DSMIPV6_NAME;
|
||||
srv.syntax = "<R[=dhcpv4 server address]|S>";
|
||||
srv.node_data_size = sizeof(Ipmip6pm_service_dsmipv6_node_t);
|
||||
srv.ifp_data_size = sizeof(Ipmip6pm_service_dsmipv6_config_t);
|
||||
srv.global_data_size = sizeof(Ipmip6pm_service_dsmipv6_config_global_t);
|
||||
|
||||
srv.config_global = (Ipmip6pm_extension_config_global_t)ipmip6pm_service_dsmipv6_config_global;
|
||||
srv.config_ifp = (Ipmip6pm_extension_config_ifp_t)ipmip6pm_service_dsmipv6_config;
|
||||
srv.provide = (Ipmip6pm_extension_provide_t)ipmip6pm_service_dsmipv6_provide;
|
||||
srv.setup = (Ipmip6pm_extension_setup_t)ipmip6pm_service_dsmipv6_setup;
|
||||
srv.pkt_rep_accept = (Ipmip6pm_extension_pkt_rep_accept_t)ipmip6pm_service_dsmipv6_req_accept;
|
||||
|
||||
ipmip6pm_context_register_extension(ctx, &srv, IPMIP6PM_FUNCTION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
#else
|
||||
IP_GLOBAL void ipmip6pm_service_dsmipv6_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_service_dsmipv6_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,656 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_service_radvd.c,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_service_radvd.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_radvd.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_attr_h.h"
|
||||
#include "ipmip6pm_if.h"
|
||||
#include "ipmip6pm_node.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6PM_SERVICE_RADVD_NAME "RADVD"
|
||||
|
||||
#define IPMIP6PM_SERVICE_RADVD_FLAG_A (1 << 0)
|
||||
#define IPMIP6PM_SERVICE_RADVD_FLAG_O (1 << 1)
|
||||
#define IPMIP6PM_SERVICE_RADVD_FLAG_M (1 << 2)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
typedef struct Ipmip6pm_service_radvd_config_global
|
||||
{
|
||||
Ipnet_radvd_if_data radvd;
|
||||
Ipnet_radvd_if_prefix_data prefix;
|
||||
} Ipmip6pm_service_radvd_config_global_t;
|
||||
|
||||
typedef struct Ipmip6pm_service_radvd_config_data
|
||||
{
|
||||
Ipnet_radvd_if_data radvd;
|
||||
Ipnet_radvd_if_prefix_data prefix;
|
||||
} Ipmip6pm_service_radvd_config_data_t;
|
||||
|
||||
typedef struct Ipmip6pm_service_radvd_handle_data
|
||||
{
|
||||
Ip_u32 radvd_flags;
|
||||
Ipnet_radvd_if_handle radvd;
|
||||
} Ipmip6pm_service_radvd_handle_data_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_radvd_config_global(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_radvd_config_global_t *gcfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
gcfg->radvd.max_rtr_adv_interval =
|
||||
ipmip_sysvar_long(600000, "ipmip6pm.radvd.MaxRtrAdvInterval");
|
||||
|
||||
gcfg->radvd.min_rtr_adv_interval =
|
||||
ipmip_sysvar_long(3000, "ipmip6pm.radvd.MinRtrAdvInterval");
|
||||
|
||||
gcfg->radvd.min_delay_between_ras =
|
||||
ipmip_sysvar_long(IP_MIN(gcfg->radvd.min_rtr_adv_interval, 3000), "ipmip6pm.radvd.MinDelayBetweenRAs");
|
||||
|
||||
gcfg->radvd.default_lifetime =
|
||||
ipmip_sysvar_long(IP_MAX(1000, (3 * gcfg->radvd.max_rtr_adv_interval)), "ipmip6pm.radvd.AdvDefaultLifetime");
|
||||
|
||||
gcfg->radvd.link_mtu =
|
||||
ipmip_sysvar_ulong(0, "ipmip6pm.radvd.AdvLinkMTU");
|
||||
|
||||
gcfg->radvd.reachable_time =
|
||||
ipmip_sysvar_ulong(0, "ipmip6pm.radvd.AdvReachableTime");
|
||||
|
||||
gcfg->radvd.retrans_timer =
|
||||
ipmip_sysvar_ulong(0, "ipmip6pm.radvd.AdvRetransTimer");
|
||||
|
||||
gcfg->radvd.hoplimit =
|
||||
(Ip_u8)ipmip_sysvar_ulong(64, "ipmip6pm.radvd.AdvCurHopLimit");
|
||||
|
||||
gcfg->radvd.managed =
|
||||
ipmip_sysvar_bool(IP_FALSE, "ipmip6pm.radvd.AdvManagedFlag");
|
||||
|
||||
gcfg->radvd.other_config =
|
||||
ipmip_sysvar_bool(IP_FALSE, "ipmip6pm.radvd.AdvOtherConfigFlag");
|
||||
|
||||
gcfg->radvd.home_agent =
|
||||
ipmip_sysvar_bool(IP_FALSE, "ipmip6pm.radvd.AdvHomeAgentFlag");
|
||||
|
||||
gcfg->radvd.adv_interval_opt =
|
||||
ipmip_sysvar_bool(IP_FALSE, "ipmip6pm.radvd.AdvIntervalOpt");
|
||||
|
||||
gcfg->radvd.adv_home_agent_opt =
|
||||
ipmip_sysvar_bool(IP_FALSE, "ipmip6pm.radvd.AdvHomeAgentOpt");
|
||||
|
||||
gcfg->radvd.adv_home_agent_opt_lifetime =
|
||||
ipmip_sysvar_long(0, "ipmip6pm.radvd.AdvHomeAgentOptLifetime");
|
||||
|
||||
gcfg->radvd.adv_home_agent_opt_preference =
|
||||
ipmip_sysvar_long(0, "ipmip6pm.radvd.AdvHomeAgentOptPreference");
|
||||
|
||||
|
||||
/* Do prefix */
|
||||
|
||||
gcfg->prefix.valid_lifetime =
|
||||
ipmip_sysvar_ulong(2592000, "ipmip6pm.radvd.prefix.AdvValidLifetime");
|
||||
|
||||
gcfg->prefix.preferred_lifetime =
|
||||
ipmip_sysvar_ulong(604800, "ipmip6pm.radvd.prefix.AdvPreferredLifetime");
|
||||
|
||||
gcfg->prefix.on_link =
|
||||
ipmip_sysvar_bool(IP_TRUE, "ipmip6pm.radvd.prefix.AdvOnLinkFlag");
|
||||
|
||||
gcfg->prefix.autonomous =
|
||||
ipmip_sysvar_bool(IP_TRUE, "ipmip6pm.radvd.prefix.AdvAutonomousFlag");
|
||||
|
||||
gcfg->prefix.router_address =
|
||||
ipmip_sysvar_bool(IP_FALSE, "ipmip6pm.radvd.prefix.AdvRouterAddressFlag");
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.MaxRtrAdvInterval=%u",
|
||||
gcfg->radvd.max_rtr_adv_interval);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.MinRtrAdvInterval=%u",
|
||||
gcfg->radvd.min_rtr_adv_interval);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.MinDelayBetweenRAs=%u",
|
||||
gcfg->radvd.min_delay_between_ras);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvDefaultLifetime=%u",
|
||||
gcfg->radvd.default_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvLinkMTU=%u",
|
||||
gcfg->radvd.link_mtu);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvReachableTime=%u",
|
||||
gcfg->radvd.reachable_time);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvRetransTimer=%u",
|
||||
gcfg->radvd.retrans_timer);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvCurHopLimit=%u",
|
||||
gcfg->radvd.hoplimit);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvManagedFlag=%s",
|
||||
gcfg->radvd.managed? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvOtherConfigFlag=%s",
|
||||
gcfg->radvd.other_config? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvHomeAgentFlag=%s",
|
||||
gcfg->radvd.home_agent? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvIntervalOpt=%s",
|
||||
gcfg->radvd.adv_interval_opt? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvHomeAgentOpt=%s",
|
||||
gcfg->radvd.adv_home_agent_opt? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvHomeAgentOptLifetime=%u",
|
||||
gcfg->radvd.adv_home_agent_opt_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.AdvHomeAgentOptPreference=%u",
|
||||
gcfg->radvd.adv_home_agent_opt_preference);
|
||||
|
||||
/* Do prefix */
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.prefix.AdvValidLifetime=%u",
|
||||
gcfg->prefix.valid_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.prefix.AdvPreferredLifetime=%u",
|
||||
gcfg->prefix.preferred_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.prefix.AdvOnLinkFlag=%s",
|
||||
gcfg->prefix.on_link? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.prefix.AdvAutonomousFlag=%s",
|
||||
gcfg->prefix.autonomous? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.radvd.prefix.AdvRouterAddressFlag=%s",
|
||||
gcfg->prefix.router_address? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_radvd_config(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6pm_if *ifp,
|
||||
Ipmip6pm_service_radvd_config_global_t *gcfg,
|
||||
Ipmip6pm_service_radvd_config_data_t *cfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
cfg->radvd.max_rtr_adv_interval =
|
||||
ipmip_sysvar_long(gcfg->radvd.max_rtr_adv_interval, "ipmip6pm.interface.%s.radvd.MaxRtrAdvInterval", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.min_rtr_adv_interval =
|
||||
ipmip_sysvar_long(cfg->radvd.max_rtr_adv_interval / 3, "ipmip6pm.interface.%s.radvd.MinRtrAdvInterval", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.min_delay_between_ras =
|
||||
ipmip_sysvar_long(IP_MIN(cfg->radvd.min_rtr_adv_interval, 3000), "ipmip6pm.interface.%s.radvd.MinDelayBetweenRAs", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.default_lifetime =
|
||||
ipmip_sysvar_long(IP_MAX(1000, (3 * cfg->radvd.max_rtr_adv_interval)), "ipmip6pm.interface.%s.radvd.AdvDefaultLifetime", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.link_mtu =
|
||||
ipmip_sysvar_ulong(gcfg->radvd.link_mtu, "ipmip6pm.interface.%s.radvd.AdvLinkMTU", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.reachable_time =
|
||||
ipmip_sysvar_ulong(gcfg->radvd.reachable_time, "ipmip6pm.interface.%s.radvd.AdvReachableTime", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.retrans_timer =
|
||||
ipmip_sysvar_ulong(gcfg->radvd.retrans_timer, "ipmip6pm.interface.%s.radvd.AdvRetransTimer", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.hoplimit =
|
||||
(Ip_u8)ipmip_sysvar_ulong(gcfg->radvd.hoplimit, "ipmip6pm.interface.%s.radvd.AdvCurHopLimit", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.managed =
|
||||
ipmip_sysvar_bool(gcfg->radvd.managed, "ipmip6pm.interface.%s.radvd.AdvManagedFlag", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.other_config =
|
||||
ipmip_sysvar_bool(gcfg->radvd.other_config, "ipmip6pm.interface.%s.radvd.AdvOtherConfigFlag", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.home_agent =
|
||||
ipmip_sysvar_bool(gcfg->radvd.home_agent, "ipmip6pm.interface.%s.radvd.AdvHomeAgentFlag", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.adv_interval_opt =
|
||||
ipmip_sysvar_bool(gcfg->radvd.adv_interval_opt, "ipmip6pm.interface.%s.radvd.AdvIntervalOpt", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.adv_home_agent_opt =
|
||||
ipmip_sysvar_bool(gcfg->radvd.adv_home_agent_opt, "ipmip6pm.interface.%s.radvd.AdvHomeAgentOpt", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.adv_home_agent_opt_lifetime =
|
||||
ipmip_sysvar_long(gcfg->radvd.adv_home_agent_opt_lifetime, "ipmip6pm.interface.%s.radvd.AdvHomeAgentOptLifetime", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->radvd.adv_home_agent_opt_preference =
|
||||
ipmip_sysvar_long(gcfg->radvd.adv_home_agent_opt_preference, "ipmip6pm.interface.%s.radvd.AdvHomeAgentOptPreference", ifp->ipmip6.iff.ifname);
|
||||
|
||||
|
||||
/* Do prefix */
|
||||
|
||||
cfg->prefix.valid_lifetime =
|
||||
ipmip_sysvar_ulong(gcfg->prefix.valid_lifetime, "ipmip6pm.interface.%s.radvd.prefix.AdvValidLifetime", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->prefix.preferred_lifetime =
|
||||
ipmip_sysvar_ulong(gcfg->prefix.preferred_lifetime, "ipmip6pm.interface.%s.radvd.prefix.AdvPreferredLifetime", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->prefix.on_link =
|
||||
ipmip_sysvar_bool(gcfg->prefix.on_link, "ipmip6pm.interface.%s.radvd.prefix.AdvOnLinkFlag", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->prefix.autonomous =
|
||||
ipmip_sysvar_bool(gcfg->prefix.autonomous, "ipmip6pm.interface.%s.radvd.prefix.AdvAutonomousFlag", ifp->ipmip6.iff.ifname);
|
||||
|
||||
cfg->prefix.router_address =
|
||||
ipmip_sysvar_bool(gcfg->prefix.router_address, "ipmip6pm.interface.%s.radvd.prefix.AdvRouterAddressFlag", ifp->ipmip6.iff.ifname);
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.MaxRtrAdvInterval=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.max_rtr_adv_interval);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.MinRtrAdvInterval=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.min_rtr_adv_interval);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.MinDelayBetweenRAs=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.min_delay_between_ras);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvDefaultLifetime=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.default_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvLinkMTU=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.link_mtu);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvReachableTime=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.reachable_time);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvRetransTimer=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.retrans_timer);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvCurHopLimit=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.hoplimit);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvManagedFlag=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.managed? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvOtherConfigFlag=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.other_config? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvHomeAgentFlag=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.home_agent? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvIntervalOpt=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.adv_interval_opt? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvHomeAgentOpt=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.adv_home_agent_opt? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvHomeAgentOptLifetime=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.adv_home_agent_opt_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.AdvHomeAgentOptPreference=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->radvd.adv_home_agent_opt_preference);
|
||||
|
||||
/* Do prefix */
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.prefix.AdvValidLifetime=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->prefix.valid_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.prefix.AdvPreferredLifetime=%u",
|
||||
ifp->ipmip6.iff.ifname, cfg->prefix.preferred_lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.prefix.AdvOnLinkFlag=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->prefix.on_link? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.prefix.AdvAutonomousFlag=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->prefix.autonomous? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.radvd.prefix.AdvRouterAddressFlag=%s",
|
||||
ifp->ipmip6.iff.ifname, cfg->prefix.router_address? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmip6pm_service_radvd_provide(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_radvd_config_global_t *gcfg,
|
||||
Ipmip6pm_service_radvd_config_data_t *cfg,
|
||||
Ipmip6pm_service_radvd_handle_data_t *handle,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_ENABLE)
|
||||
{
|
||||
Ipnet_radvd_if_data radvd;
|
||||
Ip_u8 i;
|
||||
|
||||
ipcom_memcpy(&radvd, &cfg->radvd, sizeof(radvd));
|
||||
ipcom_strcpy(radvd.ifname, node->ifp_private.ipmip6.ifname);
|
||||
|
||||
radvd.other_config = (handle->radvd_flags & IPMIP6PM_SERVICE_RADVD_FLAG_O) != 0;
|
||||
radvd.managed = (handle->radvd_flags & IPMIP6PM_SERVICE_RADVD_FLAG_M) != 0;
|
||||
|
||||
if (ipnet_radvd_if_open(&handle->radvd, &radvd) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Unable to start service for Proxy Mobile node %s",
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Ipnet_radvd_if_prefix_handle phandle;
|
||||
Ipnet_radvd_if_prefix_data pdata;
|
||||
|
||||
ipcom_memcpy(&pdata, &cfg->prefix, sizeof(pdata));
|
||||
|
||||
pdata.autonomous = (handle->radvd_flags & IPMIP6PM_SERVICE_RADVD_FLAG_A) != 0;
|
||||
|
||||
/* Do the prefixes */
|
||||
for (i = 0; i < node->mo_home_prefix_size; i++)
|
||||
{
|
||||
/* Add prefix by prefix */
|
||||
ipcom_memcpy(&pdata.prefix, &node->mo_home_prefix[i].prefix, sizeof(pdata.prefix));
|
||||
pdata.prefixlen = node->mo_home_prefix[i].prefix_length;
|
||||
|
||||
if (ipnet_radvd_if_prefix_open(handle->radvd, &phandle, &pdata) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Unable to start service on prefix %s/%d for Proxy Mobile node %s",
|
||||
ipmip_ntop_inet6(proc, &pdata.prefix, IP_NULL),
|
||||
pdata.prefixlen,
|
||||
ipmip6pm_node_describe(proc, node)));
|
||||
}
|
||||
}
|
||||
|
||||
/* Start it */
|
||||
ipnet_radvd_if_start(handle->radvd);
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_DISABLE)
|
||||
{
|
||||
if (handle)
|
||||
ipnet_radvd_if_close(handle->radvd);
|
||||
}
|
||||
|
||||
/* Don't delay */
|
||||
return IPMIP_CALLBACK_RET_SUCCESS;
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_service_radvd_setup(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_radvd_config_global_t *gcfg,
|
||||
Ipmip6pm_service_radvd_config_data_t *cfg,
|
||||
Ipmip6pm_service_radvd_handle_data_t *handle,
|
||||
struct Ipmip6pm_node *node,
|
||||
const char *value,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
const char *ptr = value;
|
||||
|
||||
/* Do some node specific setup on the RADVD */
|
||||
while (*ptr != '\0')
|
||||
{
|
||||
switch (*ptr++)
|
||||
{
|
||||
case 'A':
|
||||
case 'a':
|
||||
handle->radvd_flags |= IPMIP6PM_SERVICE_RADVD_FLAG_A;
|
||||
break;
|
||||
case 'O':
|
||||
case 'o':
|
||||
handle->radvd_flags |= IPMIP6PM_SERVICE_RADVD_FLAG_O;
|
||||
break;
|
||||
case 'M':
|
||||
case 'm':
|
||||
handle->radvd_flags |= IPMIP6PM_SERVICE_RADVD_FLAG_M;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cfg->radvd.other_config)
|
||||
handle->radvd_flags |= IPMIP6PM_SERVICE_RADVD_FLAG_O;
|
||||
if (cfg->radvd.managed)
|
||||
handle->radvd_flags |= IPMIP6PM_SERVICE_RADVD_FLAG_M;
|
||||
if (cfg->prefix.autonomous)
|
||||
handle->radvd_flags |= IPMIP6PM_SERVICE_RADVD_FLAG_A;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* No dyncamically allocated values */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_SERVICE);
|
||||
char *ptr = proc->ntop.ntop_name;
|
||||
|
||||
if ((handle->radvd_flags & IPMIP6PM_SERVICE_RADVD_FLAG_A) != 0)
|
||||
*ptr++ = 'A';
|
||||
if ((handle->radvd_flags & IPMIP6PM_SERVICE_RADVD_FLAG_O) != 0)
|
||||
*ptr++ = 'O';
|
||||
if ((handle->radvd_flags & IPMIP6PM_SERVICE_RADVD_FLAG_M) != 0)
|
||||
*ptr++ = 'M';
|
||||
*ptr++ = '\0';
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_SERVICE_RADVD_NAME);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
proc->ntop.ntop_name);
|
||||
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6pm_service_radvd_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_service_radvd_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
static Ipmip6pm_extension_t srv;
|
||||
|
||||
srv.name = IPMIP6PM_SERVICE_RADVD_NAME;
|
||||
srv.syntax = "<AOM> - Where A=Autonomous, O=Other, M=Managed";
|
||||
srv.node_data_size = sizeof(Ipmip6pm_service_radvd_handle_data_t);
|
||||
srv.ifp_data_size = sizeof(Ipmip6pm_service_radvd_config_data_t);
|
||||
srv.global_data_size= sizeof(Ipmip6pm_service_radvd_config_global_t);
|
||||
|
||||
srv.config_global = (Ipmip6pm_extension_config_global_t)ipmip6pm_service_radvd_config_global;
|
||||
srv.config_ifp = (Ipmip6pm_extension_config_ifp_t)ipmip6pm_service_radvd_config;
|
||||
srv.provide = (Ipmip6pm_extension_provide_t)ipmip6pm_service_radvd_provide;
|
||||
srv.setup = (Ipmip6pm_extension_setup_t)ipmip6pm_service_radvd_setup;
|
||||
|
||||
ipmip6pm_context_register_extension(ctx, &srv, IPMIP6PM_FUNCTION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,332 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_service_selection.c,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_service_selection.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_policy_routing.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
#include <private/ipmip6_sysext.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_attr_h.h"
|
||||
#include "ipmip6pm_if.h"
|
||||
#include "ipmip6pm_node.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6PM_SERVICE_SELECTION_NAME "SERVICE-SELECTION"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmip6pm_service_selection_config_global
|
||||
{
|
||||
Ipmip6_mh_mo_service_selection_mobility_option_t *selection;
|
||||
} Ipmip6pm_service_selection_config_global_t;
|
||||
|
||||
typedef struct Ipmip6pm_service_selection_config
|
||||
{
|
||||
Ipmip6_mh_mo_service_selection_mobility_option_t *selection;
|
||||
} Ipmip6pm_service_selection_config_t;
|
||||
|
||||
typedef struct Ipmip6pm_service_selection_node_config
|
||||
{
|
||||
Ipmip6_mh_mo_service_selection_mobility_option_t *selection;
|
||||
} Ipmip6pm_service_selection_node_config_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_selection_request_rep_apply(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6pm_service_selection_config_global_t *gcfg,
|
||||
Ipmip6pm_service_selection_config_t *ifcfg,
|
||||
Ipmip6pm_service_selection_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip6pm_pktbuf *pbuf)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
IPMIP_UNUSED_PARAMETER(ifcfg);
|
||||
|
||||
/**/
|
||||
if (node->mip6MnBLTable.mip6MnBLAccepted == IP_FALSE)
|
||||
{
|
||||
if (nodecfg->selection != IP_NULL)
|
||||
{
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"%s requesting service selection '%s'",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
(char *)&nodecfg->selection->identifier[0]));
|
||||
ipmip6_mh_pkt_opt_add_mo(&ctx->ipmip6,
|
||||
proc,
|
||||
&pbuf->ipmip6,
|
||||
&nodecfg->selection->hdr);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_selection_config_global(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_selection_config_global_t *gcfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
gcfg->selection = ipmip6_sysext_service_selection("ipmip6pm.service_selection");
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (gcfg->selection)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.service_selection=%s",
|
||||
&gcfg->selection->identifier[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_selection_config(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6pm_if *ifp,
|
||||
Ipmip6pm_service_selection_config_global_t *gcfg,
|
||||
Ipmip6pm_service_selection_config_t *cfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* Read the prefix list allowed for this interface */
|
||||
cfg->selection = ipmip6_sysext_service_selection("ipmip6pm.interface.%s.service_selection", ifp->ipmip6.iff.ifname);
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (cfg->selection != IP_NULL)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6pm.interface.%s.service_selection=%s",
|
||||
ifp->ipmip6.iff.ifname, &cfg->selection->identifier[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_selection_free(Ipmip6pm_service_selection_config_global_t *gcfg,
|
||||
Ipmip6pm_service_selection_config_t *ifcfg,
|
||||
Ipmip6pm_service_selection_node_config_t *nodecfg)
|
||||
{
|
||||
/* Do Nothing */
|
||||
if (nodecfg->selection != IP_NULL)
|
||||
{
|
||||
if (nodecfg->selection != ifcfg->selection && nodecfg->selection != gcfg->selection)
|
||||
ipcom_free(nodecfg->selection);
|
||||
nodecfg->selection = IP_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_service_selection_setup(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipmip6pm_service_selection_config_global_t *gcfg,
|
||||
Ipmip6pm_service_selection_config_t *ifcfg,
|
||||
Ipmip6pm_service_selection_node_config_t *nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
const char *value,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* Dont allow more than one */
|
||||
ipmip6pm_service_selection_free(gcfg, ifcfg, nodecfg);
|
||||
if (value == IP_NULL)
|
||||
{
|
||||
/* No explicit identifier */
|
||||
if (ifcfg->selection != IP_NULL)
|
||||
nodecfg->selection = ifcfg->selection;
|
||||
else if (gcfg->selection != IP_NULL)
|
||||
nodecfg->selection = gcfg->selection;
|
||||
}
|
||||
else
|
||||
{
|
||||
nodecfg->selection = ipmip6_util_mo_service_selection(value);
|
||||
}
|
||||
|
||||
return nodecfg->selection != IP_NULL;
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do Nothing */
|
||||
ipmip6pm_service_selection_free(gcfg, ifcfg, nodecfg);
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
if (nodecfg->selection != IP_NULL)
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_SERVICE);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_SERVICE_SELECTION_NAME);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
(char *)&nodecfg->selection->identifier[0]);
|
||||
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6pm_service_selection_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_service_selection_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
static Ipmip6pm_extension_t srv;
|
||||
|
||||
srv.name = IPMIP6PM_SERVICE_SELECTION_NAME;
|
||||
srv.syntax = "<service selection string>";
|
||||
srv.node_data_size = sizeof(Ipmip6pm_service_selection_node_config_t);
|
||||
srv.ifp_data_size = sizeof(Ipmip6pm_service_selection_config_t);
|
||||
srv.global_data_size= sizeof(Ipmip6pm_service_selection_config_global_t);
|
||||
|
||||
srv.config_global = (Ipmip6pm_extension_config_global_t)ipmip6pm_service_selection_config_global;
|
||||
srv.config_ifp = (Ipmip6pm_extension_config_ifp_t)ipmip6pm_service_selection_config;
|
||||
srv.setup = (Ipmip6pm_extension_setup_t)ipmip6pm_service_selection_setup;
|
||||
srv.pkt_req_apply = (Ipmip6pm_extension_pkt_req_apply_t)ipmip6pm_service_selection_request_rep_apply;
|
||||
|
||||
ipmip6pm_context_register_extension(ctx, &srv, IPMIP6PM_FUNCTION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,560 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6pm_service_vendor_extension.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6pm/config/ipmip6pm_service_vendor_extension.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6pm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_policy_routing.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
#include <private/ipmip6_sysext.h>
|
||||
|
||||
#include "ipmip6pm_h.h"
|
||||
#include "ipmip6pm_attr_h.h"
|
||||
#include "ipmip6pm_if.h"
|
||||
#include "ipmip6pm_node.h"
|
||||
#include "ipmip6pm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6PM_SERVICE_VENDOR_EXTENSION_NAME "VENDOR-EXTENSION"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmip6pm_vendor_extension_config_ext
|
||||
{
|
||||
Ipcom_list next;
|
||||
Ipmip6_mh_mo_vendor_specific_mobility_option_t *mo;
|
||||
} Ipmip6pm_vendor_extension_config_ext_t;
|
||||
|
||||
typedef struct Ipmip6pm_vendor_extension_config
|
||||
{
|
||||
Ipcom_list *vext;
|
||||
} Ipmip6pm_vendor_extension_config_t;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_service_vendor_extension_req_accept(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipcom_list **gcfg,
|
||||
Ipcom_list **cfg,
|
||||
Ipcom_list **nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip6pm_pktbuf *pbuf,
|
||||
struct Ipmip_timer *service)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
IPMIP_UNUSED_PARAMETER(cfg);
|
||||
IPMIP_UNUSED_PARAMETER(nodecfg);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(service);
|
||||
|
||||
if (pbuf->ipmip6.mo.vendor_options.numelem > 0)
|
||||
{
|
||||
Ipmip6_mh_mo_vendor_specific_mobility_option_t *mo;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < pbuf->ipmip6.mo.vendor_options.numelem; i++)
|
||||
{
|
||||
mo = (Ipmip6_mh_mo_vendor_specific_mobility_option_t*)pbuf->ipmip6.mo.vendor_options.hdrs[i];
|
||||
|
||||
/* Mismatch; redo selection */
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"%s received Vendor Extension %u.%u",
|
||||
ipmip6pm_node_describe(proc, node),
|
||||
IP_GET_NTOHL(&mo->vendor_id), mo->sub_type));
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_vendor_extension_request_rep_apply(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipcom_list **gcfg,
|
||||
Ipcom_list **ifcfg,
|
||||
Ipcom_list **nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
struct Ipmip6pm_pktbuf *pbuf)
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
IPMIP_UNUSED_PARAMETER(ifcfg);
|
||||
|
||||
/**/
|
||||
if (*nodecfg != IP_NULL)
|
||||
{
|
||||
for (nmo = IPCOM_LIST_FIRST(*nodecfg); nmo !=IP_NULL; nmo = IPCOM_LIST_NEXT(&nmo->next))
|
||||
ipmip6_mh_pkt_opt_add_mo(&ctx->ipmip6,
|
||||
proc,
|
||||
&pbuf->ipmip6,
|
||||
&nmo->mo->hdr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_vendor_extension_foreach(struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipcom_list *priv_cfg)
|
||||
{
|
||||
Ip_u32 vendor;
|
||||
Ip_u8 subtype = 0;
|
||||
char *endp;
|
||||
Ip_u8 *vp;
|
||||
Ip_size_t sz;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(name);
|
||||
|
||||
vendor = ipcom_strtoul(subkey, &endp, 0);
|
||||
if (*endp == '.')
|
||||
subtype = ipcom_strtoul(endp + 1, IP_NULL, 0);
|
||||
|
||||
/* Time to resolve the string value */
|
||||
vp = ipmip_util_values_to_hexarray(value, &sz);
|
||||
if (vp != IP_NULL)
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo = ipcom_malloc(sizeof(*nmo));
|
||||
|
||||
if (nmo == IP_NULL)
|
||||
{
|
||||
ipcom_free(vp);
|
||||
return;
|
||||
}
|
||||
|
||||
nmo->mo = ipmip6_util_mo_vendor_extension(vendor, subtype, vp, sz);
|
||||
if (nmo->mo == IP_NULL)
|
||||
{
|
||||
ipcom_free(nmo);
|
||||
ipcom_free(vp);
|
||||
return;
|
||||
}
|
||||
|
||||
ipcom_list_insert_last(priv_cfg, &nmo->next);
|
||||
ipcom_free(vp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_vendor_extension_config_global(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipcom_list **gcfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* */
|
||||
Ipcom_list lst;
|
||||
ipcom_list_init(&lst);
|
||||
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip6pm_service_vendor_extension_foreach,
|
||||
&lst,
|
||||
"ipmip6pm.vendor_extension.*");
|
||||
|
||||
if (IPCOM_LIST_FIRST(&lst) != IP_NULL)
|
||||
{
|
||||
Ipcom_list *e;
|
||||
*gcfg = ipcom_malloc(sizeof(Ipcom_list));
|
||||
ipcom_list_init(*gcfg);
|
||||
|
||||
while ((e = IPCOM_LIST_FIRST(&lst)) != IP_NULL)
|
||||
{
|
||||
ipcom_list_remove(e);
|
||||
ipcom_list_insert_last(*gcfg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
|
||||
if (*gcfg != IP_NULL)
|
||||
{
|
||||
while ((nmo = IPCOM_LIST_FIRST(*gcfg)) != IP_NULL)
|
||||
{
|
||||
ipcom_list_remove(&nmo->next);
|
||||
ipcom_free(nmo->mo);
|
||||
ipcom_free(nmo);
|
||||
}
|
||||
|
||||
ipcom_free(*gcfg);
|
||||
*gcfg = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
if (*gcfg != IP_NULL)
|
||||
{
|
||||
for (nmo = IPCOM_LIST_FIRST(*gcfg); nmo !=IP_NULL; nmo = IPCOM_LIST_NEXT(&nmo->next))
|
||||
{
|
||||
Ip_u8 *data = (Ip_u8 *)(nmo->mo + 1);
|
||||
int i;
|
||||
int off = ipcom_snprintf(proc->ntop.ntop_pbuf, sizeof(proc->ntop.ntop_pbuf),
|
||||
"ipmip6pm.vendor_extension.%u.%u=",
|
||||
IP_GET_NTOHL(&nmo->mo->vendor_id), nmo->mo->sub_type);
|
||||
for (i = 0; i < (nmo->mo->hdr.len - 6); i++)
|
||||
off += ipcom_snprintf(&proc->ntop.ntop_pbuf[off], sizeof(proc->ntop.ntop_pbuf) - off,
|
||||
"%s0x%02x", i > 0? "," : "", data[i]);
|
||||
ipmip_cli_config_printf(&request->message, proc->ntop.ntop_pbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6pm_service_vendor_extension_config(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6pm_if *ifp,
|
||||
Ipcom_list **gcfg,
|
||||
Ipcom_list **cfg,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* */
|
||||
Ipcom_list lst;
|
||||
ipcom_list_init(&lst);
|
||||
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip6pm_service_vendor_extension_foreach,
|
||||
&lst,
|
||||
"ipmip6pm.interface.%s.vendor_extension.*", ifp->ipmip6.iff.ifname);
|
||||
|
||||
if (IPCOM_LIST_FIRST(&lst) != IP_NULL)
|
||||
{
|
||||
Ipcom_list *e;
|
||||
*cfg = ipcom_malloc(sizeof(Ipcom_list));
|
||||
ipcom_list_init(*cfg);
|
||||
|
||||
while ((e = IPCOM_LIST_FIRST(&lst)) != IP_NULL)
|
||||
{
|
||||
ipcom_list_remove(e);
|
||||
ipcom_list_insert_last(*cfg, e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Use global */
|
||||
*cfg = *gcfg;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
|
||||
if (*cfg != IP_NULL)
|
||||
{
|
||||
if (*cfg != *gcfg)
|
||||
{
|
||||
while ((nmo = IPCOM_LIST_FIRST(*cfg)) != IP_NULL)
|
||||
{
|
||||
ipcom_list_remove(&nmo->next);
|
||||
ipcom_free(nmo->mo);
|
||||
ipcom_free(nmo);
|
||||
}
|
||||
|
||||
ipcom_free(*cfg);
|
||||
}
|
||||
|
||||
*cfg = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
if (*cfg != IP_NULL)
|
||||
{
|
||||
for (nmo = IPCOM_LIST_FIRST(*cfg); nmo !=IP_NULL; nmo = IPCOM_LIST_NEXT(&nmo->next))
|
||||
{
|
||||
Ip_u8 *data = (Ip_u8 *)(nmo->mo + 1);
|
||||
int i;
|
||||
int off = ipcom_snprintf(proc->ntop.ntop_pbuf, sizeof(proc->ntop.ntop_pbuf),
|
||||
"ipmip6pm.interface.%s.vendor_extension.%u.%u=",
|
||||
ifp->ipmip6.iff.ifname, IP_GET_NTOHL(&nmo->mo->vendor_id), nmo->mo->sub_type);
|
||||
for (i = 0; i < (nmo->mo->hdr.len - 6); i++)
|
||||
off += ipcom_snprintf(&proc->ntop.ntop_pbuf[off], sizeof(proc->ntop.ntop_pbuf) - off,
|
||||
"%s0x%02x", i > 0? "," : "", data[i]);
|
||||
ipmip_cli_config_printf(&request->message, proc->ntop.ntop_pbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6pm_service_vendor_extension_setup(struct Ipmip6pm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
Ipcom_list **gcfg,
|
||||
Ipcom_list **cfg,
|
||||
Ipcom_list **nodecfg,
|
||||
struct Ipmip6pm_node *node,
|
||||
const char *value,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(gcfg);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
/* Dont allow more than one */
|
||||
if (value != IP_NULL)
|
||||
{
|
||||
char *endp;
|
||||
Ip_u32 smi;
|
||||
Ip_u8 subtype = 0;
|
||||
|
||||
/* <SMI>.<Sub>=<Value> */
|
||||
smi = ipcom_strtoul(value, &endp, 0);
|
||||
if (*endp == '.')
|
||||
subtype = ipcom_strtoul(endp + 1, IP_NULL, 0);
|
||||
|
||||
endp = ipcom_strchr(value, '=');
|
||||
if (endp == IP_NULL)
|
||||
{
|
||||
IPMIP6_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"%s unable to parse Vendor Extension %s",
|
||||
ipmip6pm_node_describe(proc, node), value));
|
||||
return IP_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
Ip_u8 *vp;
|
||||
Ip_size_t sz;
|
||||
|
||||
vp = ipmip_util_values_to_hexarray(value, &sz);
|
||||
if (vp == IP_NULL)
|
||||
return IP_FALSE;
|
||||
|
||||
nmo = ipcom_malloc(sizeof(*nmo));
|
||||
if (nmo == IP_NULL)
|
||||
{
|
||||
ipcom_free(vp);
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
nmo->mo = ipmip6_util_mo_vendor_extension(smi, subtype, vp, sz);
|
||||
ipcom_free(vp);
|
||||
|
||||
if (*nodecfg == IP_NULL)
|
||||
{
|
||||
*nodecfg = ipcom_malloc(sizeof(Ipcom_list));
|
||||
ipcom_list_init(*nodecfg);
|
||||
}
|
||||
|
||||
ipcom_list_insert_last(*nodecfg, &nmo->next);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*nodecfg = *cfg;
|
||||
}
|
||||
|
||||
return *nodecfg != IP_NULL;
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
/* Do Nothing */
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
|
||||
if (*nodecfg != IP_NULL)
|
||||
{
|
||||
if (*nodecfg != *cfg)
|
||||
{
|
||||
while ((nmo = IPCOM_LIST_FIRST(*nodecfg)) != IP_NULL)
|
||||
{
|
||||
ipcom_list_remove(&nmo->next);
|
||||
ipcom_free(nmo->mo);
|
||||
ipcom_free(nmo);
|
||||
}
|
||||
|
||||
ipcom_free(*nodecfg);
|
||||
}
|
||||
|
||||
*nodecfg = IP_NULL;
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
Ipmip6pm_vendor_extension_config_ext_t *nmo;
|
||||
if (*nodecfg != IP_NULL)
|
||||
{
|
||||
for (nmo = IPCOM_LIST_FIRST(*nodecfg); nmo !=IP_NULL; nmo = IPCOM_LIST_NEXT(&nmo->next))
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6PM_CLI_ATTR_BC_P_SERVICE);
|
||||
|
||||
Ip_u8 *data = (Ip_u8 *)(nmo->mo + 1);
|
||||
int i;
|
||||
int off = ipcom_snprintf(proc->ntop.ntop_pbuf, sizeof(proc->ntop.ntop_pbuf),
|
||||
"%u.%u=",
|
||||
IP_GET_NTOHL(&nmo->mo->vendor_id), nmo->mo->sub_type);
|
||||
|
||||
for (i = 0; i < (nmo->mo->hdr.len - 6); i++)
|
||||
off += ipcom_snprintf(&proc->ntop.ntop_pbuf[off], sizeof(proc->ntop.ntop_pbuf) - off,
|
||||
"%s0x%02x", i > 0? "," : "", data[i]);
|
||||
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_MODULE,
|
||||
IPMIP6PM_SERVICE_VENDOR_EXTENSION_NAME);
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP6PM_CLI_ATTR_BC_P_SRV_VALUE,
|
||||
(char *)proc->ntop.ntop_pbuf);
|
||||
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6pm_service_vendor_extension_install(struct Ipmip6pm_context *ctx);
|
||||
IP_GLOBAL void
|
||||
ipmip6pm_service_vendor_extension_install(struct Ipmip6pm_context *ctx)
|
||||
{
|
||||
static Ipmip6pm_extension_t srv;
|
||||
|
||||
srv.name = IPMIP6PM_SERVICE_VENDOR_EXTENSION_NAME;
|
||||
srv.syntax = "<SMI Number>.<SubType>=<hex array|<string>";
|
||||
srv.node_data_size = sizeof(Ipcom_list *);
|
||||
srv.ifp_data_size = sizeof(Ipcom_list *);
|
||||
srv.global_data_size= sizeof(Ipcom_list *);
|
||||
|
||||
srv.config_global = (Ipmip6pm_extension_config_global_t)ipmip6pm_service_vendor_extension_config_global;
|
||||
srv.config_ifp = (Ipmip6pm_extension_config_ifp_t)ipmip6pm_service_vendor_extension_config;
|
||||
srv.setup = (Ipmip6pm_extension_setup_t)ipmip6pm_service_vendor_extension_setup;
|
||||
srv.pkt_req_apply = (Ipmip6pm_extension_pkt_req_apply_t)ipmip6pm_service_vendor_extension_request_rep_apply;
|
||||
srv.pkt_rep_accept = (Ipmip6pm_extension_pkt_rep_accept_t)ipmip6pm_service_vendor_extension_req_accept;
|
||||
|
||||
ipmip6pm_context_register_extension(ctx, &srv, IPMIP6PM_FUNCTION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user