original files of m241
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
|
||||
# this file contents now moved under a versioned file
|
||||
|
||||
@@ -0,0 +1,618 @@
|
||||
# Makefile - Top-level comp_ip_net2 Makefile
|
||||
#
|
||||
# Copyright 2006-2011, 2017 Wind River Systems, Inc.
|
||||
#
|
||||
# The right to copy, distribute, modify or otherwise make use
|
||||
# of this software may be licensed only pursuant to the terms
|
||||
# of an applicable Wind River license agreement.
|
||||
#
|
||||
# modification history
|
||||
# --------------------
|
||||
# 03z,28may17,xxy Added TSN support
|
||||
# 03y,25apr16,pdr Added PTP support (backport Vx7).
|
||||
# 03x,21may12,uol Revert to 6.9 settings
|
||||
# 03w,03may11,mry Adding ipbridge support (replaces vxbridge)
|
||||
# 03v,19aug11,mze 6.10 version remove warnings for usr builds
|
||||
# 03u,15sep10,xhs support IPLITE
|
||||
# 03t,25jun10,rjq Added IPNTP
|
||||
# 03s,25feb10,mze adjust TOOL_FAMILY
|
||||
# 03r,11feb10,uol WIND00158454: Use rclean rule also for GPP.
|
||||
# 03q,05feb10,mry Adding IPMACSEC
|
||||
# 03p,31jul09,ten Add IPL2TP
|
||||
# 03o,22jul09,uol Add IPMIPPM
|
||||
# 03n,14jul09,mdk merge from networking branch
|
||||
# 03m,18jun09,mze adding changes to support /usr/lib in VSBs
|
||||
# 03l,18jun09,mze fixin WIND00153279 again, change lost after merge.
|
||||
# 03k,11jun09,dwb Adding vxdot1x
|
||||
# 03j,15jun09,mze fixin WIND00153279 again, change lost after merge.
|
||||
# 03i,16dec08,mry Add IPWPS
|
||||
# 03h,11feb09,ggz Move coreip and bridge into CVS.
|
||||
# 03g,27jan09,pee WIND00153279
|
||||
# 03k,23apr09,uol Add module ipmippm
|
||||
# 03j,26mar09,uol WIND00158454: Use rclean rule also for GPP.
|
||||
# 03i,02mar09,uol Add ipmip6hm and ipmip6pm
|
||||
# 03h,09feb09,mca add IPCAVIUM component
|
||||
# 03g,03dec08,f_g added IPSCTP component
|
||||
# 03g,27jan09,pee WIND00153279
|
||||
# 03f,17nov08,mze move export of FEATURE_SET below VSB eval
|
||||
# 03e,04nov08,mze test
|
||||
# 03d,03nov08,mze move eval out of conditional
|
||||
# 03b,29oct08,mze fix usr side tool reference
|
||||
# 03a,02oct08,mze Change VSB exports
|
||||
# 02z,02sep08,mze removal of ipcom_libconfig.mk reference
|
||||
# 02y,31jul08,pee exporting _WRS_CONFIG_ADDEDCFLAGS
|
||||
# 02x,08jul08,pee adding IPDHCPS6 to VSB parameter translation list
|
||||
# 02w,02jul08,mze undo last change
|
||||
# 02v,02jul08,mze VSB changes
|
||||
# 02u,01jul08,mze adding new Components
|
||||
# 02t,30jun08,mze adding DIAMETERP
|
||||
# 02s,30jun08,mze VSB changes
|
||||
# 02r,24jun08,mze added SPACE
|
||||
# 02q,23jun08,mze remove IPVXCOMPAT
|
||||
# 02p,05jun08,mze VSB changes
|
||||
# 02o,03jun08,pee including VSB configuration.
|
||||
# 02n,03jun08,mze changing library location to be vsb based
|
||||
# 02m,28may08,dlk Added vxmux module.
|
||||
# 02l,20feb08,tlu Add build support for IPROHC
|
||||
# 02k,27may08,uol Move util_ipdef and util_ipinc to be visible in MSP builds.
|
||||
# 02j,26may08,brg Changing product name ipvxcompat to vxcompat
|
||||
# 02i,01may08,dlk Added util_ipdef, util_ipinc rules.
|
||||
# 02h,14may08,brg Adding ipvxcompat
|
||||
# 02g,08may08,uol Add module ipmip
|
||||
# 02f,07aug07,mry Add 802.1x supplicant support
|
||||
# 02e,04sep07,kch Stripped leading and trailing whitespace (WIND00046447).
|
||||
# 02d,17jul07,spw Added IPWLAN
|
||||
# 02c,12jul07,nlu add mip4
|
||||
# 02b,29jun07,kch Removed trailing space after the backslash immediately
|
||||
# following "ipmip4".
|
||||
# 02a,29jun07,mcarlste Add IPFREESCALE
|
||||
# 01z,29jun07,??? build rules for MIP4
|
||||
# 01y,29jun07,??? build rules for MIP4
|
||||
# 01x,19jun07,tpw Use WRVX_COMPBASE vs. WIND_COMPONENTS correctly.
|
||||
# 01w,03apr07,tlu Add build support for IPDIAMETER
|
||||
# 01v,02may07,tkf Update component library path for SMP.
|
||||
# 01u,26apr07,tkf Add IPv6-Only build support. Also fix CQ:WIND00092985.
|
||||
# 01t,21feb07,kch Added DIR_EXT for SMP build support.
|
||||
# 01s,13dec06,tkf Fix user side compiler error (WIND00083671).
|
||||
# 01r,27oct06,tkf Change library archive location to WIND_COMPONENTS/obj.
|
||||
# 01q,26sep06,kch Added IPRADIUS.
|
||||
# 01p,14sep06,tkf Replcaed target all with kernel. Added IPDHCPC6 and
|
||||
# IPDHCPS6.
|
||||
# 01o,12sep06,dlk Replace 'make' with MAKE variable.
|
||||
# 01n,09sep06,jbl add WRSNMP to the mix
|
||||
# 01m,08sep06,tkf Add user side build support.
|
||||
# 01l,06sep06,tkf Changed the way IpComps is processed.
|
||||
# 01k,07aug06,kch Renamed IPDHCPDIR to IPDHCPSDIR and IPFWDIR to
|
||||
# IPFIREWALLDIR. Also removed unsupported IPNet products.
|
||||
# 01j,19jul06,tlu Added support for IPRIPNG component
|
||||
# 01i,19jul06,tkf Include make.<CPU>.<TOOL> regardless of whether
|
||||
# VX_CPU_FAMILY is defined or not.
|
||||
# 01h,03jul06,tkf Modifications for use with version-less component
|
||||
# directories: define and export BASE_ROOT; changed rule to
|
||||
# ignore version numbers in directory names.
|
||||
# 01g,02jul06,tkf Export WIND_IPNET=true by default.
|
||||
# 01f,12jun06,dlk Simplify component logic; handle missing components.
|
||||
# 01e,08jun06,tkf More dynamic directory checking on all components.
|
||||
# 01d,25may06,tkf Merge with Dan Kresja's and John True's changes.\
|
||||
# 01c,15may06,tkf Move MSP/GPP env vars to here.
|
||||
# 01b,10may06,tkf Extract VxWorks version from env vars. Add rclean target.
|
||||
# Get CPU/TOOL info from env vars.
|
||||
# 01a,09may06,tkf Remove dependecy on build host and DCOM component.
|
||||
# Modified to build the IPNET way temporarily.
|
||||
# 00a,01may06,j_c written.
|
||||
#
|
||||
# DESCRIPTION
|
||||
# This is the top level Makefile for the comp_ip_net2 component
|
||||
#
|
||||
|
||||
##
|
||||
# Define and export current VxWorks version
|
||||
#
|
||||
WR_IPCOM_NAME := vxworks
|
||||
WR_IPCOM_VERSION := $(filter-out $(WR_IPCOM_NAME), $(subst -, ,$(WIND_PLATFORM)))
|
||||
export WR_IPCOM_VERSION := $(subst .,_,$(WR_IPCOM_VERSION))
|
||||
|
||||
export COMP_IPNET_PATH = $(CURDIR)
|
||||
|
||||
export BASE_ROOT := $(COMP_IPNET_PATH)
|
||||
|
||||
TGT_DIR = $(WIND_BASE)/target
|
||||
|
||||
|
||||
# must only bring in VSB if building kernel
|
||||
ifeq ($(SPACE),user)
|
||||
TMP_USR_BLD := 1
|
||||
endif
|
||||
|
||||
ifeq ($(SPACE),USER)
|
||||
TMP_USR_BLD := 1
|
||||
endif
|
||||
|
||||
ifndef __DEFS_VSBVARS_MK_INCLUDED
|
||||
include $(WIND_BASE)/target/h/make/defs.vsbvars.mk
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(VSB_MAKE_CONFIG_FILE)),)
|
||||
include $(VSB_MAKE_CONFIG_FILE)
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPLITE)),true)
|
||||
ifeq ($(TMP_USR_BLD),)
|
||||
|
||||
# the following is a list of the IPNET configurations that have booleans associated with them
|
||||
|
||||
_VARLIST = \
|
||||
COMPONENT_IPLITE \
|
||||
WIND_IPLITE \
|
||||
COMPONENT_COREIP \
|
||||
FEATURE_IPLITE_GEN_DEPEND \
|
||||
FEATURE_IP_GPP_BUILD \
|
||||
MSP_FEATURE_PAD \
|
||||
MSP_FEATURE_PCD \
|
||||
MSP_FEATURE_PID \
|
||||
MSP_FEATURE_PNE \
|
||||
MSP_FEATURE_VIPER \
|
||||
MSP_KERNEL \
|
||||
MSP_RTP \
|
||||
MSP_BUILD_USER \
|
||||
COMPONENT_VXMUX \
|
||||
COMPONENT_VXCOMPAT \
|
||||
COMPONENT_VXCOREIP
|
||||
else
|
||||
|
||||
_VARLIST = \
|
||||
COMPONENT_IPLITE \
|
||||
WIND_IPLITE \
|
||||
FEATURE_IPLITE_GEN_DEPEND
|
||||
|
||||
MSP_RTP= true
|
||||
export MSP_RTP
|
||||
|
||||
COMPONENT_COREIP= true
|
||||
export COMPONENT_COREIP
|
||||
|
||||
MSP_BUILD_USER= true
|
||||
export MSP_BUILD_USER
|
||||
|
||||
|
||||
endif
|
||||
else
|
||||
|
||||
ifeq ($(TMP_USR_BLD),)
|
||||
|
||||
# the following is a list of the IPNET configurations that have booleans associated with them
|
||||
|
||||
_VARLIST = \
|
||||
COMPONENT_IPNET \
|
||||
COMPONENT_IPLITE \
|
||||
WIND_IPNET \
|
||||
COMPONENT_COREIP \
|
||||
FEATURE_IPNET_VERBOSE \
|
||||
FEATURE_IPNET_GEN_DEPEND \
|
||||
FEATURE_IP_GPP_BUILD \
|
||||
MSP_FEATURE_PAD \
|
||||
MSP_FEATURE_PCD \
|
||||
MSP_FEATURE_PID \
|
||||
MSP_FEATURE_PNE \
|
||||
MSP_FEATURE_VIPER \
|
||||
MSP_KERNEL \
|
||||
MSP_RTP \
|
||||
MSP_BUILD_USER \
|
||||
COMPONENT_DOT1X \
|
||||
COMPONENT_XML \
|
||||
COMPONENT_IP8021X \
|
||||
COMPONENT_IPWPS \
|
||||
COMPONENT_IPAPPL \
|
||||
COMPONENT_IPCAVIUM \
|
||||
COMPONENT_IPCRYPTO \
|
||||
COMPONENT_IPXINC \
|
||||
COMPONENT_IPDHCPC6 \
|
||||
COMPONENT_IPDHCPR \
|
||||
COMPONENT_IPDHCPS \
|
||||
COMPONENT_IPDHCPS6 \
|
||||
COMPONENT_IPDIAMETERC \
|
||||
COMPONENT_IPDIAMETERP \
|
||||
COMPONENT_IPEAP \
|
||||
COMPONENT_IPFIREWALL \
|
||||
COMPONENT_IPFREESCALE \
|
||||
COMPONENT_IPHWCRYPTO \
|
||||
COMPONENT_IPIKE \
|
||||
COMPONENT_IPIPSEC \
|
||||
COMPONENT_IPL2TP \
|
||||
COMPONENT_IPMCP \
|
||||
COMPONENT_IPMCRYPTO \
|
||||
COMPONENT_IPMIP \
|
||||
COMPONENT_IPMIP4 \
|
||||
COMPONENT_IPMIP6 \
|
||||
COMPONENT_IPMIP6HA \
|
||||
COMPONENT_IPMIP6MN \
|
||||
COMPONENT_IPMIP6PM \
|
||||
COMPONENT_IPMIPFA \
|
||||
COMPONENT_IPMIPHA \
|
||||
COMPONENT_IPMIPMN \
|
||||
COMPONENT_IPMIPPM \
|
||||
COMPONENT_IPMPLS \
|
||||
COMPONENT_IPPPP \
|
||||
COMPONENT_IPPTP \
|
||||
COMPONENT_TSN \
|
||||
COMPONENT_IPRADIUS \
|
||||
COMPONENT_IPRIP \
|
||||
COMPONENT_IPRIPNG \
|
||||
COMPONENT_IPSNTP \
|
||||
COMPONENT_IPSSH \
|
||||
COMPONENT_IPSSL \
|
||||
COMPONENT_IPTCP \
|
||||
COMPONENT_IPSCTP \
|
||||
COMPONENT_WLAN \
|
||||
COMPONENT_SNMP \
|
||||
COMPONENT_DCOM \
|
||||
COMPONENT_OPC \
|
||||
COMPONENT_BRIDGE \
|
||||
COMPONENT_CAN \
|
||||
COMPONENT_SECURITY \
|
||||
COMPONENT_VIP \
|
||||
FEATURE_SNMP_V3 \
|
||||
FEATURE_SNMP_AGENTX \
|
||||
COMPONENT_IPROHC \
|
||||
COMPONENT_VXMUX \
|
||||
COMPONENT_VXCOMPAT \
|
||||
COMPONENT_VXCOREIP \
|
||||
COMPONENT_VXDOT1X \
|
||||
COMPONENT_IPMACSEC \
|
||||
COMPONENT_IPNTP \
|
||||
COMPONENT_IFPROXY \
|
||||
COMPONENT_WRNAD
|
||||
else
|
||||
|
||||
_VARLIST = \
|
||||
COMPONENT_IPNET \
|
||||
WIND_IPNET \
|
||||
FEATURE_IPNET_VERBOSE \
|
||||
FEATURE_IPNET_GEN_DEPEND \
|
||||
MSP_FEATURE_PAD \
|
||||
MSP_FEATURE_PCD \
|
||||
MSP_FEATURE_PID \
|
||||
MSP_FEATURE_PNE
|
||||
|
||||
MSP_RTP= true
|
||||
export MSP_RTP
|
||||
|
||||
COMPONENT_COREIP= true
|
||||
export COMPONENT_COREIP
|
||||
|
||||
MSP_BUILD_USER= true
|
||||
export MSP_BUILD_USER
|
||||
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
# straight export
|
||||
export _WRS_CONFIG_ADDEDCFLAGS
|
||||
export _WRS_CONFIG_ADDEDCFLAGS2
|
||||
export _WRS_CONFIG_ADDEDCFLAGS_APP
|
||||
|
||||
|
||||
# the following is a list of the IPNET configurations that have strings associated with them
|
||||
|
||||
_STRLIST = \
|
||||
FEATURE_IPNET_BUILD
|
||||
|
||||
|
||||
define defvars
|
||||
|
||||
ifdef _WRS_CONFIG_$1
|
||||
$1 = true
|
||||
else
|
||||
$1 = false
|
||||
endif
|
||||
export $1
|
||||
endef
|
||||
|
||||
$(eval $(foreach var,$(_VARLIST),$(call defvars,$(var))))
|
||||
|
||||
ifeq ($(MSP_FEATURE_PAD),true)
|
||||
export FEATURE_SET = pad
|
||||
endif
|
||||
|
||||
ifeq ($(MSP_FEATURE_PCD),true)
|
||||
export FEATURE_SET = pcd
|
||||
endif
|
||||
|
||||
ifeq ($(MSP_FEATURE_PID),true)
|
||||
export FEATURE_SET = pid
|
||||
endif
|
||||
|
||||
ifeq ($(MSP_FEATURE_PNE),true)
|
||||
export FEATURE_SET = pne
|
||||
endif
|
||||
|
||||
|
||||
|
||||
define defStr
|
||||
|
||||
$1 = $(_WRS_CONFIG_$1)
|
||||
export $1
|
||||
endef
|
||||
|
||||
$(eval $(foreach var,$(_STRLIST),$(call defStr,$(var))))
|
||||
|
||||
ifdef _WRS_CONFIG_COMPONENT_IPNET
|
||||
ifeq ($(WIND_IPNET),)
|
||||
export WIND_IPNET = true
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef _WRS_CONFIG_COMPONENT_IPLITE
|
||||
ifeq ($(WIND_IPLITE),)
|
||||
export WIND_IPLITE = true
|
||||
endif
|
||||
endif
|
||||
|
||||
IP_DOT := .
|
||||
IP_EMPTY :=
|
||||
IP_SPACE := $(IP_EMPTY) $(IP_EMPTY)
|
||||
##
|
||||
# The available IP components are listed as <IP_MACRO>.<IP_NAME>
|
||||
#
|
||||
IpComps := \
|
||||
BRIDGEDIR.vxbridge \
|
||||
IP8021XDIR.ip8021x \
|
||||
IPAPPLDIR.ipappl \
|
||||
IPCAVIUMDIR.ipcavium \
|
||||
IPCOMDIR.ipcom \
|
||||
IPCRYPTODIR.ipcrypto \
|
||||
IPDHCPC6DIR.ipdhcpc6 \
|
||||
IPDHCPRDIR.ipdhcpr \
|
||||
IPDHCPS6DIR.ipdhcps6 \
|
||||
IPDHCPSDIR.ipdhcps \
|
||||
IPDIAMETERDIR.ipdiameter \
|
||||
IPEAPDIR.ipeap \
|
||||
IPFIREWALLDIR.ipfirewall \
|
||||
IPFREESCALEDIR.ipfreescale \
|
||||
IPHWCRYPTODIR.iphwcrypto \
|
||||
IPIKEDIR.ipike \
|
||||
IPIPSEC2DIR.ipipsec2 \
|
||||
IPL2TPDIR.ipl2tp \
|
||||
IPLDAPCDIR.ipldapc \
|
||||
IPLITEDIR.iplite2 \
|
||||
IPMACSECDIR.ipmacsec \
|
||||
IPMCPDIR.ipmcp \
|
||||
IPMCRYPTODIR.ipmcrypto \
|
||||
IPMIP4DIR.ipmip4 \
|
||||
IPMIP6DIR.ipmip6 \
|
||||
IPMIP6HADIR.ipmip6ha \
|
||||
IPMIP6MNDIR.ipmip6mn \
|
||||
IPMIP6PMDIR.ipmip6pm \
|
||||
IPMIPDIR.ipmip \
|
||||
IPMIPFADIR.ipmipfa \
|
||||
IPMIPHADIR.ipmipha \
|
||||
IPMIPMNDIR.ipmipmn \
|
||||
IPMIPPMDIR.ipmippm \
|
||||
IPMPLSDIR.ipmpls \
|
||||
IPNET2DIR.ipnet2 \
|
||||
IPPPPDIR.ipppp \
|
||||
IPPTPDIR.ipptp \
|
||||
TSNDIR.tsn \
|
||||
IPRADIUSDIR.ipradius \
|
||||
IPRIPDIR.iprip \
|
||||
IPRIPNGDIR.ipripng \
|
||||
IPROHCDIR.iprohc \
|
||||
IPSCTPDIR.ipsctp \
|
||||
IPSNTPDIR.ipsntp \
|
||||
IPSSHDIR.ipssh \
|
||||
IPSSL2DIR.ipssl2 \
|
||||
IPTCPDIR.iptcp \
|
||||
IPWLANDIR.ipwlan \
|
||||
IPWPSDIR.ipwps \
|
||||
IPXINCDIR.ipxinc \
|
||||
VXCOMPATDIR.vxcompat \
|
||||
VXCOREIPDIR.vxcoreip \
|
||||
VXDOT1XDIR.vxdot1x \
|
||||
VXMUXDIR.vxmux \
|
||||
WRSNMP.wrsnmp \
|
||||
IPNTPDIR.ipntp \
|
||||
IFPROXYDIR.vxifproxy \
|
||||
WRNADDIR.wrnad
|
||||
|
||||
###
|
||||
# By default we choose the lexically last IPNET component version in hopes
|
||||
# that it is the most recent. The directory macros (e.g. IPCOMDIR) may of
|
||||
# course be overriden on the command line.
|
||||
|
||||
define _DIR_DEF
|
||||
ifeq ($$($(basename $(1))),)
|
||||
TMP_DIRSU := $$(wildcard $(patsubst .%,%,$(suffix $(1)))*)
|
||||
TMP_DIRS := $$(sort $$(TMP_DIRSU))
|
||||
ifneq ($$(strip $$(TMP_DIRS)),)
|
||||
export $(basename $(1)) := $$(word 1,$$(TMP_DIRS))
|
||||
endif
|
||||
endif
|
||||
IP_BUILDABLE_COMPS := $$(IP_BUILDABLE_COMPS) $(basename $(1))=$$($(basename $(1)))
|
||||
#$$(warning $(basename $(1)) = $$($(basename $(1))) )
|
||||
endef
|
||||
|
||||
$(foreach IpComp,$(IpComps), $(eval $(call _DIR_DEF,$(IpComp))))
|
||||
|
||||
ifeq ($(IPCOMDIR),)
|
||||
$(error IPCOMDIR is empty.)
|
||||
endif
|
||||
|
||||
ifeq ($(TGT_DIR),)
|
||||
ifeq ($(TMP_USR_BLD),)
|
||||
TGT_DIR = $(WIND_BASE)/target
|
||||
else
|
||||
TGT_DIR = $(WIND_BASE)/target/usr
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(WIND_BASE)/target/h/make/defs.options
|
||||
|
||||
##
|
||||
# Ensure VX_CPU_FAMILY is defined
|
||||
#
|
||||
ifeq ($(TOOL_FAMILY),)
|
||||
|
||||
ifeq ($(findstring gnu,$(TOOL)),gnu)
|
||||
TOOL_FAMILY = gnu
|
||||
endif
|
||||
|
||||
ifeq ($(findstring diab,$(TOOL)),diab)
|
||||
TOOL_FAMILY = diab
|
||||
endif
|
||||
|
||||
ifeq ($(findstring icc,$(TOOL)),icc)
|
||||
TOOL_FAMILY = icc
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(TMP_USR_BLD),)
|
||||
TMP_BUILD_SPACE := krnl
|
||||
|
||||
include $(TGT_DIR)/h/tool/$(TOOL_FAMILY)/make.$(CPU)$(TOOL)
|
||||
|
||||
ifneq ($(LOCAL_OBJS),)
|
||||
ifeq ($(WR_IPCOM_LIB_DIR),)
|
||||
export WR_IPCOM_LIB_DIR := $(CURDIR)/$(IPCOMDIR)/lib$(MAJOR_OPTION_SUFFIX)/$(VX_CPU_FAMILY)/$(CPU)/$(TOOL_COMMON_DIR)
|
||||
endif
|
||||
else
|
||||
ifeq ($(WR_IPCOM_LIB_DIR),)
|
||||
export WR_IPCOM_LIB_DIR := $(VSB_DIR)/$(VX_CPU_FAMILY)/$(CPU)$(CPU_OPTION_SUFFIX)/$(TOOL_COMMON_DIR)$(LIB_DIR_TAG)$(MINOR_OPTION_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
else
|
||||
TMP_BUILD_SPACE := usr
|
||||
include $(TGT_DIR)/usr/tool/$(TOOL_FAMILY)/make.$(CPU)$(TOOL)
|
||||
ifneq ($(LOCAL_OBJS),)
|
||||
ifeq ($(WR_IPCOM_LIB_DIR),)
|
||||
export WR_IPCOM_LIB_DIR := $(CURDIR)/$(IPCOMDIR)/lib$(MAJOR_OPTION_SUFFIX)/usr/lib/$(VX_CPU_FAMILY)/$(CPU)/$(TOOL_COMMON_DIR)
|
||||
endif
|
||||
else
|
||||
ifeq ($(WR_IPCOM_LIB_DIR),)
|
||||
export WR_IPCOM_LIB_DIR := $(VSB_DIR)/usr/lib/$(VX_CPU_FAMILY)/$(CPU)/$(TOOL_COMMON_DIR)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
export WR_IPTARGET := $(VX_CPU_FAMILY)
|
||||
|
||||
ifneq ($(FEATURE_SET),) # MSP Build
|
||||
|
||||
###
|
||||
# This block is to be used during feature set build
|
||||
#
|
||||
|
||||
include $(WIND_BASE)/config/common/defs.component
|
||||
#-include config.mk
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPNET)),true)
|
||||
kernel:
|
||||
ifeq ($(TARGET),rclean)
|
||||
@echo "make: removing targets and objects of `pwd`"
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) cleanall
|
||||
else
|
||||
ifeq ($(DEBUG),true)
|
||||
@echo "#"
|
||||
@echo "#"
|
||||
@echo "######### Build Config Info ########"
|
||||
@echo "#"
|
||||
@echo "# IP Component Dirs : $(IP_BUILDABLE_COMPS)"
|
||||
@echo "#"
|
||||
@echo "# CPU = $(CPU)"
|
||||
@echo "# TOOL = $(TOOL)"
|
||||
@echo "# VX_CPU_FAMILY = $(VX_CPU_FAMILY)"
|
||||
@echo "# WR_IPCOM_LIB_DIR = $(WR_IPCOM_LIB_DIR)"
|
||||
@echo "# WR_IPCOM_VERSION = $(WR_IPCOM_VERSION)"
|
||||
@echo "# COMP_IPNET_PATH = $(COMP_IPNET_PATH)"
|
||||
@echo "#"
|
||||
@echo "####################################"
|
||||
@echo "#"
|
||||
@echo "#"
|
||||
else
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) VSB_DIR=$(VSB_DIR) all
|
||||
endif
|
||||
endif
|
||||
usr:
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPLITE)),true)
|
||||
kernel:
|
||||
ifeq ($(TARGET),rclean)
|
||||
@echo "make: removing targets and objects of `pwd`"
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) cleanall
|
||||
else
|
||||
ifeq ($(DEBUG),true)
|
||||
@echo "#"
|
||||
@echo "#"
|
||||
@echo "######### Build Config Info ########"
|
||||
@echo "#"
|
||||
@echo "# IP Component Dirs : $(IP_BUILDABLE_COMPS)"
|
||||
@echo "#"
|
||||
@echo "# CPU = $(CPU)"
|
||||
@echo "# TOOL = $(TOOL)"
|
||||
@echo "# VX_CPU_FAMILY = $(VX_CPU_FAMILY)"
|
||||
@echo "# WR_IPCOM_LIB_DIR = $(WR_IPCOM_LIB_DIR)"
|
||||
@echo "# WR_IPCOM_VERSION = $(WR_IPCOM_VERSION)"
|
||||
@echo "# COMP_IPNET_PATH = $(COMP_IPNET_PATH)"
|
||||
@echo "#"
|
||||
@echo "####################################"
|
||||
@echo "#"
|
||||
@echo "#"
|
||||
else
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) all
|
||||
endif
|
||||
endif
|
||||
usr:
|
||||
endif
|
||||
|
||||
include $(WIND_BASE)/config/common/rules.component
|
||||
#
|
||||
# End of feature set build block.
|
||||
###
|
||||
|
||||
else # Not an MSP build
|
||||
|
||||
###
|
||||
# This block is to be used during non-feature set build
|
||||
#
|
||||
|
||||
kernel :
|
||||
@echo "make: building targets of $(COMP_IPNET_PATH)"
|
||||
ifeq ($(DEBUG),true)
|
||||
@echo "#"
|
||||
@echo "#"
|
||||
@echo "######### Build Config Info ########"
|
||||
@echo "#"
|
||||
@echo "# IP Component Dirs : $(IP_BUILDABLE_COMPS)"
|
||||
@echo "#"
|
||||
@echo "# CPU = $(CPU)"
|
||||
@echo "# TOOL = $(TOOL)"
|
||||
@echo "# VX_CPU_FAMILY = $(VX_CPU_FAMILY)"
|
||||
@echo "# WR_IPCOM_LIB_DIR = $(WR_IPCOM_LIB_DIR)"
|
||||
@echo "# WR_IPCOM_VERSION = $(WR_IPCOM_VERSION)"
|
||||
@echo "# COMP_IPNET_PATH = $(COMP_IPNET_PATH)"
|
||||
@echo "#"
|
||||
@echo "####################################"
|
||||
@echo "#"
|
||||
@echo "#"
|
||||
else
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) all
|
||||
endif
|
||||
usr :
|
||||
|
||||
endif # End MSP Build
|
||||
|
||||
rclean :
|
||||
@echo "make: removing targets and objects of `pwd`"
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) cleanall
|
||||
|
||||
.PHONY : util_ipdef util_ipinc
|
||||
|
||||
util_ipdef:
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) util_ipdef
|
||||
|
||||
util_ipinc:
|
||||
$(MAKE) -C $(IPCOMDIR) TOOL=$(TOOL) CPU=$(CPU) util_ipinc
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
ip_net2-6_9.name=ip_net2-6.9
|
||||
ip_net2-6_9.version=6.9
|
||||
ip_net2-6_9.type=comp
|
||||
ip_net2-6_9.subtype=comp_ip_net2
|
||||
ip_net2-6_9.platforms=vxworks
|
||||
ip_net2-6_9.label=IP_NET2 6.9
|
||||
ip_net2-6_9.description=Wind River IP Net2
|
||||
ip_net2-6_9.wrdoc.apiref=ip_net2_api_reference_6.9
|
||||
ip_net2-6_9.wrdoc.apibook=Wind_River_IP_NET2_6.9
|
||||
ip_net2-6_9.wrdoc.apichapter=Wind_River_IP_NET2_API_Reference,_6.9
|
||||
ip_net2-6_9.wrdoc.plugin=com.windriver.ide.doc.wr_ip_net2
|
||||
ip_net2-6_9.wrdoc.xmlfiles=plugin.xml wr_ip_net2_ref_toc.xml wr_ip_net2_guides_toc.xml
|
||||
ip_net2-6_9.wrdoc.archives=wr_ip_net2_vxworks_6_users_guide_6.9.zip
|
||||
ip_net2-6_9.dist.location=/vobs/ipnet/ipnet_roots/ip_net2
|
||||
ip_net2-6_9.dist.zip=IP-source-20060330.zip
|
||||
@@ -0,0 +1,757 @@
|
||||
# config.mk - ip_net2 specific configuration
|
||||
#
|
||||
# Copyright 2007-2009, 2017 Wind River Systems, Inc.
|
||||
#
|
||||
# The right to copy, distribute, modify or otherwise make use
|
||||
# of this software may be licensed only pursuant to the terms
|
||||
# of an applicable Wind River license agreement.
|
||||
#
|
||||
#
|
||||
#
|
||||
# modification history
|
||||
# --------------------
|
||||
# 03a,28may17,xxy Added TSN support
|
||||
# 02z,25apr16,pdr Added PTP support (back port from Vx7)
|
||||
# 02y,21may12,uol Revert to 6.9 settings
|
||||
# 02z,03may11,mry Adding ipbridge support (replaces vxbridge)
|
||||
# 02y,17Jan11,xhs last change cause lib ipripng/ipdhcpc6/ipdhcps6 missed
|
||||
# 02x,12Jan11,xhs fix defect WIND00250124
|
||||
# 02w,22sep10,spw Add IFPROXY, WRNAD
|
||||
# 02v,15sep10,xhs support IPLITE
|
||||
# 02u,25jun10,rjq Added IPNTP
|
||||
# 02t,22mar10,mze do not build IPIKE when -basic is set
|
||||
# 02s,05feb10,mry Adding IPMACSEC
|
||||
# 02r,29jan10,mze can not build IPCRYPTO when doing basic libraries
|
||||
# 02q,31jul09,ten Adding IPL2TP
|
||||
# 02p,14jul09,mdk merge from networking branch
|
||||
# 02o,11jun09,dwb Adding vxdot1x
|
||||
# 02n,16dec08,mry adding IPWPS
|
||||
# 02m,21apr09,pee align with changes in default VSB configuration for default
|
||||
# libraries.
|
||||
# 02l,24mar09,mze cleanup of INET6 INET6ONLY for WIND00160969
|
||||
# 02k,11feb09,ggz Move coreip and bridge into CVS.
|
||||
# 02j,19aug08,mze removing warnings for IPNET4
|
||||
# 02i,12jun08,mze changing default logic to account for VSB configuration
|
||||
# 02h,28may08,dlk Added non-optional VXMUX.
|
||||
# 02g,20feb08,tlu Added IPROHC component
|
||||
# 02f,14may08,brg Added IPVXCOMPAT component
|
||||
# 02e,08nov07,tlu Added IPDIAMETERP component
|
||||
# 02d,07aug07,mry Add 802.1x supplicant support
|
||||
# 02c,11oct07,uol Defect WIND00107491, add DHCP capabilities in bootrom.
|
||||
# 02b,27sep07,kch Stripped leading and trailing whitespace (WIND00046447).
|
||||
# 02a,12sep07,spw Changed IPWLAN to WLAN
|
||||
# 01z,17jul07,spw Added IPWLAN
|
||||
# 01y,27jun07,mcarlste Added IPFREESCALE component
|
||||
# 01x,03apr07,tlu Added IPDIAMETERC component
|
||||
# 01x,25apr07,tkf Added IPv6 Only Build Support.
|
||||
# 01w,13dec06,tkf Added OPT=-basic option support.
|
||||
# 01v,08nov06,kch Moved FEATURE_IPNET_GEN_DEPEND outside FS_IP_GPP_BUILD
|
||||
# block.
|
||||
# 01u,06nov06,tkf Add FEATURE_IPNET_GEN_DEPEND.
|
||||
# 01t,03nov06,tkf Included IPPPP in default build.
|
||||
# 01s,18oct06,kch Removed references to the discontinued ipldapc.
|
||||
# 01r,22sep06,kch Added IPMPLS, IPEAP, IPLDAPC and IPRADIUS.
|
||||
# 01q,22sep06,dlk Add option build support.
|
||||
# 01p,21sep06,tkf Added directory check for wrsnmp.
|
||||
# 01o,18sep06,kch Added support for COMPONENT_IPPPP. Also include
|
||||
# COMPONENT_IPDHCPS and COMPONENT_IPDHCPR for gpp default
|
||||
# build.
|
||||
# 01n,15sep06,tkf Added IPDHCPC6 and IPDHCPS6. Added more robust directory
|
||||
# checking.
|
||||
# 01m,06sep06,tkf Moved configurable macros from ipcom/Makefile so that
|
||||
# they can be managed from platform config.mk. Also include
|
||||
# IPRIPNG only if we are building for IPv6.
|
||||
# 01l,06sep06,kch Temporarily allow COMPONENT_IPRIPNG build for GPP.
|
||||
# 01k,06sep06,kch Remove COMPONENT_IPRIPNG from default GPP build.
|
||||
# 01j,01sep06,tlu Remove debugging message for RIPng build
|
||||
# 01i,04sep06,kch Added support for COMPONENT_IPDHCPS and COMPONENT_IPDHCPR.
|
||||
# 01h,04sep06,tkf Replace any backslash characters in BASE_ROOT with forward
|
||||
# slash characters.
|
||||
# 01g,07aug06,kch Added support for COMPONENT_IPAPPL, COMPONENT_IPSNTP,
|
||||
# COMPONENT_IPFIREWALL and COMPONENT_IPMCP.
|
||||
# 01f,25jul06,kch Added COMPONENT_IPRIP support.
|
||||
# 01e,18jul06,tlu Added COMPONENT_IPRIPNG support.
|
||||
# 01d,02jun06,kch Added SKIP_CONFIG make macro to support configuration
|
||||
# files override for IPNet build.
|
||||
# 01c,18jun06,tkf IPNET component directories are determined dynamically.
|
||||
# 01b,10may06,tkf IPNET can now be built from both GPP and MSP.
|
||||
# 01b,10may06,tkf Add IPNET component configuration defines.
|
||||
# 01a,01may06,j_c Written.
|
||||
#
|
||||
# DESCRIPTION
|
||||
# This file implements the IPNET component configuration as dictated by
|
||||
# the current feature set (included before this fragment).
|
||||
#
|
||||
|
||||
#ifeq ($(EXTRA_DEFINE),)
|
||||
#export EXTRA_DEFINE =
|
||||
#endif
|
||||
|
||||
######
|
||||
# Default values
|
||||
######
|
||||
|
||||
|
||||
|
||||
ifeq ($(FEATURE_IP_GPP_BUILD),true)
|
||||
FS_IP_GPP_BUILD = true
|
||||
else
|
||||
FS_IP_GPP_BUILD = false
|
||||
endif
|
||||
|
||||
#ifeq ($(FS_IP_GPP_BUILD),true)
|
||||
ifeq ($(findstring -basic,$(OPT)),-basic)
|
||||
IP_GPP_BUILD_BASIC = true
|
||||
EXTRA_DEFINE += -DIPBASIC
|
||||
endif
|
||||
#endif
|
||||
|
||||
ifeq ($(TGT_DIR),)
|
||||
TGT_DIR = $(WIND_BASE)/target
|
||||
endif
|
||||
|
||||
include $(TGT_DIR)/h/make/defs.option
|
||||
|
||||
|
||||
|
||||
ifeq ($(findstring -inet6,$(OPT)),-inet6)
|
||||
_INET6_BUILD = 1
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(findstring -inet6only,$(OPT)),-inet6only)
|
||||
_INET6_BUILD_ONLY = 1
|
||||
endif
|
||||
|
||||
###
|
||||
# User configured macros
|
||||
###
|
||||
#
|
||||
# NOTE:
|
||||
# These macros are now defined in the common.vxconfig file that
|
||||
# exists for each component, all MSP/GPP logic for these macros
|
||||
# should be part of the vxconfig file which is based on the
|
||||
# Linux Kconfig
|
||||
#
|
||||
#
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPLITE)),true)
|
||||
ifeq ($(_INET6_BUILD),)
|
||||
export FEATURE_IPLITE_INET6 = false
|
||||
else
|
||||
export FEATURE_IPLITE_INET6 = true
|
||||
endif
|
||||
else
|
||||
ifeq ($(_INET6_BUILD),)
|
||||
export FEATURE_IPNET_INET6 = false
|
||||
else
|
||||
export FEATURE_IPNET_INET6 = true
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPNET)),true)
|
||||
ifeq ($(_INET6_BUILD_ONLY),)
|
||||
export FEATURE_IPNET_INET6_ONLY = false
|
||||
else
|
||||
export FEATURE_IPNET_INET6_ONLY = true
|
||||
endif
|
||||
endif
|
||||
|
||||
#if this build is for IPV4 then disable the IPV6 and 6 only components that may have been set
|
||||
ifeq ($(_INET6_BUILD)$(_INET6_BUILD_ONLY)$(IP_GPP_BUILD_BASIC),)
|
||||
#$(warning doing a INET4 build)
|
||||
export COMPONENT_IPDHCPC6 = false
|
||||
export COMPONENT_IPDHCPS6 = false
|
||||
export COMPONENT_IPMIP6 = false
|
||||
export COMPONENT_IPMIP6HA = false
|
||||
export COMPONENT_IPMIP6MN = false
|
||||
export COMPONENT_IPMIP6PM = false
|
||||
export COMPONENT_IPRIPNG = false
|
||||
else
|
||||
|
||||
#override configuration to support old OPT build
|
||||
ifneq ($(OPT),)
|
||||
ifeq ($(WIND_IPLITE),true)
|
||||
export COMPONENT_IPRIPNG = false
|
||||
else
|
||||
ifeq ($(_WRS_CONFIG_FEATURE_IPNET_INET4_ONLY),y)
|
||||
export COMPONENT_IPDHCPC6 = true
|
||||
export COMPONENT_IPDHCPS6 = true
|
||||
export COMPONENT_IPRIPNG = true
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#$(warning Not doing a INET4 build)
|
||||
endif
|
||||
|
||||
ifneq ($(IP_GPP_BUILD_BASIC),)
|
||||
#$(warning building basic)
|
||||
export COMPONENT_IPMCRYPTO = true
|
||||
ifeq ($(WIND_IPNET),true)
|
||||
export COMPONENT_IPAPPL = true
|
||||
export COMPONENT_IPTCP = true
|
||||
export COMPONENT_VXCOMPAT = true
|
||||
export COMPONENT_VXMUX = true
|
||||
endif
|
||||
|
||||
export COMPONENT_IFPROXY = false
|
||||
export COMPONENT_IPMIP6 = false
|
||||
export COMPONENT_IP8021X = false
|
||||
export COMPONENT_IPDIAMETERC = false
|
||||
export COMPONENT_IPDIAMETERP = false
|
||||
export COMPONENT_IPEAP = false
|
||||
export COMPONENT_IPFIREWALL = false
|
||||
export COMPONENT_IPFREESCALE = false
|
||||
export COMPONENT_IPHWCRYPTO = false
|
||||
export COMPONENT_IPCAVIUM = false
|
||||
export COMPONENT_IPMCP = false
|
||||
export COMPONENT_IPVXBRIDGE = false
|
||||
export COMPONENT_IPSCTP = false
|
||||
export COMPONENT_IPROHC = false
|
||||
export COMPONENT_IPSEC = false
|
||||
export COMPONENT_IPSECURITY = false
|
||||
export COMPONENT_IPL2TP = false
|
||||
export COMPONENT_IPIPSEC = false
|
||||
export COMPONENT_IPMIP = false
|
||||
export COMPONENT_IPMIP4 = false
|
||||
export COMPONENT_IPMPLS = false
|
||||
export COMPONENT_IPMIPPM = false
|
||||
export COMPONENT_IPMIPHA = false
|
||||
export COMPONENT_IPMIPFA = false
|
||||
export COMPONENT_IPMIPMN = false
|
||||
export COMPONENT_IPMIP6HA = false
|
||||
export COMPONENT_IPMIP6MN = false
|
||||
export COMPONENT_IPMIP6PM = false
|
||||
export COMPONENT_IPRIP = false
|
||||
export COMPONENT_IPSNTP = false
|
||||
export COMPONENT_IPNTP = false
|
||||
export COMPONENT_IPDHCPS = false
|
||||
export COMPONENT_IPDHCPR = false
|
||||
export COMPONENT_IPPPP = false
|
||||
export COMPONENT_IPPTP = false
|
||||
export COMPONENT_TSN = false
|
||||
export COMPONENT_IPRIPNG = false
|
||||
export COMPONENT_IPDHCPC6 = false
|
||||
export COMPONENT_IPDHCPS6 = false
|
||||
export COMPONENT_IPCRYPTO = false
|
||||
export COMPONENT_IPRADIUS = false
|
||||
export COMPONENT_BRIDGE = false
|
||||
export COMPONENT_IPIKE = false
|
||||
export COMPONENT_WRNAD = false
|
||||
# what follows are a result of disabling IPCRYPTO
|
||||
export COMPONENT_IPSSH = false
|
||||
export COMPONENT_IPSSL = false
|
||||
export COMPONENT_WLAN = false
|
||||
export COMPONENT_IPWPS = false
|
||||
export COMPONENT_SECURITY = false
|
||||
export COMPONENT_SNMP = false
|
||||
export COMPONENT_DOT1X = false
|
||||
export COMPONENT_IPMACSEC = false
|
||||
endif
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Set $(SKIP_CONFIG) to true if the $(SKIP_CONFIG) is not yet defined at
|
||||
# this point. This forces the IPNet not to compile the xxx_config.c
|
||||
# when building the IPNet archives. This macro is defined here but its
|
||||
# value is checked in the IPNet makefiles. Use the conditional variable
|
||||
#
|
||||
export SKIP_CONFIG ?= true
|
||||
|
||||
|
||||
#
|
||||
# Derived Macros
|
||||
#
|
||||
BASE_ROOT ?= $(COMP_IPNET_PATH)
|
||||
BASE_ROOT := $(subst \,/,$(BASE_ROOT))
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPNET)),true)
|
||||
ifeq ($(strip $(COMPONENT_IPLITE)),true)
|
||||
$(error "Can only include COMPONENT_IPNET or COMPONENT_IPLITE, not both")
|
||||
endif
|
||||
IPNET_ROOT = $(BASE_ROOT)/$(IPNET2DIR)
|
||||
export WRS_IPNET = true
|
||||
ifneq ($(findstring -DWRS_IPNET,$(EXTRA_DEFINE)),-DWRS_IPNET)
|
||||
EXTRA_DEFINE += -DWRS_IPNET
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPLITE)),true)
|
||||
ifeq ($(strip $(COMPONENT_IPNET)),true)
|
||||
$(error "Can only include COMPONENT_IPNET or COMPONENT_IPLITE, not both")
|
||||
endif
|
||||
IPLITE_ROOT = $(BASE_ROOT)/$(IPLITEDIR)
|
||||
export WRS_IPLITE = true
|
||||
ifneq ($(findstring -DWRS_IPLITE,$(EXTRA_DEFINE)),-DWRS_IPLITE)
|
||||
EXTRA_DEFINE += -DWRS_IPLITE
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPTCP)),true)
|
||||
ifeq ($(IPTCPDIR),)
|
||||
$(error IPTCP is not installed)
|
||||
endif
|
||||
IPTCP_ROOT = $(BASE_ROOT)/$(IPTCPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPSCTP)),true)
|
||||
ifeq ($(IPSCTPDIR),)
|
||||
$(error IPSCTP is not installed)
|
||||
endif
|
||||
IPSCTP_ROOT = $(BASE_ROOT)/$(IPSCTPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPSSH)),true)
|
||||
ifeq ($(IPSSHDIR),)
|
||||
$(error IPSSH is not installed)
|
||||
endif
|
||||
IPSSH_ROOT = $(BASE_ROOT)/$(IPSSHDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPIKE)),true)
|
||||
ifeq ($(IPIKEDIR),)
|
||||
$(error IPIKE is not installed)
|
||||
endif
|
||||
IPIKE_ROOT = $(BASE_ROOT)/$(IPIKEDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPIPSEC)),true)
|
||||
ifeq ($(IPIPSEC2DIR),)
|
||||
$(error IPIPSEC2 is not installed)
|
||||
endif
|
||||
IPIPSEC_ROOT = $(BASE_ROOT)/$(IPIPSEC2DIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPHWCRYPTO)),true)
|
||||
ifeq ($(IPHWCRYPTODIR),)
|
||||
$(error IPHWCRYPTO is not installed)
|
||||
endif
|
||||
IPHWCRYPTO_ROOT = $(BASE_ROOT)/$(IPHWCRYPTODIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMCRYPTO)),true)
|
||||
ifeq ($(IPMCRYPTODIR),)
|
||||
$(error IPMCRYPTO is not installed)
|
||||
endif
|
||||
IPMCRYPTO_ROOT = $(BASE_ROOT)/$(IPMCRYPTODIR)
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPCRYPTO)),true)
|
||||
ifeq ($(IPCRYPTODIR),)
|
||||
$(error IPCRYPTO is not installed)
|
||||
endif
|
||||
IPCRYPTO_ROOT = $(BASE_ROOT)/$(IPCRYPTODIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPSSL)),true)
|
||||
ifeq ($(IPSSL2DIR),)
|
||||
$(error IPSSL2 is not installed)
|
||||
endif
|
||||
IPSSL_ROOT = $(BASE_ROOT)/$(IPSSL2DIR)
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPXINC)),true)
|
||||
ifeq ($(IPXINCDIR),)
|
||||
$(error IPXINC is not installed)
|
||||
endif
|
||||
IPXINC_ROOT = $(BASE_ROOT)/$(IPXINCDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPCCI)),true)
|
||||
ifeq ($(IPCCIDIR),)
|
||||
$(error IPCCI is not installed)
|
||||
endif
|
||||
IPCCI_ROOT = $(BASE_ROOT)/$(IPCCIDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIP)),true)
|
||||
ifeq ($(IPMIPDIR),)
|
||||
$(error IPMIP is not installed)
|
||||
endif
|
||||
IPMIP_ROOT = $(BASE_ROOT)/$(IPMIPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIP4)),true)
|
||||
ifeq ($(IPMIP4DIR),)
|
||||
$(error IPMIP4 is not installed)
|
||||
endif
|
||||
IPMIP4_ROOT = $(BASE_ROOT)/$(IPMIP4DIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_WLAN)),true)
|
||||
ifeq ($(IPWLANDIR),)
|
||||
$(error IPWLAN is not installed)
|
||||
endif
|
||||
IPWLAN_ROOT = $(BASE_ROOT)/$(IPWLANDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIPFA)),true)
|
||||
ifeq ($(IPMIPFADIR),)
|
||||
$(error IPMIPFA is not installed)
|
||||
endif
|
||||
IPMIPFA_ROOT = $(BASE_ROOT)/$(IPMIPFADIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIPHA)),true)
|
||||
ifeq ($(IPMIPHADIR),)
|
||||
$(error IPMIPHA is not installed)
|
||||
endif
|
||||
IPMIPHA_ROOT = $(BASE_ROOT)/$(IPMIPHADIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIPMN)),true)
|
||||
ifeq ($(IPMIPMNDIR),)
|
||||
$(error IPMIPMN is not installed)
|
||||
endif
|
||||
IPMIPMN_ROOT = $(BASE_ROOT)/$(IPMIPMNDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIPPM)),true)
|
||||
ifeq ($(IPMIPPMDIR),)
|
||||
$(error IPMIPPM is not installed)
|
||||
endif
|
||||
IPMIPPM_ROOT = $(BASE_ROOT)/$(IPMIPPMDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIP6)),true)
|
||||
ifeq ($(IPMIP6DIR),)
|
||||
$(error IPMIP6 is not installed)
|
||||
endif
|
||||
IPMIP6_ROOT = $(BASE_ROOT)/$(IPMIP6DIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIP6HA)),true)
|
||||
ifeq ($(IPMIP6HADIR),)
|
||||
$(error IPMIP6HA is not installed)
|
||||
endif
|
||||
IPMIP6HA_ROOT = $(BASE_ROOT)/$(IPMIP6HADIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIP6MN)),true)
|
||||
ifeq ($(IPMIP6MNDIR),)
|
||||
$(error IPMIP6MN is not installed)
|
||||
endif
|
||||
IPMIP6MN_ROOT = $(BASE_ROOT)/$(IPMIP6MNDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMIP6PM)),true)
|
||||
ifeq ($(IPMIP6PMDIR),)
|
||||
$(error IPMIP6PM is not installed)
|
||||
endif
|
||||
IPMIP6PM_ROOT = $(BASE_ROOT)/$(IPMIP6PMDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_MPLS)),true)
|
||||
ifeq ($(IPMPLSDIR),)
|
||||
$(error IPMPLS is not installed)
|
||||
endif
|
||||
IPMPLS_ROOT = $(BASE_ROOT)/$(IPMPLSDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPRIPNG)),true)
|
||||
ifeq ($(IPRIPNGDIR),)
|
||||
$(error IPRIPNG is not installed)
|
||||
endif
|
||||
IPRIPNG_ROOT = $(BASE_ROOT)/$(IPRIPNGDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPRIP)),true)
|
||||
ifeq ($(IPRIPDIR),)
|
||||
$(error IPRIP is not installed)
|
||||
endif
|
||||
IPRIP_ROOT = $(BASE_ROOT)/$(IPRIPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPAPPL)),true)
|
||||
ifeq ($(IPAPPLDIR),)
|
||||
$(error IPAPPL is not installed)
|
||||
endif
|
||||
IPAPPL_ROOT = $(BASE_ROOT)/$(IPAPPLDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPSNTP)),true)
|
||||
ifeq ($(IPSNTPDIR),)
|
||||
$(error IPSNTP is not installed)
|
||||
endif
|
||||
IPSNTP_ROOT = $(BASE_ROOT)/$(IPSNTPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMCP)),true)
|
||||
ifeq ($(IPMCPDIR),)
|
||||
$(error IPMCP is not installed)
|
||||
endif
|
||||
IPMCP_ROOT = $(BASE_ROOT)/$(IPMCPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPFIREWALL)),true)
|
||||
ifeq ($(IPFIREWALLDIR),)
|
||||
$(error IPFIREWALL is not installed)
|
||||
endif
|
||||
IPFIREWALL_ROOT = $(BASE_ROOT)/$(IPFIREWALLDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPDHCPS)),true)
|
||||
ifeq ($(IPDHCPSDIR),)
|
||||
$(error IPDHCP is not installed)
|
||||
endif
|
||||
IPDHCPS_ROOT = $(BASE_ROOT)/$(IPDHCPSDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPDHCPR)),true)
|
||||
ifeq ($(IPDHCPRDIR),)
|
||||
$(error IPDHCPR is not installed)
|
||||
endif
|
||||
IPDHCPR_ROOT = $(BASE_ROOT)/$(IPDHCPRDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPDHCPC6)),true)
|
||||
ifeq ($(IPDHCPC6DIR),)
|
||||
$(error IPDHCPR is not installed)
|
||||
endif
|
||||
IPDHCPC6_ROOT = $(BASE_ROOT)/$(IPDHCPC6DIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPDHCPS6)),true)
|
||||
ifeq ($(IPDHCPS6DIR),)
|
||||
$(error IPDHCPR is not installed)
|
||||
endif
|
||||
IPDHCPS6_ROOT = $(BASE_ROOT)/$(IPDHCPS6DIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPL2TP)),true)
|
||||
ifeq ($(IPL2TPDIR),)
|
||||
$(error IPL2TPDIR is not installed)
|
||||
endif
|
||||
IPL2TP_ROOT = $(BASE_ROOT)/$(IPL2TPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPPPP)),true)
|
||||
ifeq ($(IPPPPDIR),)
|
||||
$(error IPPPPDIR is not installed)
|
||||
endif
|
||||
IPPPP_ROOT = $(BASE_ROOT)/$(IPPPPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPPTP)),true)
|
||||
ifeq ($(IPPTPDIR),)
|
||||
$(error IPPTPDIR is not installed)
|
||||
endif
|
||||
IPPTP_ROOT = $(BASE_ROOT)/$(IPPTPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_TSN)),true)
|
||||
ifeq ($(TSNDIR),)
|
||||
$(error TSNDIR is not installed)
|
||||
endif
|
||||
TSN_ROOT = $(BASE_ROOT)/$(TSNDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPMPLS)),true)
|
||||
ifeq ($(IPMPLSDIR),)
|
||||
$(error IPMPLSDIR is not installed)
|
||||
endif
|
||||
IPMPLS_ROOT = $(BASE_ROOT)/$(IPMPLSDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPEAP)),true)
|
||||
ifeq ($(IPEAPDIR),)
|
||||
$(error IPEAPDIR is not installed)
|
||||
endif
|
||||
IPEAP_ROOT = $(BASE_ROOT)/$(IPEAPDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(COMPONENT_IP8021X),true)
|
||||
ifeq ($(IP8021XDIR),)
|
||||
$(error IP8021XDIR is not installed)
|
||||
endif
|
||||
IP8021X_ROOT = $(BASE_ROOT)/$(IP8021XDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(COMPONENT_IPWPS),true)
|
||||
ifeq ($(IPWPSDIR),)
|
||||
$(error IPWPSDIR is not installed)
|
||||
endif
|
||||
IPWPS_ROOT = $(BASE_ROOT)/$(IPWPSDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPRADIUS)),true)
|
||||
ifeq ($(IPRADIUSDIR),)
|
||||
$(error IPRADIUSDIR is not installed)
|
||||
endif
|
||||
IPRADIUS_ROOT = $(BASE_ROOT)/$(IPRADIUSDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPDIAMETERC)),true)
|
||||
ifeq ($(IPDIAMETERDIR),)
|
||||
$(error IPDIAMETERDIR is not installed)
|
||||
endif
|
||||
IPDIAMETER_ROOT = $(BASE_ROOT)/$(IPDIAMETERDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPDIAMETERP)),true)
|
||||
ifeq ($(IPDIAMETERDIR),)
|
||||
$(error IPDIAMETERDIR is not installed)
|
||||
endif
|
||||
IPDIAMETER_ROOT = $(BASE_ROOT)/$(IPDIAMETERDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPROHC)),true)
|
||||
ifeq ($(IPROHCDIR),)
|
||||
$(error IPROHCDIR is not installed)
|
||||
endif
|
||||
IPROHC_ROOT = $(BASE_ROOT)/$(IPROHCDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPFREESCALE)),true)
|
||||
ifeq ($(IPFREESCALEDIR),)
|
||||
$(error IPFREESCALE is not installed)
|
||||
endif
|
||||
IPFREESCALE_ROOT = $(BASE_ROOT)/$(IPFREESCALEDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPCAVIUM)),true)
|
||||
ifeq ($(IPCAVIUMDIR),)
|
||||
$(error IPCAVIUM is not installed)
|
||||
endif
|
||||
IPCAVIUM_ROOT = $(BASE_ROOT)/$(IPCAVIUMDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_VXCOMPAT)),true)
|
||||
ifeq ($(VXCOMPATDIR),)
|
||||
$(error VXCOMPAT is not installed)
|
||||
endif
|
||||
VXCOMPAT_ROOT = $(BASE_ROOT)/$(VXCOMPATDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_BRIDGE)),true)
|
||||
ifeq ($(BRIDGEDIR),)
|
||||
$(error BRIDGE is not installed)
|
||||
endif
|
||||
VXBRIDGE_ROOT = $(BASE_ROOT)/$(BRIDGEDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_DOT1X)),true)
|
||||
ifeq ($(VXDOT1XDIR),)
|
||||
$(error VXDOT1X is not installed)
|
||||
endif
|
||||
VXDOT1X_ROOT = $(BASE_ROOT)/$(VXDOT1XDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(COMPONENT_IPMACSEC),true)
|
||||
ifeq ($(IPMACSECDIR),)
|
||||
$(error IPMACSECDIR is not installed)
|
||||
endif
|
||||
IPMACSEC_ROOT = $(BASE_ROOT)/$(IPMACSECDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(COMPONENT_IFPROXY),true)
|
||||
ifeq ($(IFPROXYDIR),)
|
||||
$(error IFPROXY is not installed)
|
||||
endif
|
||||
IFPROXY_ROOT = $(BASE_ROOT)/$(IFPROXYDIR)
|
||||
endif
|
||||
|
||||
ifeq ($(COMPONENT_WRNAD),true)
|
||||
ifeq ($(WRNADDIR),)
|
||||
$(error WRNAD is not installed)
|
||||
endif
|
||||
WRNAD_ROOT = $(BASE_ROOT)/$(WRNADDIR)
|
||||
endif
|
||||
|
||||
# VXMUX is not really optional.
|
||||
ifeq ($(VXMUXDIR),)
|
||||
$(error VXMUX is not installed)
|
||||
endif
|
||||
VXMUX_ROOT = $(BASE_ROOT)/$(VXMUXDIR)
|
||||
|
||||
# VXCOREIP is not optional.
|
||||
ifeq ($(VXCOREIPDIR),)
|
||||
$(error VXCOREIP is not installed)
|
||||
endif
|
||||
VXCOREIP_ROOT = $(BASE_ROOT)/$(VXCOREIPDIR)
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPNTP)),true)
|
||||
ifeq ($(IPNTPDIR),)
|
||||
$(error IPNTP is not installed)
|
||||
endif
|
||||
IPNTP_ROOT = $(BASE_ROOT)/$(IPNTPDIR)
|
||||
endif
|
||||
|
||||
####
|
||||
# If user specified IPv6 only stack, we should exclude IPV4 support.
|
||||
#
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPNET)),true)
|
||||
ifeq ($(strip $(FEATURE_IPNET_INET6_ONLY)),true)
|
||||
IPDEFINE ?=
|
||||
ifneq ($(findstring -DINET6,$(ADDED_CFLAGS) $(EXTRA_DEFINE)),-DINET6)
|
||||
EXTRA_DEFINE += -DINET6
|
||||
endif
|
||||
export IPCOM_USE_INET6 = yes
|
||||
IPDEFINE += -DIPCOM_EXCLUDE_INET
|
||||
else
|
||||
ifneq ($(findstring -DINET,$(ADDED_CFLAGS) $(EXTRA_DEFINE)),-DINET)
|
||||
EXTRA_DEFINE += -DINET
|
||||
endif
|
||||
ifeq ($(strip $(FEATURE_IPNET_INET6)),true)
|
||||
ifneq ($(findstring -DINET6,$(ADDED_CFLAGS) $(EXTRA_DEFINE)),-DINET6)
|
||||
EXTRA_DEFINE += -DINET6
|
||||
endif
|
||||
export IPCOM_USE_INET6 = yes
|
||||
else
|
||||
export IPCOM_USE_INET6 = no
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_IPLITE)),true)
|
||||
ifneq ($(findstring -DINET,$(ADDED_CFLAGS) $(EXTRA_DEFINE)),-DINET)
|
||||
EXTRA_DEFINE += -DINET
|
||||
endif
|
||||
ifeq ($(strip $(FEATURE_IPLITE_INET6)),true)
|
||||
ifneq ($(findstring -DINET6,$(ADDED_CFLAGS) $(EXTRA_DEFINE)),-DINET6)
|
||||
EXTRA_DEFINE += -DINET6
|
||||
endif
|
||||
export IPCOM_USE_INET6 = yes
|
||||
else
|
||||
export IPCOM_USE_INET6 = no
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMPONENT_SNMP)),true)
|
||||
ifeq ($(WRSNMP),)
|
||||
$(error WRSNMP is not installed)
|
||||
endif
|
||||
WRSNMP_ROOT = $(BASE_ROOT)/$(WRSNMP)
|
||||
endif
|
||||
|
||||
export IPBUILD ?= $(strip $(FEATURE_IPNET_BUILD))
|
||||
|
||||
ifeq ($(IPGENDEPEND),)
|
||||
ifeq ($(strip $(COMPONENT_IPNET)),true)
|
||||
ifeq ($(strip $(FEATURE_IPNET_GEN_DEPEND)),true)
|
||||
export IPGENDEPEND = yes
|
||||
else
|
||||
export IPGENDEPEND = no
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(COMPONENT_IPLITE)),true)
|
||||
ifeq ($(strip $(FEATURE_IPLITE_GEN_DEPEND)),true)
|
||||
export IPGENDEPEND = yes
|
||||
else
|
||||
export IPGENDEPEND = no
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(IPVERBOSE),)
|
||||
ifeq ($(strip $(FEATURE_IPNET_VERBOSE)),true)
|
||||
export IPVERBOSE = yes
|
||||
else
|
||||
export IPVERBOSE = no
|
||||
endif
|
||||
endif
|
||||
@@ -0,0 +1,178 @@
|
||||
/* 00comp_ipnet_8021x.cdf - IPNet 802.1X Supplicant configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
--------------------
|
||||
01c,06jul10,mry WIND00141200, NetCfg restructure
|
||||
01b,04mar10,hfc fix for WIND00184598
|
||||
01a,07aug07,mry created.
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IP8021X
|
||||
Folder FOLDER_IP8021X_SUPP {
|
||||
NAME 802.1X Supplicant Components
|
||||
SYNOPSIS 802.1X Supplicant Components
|
||||
CHILDREN INCLUDE_IP8021X_SUPPLICANT \
|
||||
INCLUDE_DOT1X_SUPP_LEGACY_API \
|
||||
INCLUDE_IP8021X_SUPPLICANT_MIB
|
||||
_CHILDREN FOLDER_NET_L5_APPLICATIONS
|
||||
}
|
||||
|
||||
Component INCLUDE_IP8021X_SUPPLICANT {
|
||||
NAME 802.1X Supplicant
|
||||
SYNOPSIS Enables 802.1X Supplicant functionality
|
||||
MODULES ip8021x.o
|
||||
LINK_SYMS ip8021x_cmd_8021x
|
||||
CONFIGLETTES ip8021x_config.c
|
||||
CFG_PARAMS IPSUPP_IFNAM \
|
||||
IPSUPP_SSID \
|
||||
IPSUPP_PSK \
|
||||
IPSUPP_AUTHTYPE \
|
||||
IPSUPP_ENCRTYPE \
|
||||
IPSUPP_ENFORCE_RFC4017 \
|
||||
IPSUPP_HELDPERIOD \
|
||||
IPSUPP_AUTHPERIOD \
|
||||
IPSUPP_STARTPERIOD \
|
||||
IPSUPP_MAXSTART \
|
||||
IP8021X_LOG_LEVEL
|
||||
}
|
||||
|
||||
Component INCLUDE_DOT1X_SUPP_LEGACY_API {
|
||||
NAME 802.1X Supplicant Legacy API
|
||||
SYNOPSIS Enables 802.1X Supplicant Legacy API support
|
||||
REQUIRES INCLUDE_IP8021X_SUPPLICANT
|
||||
MODULES ip8021x_supp_legacy_api.o
|
||||
LINK_SYMS dot1xLegacyApiList
|
||||
}
|
||||
|
||||
Component INCLUDE_IP8021X_SUPPLICANT_MIB {
|
||||
NAME 802.1X Supplicant MIB Component
|
||||
SYNOPSIS 802.1X Supplicant MIB Component
|
||||
REQUIRES INCLUDE_IP8021X_SUPPLICANT \
|
||||
INCLUDE_WINDMANAGE_SNMP_CORE \
|
||||
INCLUDE_MIB_CONFIG
|
||||
INIT_RTN dot1xMibAdd();
|
||||
_INIT_ORDER usrNetAppInit
|
||||
MODULES ip8021x_vxmib.o \
|
||||
snmpDot1x.o
|
||||
LINK_SYMS ip8021x_vxmib_entry_get
|
||||
}
|
||||
|
||||
/******************** Configuration Parameters *****************************/
|
||||
|
||||
Parameter IPSUPP_IFNAM {
|
||||
NAME Interface Name
|
||||
SYNOPSIS The Interface name to which the IP supplicant is bound.
|
||||
TYPE char *
|
||||
DEFAULT "wls0"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_SSID {
|
||||
NAME Peer's SSID
|
||||
SYNOPSIS The Service Set IDentifier of the peer to which the \
|
||||
IP supplicant is authenticating. \
|
||||
NOTE: Only Required for PSK mode. max 32 characters.
|
||||
TYPE char *
|
||||
DEFAULT "wind"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_PSK {
|
||||
NAME Pre-Shared Key
|
||||
SYNOPSIS The Pre-Shared Key either as a passphrase (8-63 characters) \
|
||||
or as a hex key (32 octets exactly) \
|
||||
e.g.: Passphrase: "Wind_River_Wireless_Security_6.9" \
|
||||
Hex Key: "0x00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff"
|
||||
TYPE char *
|
||||
DEFAULT "Wind_River_Wireless_Security_6.9"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_AUTHTYPE {
|
||||
NAME Authentication Type
|
||||
SYNOPSIS Authentication Type used by the supplicant. \
|
||||
Valid values: "wired", "wps", "wpa", "wpa-psk", "wpa2", "wpa2-psk"
|
||||
Note that when "wps" is selected, this is a WPS exclusive mode and the
|
||||
supplicant will not handle 8021x exchanges until a valid WPS exchange
|
||||
is completed. This is a way to prevent the supplicant from negotiating
|
||||
with a non WPS enabled device (i.e. an added security measure).
|
||||
WPS mode can still be supported when the auth type is set to any of the
|
||||
wireless modes ("wpa", "wpa-psk", "wpa2", "wpa2-psk"), but it is not
|
||||
exclusive meaning if an association is made to a non WPS AP that supports
|
||||
the configured auth/encr types, a successful session may be established
|
||||
even if WPS had been enabled.
|
||||
TYPE char *
|
||||
DEFAULT "wpa-psk"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_ENCRTYPE {
|
||||
NAME Encryption Type
|
||||
SYNOPSIS Encryption Type used by the supplicant. \
|
||||
Valid values: "tkip", "ccmp". \
|
||||
NOTE: Irrelevant if AUTHTYPE == "wired" or "wps"
|
||||
|
||||
TYPE char *
|
||||
DEFAULT "tkip"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_ENFORCE_RFC4017 {
|
||||
NAME Enforce RFC 4017
|
||||
SYNOPSIS If set, disables support for weak outer EAP methods \
|
||||
not suitable for wireless authenitcation as per RFC. \
|
||||
Valid values: 0, 1.
|
||||
TYPE char *
|
||||
DEFAULT "1"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_HELDPERIOD {
|
||||
NAME dot1xSuppHeldPeriod
|
||||
SYNOPSIS The value, in seconds, of the heldPeriod \
|
||||
constant currently in use by the Supplicant \
|
||||
PAE state machine (IEEE Std 802.1X-2001, 8.5.8.1.2).
|
||||
TYPE char *
|
||||
DEFAULT "60"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_AUTHPERIOD {
|
||||
NAME dot1xSuppAuthPeriod
|
||||
SYNOPSIS The value, in seconds, of the authPeriod \
|
||||
constant currently in use by the Supplicant \
|
||||
PAE state machine (IEEE Std 802.1X-2001, 8.5.8.1.2).
|
||||
TYPE char *
|
||||
DEFAULT "30"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_STARTPERIOD {
|
||||
NAME dot1xSuppStartPeriod
|
||||
SYNOPSIS The value, in seconds, of the startPeriod \
|
||||
constant currently in use by the Supplicant \
|
||||
PAE state machine (IEEE Std 802.1X-2001, 8.5.8.1.2).
|
||||
TYPE char *
|
||||
DEFAULT "30"
|
||||
}
|
||||
|
||||
Parameter IPSUPP_MAXSTART {
|
||||
NAME dot1xSuppMaxStart
|
||||
SYNOPSIS The value of the maxStart constant currently in use by \
|
||||
the Supplicant PAE state machine (IEEE Std 802.1X-2001, 8.5.8.1.2).
|
||||
TYPE char *
|
||||
DEFAULT "3"
|
||||
}
|
||||
|
||||
Parameter IP8021X_LOG_LEVEL {
|
||||
NAME IP8021X Syslog Level
|
||||
SYNOPSIS Syslog Level for the IP8021X module. \
|
||||
One of: IPCOM_LOG_EMERG, IPCOM_LOG_CRIT, IPCOM_LOG_ERR, \
|
||||
IPCOM_LOG_WARNING, IPCOM_LOG_NOTICE, IPCOM_LOG_INFO, \
|
||||
IPCOM_LOG_DEBUG, IPCOM_LOG_DEBUG2
|
||||
TYPE int
|
||||
DEFAULT IPCOM_LOG_INFO
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.11 $
|
||||
# $Source: /home/interpeak/CVSRoot/ip8021x/config/common.vxconfig,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IP8021X
|
||||
config SUPPORTS_IP8021X
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_config.c,v $ $Revision: 1.21 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/config/ip8021x_config.c,v $
|
||||
* $Author: myakan $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* Copyright 2000-2006 Interpeak AB (http://www.interpeak.se). All rights reserved.
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int ip8021x_cmd_8021x(int argc, char** argv);
|
||||
|
||||
#ifdef INCLUDE_IP8021X_SUPPLICANT_MIB
|
||||
IP_EXTERN IP_GLOBAL void ip8021x_vxmib_handler_install(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ip8021x_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_CONST Ipcom_sysvar ip8021x_conf_sysvar[] =
|
||||
{
|
||||
IP_SYSVAR("ip8021x.if_name", "wls0", IPSUPP_IFNAM ),
|
||||
IP_SYSVAR("ip8021x.ssid", "wind", IPSUPP_SSID ),
|
||||
IP_SYSVAR("ip8021x.psk", "Wind_River_Wireless_Security_6.9", IPSUPP_PSK ),
|
||||
IP_SYSVAR("ip8021x.auth_type", "wpa-psk", IPSUPP_AUTHTYPE ), /* wps | wired | wpa-psk | wpa2-psk | wpa | wpa2 */
|
||||
IP_SYSVAR("ip8021x.encr_type", "tkip", IPSUPP_ENCRTYPE ), /* tkip | ccmp */
|
||||
IP_SYSVAR("ip8021x.enforce_rfc4017","1", IPSUPP_ENFORCE_RFC4017 ),
|
||||
IP_SYSVAR("ip8021x.auth_period", "30", IPSUPP_AUTHPERIOD ),
|
||||
IP_SYSVAR("ip8021x.start_period", "30", IPSUPP_STARTPERIOD ),
|
||||
IP_SYSVAR("ip8021x.held_period", "60", IPSUPP_HELDPERIOD ),
|
||||
IP_SYSVAR("ip8021x.max_start", "3", IPSUPP_MAXSTART ),
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_configure
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ip8021x_configure(void)
|
||||
{
|
||||
(void)ipcom_sysvar_setv(ip8021x_conf_sysvar, 0);
|
||||
|
||||
ipcom_openlog(IP_NULL, 0, IPCOM_LOG_IP8021X);
|
||||
(void)ipcom_setlogmask_on(IP8021X_LOG_LEVEL, IPCOM_LOG_IP8021X);
|
||||
|
||||
#if 1
|
||||
ipcom_shell_add_cmd("8021x", "8021x <connect|disconnect|logoff|getstatus|add|delete|list|eapcr>", "8021x", ip8021x_cmd_8021x,
|
||||
IPCOM_PROC_PRIO_4, IPCOM_PROC_STACK_DEFAULT);
|
||||
#endif
|
||||
#ifdef INCLUDE_IP8021X_SUPPLICANT_MIB
|
||||
ip8021x_vxmib_handler_install();
|
||||
#endif
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_config.h,v $ $Revision: 1.13 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/config/ip8021x_config.h,v $
|
||||
* $Author: krosenfe $ $Date: 2010-04-05 20:52:27 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP8021X_CONFIG_H
|
||||
#define IP8021X_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include <vsbConfig.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_IP8021X_DEBUG
|
||||
#ifndef IPSUPP_DEBUG
|
||||
#define IPSUPP_DEBUG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
|
||||
#if defined(_WRS_CONFIG_IP8021X_SYSLOG_PRIORITY)
|
||||
#define IPCOM_SYSLOG_PRIORITY _WRS_CONFIG_IP8021X_SYSLOG_PRIORITY
|
||||
#else
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_ERR
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_SYSLOG_FACILITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IP8021X
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IP8021X_RSN_CAP
|
||||
*===========================================================================
|
||||
* EAPOL key msg 2 contains an information element, that must match the
|
||||
* information element in the association request. When using WPA2, the
|
||||
* information element contains an RSN capabilities field.
|
||||
*
|
||||
*/
|
||||
#define IP8021X_RSN_CAP_PRE_AUTH 0x01
|
||||
#define IP8021X_RSN_CAP_NO_PAIRWISE 0x02
|
||||
#define IP8021X_RSN_CAP_PTK_SA_REPLAY_COUNTER_2 0x04
|
||||
#define IP8021X_RSN_CAP_PTK_SA_REPLAY_COUNTER_4 0x08
|
||||
#define IP8021X_RSN_CAP_PTK_SA_REPLAY_COUNTER_16 0x0B
|
||||
#define IP8021X_RSN_CAP_GTK_SA_REPLAY_COUNTER_2 0x10
|
||||
#define IP8021X_RSN_CAP_GTK_SA_REPLAY_COUNTER_4 0x20
|
||||
#define IP8021X_RSN_CAP_GTK_SA_REPLAY_COUNTER_16 0x30
|
||||
|
||||
#define IP8021X_RSN_CAP (IP8021X_RSN_CAP_PTK_SA_REPLAY_COUNTER_2 | IP8021X_RSN_CAP_GTK_SA_REPLAY_COUNTER_2)
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IP8021X_USE_STATS
|
||||
*===========================================================================
|
||||
* Set this define to enable supplicant statistics counters as defined in
|
||||
* IEEE 802.1x.
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_IP8021X_USE_STATS
|
||||
#define IP8021X_USE_STATS
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IP8021X_SIM_SUPPORT
|
||||
*===========================================================================
|
||||
* Set this define to enable 802.1x simulation support.
|
||||
*/
|
||||
#if 0
|
||||
#define IP8021X_SIM_SUPPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Forward declarations */
|
||||
struct Ip8021x_pkt_st;
|
||||
struct Ip8021x_ctx_st;
|
||||
|
||||
typedef Ip_err (*Ip8021x_output)(struct Ip8021x_ctx_st* ctx, struct Ip8021x_pkt_st* pkt);
|
||||
typedef int (*Ip8021x_input)(struct Ip8021x_ctx_st* ctx, struct Ip8021x_pkt_st* pkt, int len);
|
||||
typedef Ip_err (*Ip8021x_ioctl)(struct Ip8021x_ctx_st* ctx, unsigned long request, void* data);
|
||||
typedef Ip_err (*Ip8021x_get_supp_addr)(struct Ip8021x_ctx_st* ctx, Ip_u8* spa);
|
||||
typedef Ip_fd (*Ip8021x_get_fd)(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
|
||||
typedef struct Ip8021x_funcs_st
|
||||
{
|
||||
Ip8021x_output output;
|
||||
Ip8021x_input input;
|
||||
Ip8021x_ioctl ioctl;
|
||||
Ip8021x_get_supp_addr get_spa;
|
||||
Ip8021x_get_fd get_fd;
|
||||
} Ip8021x_funcs;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip8021x_funcs* ip8021x_get_callbacks(struct Ip8021x_ctx_st *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,11 @@
|
||||
IPTARGETS := lib
|
||||
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include ip8021x.mk
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
@@ -0,0 +1,102 @@
|
||||
#############################################################################
|
||||
# INTERPEAK DMAKE MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x.mk,v $ $Revision: 1.8 $
|
||||
# $Source: /home/interpeak/CVSRoot/ip8021x/gmake/ip8021x.mk,v $
|
||||
# $Author: dbush $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ip8021x
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEFINE
|
||||
#############################################################################
|
||||
|
||||
IPDEFINE += -DIP8021X
|
||||
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
#############################################################################
|
||||
|
||||
IPINCLUDE += -I$(IP8021X_ROOT)/config
|
||||
IPINCLUDE += -I$(IP8021X_ROOT)/include
|
||||
IPINCLUDE += -I$(BASE_ROOT)/$(IPWLANDIR)/include
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
#############################################################################
|
||||
|
||||
# Configuration
|
||||
#ifneq ($(IPPORT),las)
|
||||
#IPLIBOBJECTS += ip8021x_config.o
|
||||
#endif
|
||||
|
||||
# Main
|
||||
IPLIBOBJECTS += ip8021x.o
|
||||
IPLIBOBJECTS += ip8021x_aes.o
|
||||
IPLIBOBJECTS += ip8021x_hmac.o
|
||||
IPLIBOBJECTS += ip8021x_rc4.o
|
||||
IPLIBOBJECTS += ip8021x_sock.o
|
||||
IPLIBOBJECTS += ip8021x_state_machine.o
|
||||
IPLIBOBJECTS += ip8021x_wpa_ie.o
|
||||
IPLIBOBJECTS += ip8021x_supp_legacy_api.o
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
#############################################################################
|
||||
|
||||
# object root
|
||||
IPSRCDIRS += $(IP8021X_ROOT)/src $(IP8021X_ROOT)/config
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
#############################################################################
|
||||
|
||||
IPLIBS += $(IPLIBROOT)/libip8021x.a
|
||||
|
||||
|
||||
#############################################################################
|
||||
# BINARIES
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(IPPORT),las)
|
||||
# Path to binaries
|
||||
IPCMDDIR := $(IPOBJDIR)/bin
|
||||
IPDAEMONDIR := $(IPOBJDIR)/sbin
|
||||
|
||||
# List of daemons to build
|
||||
IP8021XDAEMONS = ipwpasupp
|
||||
_IP8021XDAEMONS = $(addprefix $(IPDAEMONDIR)/,$(IP8021XDAEMONS))
|
||||
|
||||
bin: $(_IP8021XDAEMONS)
|
||||
|
||||
$(IPOBJDIR)/ip8021x.o: $(IP8021X_ROOT)/src/ip8021x.c
|
||||
@$(IPECHO) "+++ Compiling IP8021X daemon $<"
|
||||
$(IPVERB)$(IPCC) -Dip8021xd=ipcom_daemon_entry_point -Dip8021x_create=ipcom_daemon_create $(IPCFLAGS) -o $@ $<
|
||||
|
||||
#$(IPOBJDIR)/ip8021x_config.o: $(IP8021X_ROOT)/config/ip8021x_config.c
|
||||
# $(IPVERB)$(IPCC) -Dip8021x_configure=ipcom_daemon_configure $(IPCFLAGS) -o $@ $<
|
||||
|
||||
#$(IPDAEMONDIR)/ipwpasupp: $(IPOBJDIR)/ip8021x.o $(IPOBJDIR)/ip8021x_config.o $(IPOBJDIR)/ipcom_daemon_stub.o
|
||||
(IPDAEMONDIR)/ipwpasupp: $(IPOBJDIR)/ip8021x.o $(IPOBJDIR)/ipcom_daemon_stub.o
|
||||
@$(IPECHO) "+++ Linking IP8021X daemon $@"
|
||||
$(IPVERB)$(IPLD) -o $@ $(IPLDFLAGS) $^ $(IPLIBS) $(IPLIBS) $(IPLIBS) $(IPLASTLIBS)
|
||||
|
||||
endif
|
||||
#############################################################################
|
||||
# END OF IP8021X.MK
|
||||
#############################################################################
|
||||
|
||||
@@ -0,0 +1,593 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x.h,v $ $Revision: 1.22 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/include/ip8021x.h,v $
|
||||
* $Author: krosenfe $ $Date: 2010-04-01 20:49:57 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* Copyright 2000-2006 Interpeak AB (http://www.interpeak.se). All rights reserved.
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP8021X_H
|
||||
#define IP8021X_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_ipd.h>
|
||||
|
||||
#ifdef IPEAP
|
||||
#include <ipeap.h>
|
||||
#endif
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef IPWPS
|
||||
#ifndef IP8021X_AUTH_SUPPORT
|
||||
#define IP8021X_AUTH_SUPPORT
|
||||
#define IP8021X_EAP_REQ_MAX_RETRIES 5
|
||||
#define IP8021X_EAP_REQ_RETRANSMIT_TMO 500
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define IP8021X_RELEASE 67000
|
||||
|
||||
#ifdef IP8021X_SIM_SUPPORT
|
||||
#define IP8021X_IFNAMSIZ 128
|
||||
#else
|
||||
#define IP8021X_IFNAMSIZ IP_IFNAMSIZ
|
||||
#endif
|
||||
#define IP8021X_RELEASE 67000
|
||||
|
||||
/* Return codes for ip8021x_state_get */
|
||||
#define IP8021X_STATE_LOGOFF 1
|
||||
#define IP8021X_STATE_DISCONNECTED 2
|
||||
#define IP8021X_STATE_CONNECTING 3
|
||||
#define IP8021X_STATE_ACQUIRED 4
|
||||
#define IP8021X_STATE_AUTHENTICATING 5
|
||||
#define IP8021X_STATE_HELD 6
|
||||
#define IP8021X_STATE_AUTHENTICATED 7
|
||||
|
||||
/* Return codes for ip8021x_pkt_input */
|
||||
#define IP8021X_EAP_PENDING 1 /* Keep in sync with IPEAP_PENDING_SEND_OUT_PKT */
|
||||
#define IP8021X_DROPPED_PKT 2 /* Keep in sync with IPEAP_DROPPED_PKT */
|
||||
#define IP8021X_EAP_SUCCESS 3 /* Keep in sync with IPEAP_SUCCESS */
|
||||
#define IP8021X_EAP_FAILURE 4 /* Keep in sync with IPEAP_FAILURE */
|
||||
#define IP8021X_KEY_MSG 20
|
||||
|
||||
#define IP8021X_PROCESS_NAME "ip8021x"
|
||||
|
||||
/* Deauthentication Reason codes (from IEEE Std 802.11i-2004) */
|
||||
#define IP8021X_DEAUTH_REASON_MIC_FAILURE 14 /* Michael failure */
|
||||
#define IP8021X_DEAUTH_REASON_4WAYHS_TIMEOUT 15 /* 4-way handshake timeout */
|
||||
#define IP8021X_DEAUTH_REASON_IE_MISMATCH 17 /* IE in 4-way handshake doesn't match */
|
||||
|
||||
#define IP8021X_MSG1_TIMEOUT 30000 /* In milliseconds*/
|
||||
|
||||
#define IP8021X_MAX_SUPPS_BITS 8 /* # of bits used to represent a supplicant instance */
|
||||
#define IP8021X_MAX_SUPPS (1 << IP8021X_MAX_SUPPS_BITS) /* Maximum # of supported supplicant instances */
|
||||
#define IP8021X_SUPP_INSTANCE_SHIFT (sizeof(Ip_u32)*8 - IP8021X_MAX_SUPPS_BITS)
|
||||
#define IP8021X_SUPP_INSTANCE_MASK ((IP8021X_MAX_SUPPS-1) << IP8021X_SUPP_INSTANCE_SHIFT) /* Use upper most bits for a mask */
|
||||
#define IP8021X_ENCODE_SUPP_INSTANCE(word,inst) (((word) & ~IP8021X_SUPP_INSTANCE_MASK) | ((inst & (IP8021X_MAX_SUPPS-1)) << IP8021X_SUPP_INSTANCE_SHIFT))
|
||||
#define IP8021X_DECODE_SUPP_INSTANCE(word) ((((word) & IP8021X_SUPP_INSTANCE_MASK) >> IP8021X_SUPP_INSTANCE_SHIFT) & (IP8021X_MAX_SUPPS-1))
|
||||
|
||||
#define IP8021X_IPD_EVENT_LOGOFF 100
|
||||
#define IP8021X_IPD_EVENT_DISCONNECT 101
|
||||
#define IP8021X_IPD_EVENT_CONNECT 102
|
||||
#define IP8021X_IPD_EVENT_GETSTATUS 103
|
||||
#define IP8021X_IPD_EVENT_ADD 104
|
||||
#define IP8021X_IPD_EVENT_DELETE 105
|
||||
#define IP8021X_IPD_EVENT_LIST 106
|
||||
#define IP8021X_IPD_EVENT_EAPCR 107
|
||||
#define IP8021X_IPD_EVENT_PHYPORT_UP 108
|
||||
#define IP8021X_IPD_EVENT_PHYPORT_DOWN 109
|
||||
#define IP8021X_IPD_EVENT_MIC_ERR_PAIR 110
|
||||
#define IP8021X_IPD_EVENT_MIC_ERR_GRP 111
|
||||
#define IP8021X_IPD_EVENT_DATAMSG 112
|
||||
#define IP8021X_IPD_EVENT_WPSON 113 /* Enable WPS mode */
|
||||
#define IP8021X_IPD_EVENT_WPSOFF 114 /* Disable WPS mode */
|
||||
#define IP8021X_IPD_EVENT_SEND_EAPOL_START 115
|
||||
#define IP8021X_IPD_EVENT_AUTH_REG 116 /* Authenticator registration */
|
||||
#define IP8021X_IPD_EVENT_AUTH_DEREG 117 /* Authenticator de-registration */
|
||||
|
||||
/* IPD data message subtypes */
|
||||
#define IP8021X_IPD_DATAMSG_MIB_SUPP_CFG 1
|
||||
#define IP8021X_IPD_DATAMSG_MIB_SUPP_STATS 2
|
||||
#define IP8021X_IPD_DATAMSG_MIB_SUPP_HELD_PERIOD 3
|
||||
#define IP8021X_IPD_DATAMSG_MIB_SUPP_AUTH_PERIOD 4
|
||||
#define IP8021X_IPD_DATAMSG_MIB_SUPP_START_PERIOD 5
|
||||
#define IP8021X_IPD_DATAMSG_MIB_SUPP_MAX_START 6
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Forward declarations */
|
||||
struct Ip8021x_ctx_st;
|
||||
struct Ip8021x_eapol_key_msg_st;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ip8021x_pkt
|
||||
*===========================================================================
|
||||
* This type represents an 802.1x packet
|
||||
*/
|
||||
typedef struct Ip8021x_pkt_st
|
||||
{
|
||||
int start; /* Index to first used byte */
|
||||
int end; /* Index to first free byte */
|
||||
int len; /* Length of allocated buffer */
|
||||
int ref; /* No of references to this packet */
|
||||
Ip_u8* buf;
|
||||
} Ip8021x_pkt;
|
||||
|
||||
#ifdef IP8021X_USE_STATS
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ip8021x_stats
|
||||
*===========================================================================
|
||||
* Supplicant statistic counters as defined in 802.1x
|
||||
*/
|
||||
typedef struct Ip8021x_stats_st
|
||||
{
|
||||
Ip_u32 eapol_frames_recv;
|
||||
Ip_u32 eapol_frames_tx;
|
||||
Ip_u32 eapol_start_frames_tx;
|
||||
Ip_u32 eapol_logoff_frames_tx;
|
||||
Ip_u32 eapol_resp_id_frames_tx;
|
||||
Ip_u32 eapol_resp_frames_tx;
|
||||
Ip_u32 eapol_req_frames_recv;
|
||||
Ip_u32 eapol_req_id_frames_recv;
|
||||
#ifdef IP8021X_AUTH_SUPPORT
|
||||
Ip_u32 eapol_req_id_frames_tx;
|
||||
Ip_u32 eapol_req_frames_tx;
|
||||
Ip_u32 eapol_resp_frames_recv;
|
||||
Ip_u32 eapol_resp_id_frames_recv;
|
||||
#endif
|
||||
Ip_u32 eapol_invalid_frames_recv;
|
||||
Ip_u32 eapol_length_error_frames_recv;
|
||||
Ip_u32 eapol_key_msg_drops;
|
||||
Ip_u32 eapol_key_msg_errors;
|
||||
Ip_u32 eapol_msg1_timeouts;
|
||||
Ip_u8 eapol_last_frame_version;
|
||||
Ip_u8 eapol_last_frame_source_addr[6];
|
||||
Ip_u32 tkip_mic_errors;
|
||||
Ip_u32 tkip_cm_triggers;
|
||||
Ip_u32 deauth_reqs;
|
||||
Ip_u32 eapol_mic_error_report_sent;
|
||||
Ip_u32 eapol_mic_error_report_fail;
|
||||
|
||||
} Ip8021x_stats;
|
||||
#endif
|
||||
|
||||
typedef struct ip8021x_instance_info_st {
|
||||
Ip_u32 instance_id; /* Identifier for the specified ip8021x instance */
|
||||
char ifname[IP8021X_IFNAMSIZ]; /* Interface name for the specified ip8021x instance */
|
||||
Ip_u8 mac_addr[6]; /* Interface mac address for the specified ip8021x instance */
|
||||
} ip8021x_instance_info;
|
||||
|
||||
typedef struct Ip8021x_mib_supp_cfg_st {
|
||||
int supp_state;
|
||||
int auth_period;
|
||||
int held_period;
|
||||
int start_period;
|
||||
int max_start;
|
||||
} Ip8021x_mib_supp_cfg;
|
||||
|
||||
#ifdef IP8021X_AUTH_SUPPORT
|
||||
/* external authenticator uses this message to register/deregister on an interface */
|
||||
typedef struct ip8021x_auth_reg_st {
|
||||
char ifname[IP8021X_IFNAMSIZ]; /* interface */
|
||||
void *assocCallback; /* callback for (dis)association indications */
|
||||
void *assocCallbackParm;
|
||||
void *packetCallback; /* callback for incoming EAPOL packets */
|
||||
void *packetCallbackParm;
|
||||
Ip_bool assocDereg; /* deregister association callback */
|
||||
Ip_bool packetDereg; /* deregister packet callback */
|
||||
} Ip8021x_auth_reg;
|
||||
#endif
|
||||
|
||||
/* For processing MIB messages or
|
||||
* generic comms to the supplicant */
|
||||
typedef struct Ip8021x_ipd_msg_st
|
||||
{
|
||||
/* This is an overlay struct.
|
||||
DO NOT MOVE THIS MEMBER! */
|
||||
Ipcom_ipd_msg ipd_msg;
|
||||
int subtype;
|
||||
union {
|
||||
Ip8021x_mib_supp_cfg supp_cfg;
|
||||
#ifdef IP8021X_USE_STATS
|
||||
Ip8021x_stats supp_stats;
|
||||
#endif
|
||||
ip8021x_instance_info ip8021x_info;
|
||||
#ifdef IP8021X_AUTH_SUPPORT
|
||||
Ip8021x_auth_reg auth_reg;
|
||||
#endif
|
||||
} data;
|
||||
} Ip8021x_ipd_msg;
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ctx_new
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Allocate a new 802.1x context
|
||||
* Parameters:
|
||||
* Returns:
|
||||
* Pointer to a context
|
||||
* IP_NULL if no new context could be created
|
||||
*/
|
||||
IP_PUBLIC struct Ip8021x_ctx_st* ip8021x_ctx_new(void);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ctx_free
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Free an 802.1x context
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ip8021x_ctx_free(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ctx_sock_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Initialize the example implementation of the function callbacks,
|
||||
* based on packet sockets.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* pointer to a function pointer structure.
|
||||
* IP_NULL is case of failure
|
||||
*/
|
||||
IP_PUBLIC struct Ip8021x_funcs_st* ip8021x_ctx_sock_init(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa_psk_sta_init
|
||||
*===========================================================================
|
||||
* Description: Initialize the 802.1x context for use in a wireless
|
||||
* environment, using WPA-PSK authentication. WPA-PSK
|
||||
* authentication is sometimes refered to as WPA Personal.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the context was successfully initialized
|
||||
* < 0 if the initialization failed
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_wpa_psk_sta_init(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa2_psk_sta_init
|
||||
*===========================================================================
|
||||
* Description: Initialize the 802.1x context for use in a wireless
|
||||
* environment, using WPA-PSK authentication. The key exchange
|
||||
* will be done according to IEEE 802.11i or WPA2.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the context was successfully initialized
|
||||
* < 0 if the initialization failed
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_wpa2_psk_sta_init(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa_sta_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Initialize the 802.1x context for use in a wireless environment, using
|
||||
* WPA authentication. WPA authentication is sometimes refered to as WPA
|
||||
* Enterprise.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the context was successfully initialized
|
||||
* < 0 if the initialization failed
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_wpa_sta_init(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa2_sta_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Initialize the 802.1x context for use in a wireless environment, using
|
||||
* WPA authentication. The key exchange will be done according to
|
||||
* IEEE 802.11i or WPA2.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the context was successfully initialized
|
||||
* < 0 if the initialization failed
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_wpa2_sta_init(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wired_suppl_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Initialize the 802.1x context for use in a wired environment.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the context was successfully initialized
|
||||
* < 0 if the initialization failed
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_wired_suppl_init(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wps_suppl_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Initialize the 802.1x context for use in a wps environment.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the context was successfully initialized
|
||||
* < 0 if the initialization failed
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_wps_suppl_init(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ctx_set_callbacks
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Setup the function callbacks for this context.
|
||||
* Parameters:
|
||||
* ctx - pointer to a context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the callbacks were successfully set
|
||||
* < 0 in case of failure
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_ctx_set_callbacks(struct Ip8021x_ctx_st *ctx, struct Ip8021x_funcs_st* funcs);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ctx_set_if_name
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Set the name of the interface this context shall be bound to.
|
||||
* Parameters:
|
||||
* ctx - pointer to the context
|
||||
* if_name - name of the interface that the context shall be bound to.
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS if the interface name was successfully set.
|
||||
* < 0 if the name could not be set.
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_ctx_set_if_name(struct Ip8021x_ctx_st* ctx, const char* if_name);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Returns the 802.1x state of this context
|
||||
* Parameters:
|
||||
* ctx - pointer to the context
|
||||
* Returns:
|
||||
* IP8021X_STATE_LOGOFF
|
||||
* IP8021X_STATE_DISCONNECTED
|
||||
* IP8021X_STATE_CONNECTING
|
||||
* IP8021X_STATE_ACQUIRED
|
||||
* IP8021X_STATE_AUTHENTICATING
|
||||
* IP8021X_STATE_HELD
|
||||
* IP8021X_STATE_AUTHENTICATED
|
||||
*/
|
||||
IP_PUBLIC int ip8021x_state_get(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_port_status_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Returns the 802.1x state of this context
|
||||
* Parameters:
|
||||
* ctx - pointer to the context
|
||||
* Returns:
|
||||
* IP8021X_PORT_STATUS_AUTHORIZED
|
||||
* IP8021X_PORT_STATUS_UNAUTHORIZED
|
||||
*/
|
||||
IP_PUBLIC int ip8021x_port_status_get(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_cfg_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Returns the supplicant configuration values as defined in IEEE 802.1x
|
||||
* Parameters:
|
||||
* ctx - pointer to the 802.1x context
|
||||
* supp_cfg - pointer to structure where the data will be written
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ip8021x_cfg_get(struct Ip8021x_ctx_st* ctx, Ip8021x_mib_supp_cfg* supp_cfg);
|
||||
|
||||
#ifdef IP8021X_USE_STATS
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_stats_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Returns the supplicant statistics counters as defined in IEEE 802.1x
|
||||
* Parameters:
|
||||
* ctx - pointer to the 802.1x context
|
||||
* stats - pointer to structure where the data will be written
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ip8021x_stats_get(struct Ip8021x_ctx_st* ctx, Ip8021x_stats* stats);
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_pkt_input
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Processes an incoming 802.1x packet. Any response packet that needs to
|
||||
* be sent will be sent by calling the output function pointer.
|
||||
* Parameters:
|
||||
* ctx - pointer to the 802.1x context
|
||||
* pkt - pointer to the packet that shall be processed.
|
||||
* Returns:
|
||||
* IP8021X_EAP_PENDING - an EAP authentication handshake is in progress.
|
||||
* IP8021X_DROPPED_PKT - packet dropped
|
||||
* IP8021X_EAP_SUCCESS - an EAP success message was received from the authenticator
|
||||
* IP8021X_EAP_FAILURE - an EAP failure message was received from the authenticator
|
||||
* IP8021X_KEY_MSG - an EAPOL key message was received from the authenticator
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_pkt_input(struct Ip8021x_ctx_st *ctx, Ip8021x_pkt *pkt);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_logoff
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Sends an EAPOL logoff frame and sets the 802.1x context in state
|
||||
* IP8021X_STATE_LOGOFF which is transitioned to IP8021X_STATE_DISCONNECTED
|
||||
* Parameters:
|
||||
* ctx - pointer to the 802.1x context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_logoff(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_connecting
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Sets the 802.1x context in state IP8021X_STATE_CONNECTING and sends an
|
||||
* EAPOL-START frame. This function is, for instance, called when the
|
||||
* link is up.
|
||||
* Parameters:
|
||||
* ctx - pointer to the 802.1x context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_connecting(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_disconnected
|
||||
*===========================================================================
|
||||
* Sets the 802.1x context in state IP8021X_STATE_DISCONNECTED. This
|
||||
* function is, for instance, called when the link is down.
|
||||
* Parameters:
|
||||
* ctx - pointer to the 802.1x context
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_disconnected(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
#ifdef IPWPS
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_set_wps_mode
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Enable/Disable WPS mode for a specific 8021x interface.
|
||||
* During WPS mode, the 8021x module doesn't invoke the IEEE 802.1X state
|
||||
* machine transitions and just behaves as a passthrough for EAPOL and EAP
|
||||
* packets.
|
||||
*
|
||||
* Parameters:
|
||||
* char *wps_if - 8021X interface to enable WPS on
|
||||
* Ip_bool on - IP_TRUE to enable (turn on WPS mode),
|
||||
* IP_FLASE to disable (turn it off).
|
||||
* char *wps_eap_id - (optional) EAP Identity to use when creating the EAP context
|
||||
* ONLY needed when WPS mode is being turned on.
|
||||
* If NULL, then no identity is set.
|
||||
* Ip_u32 *ip8021x_instance - Container for IP8021X instance corresponding to the
|
||||
* WPS interface (valid only upon success)
|
||||
* Ip_u8 *mac_addr - Ptr to buffer that will hold the Mac Address of the interface
|
||||
* corresponding to the ip8021x_instance.
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS upon success, error indication otherwise
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_set_wps_mode(char *wps_if, Ip_bool on, char *wps_eap_id,
|
||||
Ip_u32 *ip8021x_instance, Ip_u8 *mac_addr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_send_eapol_start
|
||||
*===========================================================================
|
||||
* Description: Ask the IP8021X module to send an EAPOL START (auth mode only).
|
||||
* Parameters:
|
||||
* Ip_u32 instance - IP8021X instance to send the EAPOL START.
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS upon success, error indication otherwise
|
||||
*/
|
||||
IP_PUBLIC Ip_err ip8021x_send_eapol_start(Ip_u32 instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,315 @@
|
||||
/* ip8021x_supp_legacy_api.h - 802.1X Supplicant Legacy API Support */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_supp_legacy_api.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/include/ip8021x_supp_legacy_api.h,v $
|
||||
* $Author: myakan $ $Date: 2008-10-24 16:34:51 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* Copyright 2008 Wind River Systems, Inc.
|
||||
* Design and implementation by Medhat Yakan
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP8021X_SUPP_LEGACY_SPI_H
|
||||
#define IP8021X_SUPP_LEGACY_SPI_H
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library contains the legacy API support for the ip8021x supplicant.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define DOT1X_MODE_TYPE(mode) ((mode) & 0xff)
|
||||
#define DOT1X_MODE_ENCRTYPE(mode) ((mode) & 0xff00)
|
||||
#define DOT1X_MODE_AUTHTYPE(mode) ((mode) & 0xff0000)
|
||||
|
||||
#ifndef STATUS
|
||||
#define STATUS int
|
||||
#endif
|
||||
#ifndef OK
|
||||
#define OK (0)
|
||||
#endif
|
||||
#ifndef ERROR
|
||||
#define ERROR (-1)
|
||||
#endif
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL Ip_bool
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
DOT1X_MODE_WIRELINE = (0 << 0), /* Defines mode for wireline operation */
|
||||
DOT1X_MODE_WIRELESS = (1 << 0), /* Defines mode for wireless operation */
|
||||
DOT1X_MODE_ENCRTYPE_TKIP = (1 << 8), /* Defines mode for TKIP encr type, valid only with DOT1X_MODE_WIRELESS */
|
||||
DOT1X_MODE_ENCRTYPE_CCMP = (2 << 8), /* Defines mode for CCMP encr type, valid only with DOT1X_MODE_WIRELESS */
|
||||
DOT1X_MODE_AUTHTYPE_WPA = (1 << 16), /* Defines mode for WPA auth type, valid only with DOT1X_MODE_WIRELESS */
|
||||
DOT1X_MODE_AUTHTYPE_WPA_PSK = (2 << 16), /* Defines mode for WPA-PSK auth type, valid only with DOT1X_MODE_WIRELESS */
|
||||
DOT1X_MODE_AUTHTYPE_WPA2 = (4 << 16), /* Defines mode for WPA2 auth type, valid only with DOT1X_MODE_WIRELESS */
|
||||
DOT1X_MODE_AUTHTYPE_WPA2_PSK = (8 << 16) /* Defines mode for WPA2-PSK auth type, valid only with DOT1X_MODE_WIRELESS */
|
||||
} DOT1X_SUPP_MODE;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xSuppIdGet - Retrieve supplicant ID
|
||||
*
|
||||
* This routine returns the supplicant ID corresponding to the specified interface.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* \is
|
||||
* \i <name>
|
||||
* device interface name, e.g. "wls"
|
||||
*
|
||||
* \i <unit>
|
||||
* instance of the device
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
* Supplicant ID or -1 on error
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int dot1xSuppIdGet
|
||||
(
|
||||
char *name,
|
||||
int unit
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xSuppCreate - Create a new supplicant
|
||||
*
|
||||
* This routine allocates, configures and initializes a supplicant instance.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* \is
|
||||
* \i <unit>
|
||||
* instance of the device
|
||||
*
|
||||
* \i <pDevName>
|
||||
* device interface name, e.g. "wls"
|
||||
*
|
||||
* \i <mode>
|
||||
* Supplicant Mode, a combination of one or more of the following values:
|
||||
* DOT1X_MODE_WIRELINE (backwards compatible value)
|
||||
* DOT1X_MODE_WIRELESS (backwards compatible value)
|
||||
* DOT1X_MODE_ENCRTYPE_TKIP
|
||||
* DOT1X_MODE_ENCRTYPE_CCMP
|
||||
* DOT1X_MODE_AUTHTYPE_WPA
|
||||
* DOT1X_MODE_AUTHTYPE_WPA_PSK
|
||||
* DOT1X_MODE_AUTHTYPE_WPA2
|
||||
* DOT1X_MODE_AUTHTYPE_WPA2_PSK
|
||||
*
|
||||
* The following combinations are allowed to be passed as mode:
|
||||
*
|
||||
* DOT1X_MODE_WIRELINE (encr and auth types are irrelevant)
|
||||
* DOT1X_MODE_WIRELESS (Uses current "ip8021x.encr_type" and "ip8021x.auth_type" values for encr and auth types)
|
||||
*
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_AUTHTYPE_WPA (Uses "ip8021x.encr_type" values for encr type)
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_AUTHTYPE_WPA_PSK (Uses "ip8021x.encr_type" values for encr type
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_AUTHTYPE_WPA2 (Uses "ip8021x.encr_type" values for encr type)
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_AUTHTYPE_WPA2_PSK (Uses "ip8021x.encr_type" values for encr type)
|
||||
*
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_TKIP (Uses "ip8021x.auth_type" values for auth type)
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_TKIP | DOT1X_MODE_AUTHTYPE_WPA
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_TKIP | DOT1X_MODE_AUTHTYPE_WPA_PSK
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_TKIP | DOT1X_MODE_AUTHTYPE_WPA2
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_TKIP | DOT1X_MODE_AUTHTYPE_WPA2_PSK
|
||||
*
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_CCMP (Uses "ip8021x.auth_type" values for auth type)
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_CCMP | DOT1X_MODE_AUTHTYPE_WPA
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_CCMP | DOT1X_MODE_AUTHTYPE_WPA_PSK
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_CCMP | DOT1X_MODE_AUTHTYPE_WPA2
|
||||
* DOT1X_MODE_WIRELESS | DOT1X_MODE_ENCRTYPE_CCMP | DOT1X_MODE_AUTHTYPE_WPA2_PSK
|
||||
*
|
||||
* Any other value of mode passed other than the above combinations will be rejected.
|
||||
*
|
||||
* \ie
|
||||
*
|
||||
* WARNING:
|
||||
* The values of the "ip8021x.if_name", "ip8021x.encr_type" and "ip8021x.auth_type" sysvars
|
||||
* may be modified by this call.
|
||||
* This function cannot be called concurrently from two different contexts or
|
||||
* undesired results may occur. It is the caller's responsibility to ensure that no
|
||||
* 2 istances of this function are running concurrently.
|
||||
*
|
||||
* RETURNS:
|
||||
* Supplicant ID of the newly created supplicant or -1 on error.
|
||||
*/
|
||||
IP_PUBLIC int dot1xSuppCreate
|
||||
(
|
||||
int unit,
|
||||
char * pDevName,
|
||||
int mode
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xSuppDelete - Delete a supplicant
|
||||
*
|
||||
* This routine destroys an existing supplicant instance and its corresponding
|
||||
* configuration structure.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* \is
|
||||
* \i <suppId>
|
||||
* ID of supplicant to delete
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
* OK or ERROR
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppDelete
|
||||
(
|
||||
int suppId
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xSuppConnect - Connect a supplicant
|
||||
*
|
||||
* This routine causes the supplicant to enter the CONNECTING state and
|
||||
* send an EAPOL start to the authenticator to trigger an EAP exchange
|
||||
* with the authentication server.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* \is
|
||||
* \i <suppId>
|
||||
* ID of supplicant to connect
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
* OK or ERROR
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppConnect(
|
||||
int suppId
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xSuppShutdownAll - Shutdown all supplicants
|
||||
*
|
||||
* This routine stops all supplicants and cleans up the ip8021x task.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* None.
|
||||
*
|
||||
* RETURNS:
|
||||
* OK or ERROR
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppShutdownAll(void);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xSuppShow - Display supplicant info
|
||||
*
|
||||
* This routine displays information on initialized supplicants.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* \is
|
||||
* \i <verbose>
|
||||
* verbosity level:
|
||||
* 0: List supplicant configuration only.
|
||||
* 1: Display status of each initialized supplicant.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
* OK or ERROR
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppShow
|
||||
(
|
||||
BOOL verbose
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xSuppGtcUserInput - Provide EAP-GTC Challenge response
|
||||
*
|
||||
* This routine is used to provide the supplicant with the EAP Challenge response
|
||||
* when prompted for one during EAP-GTC authentication.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* \is
|
||||
* \i <suppId>
|
||||
* ID of supplicant to handle the challenge response
|
||||
*
|
||||
* \i <pUserInput>
|
||||
* Pointer to a string containing the challenge response
|
||||
*
|
||||
* \ie
|
||||
*
|
||||
*
|
||||
* RETURNS:
|
||||
* OK or ERROR
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppGtcUserInput
|
||||
(
|
||||
int suppId,
|
||||
char *pUserInput
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* dot1xLegacyApiList - List supplicant legacy APIs
|
||||
*
|
||||
* This routine displays a list of the supported 802.1x supplicant legacy APIs.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* None
|
||||
* RETURNS:
|
||||
* OK or ERROR
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xLegacyApiList(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IP8021X_SUPP_LEGACY_SPI_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
#############################################################################
|
||||
# INTERPEAK DMAKE MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x.mk,v $ $Revision: 1.11 $
|
||||
# $Source: /home/interpeak/CVSRoot/ip8021x/make/ip8021x.mk,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
# Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# DESCRIPTION
|
||||
#############################################################################
|
||||
# IP8021X dmake build description.
|
||||
|
||||
IP8021X = yes
|
||||
|
||||
#############################################################################
|
||||
# PATHS
|
||||
#############################################################################
|
||||
|
||||
# object root
|
||||
IP8021X_OBJROOT *= $(IPOBJDIR)$/ip8021x
|
||||
|
||||
|
||||
#############################################################################
|
||||
# IPDEFINE
|
||||
#############################################################################
|
||||
|
||||
IPDEFINE += IP8021X
|
||||
|
||||
|
||||
#############################################################################
|
||||
# IPINCLUDE
|
||||
#############################################################################
|
||||
|
||||
IPINCLUDE += $(IP8021X_ROOT)$/config
|
||||
IPINCLUDE += $(IP8021X_ROOT)$/include
|
||||
|
||||
|
||||
#############################################################################
|
||||
# USER OBJECTS
|
||||
#############################################################################
|
||||
|
||||
# User files
|
||||
IP8021X_UOBJ += ip8021x.o
|
||||
IP8021X_UOBJ += ip8021x_aes.o
|
||||
IP8021X_UOBJ += ip8021x_hmac.o
|
||||
IP8021X_UOBJ += ip8021x_rc4.o
|
||||
IP8021X_UOBJ += ip8021x_sock.o
|
||||
IP8021X_UOBJ += ip8021x_state_machine.o
|
||||
IP8021X_UOBJ += ip8021x_wpa_ie.o
|
||||
IPLIBOBJECTS += ip8021x_supp_legacy_api.o
|
||||
|
||||
_IP8021X_UOBJ = $(foreach,i,$(IP8021X_UOBJ) $(IP8021X_OBJROOT)$/$i)
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIBRARIES
|
||||
#############################################################################
|
||||
|
||||
# lib names
|
||||
IP8021X_ULIB = $(IPLIBDIR)$/$(IPLIBPREFIX)ip8021x_ulib$(IPLIBSUFFIX)
|
||||
IP8021X_LIBS = $(IP8021X_ULIB)
|
||||
IPLIBRARIES += $(IP8021X_LIBS)
|
||||
|
||||
|
||||
#############################################################################
|
||||
# COMPILATION/LINKING
|
||||
#############################################################################
|
||||
|
||||
# product files
|
||||
"$(IP8021X_OBJROOT)$/%.o": $(IP8021X_ROOT)$/src$/%.c
|
||||
$(IPCC) $(IPCFLAGS) $(_IPDEFINE) $(_IPINCLUDE) $(IPCCOUT) $<
|
||||
|
||||
# user library
|
||||
"$(IP8021X_ULIB)": ip8021x_dirs $(_IP8021X_UOBJ)
|
||||
$(IPAR) $(IPAROUT)$(IP8021X_ULIB) $(_IP8021X_UOBJ)
|
||||
|
||||
|
||||
#############################################################################
|
||||
# MAIN DEPENDENCIES
|
||||
#############################################################################
|
||||
|
||||
IPLIBS += ip8021x_libs
|
||||
|
||||
# libraries
|
||||
ip8021x_libs: ip8021x_dirs $(IP8021X_LIBS)
|
||||
|
||||
# directories
|
||||
ip8021x_dirs: ipcom_dirs $(IP8021X_OBJROOT)
|
||||
|
||||
"$(IP8021X_OBJROOT)":
|
||||
$(IPMKDIR) $(IP8021X_OBJROOT)
|
||||
|
||||
ip8021x_clean:
|
||||
$(IPRMDIR) $(IP8021X_OBJROOT)
|
||||
|
||||
ip8021x_vclean: ip8021x_clean
|
||||
$(IPRM) $(IP8021X_LIBS)
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LINT
|
||||
###########################################################################
|
||||
|
||||
IP8021X_SRC = $(foreach,i,$(IP8021X_UOBJ) $(subst,.o,.c $i))
|
||||
_IP8021X_SRC = $(foreach,i,$(IP8021X_SRC) $(IP8021X_ROOT)$/src$/$i)
|
||||
|
||||
ip8021x_lint .PHONY:
|
||||
$(IPLINT) $(_IPDEFINE) $(_IPINCLUDE) $(_IP8021X_SRC)
|
||||
|
||||
|
||||
#############################################################################
|
||||
# END OF IP8021X.MK
|
||||
#############################################################################
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_aes.c,v $ $Revision: 1.3.40.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_aes.c,v $
|
||||
* $Author: hxu4 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
802.11i specifies that AES keys shall be encrypted using the AES key wrap
|
||||
algorithm, defined in rfc 3394.
|
||||
|
||||
The following notation is used in the description of the key wrapping
|
||||
algorithms:
|
||||
|
||||
AES(K, W) Encrypt W using the AES codebook with key K
|
||||
AES-1(K, W) Decrypt W using the AES codebook with key K
|
||||
MSB(j, W) Return the most significant j bits of W
|
||||
LSB(j, W) Return the least significant j bits of W
|
||||
B1 ^ B2 The bitwise exclusive or (XOR) of B1 and B2
|
||||
B1 | B2 Concatenate B1 and B2
|
||||
K The key-encryption key K
|
||||
n The number of 64-bit key data blocks
|
||||
s The number of steps in the wrapping process, s = 6n
|
||||
P[i] The ith plaintext key data block
|
||||
C[i] The ith ciphertext data block
|
||||
A The 64-bit integrity check register
|
||||
R[i] An array of 64-bit registers where
|
||||
i = 0, 1, 2, ..., n
|
||||
A[t], R[i][t] The contents of registers A and R[i] after encryption
|
||||
step t.
|
||||
IV The 64-bit initial value used during the wrapping
|
||||
process.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
|
||||
#ifdef IPMCRYPTO
|
||||
#include <ip/openssl/aes.h>
|
||||
#else
|
||||
#include <openssl/aes.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_aes_key_unwrap
|
||||
*===========================================================================
|
||||
* Description: This function implements the AES key unwrap algorithm as
|
||||
* specified in rfc 3394. This implementation is based on the
|
||||
* index based operation. All parameter have the same name as
|
||||
* in rfc 3394.
|
||||
* Note: this implementation only supports n <= 42. However,
|
||||
* in WPA n is always 2 so this should be a problem.
|
||||
* Parameters: K - the key encryption key
|
||||
* n - the number of 64-bit key data blocks
|
||||
* C - the cipher text data blocks
|
||||
* P - the plain text data blocks
|
||||
* Returns:
|
||||
* IPCOM_SUCCESS - if the key was successfully unwrapped
|
||||
* IPCOM_ERR_FAILED - in case the integrity check fails
|
||||
* IPCOM_ERR_INVALID_ARG - if n>42
|
||||
*/
|
||||
IP_GLOBAL Ip_err
|
||||
ip8021x_aes_key_unwrap(const Ip_u8 *K, int n, const Ip_u8 *C, Ip_u8 *P)
|
||||
{
|
||||
Ip_u8 A[8];
|
||||
Ip_u8 *R;
|
||||
Ip_u8 B[16];
|
||||
int i;
|
||||
int j;
|
||||
AES_KEY key;
|
||||
|
||||
if (n > 42)
|
||||
{
|
||||
IP_PANIC();
|
||||
return IPCOM_ERR_INVALID_ARG;
|
||||
}
|
||||
(void)AES_set_decrypt_key(K, 128, &key);
|
||||
|
||||
/* 1) Initialize variables.
|
||||
* Set A = C[0]
|
||||
* For i = 1 to n
|
||||
* R[i] = C[i]
|
||||
*/
|
||||
ipcom_memcpy(A, C, 8);
|
||||
R = P; /* Use plain buffer as R, will save us a malloc/free and a memcpy in 3 below. */
|
||||
ipcom_memcpy(R, C + 8, 8 * n);
|
||||
|
||||
/* 2) Compute intermediate values.
|
||||
* For j = 5 to 0
|
||||
* For i = n to 1
|
||||
* B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i
|
||||
* A = MSB(64, B)
|
||||
* R[i] = LSB(64, B)
|
||||
*/
|
||||
for (j = 5; j >= 0; j--)
|
||||
{
|
||||
R = P + (n - 1) * 8;
|
||||
for (i = n; i >= 1; i--)
|
||||
{
|
||||
ipcom_memcpy(B, A, 8);
|
||||
/* (A ^ t), t can maximum be 6n (5*n+n). If n<=42 then t<256 and only b[7] will
|
||||
* be affected by the xor operation */
|
||||
B[7] ^= n * j + i;
|
||||
ipcom_memcpy(B + 8, R, 8);
|
||||
AES_decrypt(B, B, &key);
|
||||
ipcom_memcpy(A, B, 8);
|
||||
ipcom_memcpy(R, B + 8, 8);
|
||||
R -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* 3) Output results.
|
||||
*
|
||||
* The unwrapped key is already in P, since we set R=P above.
|
||||
* Verify the integrity check register.
|
||||
*/
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (A[i] != 0xa6)
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK INTERNAL API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_h.h,v $ $Revision: 1.27 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_h.h,v $
|
||||
* $Author: krosenfe $ $Date: 2010-04-01 20:49:57 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP8021X_H_H
|
||||
#define IP8021X_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_tmo.h>
|
||||
#include <ipcom_sock.h>
|
||||
|
||||
#ifdef IPMCRYPTO
|
||||
#include <ip/openssl/sha.h>
|
||||
#include <ip/openssl/md5.h>
|
||||
#else
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/md5.h>
|
||||
#endif
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_wpa_ie.h"
|
||||
#include "ip8021x_state_machine.h"
|
||||
#include "ipwlan_wlan.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IP8021X_ETH_P_EAPOL 0x888e
|
||||
|
||||
#define IP8021X_EAPOL_KEY_INFO_KEY_VER 1
|
||||
#define IP8021X_EAPOL_KEY_INFO_KEY_TYPE 2
|
||||
#define IP8021X_EAPOL_KEY_INFO_KEY_INDEX 3
|
||||
#define IP8021X_EAPOL_KEY_INFO_INSTALL 4
|
||||
#define IP8021X_EAPOL_KEY_INFO_KEY_ACK 5
|
||||
#define IP8021X_EAPOL_KEY_INFO_KEY_MIC 6
|
||||
#define IP8021X_EAPOL_KEY_INFO_SECURE 7
|
||||
#define IP8021X_EAPOL_KEY_INFO_ERROR 8
|
||||
#define IP8021X_EAPOL_KEY_INFO_REQUEST 9
|
||||
#define IP8021X_EAPOL_KEY_INFO_ENCR_KEY 10
|
||||
|
||||
|
||||
#define IP8021X_EAPOL_TYPE_PACKET 0
|
||||
#define IP8021X_EAPOL_TYPE_START 1
|
||||
#define IP8021X_EAPOL_TYPE_LOGOFF 2
|
||||
#define IP8021X_EAPOL_TYPE_KEY 3
|
||||
|
||||
#define IP8021X_EAPOL_MODE_WIRED 1
|
||||
#define IP8021X_EAPOL_MODE_WPA (1<<1)
|
||||
#define IP8021X_EAPOL_MODE_WPA2 (1<<2)
|
||||
#define IP8021X_EAPOL_MODE_WPA_PSK (1<<3)
|
||||
#define IP8021X_EAPOL_MODE_WPA2_PSK (1<<4)
|
||||
#define IP8021X_EAPOL_MODE_WPS (1<<5)
|
||||
|
||||
#define IP8021X_PORT_STATUS_AUTHORIZED 100
|
||||
#define IP8021X_PORT_STATUS_UNAUTHORIZED 101
|
||||
|
||||
/* These MUST match values defines in "dot1xCommonIoctls.h" */
|
||||
#define IP8021X_PHY_PORT_EVENT_INVALID 0
|
||||
#define IP8021X_PHY_PORT_EVENT_ASSOCIATION 1
|
||||
#define IP8021X_PHY_PORT_EVENT_DISASSOCIATION 2
|
||||
#define IP8021X_MIC_ERROR_EVENT_PAIRWISE 3
|
||||
#define IP8021X_MIC_ERROR_EVENT_GROUPWISE 4
|
||||
|
||||
#define IP8021X_PHY_PORT_STATUS_UNKNOWN 0
|
||||
#define IP8021X_PHY_PORT_STATUS_UP 1
|
||||
#define IP8021X_PHY_PORT_STATUS_DOWN 2
|
||||
|
||||
#define IP8021X_STATE_STA_UNINITIALIZED 0
|
||||
#define IP8021X_STATE_STA_WAITING_KEY_MSG1 1
|
||||
#define IP8021X_STATE_STA_WAITING_KEY_MSG3 2
|
||||
#define IP8021X_STATE_STA_WAITING_KEY_MSG5 3
|
||||
#define IP8021X_STATE_STA_FINISHED 4
|
||||
#define IP8021X_STATE_STA_EAPOL_START_SENT 5
|
||||
#define IP8021X_STATE_STA_EAP_HANDSHAKE 6
|
||||
|
||||
#define IP8021X_HMAC_SHA1 1
|
||||
#define IP8021X_HMAC_MD5 2
|
||||
|
||||
#define IP8021X_DESCRIPTOR_TYPE_WPA 254
|
||||
#define IP8021X_DESCRIPTOR_TYPE_WPA2 2
|
||||
|
||||
#define IP8021X_FLAG_PORT_OPENED 0x00000001
|
||||
#define IP8021X_FLAG_PMK_ESTABLISHED 0x00000002
|
||||
#define IP8021X_FLAG_PTK_INSTALLED 0x00000004
|
||||
#define IP8021X_FLAG_GTK_INSTALLED 0x00000008
|
||||
|
||||
#if 0
|
||||
#define IP8021X_GET_KEY_INFO_BITS(ptr, index, startbit, bits) ((ptr[index]>> startbit) & (0xff >> (8-bits)));
|
||||
#define IP8021X_SET_KEY_INFO_BITS(ptr, index, startbit, bits, value) do { \
|
||||
int mask; \
|
||||
int i; \
|
||||
ip_assert(index < 2); \
|
||||
ip_assert(bits <= 3); \
|
||||
ip_assert(startbit + bits <= 8); \
|
||||
/* Clear bits to be set */ \
|
||||
for(i=startbit; i<startbit+bits; i++) \
|
||||
{ \
|
||||
mask = 1 << i; \
|
||||
ptr[index] &= ~mask; \
|
||||
} \
|
||||
\
|
||||
/* Set bits */ \
|
||||
ptr[index] |= value << startbit; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef IP8021X_SIM_SUPPORT
|
||||
/* Specifies the reserved interface name qualifier for simtest interfaces */
|
||||
#define IP8021X_SIMTEST_IFNAME "simtest"
|
||||
|
||||
/* simtest interface name:
|
||||
* Starts with simtest
|
||||
* followed by a physical interface name which is used to retrieve the mac address to be used as source address
|
||||
* followed by the peer address or the "loopback" identifier for local peer
|
||||
* followed by an optional custom port number used as the source and destination UDP port.
|
||||
*/
|
||||
#define IP8021x_SIMTEST_IFNAME_HELP IP8021X_SIMTEST_IFNAME "-<ifname>-loopback[-port]" \
|
||||
" or " IP8021X_SIMTEST_IFNAME "-<ifname>-<ipv4_addr>[-<port>]"
|
||||
|
||||
#define IP8021X_SIMTEST_DEFAULT_PORT 31334 /* El3ET port, used if no custom port is specified */
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ip8021x_eapol_set_key_info(Ip_u8* key_info, int field_id, int value);
|
||||
IP_GLOBAL int ip8021x_eapol_get_key_info(Ip_u8* key_info, int field_id);
|
||||
|
||||
struct Ip8021x_hmac_ctx_st
|
||||
{
|
||||
union {
|
||||
SHA_CTX sha;
|
||||
MD5_CTX md5;
|
||||
} hash_ctx;
|
||||
int hash_id;
|
||||
int key_len;
|
||||
Ip_u8 k_ipad[64];
|
||||
Ip_u8 k_opad[64];
|
||||
};
|
||||
typedef struct Ip8021x_hmac_ctx_st Ip8021x_hmac_ctx;
|
||||
|
||||
union ip8021x_temporal_key
|
||||
{
|
||||
Ip_u8 tkip[32];
|
||||
Ip_u8 ccmp[16];
|
||||
};
|
||||
|
||||
struct Ip8021x_ptk_keys_st
|
||||
{
|
||||
Ip_u8 key_conf_key[16];
|
||||
Ip_u8 key_enc_key[16];
|
||||
union ip8021x_temporal_key temp_key;
|
||||
};
|
||||
typedef struct Ip8021x_ptk_keys_st Ip8021x_ptk_keys;
|
||||
|
||||
|
||||
/* Pairwise Transient Key */
|
||||
union Ip8021x_ptk_key
|
||||
{
|
||||
Ip_u8 ptk[64];
|
||||
Ip8021x_ptk_keys keys;
|
||||
};
|
||||
|
||||
struct Ip8021x_eapol_hdr_st
|
||||
{
|
||||
Ip_u8 version;
|
||||
Ip_u8 type;
|
||||
Ip_u16 len;
|
||||
};
|
||||
typedef struct Ip8021x_eapol_hdr_st Ip8021x_eapol_hdr;
|
||||
|
||||
|
||||
typedef struct Ip8021x_eapol_key_msg_st
|
||||
{
|
||||
/* Generic EAPOL field */
|
||||
Ip_u8 version;
|
||||
Ip_u8 type;
|
||||
Ip_u16 len;
|
||||
|
||||
/* EAPOL key fields */
|
||||
Ip_u8 descriptor_type;
|
||||
Ip_u8 key_info[2];
|
||||
Ip_u8 key_len[2];
|
||||
Ip_u8 replay_counter[8];
|
||||
Ip_u8 key_nonce[32];
|
||||
Ip_u8 key_iv[16];
|
||||
Ip_u8 key_rsc[8];
|
||||
Ip_u8 reserved[8];
|
||||
Ip_u8 key_mic[16];
|
||||
Ip_u8 key_data_len[2];
|
||||
Ip_u8 key_data[1];
|
||||
} Ip8021x_eapol_key_msg;
|
||||
|
||||
|
||||
#ifdef IP8021X_USE_STATS
|
||||
#define IP8021X_STATS(xctx, xvar) xctx->stats.xvar
|
||||
#define IP8021X_STAT_LINE(xline) xline
|
||||
|
||||
#else
|
||||
#define IP8021X_STATS(xctx, xvar) IP_NOOP
|
||||
#define IP8021X_STAT_LINE(xline) IP_NOOP
|
||||
#endif
|
||||
|
||||
/* Configuration entries for each supplicant instance */
|
||||
typedef struct ip8021x_config_st {
|
||||
Ip_bool valid; /* set after the supplicant instance is created */
|
||||
char if_name[IP8021X_IFNAMSIZ];
|
||||
char encr_type[32];
|
||||
char auth_type[32];
|
||||
Ip_u8 psk[IP_IW_KEY_PMK_LEN+3]; /* enough to fit 63 char passphrase, or 32 octet hex key (0xaabb....) plus null terminating char */
|
||||
char ssid[32+1];
|
||||
} ip8021x_config;
|
||||
|
||||
/* Supplicant Context (supp instance specific */
|
||||
typedef struct Ip8021x_ctx_st
|
||||
{
|
||||
Ip_u32 init; /* Indicates a properly initialized instance (1st supp needs to have been created/configured) */
|
||||
Ip_u32 instance; /* supplicant instance # corresponding to this context */
|
||||
ip8021x_config *config; /* ptr to corresponding config entry */
|
||||
char if_name[IP8021X_IFNAMSIZ];
|
||||
|
||||
Ip8021x_state_machine sm;
|
||||
|
||||
Ip_u8 aa[6]; /* Authenticator MAC address */
|
||||
Ip_u8 spa[6]; /* Supplicant MAC address */
|
||||
|
||||
Ipcom_mutex mutex;
|
||||
|
||||
Ipcom_tmo tmo; /* IP8021x State Machine Timer onject */
|
||||
Ipcom_tmo tkip_cm_tmo; /* TKIP CounterMeasures Timer object */
|
||||
Ipcom_tmo eapol_msg1_tmo; /* Eapol Msg 1 Timer object */
|
||||
Ipcom_tmo auth_req_tmo; /* Auth request Timer */
|
||||
Ip_u32 tkip_mic_errors_in_last_minute;
|
||||
|
||||
Ip_u64 rx_key_replay_counter; /* Last received key replay counter */
|
||||
Ip_u64 tx_key_replay_counter; /* Last sent key replay counter (used in key request eapol msgs) */
|
||||
|
||||
Ip_u8 ANonce[32];
|
||||
Ip_u8 SNonce[32];
|
||||
|
||||
Ip_u8 pmk[32]; /* Pair-wise master key */
|
||||
Ip_u8 ptk[64]; /* Pair-wise temporal key */
|
||||
Ip_u8 gtk[32]; /* Group-wise temporal key */
|
||||
int gtk_len;
|
||||
|
||||
int ptk_index; /* Key index of pairwise key */
|
||||
int gtk_index; /* Key index of groupwise key */
|
||||
int gtk_tx_flag; /* tx flag, used in WPA2 only */
|
||||
|
||||
Ip8021x_funcs* cb;
|
||||
|
||||
Ip_fd sock;
|
||||
|
||||
#ifdef IP8021X_USE_STATS
|
||||
Ip8021x_stats stats;
|
||||
#endif
|
||||
|
||||
int encr_type;
|
||||
int multicast_encr_type;
|
||||
int auth_type;
|
||||
Ip_u16 rsn_cap;
|
||||
|
||||
Ip8021x_wpa_ie wpa_ie;
|
||||
Ip_u8 last_ie[64];
|
||||
Ip_u16 last_ie_size;
|
||||
int eapol_key_descr_type;
|
||||
|
||||
Ip_u32 state; /* TODO: can this member be removed? */
|
||||
Ip_u32 port_status;
|
||||
Ip_u32 phy_layer_status; /* Physical layer status as reported by driver */
|
||||
|
||||
Ip_u32 mode;
|
||||
Ip_u32 flags;
|
||||
Ip_u32 enforce_rfc4017;
|
||||
|
||||
#ifdef IP8021X_SIM_SUPPORT
|
||||
Ip_bool simtest; /* true if simtest enabled */
|
||||
char simif[IP_IFNAMSIZ];
|
||||
struct Ip_in_addr simaddr; /* Ipv4 address */
|
||||
Ip_u16 simport;
|
||||
Ip_fd simsock;
|
||||
#endif
|
||||
|
||||
#ifdef IPEAP
|
||||
struct Ipeap_ctx_st *eap_ctx;
|
||||
#ifdef IP8021X_AUTH_SUPPORT
|
||||
char peer_identity[IPEAP_IDENTITY_MAX_LEN];
|
||||
Ip_u8 req_retry_count;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef IPWPS
|
||||
Ip_bool wps_enabled;
|
||||
char wsc_eap_id[128];
|
||||
#endif
|
||||
void* extra;
|
||||
#ifdef IP8021X_AUTH_SUPPORT
|
||||
void* authAssocCallback; /* callback for external authenticator */
|
||||
void* authAssocCallbackParm;
|
||||
void* authPacketCallback;
|
||||
void* authPacketCallbackParm;
|
||||
#endif
|
||||
} Ip8021x_ctx;
|
||||
|
||||
typedef enum {
|
||||
IP8021X_UITYPE_EAP_CHALLENGE_RESP = 0
|
||||
} Ip8021x_user_input_type;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN Ip_u8 ip8021x_pae_grp_addr[6];
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void
|
||||
ip8021x_generate_ptk(Ip_u8* pmk, int pmk_len,
|
||||
Ip_u8* auth_addr, int auth_addr_len,
|
||||
Ip_u8* sta_addr, int sta_addr_len,
|
||||
Ip_u8* auth_nonce, int auth_nonce_len,
|
||||
Ip_u8* sta_nonce, int sta_nonce_len,
|
||||
Ip_u8* ptk,
|
||||
int req_bits);
|
||||
|
||||
IP_GLOBAL void ip8021x_hmac_init(Ip8021x_hmac_ctx* ctx, Ip_u8* key, int key_len, int hash_id);
|
||||
|
||||
IP_GLOBAL void ip8021x_hmac_update(Ip8021x_hmac_ctx* ctx, Ip_u8* data, int data_len);
|
||||
|
||||
IP_GLOBAL void ip8021x_hmac_final(Ip8021x_hmac_ctx* ctx, Ip_u8* digest, int digest_len);
|
||||
|
||||
IP_GLOBAL void ip8021x_hmac(Ip_u8* key, int key_len, Ip_u8* data, int data_len,
|
||||
Ip_u8* digest, int digest_len, int hash_id);
|
||||
|
||||
IP_GLOBAL void ip8021x_rc4_skip(Ip_u8 *key, Ip_size_t keylen, Ip_size_t skip, Ip_u8 *data, Ip_size_t data_len);
|
||||
IP_GLOBAL void ip8021x_rc4(Ip_u8 *key, Ip_size_t key_len, Ip_u8 *buf, Ip_size_t len);
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_aes_key_unwrap(const Ip_u8 *K, int n, const Ip_u8 *C, Ip_u8 *P);
|
||||
|
||||
IP_PUBLIC Ip_err ip8021x_wpa_psk_set_pmk(Ip8021x_ctx* ctx, const char* ascii_psk);
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_F(const char *password, unsigned char *ssid, int ssidlength,
|
||||
int iterations, int count, unsigned char *output);
|
||||
IP_GLOBAL Ip_err ip8021x_wpa_psk_pw_hash(const char *password, unsigned char *ssid,
|
||||
int ssidlength, unsigned char *output);
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_prf(Ip_u8* pmk, int pmk_len, const char* label,
|
||||
Ip_u8* data, int data_len, int req_bits, Ip_u8* out_buf);
|
||||
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_send_eapol_msg(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt, Ip_u8 version, Ip_u8 pkt_type);
|
||||
IP_GLOBAL Ip_err ip8021x_send_msg(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt);
|
||||
IP_GLOBAL Ip_err ip8021x_send_key_msg2(Ip8021x_ctx* ctx, Ip8021x_eapol_key_msg* key_msg1);
|
||||
IP_GLOBAL Ip_err ip8021x_send_key_msg4(Ip8021x_ctx* ctx, Ip8021x_eapol_key_msg* key_msg3);
|
||||
IP_GLOBAL Ip_err ip8021x_send_key_msg6(Ip8021x_ctx* ctx, Ip8021x_eapol_key_msg* key_msg5);
|
||||
IP_GLOBAL Ip_err ip8021x_send_eapol_key_msg(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt);
|
||||
|
||||
IP_GLOBAL void ip8021x_calculate_mic(Ip8021x_ctx* ctx, Ip8021x_eapol_key_msg* msg, Ip_u8* mic);
|
||||
|
||||
IP_GLOBAL const char* ip8021x_eapol_key_get_state_str(Ip_u32 state);
|
||||
IP_GLOBAL const char* ip8021x_eapol_get_msg_type_str(Ip_u8 pkt_type);
|
||||
IP_GLOBAL const char* ip8021x_encr_type_str(int encr_type);
|
||||
IP_GLOBAL const char* ip8021x_auth_type_str(int auth_type);
|
||||
IP_GLOBAL const char* ip8021x_mode_str(int mode);
|
||||
IP_GLOBAL const char* ip8021x_eapol_key_descr_type_str(int eapol_key_descr_type);
|
||||
IP_GLOBAL const char* ip8021x_flags_str(Ip_u32 eapol_key_descr_type);
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_tx_eapol_start(Ip8021x_ctx* ctx);
|
||||
IP_GLOBAL Ip_err ip8021x_tx_eapol_logoff(Ip8021x_ctx* ctx);
|
||||
|
||||
IP_GLOBAL Ip8021x_pkt* ip8021x_pkt_new(int len, int offset, Ip_u8 version, Ip_u8 type);
|
||||
IP_GLOBAL void ip8021x_pkt_free(Ip8021x_pkt*);
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_eapol_msg_input(Ip8021x_ctx* ctx, Ip8021x_pkt* in_pkt);
|
||||
IP_GLOBAL Ip_err ip8021x_eapol_key_msg_input(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt);
|
||||
|
||||
|
||||
|
||||
#ifdef IPEAP
|
||||
IP_GLOBAL void ip8021x_pkt_map_to_eap(Ip8021x_pkt* pkt, Ipeap_pkt* eap_pkt);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_hmac.c,v $ $Revision: 1.6.40.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_hmac.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* Copyright 2000-2006 Interpeak AB (http://www.interpeak.se). All rights reserved.
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_hmac_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_hmac_init(Ip8021x_hmac_ctx* ctx, Ip_u8* key, int key_len, int hash_id)
|
||||
{
|
||||
Ip_u8 temp_key[20];
|
||||
int i;
|
||||
|
||||
ipcom_memset(ctx, 0, sizeof(Ip8021x_hmac_ctx));
|
||||
|
||||
switch(hash_id)
|
||||
{
|
||||
|
||||
case IP8021X_HMAC_SHA1:
|
||||
|
||||
/* if key is longer than 64 bytes reset it to key=SHA1(key) */
|
||||
if (key_len > 64)
|
||||
{
|
||||
(void)SHA1_Init(&ctx->hash_ctx.sha);
|
||||
(void)SHA1_Update(&ctx->hash_ctx.sha, key, key_len);
|
||||
(void)SHA1_Final(temp_key, &ctx->hash_ctx.sha);
|
||||
|
||||
key = temp_key;
|
||||
key_len = 20;
|
||||
}
|
||||
break;
|
||||
|
||||
case IP8021X_HMAC_MD5:
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
|
||||
/* MD5 cannot be used */
|
||||
if (FIPS_mode())
|
||||
{
|
||||
/* Authentication failed. */
|
||||
IPCOM_LOG0(WARNING, "ip8021x: MD5 is not supported when FIPS mode is enabled!");
|
||||
(void)ipcom_errno_set(IPCOM_ERR_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if key is longer than 64 bytes reset it to key=MD5(key) */
|
||||
if (key_len > 64)
|
||||
{
|
||||
(void)MD5_Init(&ctx->hash_ctx.md5);
|
||||
(void)MD5_Update(&ctx->hash_ctx.md5, key, key_len);
|
||||
(void)MD5_Final(temp_key, &ctx->hash_ctx.md5);
|
||||
|
||||
key = temp_key;
|
||||
key_len = 16;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
|
||||
}
|
||||
|
||||
ctx->hash_id = hash_id;
|
||||
ctx->key_len = key_len;
|
||||
ipcom_memcpy(ctx->k_ipad, key, key_len);
|
||||
ipcom_memcpy(ctx->k_opad, key, key_len);
|
||||
|
||||
/* XOR key with ipad and opad values */
|
||||
for (i=0; i<64; i++) {
|
||||
ctx->k_ipad[i] ^= 0x36;
|
||||
ctx->k_opad[i] ^= 0x5c;
|
||||
}
|
||||
|
||||
switch(hash_id)
|
||||
{
|
||||
case IP8021X_HMAC_SHA1:
|
||||
|
||||
(void)SHA1_Init(&ctx->hash_ctx.sha);
|
||||
(void)SHA1_Update(&ctx->hash_ctx.sha, ctx->k_ipad, sizeof(ctx->k_ipad));
|
||||
break;
|
||||
|
||||
case IP8021X_HMAC_MD5:
|
||||
#ifdef OPENSSL_FIPS
|
||||
/* MD5 cannot be used */
|
||||
if (FIPS_mode())
|
||||
{
|
||||
/* Authentication failed. */
|
||||
IPCOM_LOG0(WARNING, "ip8021x: MD5 is not supported when FIPS mode is enabled!");
|
||||
(void)ipcom_errno_set(IPCOM_ERR_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
(void)MD5_Init(&ctx->hash_ctx.md5);
|
||||
(void)MD5_Update(&ctx->hash_ctx.md5, ctx->k_ipad, sizeof(ctx->k_ipad));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_hmac_update
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_hmac_update(Ip8021x_hmac_ctx* ctx, Ip_u8* data, int data_len)
|
||||
{
|
||||
switch(ctx->hash_id)
|
||||
{
|
||||
case IP8021X_HMAC_SHA1:
|
||||
|
||||
(void)SHA1_Update(&ctx->hash_ctx.sha, data, data_len);
|
||||
break;
|
||||
|
||||
case IP8021X_HMAC_MD5:
|
||||
#ifdef OPENSSL_FIPS
|
||||
/* MD5 cannot be used */
|
||||
if (FIPS_mode())
|
||||
{
|
||||
/* Authentication failed. */
|
||||
IPCOM_LOG0(WARNING, "ip8021x: MD5 is not supported when FIPS mode is enabled!");
|
||||
(void)ipcom_errno_set(IPCOM_ERR_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
(void)MD5_Update(&ctx->hash_ctx.md5, data, data_len);
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_hmac_final
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_hmac_final(Ip8021x_hmac_ctx* ctx, Ip_u8* digest, int digest_len)
|
||||
{
|
||||
Ip_u8 tmp_buf[20];
|
||||
|
||||
(void)digest_len;
|
||||
|
||||
switch(ctx->hash_id)
|
||||
{
|
||||
case IP8021X_HMAC_SHA1:
|
||||
|
||||
ip_assert(digest_len >= 20);
|
||||
|
||||
(void)SHA1_Final(tmp_buf, &ctx->hash_ctx.sha);
|
||||
|
||||
(void)SHA1_Init(&ctx->hash_ctx.sha);
|
||||
(void)SHA1_Update(&ctx->hash_ctx.sha, ctx->k_opad, sizeof(ctx->k_opad));;
|
||||
(void)SHA1_Update(&ctx->hash_ctx.sha, tmp_buf, sizeof(tmp_buf));
|
||||
(void)SHA1_Final(digest, &ctx->hash_ctx.sha);
|
||||
break;
|
||||
|
||||
case IP8021X_HMAC_MD5:
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
/* MD5 cannot be used */
|
||||
if (FIPS_mode())
|
||||
{
|
||||
/* Authentication failed. */
|
||||
IPCOM_LOG0(WARNING, "ip8021x: MD5 is not supported when FIPS mode is enabled!");
|
||||
(void)ipcom_errno_set(IPCOM_ERR_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
ip_assert(digest_len >= 16);
|
||||
|
||||
(void)MD5_Final(tmp_buf, &ctx->hash_ctx.md5);
|
||||
|
||||
(void)MD5_Init(&ctx->hash_ctx.md5);
|
||||
(void)MD5_Update(&ctx->hash_ctx.md5, ctx->k_opad, sizeof(ctx->k_opad));;
|
||||
(void)MD5_Update(&ctx->hash_ctx.md5, tmp_buf, 16);
|
||||
(void)MD5_Final(digest, &ctx->hash_ctx.md5);
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ip8021x_hmac(Ip_u8* key, int key_len, Ip_u8* data, int data_len,
|
||||
Ip_u8* digest, int digest_len, int hash_id)
|
||||
{
|
||||
Ip8021x_hmac_ctx ctx;
|
||||
|
||||
ip8021x_hmac_init(&ctx, key, key_len, hash_id);
|
||||
ip8021x_hmac_update(&ctx, data, data_len);
|
||||
ip8021x_hmac_final(&ctx, digest, digest_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_rc4.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_rc4.c,v $
|
||||
* $Author: myakan $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* Copyright 2000-2006 Interpeak AB (http://www.interpeak.se). All rights reserved.
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IP8021X_RC4_SWAP(a,b) do { Ip_u8 t = S[a]; S[a] = S[b]; S[b] = t; } while(0)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_rc4_skip
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_rc4_skip(Ip_u8 *key, Ip_size_t keylen, Ip_size_t skip, Ip_u8 *data, Ip_size_t data_len)
|
||||
{
|
||||
Ip_u32 i;
|
||||
Ip_u32 j;
|
||||
Ip_u32 k;
|
||||
Ip_u8 S[256];
|
||||
unsigned int pos;
|
||||
|
||||
/* Initialize RC4 S-box */
|
||||
for (i = 0; i < 256; i++)
|
||||
S[i] = i; /*lint !e734*/
|
||||
j = 0;
|
||||
pos = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
j = (j + S[i] + key[pos]) & 0xff;
|
||||
pos++;
|
||||
if (pos >= keylen)
|
||||
pos = 0;
|
||||
IP8021X_RC4_SWAP(i, j);
|
||||
}
|
||||
|
||||
/* Skip the first 'skip' bytes of the key stream */
|
||||
i = 0;
|
||||
j = 0;
|
||||
for (k = 0; k < skip; k++) {
|
||||
i = (i + 1) & 0xff;
|
||||
j = (j + S[i]) & 0xff;
|
||||
IP8021X_RC4_SWAP(i, j);
|
||||
}
|
||||
|
||||
/* Encrypt/decrypt the data */
|
||||
for (k = 0; k < data_len; k++) {
|
||||
i = (i + 1) & 0xff;
|
||||
j = (j + S[i]) & 0xff;
|
||||
IP8021X_RC4_SWAP(i, j);
|
||||
*data++ ^= S[(S[i] + S[j]) & 0xff];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_rc4
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_rc4(Ip_u8 *key, Ip_size_t key_len, Ip_u8 *buf, Ip_size_t len)
|
||||
{
|
||||
ip8021x_rc4_skip(key, key_len, 0, buf, len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_rsn_ie.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_rsn_ie.c,v $
|
||||
* $Author: krosenfe $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_err.h>
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
#include "ip8021x_rsn_ie.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
Ip_u8 IP8021x_RSN_IE_TKIP[] = { 0x00, 0x0f, 0xac, 0x02 };
|
||||
|
||||
Ip_u8 IP8021x_RSN_IE_PSK[] = { 0x00, 0x0f, 0xac, 0x02 };
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ip8021x_pkt_put_rsn_ie(Ip8021x_pkt* pkt, Ip8021x_rsn_ie* rsn_ie)
|
||||
{
|
||||
int space_left;
|
||||
int rsn_ie_size;
|
||||
Ip_u8* ptr;
|
||||
|
||||
space_left = pkt->len-pkt->end;
|
||||
rsn_ie_size = 1+1+2+4+2+(rsn_ie->pairwise_cipher_suite_len)*4+2
|
||||
+(rsn_ie->auth_key_mgnt_len)*4+2+(rsn_ie->pmkid_len)*16;
|
||||
|
||||
/* is packet large enough to hold rsn_ie? */
|
||||
if(space_left<rsn_ie_size)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ip8021x_pkt_put_rsn_ie :: packet too small to hold rsn_ie, pkt size: %d, rsn_ie size: %d",
|
||||
space_left, rsn_ie_size);
|
||||
return IPCOM_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Is rsn_ie a valid information element? */
|
||||
if(rsn_ie->pairwise_cipher_suite_len<=0 || rsn_ie->pairwise_cipher_suite_len<=0)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ip8021x_pkt_put_rsn_ie :: invalid rsn_ie: cipher_len: %d, akm_len: %d",
|
||||
rsn_ie->pairwise_cipher_suite_len, rsn_ie->pairwise_cipher_suite_len);
|
||||
return IPCOM_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ptr = &pkt->buf[pkt->end];
|
||||
|
||||
*ptr++ = rsn_ie->id;
|
||||
*ptr++ = rsn_ie_size-2; /* id and length fields not included rsn ie length count */
|
||||
ipcom_memcpy(ptr, rsn_ie->version, 6); /* version and group cipher fields */
|
||||
ptr += 6;
|
||||
IP_SET_HTONS(ptr, rsn_ie->pairwise_cipher_suite_len);
|
||||
ptr += 2;
|
||||
ipcom_memcpy(ptr, rsn_ie->pairwise_cipher_suite, (rsn_ie->pairwise_cipher_suite_len)*4);
|
||||
ptr += 4*rsn_ie->pairwise_cipher_suite_len;
|
||||
IP_SET_HTONS(ptr, rsn_ie->auth_key_mgnt_len);
|
||||
ptr += 2;
|
||||
ipcom_memcpy(ptr, rsn_ie->auth_key_mgnt, 4*(rsn_ie->auth_key_mgnt_len));
|
||||
ptr += 4*rsn_ie->auth_key_mgnt_len;
|
||||
IP_SET_HTONS(ptr, rsn_ie->pmkid_len);
|
||||
ptr += 2;
|
||||
if(rsn_ie->pmkid_len != 0)
|
||||
ipcom_memcpy(ptr, rsn_ie->pmkid, 16*(rsn_ie->pmkid_len));
|
||||
|
||||
pkt->end += rsn_ie_size;
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_rsn_ie_set_default
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_rsn_ie_set_default(Ip8021x_rsn_ie* rsn_ie)
|
||||
{
|
||||
|
||||
ipcom_memset(rsn_ie, 0, sizeof(Ip8021x_rsn_ie));
|
||||
|
||||
rsn_ie->id = 0x30;
|
||||
rsn_ie->version[0] = 1;
|
||||
rsn_ie->version[1] = 0;
|
||||
ipcom_memcpy(rsn_ie->grp_cipher_suite, IP8021x_RSN_IE_TKIP, sizeof(IP8021x_RSN_IE_TKIP));
|
||||
(Ip_u16)rsn_ie->pairwise_cipher_suite_len = 1;
|
||||
ipcom_memcpy(rsn_ie->pairwise_cipher_suite, IP8021x_RSN_IE_TKIP, sizeof(IP8021x_RSN_IE_TKIP));
|
||||
(Ip_u16)rsn_ie->auth_key_mgnt_len = 1;
|
||||
ipcom_memcpy(rsn_ie->auth_key_mgnt, IP8021x_RSN_IE_PSK, sizeof(IP8021x_RSN_IE_PSK));
|
||||
(Ip_u16)rsn_ie->rsn_cap = 0;
|
||||
(Ip_u16)rsn_ie->pmkid_len = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK INTERNAL API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_rsn_ie.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_rsn_ie.h,v $
|
||||
* $Author: roger $ $Date: 2005-05-12 17:41:52 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP8021X_RSN_IE_H
|
||||
#define IP8021X_RSN_IE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Maximum number of cipher suites in RSN information elements */
|
||||
#define IP8021X_MAX_CIPHERS 4
|
||||
|
||||
/* Maximum number of authentication and key management suites in RSN information elements */
|
||||
#define IP8021X_MAX_AUTH_KEY 4
|
||||
|
||||
/* Maximum number pairwise key identifiers RSN information elements */
|
||||
#define IP8021X_MAX_PKMID 4
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ip8021x_rsn_ie_st
|
||||
{
|
||||
Ip_u8 id;
|
||||
Ip_u8 len;
|
||||
Ip_u8 version[2];
|
||||
Ip_u8 grp_cipher_suite[4];
|
||||
Ip_u16 pairwise_cipher_suite_len;
|
||||
Ip_u8 pairwise_cipher_suite[4*IP8021X_MAX_CIPHERS];
|
||||
Ip_u16 auth_key_mgnt_len;
|
||||
Ip_u8 auth_key_mgnt[4*IP8021X_MAX_AUTH_KEY];
|
||||
Ip_u16 rsn_cap;
|
||||
Ip_u16 pmkid_len;
|
||||
Ip_u8 pmkid[16*IP8021X_MAX_PKMID];
|
||||
|
||||
} Ip8021x_rsn_ie;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_pkt_put_rsn_ie(Ip8021x_pkt* pkt, Ip8021x_rsn_ie* rsn_ie);
|
||||
|
||||
IP_GLOBAL void ip8021x_rsn_ie_set_default(Ip8021x_rsn_ie* rsn_ie);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,629 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_sock.c,v $ $Revision: 1.12.18.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_sock.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_errno.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sock2.h>
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_STATIC Ip_err ip8021x_output_sock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt);
|
||||
IP_STATIC int ip8021x_input_sock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt, int len);
|
||||
IP_STATIC Ip_err ip8021x_ioctl_sock(Ip8021x_ctx* ctx, unsigned long request, void* data);
|
||||
IP_STATIC Ip_err ip8021x_get_spa_sock(Ip8021x_ctx* ctx, Ip_u8* spa);
|
||||
IP_STATIC Ip_fd ip8021x_get_fd_sock(struct Ip8021x_ctx_st* ctx);
|
||||
|
||||
#ifdef IP8021X_SIM_SUPPORT
|
||||
IP_STATIC Ip_err ip8021x_output_simsock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt);
|
||||
IP_STATIC int ip8021x_input_simsock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt, int len);
|
||||
IP_STATIC Ip_err ip8021x_ioctl_simsock(Ip8021x_ctx* ctx, unsigned long request, void* data);
|
||||
IP_STATIC Ip_err ip8021x_get_spa_simsock(Ip8021x_ctx* ctx, Ip_u8* spa);
|
||||
IP_STATIC Ip_fd ip8021x_get_fd_simsock(struct Ip8021x_ctx_st* ctx);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC Ip8021x_funcs Ip8021x_sock_funcs =
|
||||
{
|
||||
ip8021x_output_sock,
|
||||
ip8021x_input_sock,
|
||||
ip8021x_ioctl_sock,
|
||||
ip8021x_get_spa_sock,
|
||||
ip8021x_get_fd_sock
|
||||
};
|
||||
|
||||
#ifdef IP8021X_SIM_SUPPORT
|
||||
IP_STATIC Ip8021x_funcs Ip8021x_simsock_funcs =
|
||||
{
|
||||
ip8021x_output_simsock,
|
||||
ip8021x_input_simsock,
|
||||
ip8021x_ioctl_simsock,
|
||||
ip8021x_get_spa_simsock,
|
||||
ip8021x_get_fd_simsock
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_output_sock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ip8021x_output_sock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt)
|
||||
{
|
||||
struct Ip_sockaddr_ll ll;
|
||||
int pkt_len;
|
||||
int rc;
|
||||
|
||||
pkt_len = pkt->end-pkt->start;
|
||||
|
||||
ipcom_memset(&ll, 0, sizeof(ll));
|
||||
ll.sll_family = IP_AF_PACKET;
|
||||
ll.sll_halen = 6;
|
||||
ipcom_memcpy(ll.sll_addr, ctx->aa, 6);
|
||||
ll.sll_ifindex = ipcom_if_nametoindex(ctx->if_name);
|
||||
|
||||
rc = ipcom_sendto(ctx->sock, &pkt->buf[pkt->start], pkt_len, 0, (struct Ip_sockaddr*) &ll, sizeof(ll));
|
||||
if(rc != pkt_len)
|
||||
{
|
||||
IPCOM_LOG3(ERR, "ip8021x_output_sock :: ipcom_sendto failed, errno=%d, pkt_len=%d, rc=%d",
|
||||
ipcom_errno, pkt_len, rc);
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_input_sock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ip8021x_input_sock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt, int len)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ip_assert(pkt->len - pkt->end >= len);
|
||||
|
||||
rc = ipcom_recvfrom(ctx->sock, &pkt->buf[pkt->end], len, 0, IP_NULL, IP_NULL);
|
||||
|
||||
/* Some drivers return 60 bytes minimum, even if the received message is smaller */
|
||||
if(rc == 60)
|
||||
{
|
||||
int tmp_len;
|
||||
|
||||
tmp_len = IP_GET_HTONS(&pkt->buf[pkt->end+16]);
|
||||
if(tmp_len+18 < rc)
|
||||
{
|
||||
IPCOM_LOG2(DEBUG2, "ip8021x_input_sock :: correcting size of received message, from %d to %d", rc, tmp_len+18);
|
||||
rc = tmp_len + 18;
|
||||
}
|
||||
}
|
||||
if(rc > 0)
|
||||
pkt->end += rc;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ioctl_sock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ip8021x_ioctl_sock(Ip8021x_ctx* ctx, unsigned long request, void* data)
|
||||
{
|
||||
int rc;
|
||||
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG2(DEBUG2, "ip8021x_ioctl_sock: request 0x%x (%d)", request, request&0xff);
|
||||
#endif
|
||||
rc = ipcom_socketioctl(ctx->sock, request, data);
|
||||
if (rc != IPCOM_SUCCESS) {
|
||||
IPCOM_LOG2(DEBUG2, "ip8021x_ioctl_sock: request %d failed (rc = %d)", request, rc);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_get_spa_sock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ip8021x_get_spa_sock(Ip8021x_ctx* ctx, Ip_u8* spa)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
Ip_fd sock;
|
||||
Ip_bool ok = IP_FALSE;
|
||||
Ip_u8 undef_eth_addr[6] = {1, 2, 3, 4, 5, 6};
|
||||
int i;
|
||||
|
||||
sock = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, 0);
|
||||
if(sock == -1)
|
||||
{
|
||||
IP_PANIC();
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
ipcom_strcpy(ifreq.ifr_name, ctx->if_name);
|
||||
for(i=0; i<100; i++)
|
||||
{
|
||||
if (ipcom_socketioctl(sock, IP_SIOCGIFLLADDR, (char *)&ifreq) < 0)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ip8021x_get_spa_sock: ipcom_socketioctl(IP_SIOCGHWADDR): %d", ipcom_errno);
|
||||
ipcom_socketclose(sock);
|
||||
IP_PANIC();
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
/* On some OSs the WLAN driver sets the MAC addr once the device comes up, which can take some time */
|
||||
if(ipcom_memcmp(ifreq.ifr_ifru.ifru_addr.sa_data, undef_eth_addr, 6) != 0)
|
||||
{
|
||||
ok = IP_TRUE;
|
||||
break;
|
||||
}
|
||||
ipcom_millisleep(100);
|
||||
}
|
||||
if(!ok)
|
||||
{
|
||||
ipcom_socketclose(sock);
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
ipcom_memcpy(spa, ifreq.ifr_ifru.ifru_addr.sa_data, 6);
|
||||
ipcom_socketclose(sock);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_get_fd_sock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_fd
|
||||
ip8021x_get_fd_sock(struct Ip8021x_ctx_st* ctx)
|
||||
{
|
||||
return ctx->sock;
|
||||
}
|
||||
|
||||
#ifdef IP8021X_SIM_SUPPORT
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_output_simsock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Send an EAPOL packet over a simsock using EAPOL Layer 3 Encapsulation and Tunneling (EL3ET)
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ip8021x_output_simsock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt)
|
||||
{
|
||||
struct Ip_sockaddr_in addr;
|
||||
int buf_len;
|
||||
char *buf;
|
||||
int rc;
|
||||
|
||||
if (!ctx->simtest) {
|
||||
IPCOM_LOG0(ERR, "ip8021x_output_simsock called when not in sim mode");
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
/* Create the EL3ET packet */
|
||||
buf_len = pkt->end-pkt->start + 12;
|
||||
buf = ipcom_malloc(buf_len);
|
||||
if (!buf) {
|
||||
IPCOM_LOG0(CRIT, "ip8021x_output_simsock called when not in sim mode");
|
||||
return IPCOM_ERR_NO_MEMORY;
|
||||
}
|
||||
ipcom_memcpy(buf, ctx->spa, 6);
|
||||
ipcom_memcpy(&buf[6], ctx->aa, 6);
|
||||
ipcom_memcpy(&buf[12], &pkt->buf[pkt->start], pkt->end-pkt->start);
|
||||
|
||||
|
||||
/* Copy over the destination address in a socket address structure. */
|
||||
ipcom_memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = IP_AF_INET;
|
||||
IPCOM_SA_LEN_SET(&addr, sizeof(struct Ip_sockaddr_in));
|
||||
addr.sin_addr.s_addr = ctx->simaddr.s_addr;
|
||||
addr.sin_port = ctx->simport;
|
||||
|
||||
/* Use sendto() to transmit the UDP packet. */
|
||||
#ifdef IP8021X_USE_DUMP_PACKET
|
||||
IPCOM_LOG0(DEBUG2, "ip8021x_output_simsock :: Sending packet:");
|
||||
ip8021x_dump_packet(buf, buflen, IP_FALSE);
|
||||
#endif
|
||||
rc = ipcom_sendto(ctx->sock, buf, (Ip_size_t)buf_len, 0, (IP_CONST struct Ip_sockaddr *)&addr, sizeof(addr));
|
||||
if (rc != buf_len)
|
||||
{
|
||||
Ip_socklen_t errlen;
|
||||
int so_errno;
|
||||
|
||||
errlen = sizeof(int);
|
||||
IPCOM_LOG3(ERR, "ip8021x_output_simsock() :: failed to send eapol packet, errno = %d, buf_len=%d, rc=%d",
|
||||
ipcom_errno, buf_len, rc);
|
||||
|
||||
/* Clear socket error */
|
||||
(void)ipcom_getsockopt(ctx->sock, IP_SOL_SOCKET, IP_SO_ERROR, &so_errno, &errlen);
|
||||
rc = IPCOM_ERR_FAILED;
|
||||
} else {
|
||||
rc = IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
if (buf)
|
||||
ipcom_free(buf);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_input_simsock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ip8021x_input_simsock(Ip8021x_ctx* ctx, Ip8021x_pkt* pkt, int len)
|
||||
{
|
||||
struct Ip_sockaddr_in from;
|
||||
Ip_socklen_t fromlen = sizeof(from);
|
||||
int rc;
|
||||
|
||||
if (!ctx->simtest) {
|
||||
IPCOM_LOG0(ERR, "ip8021x_input_simsock called when not in sim mode");
|
||||
return -1;
|
||||
}
|
||||
ip_assert(pkt->len - pkt->end >= len);
|
||||
|
||||
rc = ipcom_recvfrom(ctx->sock, &pkt->buf[pkt->end], len, 0, (struct Ip_sockaddr*) &from, &fromlen);
|
||||
if ((from.sin_addr.s_addr != ctx->simaddr.s_addr) || (from.sin_port != ctx->simport)){
|
||||
IPCOM_LOG2(ERR, "ip8021x_input_simsock :: Rcvd from unknown peer addr = %s, port = %d",
|
||||
ipcom_inet_ntoa(from.sin_addr), ip_ntohs(from.sin_port));
|
||||
return -1;
|
||||
}
|
||||
#ifdef IP8021X_USE_DUMP_PACKET
|
||||
if (rc > 0) {
|
||||
IPCOM_LOG0(DEBUG2, "ip8021x_input_simsock :: Received packet:");
|
||||
ip8021x_dump_packet(&pkt->buf[pkt->end], rc, IP_FALSE);
|
||||
}
|
||||
#endif
|
||||
if(rc < 12) {
|
||||
IPCOM_LOG1(ERR, "ip8021x_input_simsock :: Invalid packet len %d", rc);
|
||||
return -1; /* Just for now */
|
||||
}
|
||||
pkt->start+=12;
|
||||
pkt->end += rc;
|
||||
|
||||
return rc-12;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ioctl_simsock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ip8021x_ioctl_simsock(Ip8021x_ctx* ctx, unsigned long request, void* data)
|
||||
{
|
||||
|
||||
if (!ctx->simtest) {
|
||||
IPCOM_LOG0(ERR, "ip8021x_ioctl_simsock called when not in sim mode");
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG1(DEBUG2, "ip8021x_ioctl_simsock :: request %d", request);
|
||||
#endif
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_get_spa_simsock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ip8021x_get_spa_simsock(Ip8021x_ctx* ctx, Ip_u8* spa)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
Ip_fd sock;
|
||||
Ip_bool ok = IP_FALSE;
|
||||
Ip_u8 undef_eth_addr[6] = {1, 2, 3, 4, 5, 6};
|
||||
int i;
|
||||
|
||||
if (!ctx->simtest) {
|
||||
IPCOM_LOG0(ERR, "ip8021x_get_spa_simsock called when not in sim mode");
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
if (ctx->simif[0] == IP_NULL) {
|
||||
IPCOM_LOG0(ERR, "ip8021x_get_spa_simsock :: no simif");
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
sock = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, 0);
|
||||
if(sock == -1)
|
||||
{
|
||||
IP_PANIC();
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
ipcom_strcpy(ifreq.ifr_name, ctx->simif);
|
||||
for(i=0; i<100; i++)
|
||||
{
|
||||
if (ipcom_socketioctl(sock, IP_SIOCGIFLLADDR, (char *)&ifreq) < 0)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ip8021x_get_spa_simsock: ipcom_socketioctl(IP_SIOCGHWADDR): %d, if: %s", ipcom_errno, ctx->simif);
|
||||
ipcom_socketclose(sock);
|
||||
IP_PANIC();
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
/* On some OSs the WLAN driver sets the MAC addr once the device comes up, which can take some time */
|
||||
if(ipcom_memcmp(ifreq.ifr_ifru.ifru_addr.sa_data, undef_eth_addr, 6) != 0)
|
||||
{
|
||||
ok = IP_TRUE;
|
||||
break;
|
||||
}
|
||||
ipcom_millisleep(100);
|
||||
}
|
||||
if(!ok)
|
||||
return IPCOM_ERR_FAILED;
|
||||
|
||||
ipcom_memcpy(spa, ifreq.ifr_ifru.ifru_addr.sa_data, 6);
|
||||
ipcom_socketclose(sock);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_get_fd_simsock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_fd
|
||||
ip8021x_get_fd_simsock(struct Ip8021x_ctx_st* ctx)
|
||||
{
|
||||
if (!ctx->simtest) {
|
||||
IPCOM_LOG0(ERR, "ip8021x_get_fd_simsock called when not in sim mode");
|
||||
return IP_INVALID_SOCKET;
|
||||
}
|
||||
return ctx->sock;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ctx_simsock_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip8021x_funcs*
|
||||
ip8021x_ctx_simsock_init(Ip8021x_ctx* ctx)
|
||||
{
|
||||
struct Ip_sockaddr_in addr;
|
||||
|
||||
ctx->sock = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, 0);
|
||||
if (ctx->sock == IP_INVALID_SOCKET) {
|
||||
IPCOM_LOG1(ERR, "ip8021x_ctx_simsock_init :: failed to create UDP socket, errno = %d"IP_LF, ipcom_errno);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/* Bind socket to a local port. */
|
||||
ipcom_memset(&addr, 0, sizeof(addr));
|
||||
IPCOM_SA_LEN_SET(&addr, sizeof(struct Ip_sockaddr_in));
|
||||
addr.sin_family = IP_AF_INET;
|
||||
addr.sin_addr.s_addr = ip_htonl(IP_INADDR_ANY);
|
||||
addr.sin_port = ctx->simport;
|
||||
if (ipcom_bind(ctx->sock, (struct Ip_sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ip8021x_ctx_simsock_init :: failed to bind UDP socket, errno = %d"IP_LF, ipcom_errno);
|
||||
ipcom_socketclose(ctx->sock);
|
||||
ctx->sock = IP_INVALID_SOCKET;
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
return &Ip8021x_simsock_funcs;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_ctx_sock_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip8021x_funcs*
|
||||
ip8021x_ctx_sock_init(Ip8021x_ctx* ctx)
|
||||
{
|
||||
struct Ip_sockaddr_ll ll;
|
||||
|
||||
#ifdef IP8021X_SIM_SUPPORT
|
||||
if (ctx->simtest) {
|
||||
return ip8021x_ctx_simsock_init(ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(ctx->if_name[0] == 0)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "ip8021x_ctx_sock_init :: if_name not set");
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
ctx->sock = ipcom_socket(IP_PF_PACKET, IP_SOCK_RAW, ip_htons(IP8021X_ETH_P_EAPOL));
|
||||
if(ctx->sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ip8021x_ctx_sock_init :: ipcom_socket() failed, errno: %d\n", ipcom_errno);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
ipcom_memset(&ll, 0, sizeof(ll));
|
||||
ll.sll_family = IP_AF_PACKET;
|
||||
ll.sll_ifindex = ipcom_if_nametoindex(ctx->if_name);
|
||||
if(ll.sll_ifindex == 0)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ip8021x_ctx_sock_init: ipcom_if_nametoindex failed for %s", ctx->if_name);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
/* Bind raw socket to device */
|
||||
if (ipcom_setsockopt(ctx->sock, IP_SOL_SOCKET, IP_SO_BINDTODEVICE,
|
||||
ctx->if_name, IP_IFNAMSIZ) == IP_SOCKERR)
|
||||
{
|
||||
IPCOM_LOG3(ERR, "ip8021x_ctx_sock_init :: ipcom_setsockopt(bindtodevice,%s) failed : %s [%d]",
|
||||
ctx->if_name, ipcom_strerror(ipcom_errno), ipcom_errno);;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
return &Ip8021x_sock_funcs;
|
||||
|
||||
err_out:
|
||||
if(ctx->sock != IP_INVALID_SOCKET)
|
||||
{
|
||||
ipcom_socketclose(ctx->sock);
|
||||
ctx->sock = IP_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_sock.h,v $ $Revision: 1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_sock.h,v $
|
||||
* $Author: roger $ $Date: 2005-05-26 07:42:48 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPPRODUCT_H
|
||||
#define IPPRODUCT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipproduct_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_state_machine.c,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_state_machine.c,v $
|
||||
* $Author: myakan $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef IPSUPP_DEBUG
|
||||
Ip_bool ip8021x_sm_debug = IP_FALSE;
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_port_status_str
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL const char*
|
||||
ip8021x_port_status_str(int port_status)
|
||||
{
|
||||
switch(port_status)
|
||||
{
|
||||
case IP8021X_PORT_STATUS_AUTHORIZED:
|
||||
return "AUTHORIZED";
|
||||
case IP8021X_PORT_STATUS_UNAUTHORIZED:
|
||||
return "UNAUTHORIZED";
|
||||
default:
|
||||
IP_PANIC();
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_sm_state_str
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL const char*
|
||||
ip8021x_sm_state_str(int state)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case 0:
|
||||
return "UNDEFINED";
|
||||
case IP8021X_STATE_LOGOFF:
|
||||
return "LOGOFF";
|
||||
case IP8021X_STATE_DISCONNECTED:
|
||||
return "DISCONNECTED";
|
||||
case IP8021X_STATE_CONNECTING:
|
||||
return "CONNECTING";
|
||||
case IP8021X_STATE_ACQUIRED:
|
||||
return "ACQUIRED";
|
||||
case IP8021X_STATE_AUTHENTICATING:
|
||||
return "AUTHENTICATING";
|
||||
case IP8021X_STATE_HELD:
|
||||
return "HELD";
|
||||
case IP8021X_STATE_AUTHENTICATED:
|
||||
return "AUTHENTICATED";
|
||||
}
|
||||
|
||||
IP_PANIC();
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_tmo_cb
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_s32
|
||||
ip8021x_tmo_cb(struct Ipcom_tmo_struct *tmo, void *cookie)
|
||||
{
|
||||
Ip8021x_ctx *ctx;
|
||||
int rc;
|
||||
|
||||
(void)tmo;
|
||||
ctx = cookie;
|
||||
|
||||
ipcom_mutex_lock(ctx->mutex);
|
||||
rc = ip8021x_state_machine_tick(ctx, 1);
|
||||
ipcom_mutex_unlock(ctx->mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_enter_logoff
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_state_enter_logoff(Ip8021x_ctx* ctx)
|
||||
{
|
||||
ctx->sm.state = IP8021X_STATE_LOGOFF;
|
||||
ctx->sm.logoff_sent = IP_TRUE;
|
||||
ctx->port_status = IP8021X_PORT_STATUS_UNAUTHORIZED;
|
||||
(void)ip8021x_tx_eapol_logoff(ctx);
|
||||
ip8021x_state_enter_disconnected(ctx);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_enter_disconnected
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_state_enter_disconnected(Ip8021x_ctx* ctx)
|
||||
{
|
||||
ctx->sm.state = IP8021X_STATE_DISCONNECTED;
|
||||
ctx->port_status = IP8021X_PORT_STATUS_UNAUTHORIZED;
|
||||
ctx->sm.auth_while = 0;
|
||||
ctx->sm.held_while = 0;
|
||||
ctx->sm.start_while = 0;
|
||||
ctx->sm.start_count = 0;
|
||||
ctx->sm.logoff_sent = IP_FALSE;
|
||||
ipcom_memset(ctx->aa, 0, sizeof(ctx->aa));
|
||||
#ifdef IPEAP
|
||||
ipeap_reset_last_id(ctx->eap_ctx);
|
||||
|
||||
#endif
|
||||
if(IPCOM_TMO_PENDING(&ctx->tmo))
|
||||
(void)ipcom_tmo_cancel(&ctx->tmo);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_enter_acquired
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_state_enter_acquired(Ip8021x_ctx* ctx)
|
||||
{
|
||||
ctx->sm.state = IP8021X_STATE_ACQUIRED;
|
||||
ctx->sm.auth_while = ctx->sm.auth_period;
|
||||
ctx->sm.start_count = 0;
|
||||
ctx->sm.start_while = 0;
|
||||
ctx->sm.held_while = 0;
|
||||
if(!IPCOM_TMO_PENDING(&ctx->tmo))
|
||||
(void)ipcom_tmo_request(&ctx->tmo, ip8021x_tmo_cb, ctx, 1000);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_enter_authenticating
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_state_enter_authenticating(Ip8021x_ctx* ctx)
|
||||
{
|
||||
ctx->sm.state = IP8021X_STATE_AUTHENTICATING;
|
||||
ctx->sm.auth_while = ctx->sm.auth_period;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_enter_held
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_state_enter_held(Ip8021x_ctx* ctx)
|
||||
{
|
||||
ctx->sm.state = IP8021X_STATE_HELD;
|
||||
ctx->sm.held_while = ctx->sm.held_period;
|
||||
ctx->sm.start_count = 0;
|
||||
ctx->sm.start_while = 0;
|
||||
ctx->sm.auth_while = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_enter_connecting
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_state_enter_connecting(Ip8021x_ctx* ctx)
|
||||
{
|
||||
ctx->sm.state = IP8021X_STATE_CONNECTING;
|
||||
ctx->sm.start_while = ctx->sm.start_period;
|
||||
ctx->sm.start_count++;
|
||||
ctx->sm.auth_while = 0;
|
||||
ctx->sm.held_while = 0;
|
||||
ipcom_memset(ctx->aa, 0, sizeof(ctx->aa));
|
||||
(void)ip8021x_tx_eapol_start(ctx);
|
||||
if(!IPCOM_TMO_PENDING(&ctx->tmo))
|
||||
(void)ipcom_tmo_request(&ctx->tmo, ip8021x_tmo_cb, ctx, 1000);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_enter_authenticated
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_state_enter_authenticated(Ip8021x_ctx* ctx)
|
||||
{
|
||||
ctx->port_status = IP8021X_PORT_STATUS_AUTHORIZED;
|
||||
ctx->sm.state = IP8021X_STATE_AUTHENTICATED;
|
||||
ctx->sm.start_while = 0;
|
||||
ctx->sm.auth_while = 0;
|
||||
ctx->sm.held_while = 0;
|
||||
if(IPCOM_TMO_PENDING(&ctx->tmo))
|
||||
(void)ipcom_tmo_cancel(&ctx->tmo);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_state_machine_tick
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ip8021x_state_machine_tick(Ip8021x_ctx* ctx, int seconds)
|
||||
{
|
||||
ip_assert(ctx->sm.max_start > 0);
|
||||
ip_assert(ctx->sm.auth_while >= 0);
|
||||
ip_assert(ctx->sm.held_while >= 0);
|
||||
ip_assert(ctx->sm.start_while >= 0);
|
||||
|
||||
if(ctx->sm.auth_while > 0)
|
||||
{
|
||||
if(seconds < ctx->sm.auth_while)
|
||||
ctx->sm.auth_while -= seconds;
|
||||
else
|
||||
{
|
||||
ctx->sm.auth_while = 0;
|
||||
ip8021x_state_enter_connecting(ctx);
|
||||
}
|
||||
}
|
||||
if(ctx->sm.held_while > 0)
|
||||
{
|
||||
if(seconds < ctx->sm.held_while)
|
||||
ctx->sm.held_while -= seconds;
|
||||
else
|
||||
{
|
||||
ctx->sm.held_while = 0;
|
||||
ip8021x_state_enter_connecting(ctx);
|
||||
}
|
||||
}
|
||||
if(ctx->sm.start_while > 0)
|
||||
{
|
||||
if(seconds < ctx->sm.start_while)
|
||||
ctx->sm.start_while -= seconds;
|
||||
else
|
||||
{
|
||||
ctx->sm.start_while = 0;
|
||||
if(ctx->sm.start_count >= ctx->sm.max_start)
|
||||
ip8021x_state_enter_authenticated(ctx);
|
||||
else
|
||||
ip8021x_state_enter_connecting(ctx);
|
||||
}
|
||||
}
|
||||
#ifdef IPSUPP_DEBUG
|
||||
if (ip8021x_sm_debug)
|
||||
IPCOM_LOG5(DEBUG2, "State machine: state: %s, auth_while: %d, held_while %d, start_while %d, start count: %d",
|
||||
ip8021x_sm_state_str(ctx->sm.state), ctx->sm.auth_while, ctx->sm.held_while,
|
||||
ctx->sm.start_while, ctx->sm.start_count);
|
||||
#endif
|
||||
|
||||
if(IPCOM_TMO_PENDING(&ctx->tmo) /* Timer already set? */
|
||||
|| (ctx->sm.auth_while == 0 && ctx->sm.held_while == 0 && ctx->sm.start_while == 0)) /* No timers set? */
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_state_machine.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_state_machine.h,v $
|
||||
* $Author: myakan $ $Date: 2008-03-03 23:06:16 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP8021X_STATE_MACHINE_H
|
||||
#define IP8021X_STATE_MACHINE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Forward declarations */
|
||||
struct Ip8021x_ctx_st;
|
||||
|
||||
struct Ip8021x_state_machine_st
|
||||
{
|
||||
int state; /* Supplicant state */
|
||||
|
||||
/* Timers */
|
||||
int auth_while;
|
||||
int held_while;
|
||||
int start_while;
|
||||
|
||||
/* Initial values of timers */
|
||||
int auth_period;
|
||||
int held_period;
|
||||
int start_period;
|
||||
|
||||
int max_start;
|
||||
int start_count;
|
||||
|
||||
Ip_bool user_logoff;
|
||||
Ip_bool logoff_sent;
|
||||
};
|
||||
typedef struct Ip8021x_state_machine_st Ip8021x_state_machine;
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ip8021x_state_enter_logoff(struct Ip8021x_ctx_st* ctx);
|
||||
IP_GLOBAL void ip8021x_state_enter_disconnected(struct Ip8021x_ctx_st* ctx);
|
||||
IP_GLOBAL void ip8021x_state_enter_acquired(struct Ip8021x_ctx_st* ctx);
|
||||
IP_GLOBAL void ip8021x_state_enter_authenticating(struct Ip8021x_ctx_st* ctx);
|
||||
IP_GLOBAL void ip8021x_state_enter_held(struct Ip8021x_ctx_st* ctx);
|
||||
IP_GLOBAL void ip8021x_state_enter_connecting(struct Ip8021x_ctx_st* ctx);
|
||||
IP_GLOBAL void ip8021x_state_enter_authenticated(struct Ip8021x_ctx_st* ctx);
|
||||
IP_GLOBAL int ip8021x_state_machine_tick(struct Ip8021x_ctx_st* ctx, int seconds);
|
||||
IP_GLOBAL Ip_s32 ip8021x_tmo_cb(struct Ipcom_tmo_struct *tmo, void *cookie);
|
||||
IP_GLOBAL const char* ip8021x_sm_state_str(int state);
|
||||
IP_GLOBAL const char* ip8021x_port_status_str(int port_status);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,319 @@
|
||||
/* ip8021x_supp_legacy_api.c - 802.1X LEGACY SUPPLICANT API SUPPORT */
|
||||
|
||||
/* Copyright 2008 Wind River Systems, Inc. */
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_ipd.h>
|
||||
|
||||
#include "ip8021x_supp_legacy_api.h"
|
||||
#include "ip8021x_h.h"
|
||||
|
||||
#define DOT1X_ASSERT(val,msg,retfail) { \
|
||||
if (!(val)) { \
|
||||
IPCOM_LOG0(ERR, msg); \
|
||||
return (retfail); \
|
||||
} \
|
||||
}
|
||||
#define DOT1X_MODE_ASSERT(val) DOT1X_ASSERT((val), "INVALID MODE", -1)
|
||||
|
||||
#define DOT1X_SYSVARSET(sysvar,val,retfail) { \
|
||||
if (ipcom_sysvar_set((sysvar), (val), IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) { \
|
||||
IPCOM_LOG1(CRIT, "Failed to change %s sysvar", (sysvar)); \
|
||||
return (retfail); \
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xSuppIdGet
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC int dot1xSuppIdGet(char *name, int unit) {
|
||||
static char idlist[(IP_IFNAMSIZ+8)*IP8021X_MAX_SUPPS];
|
||||
Ip_size_t len = sizeof(idlist);
|
||||
char if_name[IP_IFNAMSIZ];
|
||||
Ip_u32 namelen;
|
||||
int inst = -1;
|
||||
char *token;
|
||||
|
||||
DOT1X_ASSERT(name, "dot1xSuppIdGet :: INVALID ARGUMENT", -1);
|
||||
|
||||
if (ipcom_snprintf(if_name, sizeof(if_name), "%s%d", name, unit) < 0) {
|
||||
IPCOM_LOG0(ERR, "dot1xSuppIdGet :: sprintf failure");
|
||||
return -1;
|
||||
}
|
||||
namelen = ipcom_strlen(if_name);
|
||||
|
||||
if (!ipcom_sysvar_get("ip8021x.ids", idlist, &len)) {
|
||||
IPCOM_LOG0(ERR, "dot1xSuppIdGet :: failed to retrieve idlist sysvar");
|
||||
return -1;
|
||||
}
|
||||
token = ipcom_strtok(idlist, ",");
|
||||
while (token)
|
||||
{
|
||||
if ((ipcom_strncmp(token, if_name, namelen) == 0) &&
|
||||
(token[namelen] == '.')) {
|
||||
inst = ipcom_atoi(&token[namelen+1]);
|
||||
if (inst < IP8021X_MAX_SUPPS) {
|
||||
break;
|
||||
} else {
|
||||
inst = -1;
|
||||
}
|
||||
}
|
||||
token = ipcom_strtok(IP_NULL, ",");
|
||||
}
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xSuppCreate
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC int dot1xSuppCreate(int unit, char * pDevName, int mode) {
|
||||
char if_name[IP_IFNAMSIZ];
|
||||
|
||||
if (pDevName == IP_NULL) {
|
||||
IPCOM_LOG0(ERR, "dot1xSuppIdGet :: INVALID devname argument");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ipcom_snprintf(if_name, sizeof(if_name), "%s%d", pDevName, unit) < 0) {
|
||||
IPCOM_LOG0(ERR, "dot1xSuppIdGet :: sprintf failure");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Enforce valid combinations */
|
||||
DOT1X_MODE_ASSERT((DOT1X_MODE_TYPE(mode) == DOT1X_MODE_WIRELINE) || (DOT1X_MODE_TYPE(mode) == DOT1X_MODE_WIRELESS));
|
||||
if ((DOT1X_MODE_TYPE(mode) == DOT1X_MODE_WIRELESS)) {
|
||||
DOT1X_MODE_ASSERT((DOT1X_MODE_ENCRTYPE(mode) == 0) || (DOT1X_MODE_ENCRTYPE(mode) == DOT1X_MODE_ENCRTYPE_TKIP) ||
|
||||
(DOT1X_MODE_ENCRTYPE(mode) == DOT1X_MODE_ENCRTYPE_CCMP));
|
||||
DOT1X_MODE_ASSERT((DOT1X_MODE_AUTHTYPE(mode) == 0) ||
|
||||
(DOT1X_MODE_AUTHTYPE(mode) == DOT1X_MODE_AUTHTYPE_WPA) || (DOT1X_MODE_AUTHTYPE(mode) == DOT1X_MODE_AUTHTYPE_WPA_PSK) ||
|
||||
(DOT1X_MODE_AUTHTYPE(mode) == DOT1X_MODE_AUTHTYPE_WPA2) || (DOT1X_MODE_AUTHTYPE(mode) == DOT1X_MODE_AUTHTYPE_WPA2_PSK));
|
||||
}
|
||||
|
||||
/* Set the sysvars */
|
||||
DOT1X_SYSVARSET("ip8021x.if_name", if_name, -1);
|
||||
|
||||
if (DOT1X_MODE_TYPE(mode) == DOT1X_MODE_WIRELINE) {
|
||||
DOT1X_SYSVARSET("ip8021x.auth_type", "wired", -1);
|
||||
} else {
|
||||
switch (DOT1X_MODE_ENCRTYPE(mode)) {
|
||||
case DOT1X_MODE_ENCRTYPE_TKIP:
|
||||
DOT1X_SYSVARSET("ip8021x.encr_type", "tkip", -1);
|
||||
break;
|
||||
case DOT1X_MODE_ENCRTYPE_CCMP:
|
||||
DOT1X_SYSVARSET("ip8021x.encr_type", "ccmp", -1);
|
||||
break;
|
||||
default:
|
||||
/* do nothing (use existing sysvar value). The asserts should have caught invalid values */
|
||||
break;
|
||||
}
|
||||
|
||||
switch (DOT1X_MODE_AUTHTYPE(mode)) {
|
||||
case DOT1X_MODE_AUTHTYPE_WPA:
|
||||
DOT1X_SYSVARSET("ip8021x.auth_type", "wpa", -1);
|
||||
break;
|
||||
case DOT1X_MODE_AUTHTYPE_WPA_PSK:
|
||||
DOT1X_SYSVARSET("ip8021x.auth_type", "wpa-psk", -1);
|
||||
break;
|
||||
case DOT1X_MODE_AUTHTYPE_WPA2:
|
||||
DOT1X_SYSVARSET("ip8021x.auth_type", "wpa2", -1);
|
||||
break;
|
||||
case DOT1X_MODE_AUTHTYPE_WPA2_PSK:
|
||||
DOT1X_SYSVARSET("ip8021x.auth_type", "wpa2-psk", -1);
|
||||
break;
|
||||
default:
|
||||
/* do nothing (use existing sysvar value). The asserts should have caught invalid values */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the new supp with the newly configured sysvars */
|
||||
if (ipcom_ipd_send(IP8021X_PROCESS_NAME, IP8021X_IPD_EVENT_ADD) != IPCOM_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* reconfig the ip8021x Process to init the new supp */
|
||||
if (ipcom_ipd_send(IP8021X_PROCESS_NAME, IPCOM_IPD_MSGTYPE_RECONFIGURE) != IPCOM_SUCCESS) {
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Now retrieve the id of the newly created supp */
|
||||
return dot1xSuppIdGet(pDevName, unit);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xSuppDelete
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppDelete(int suppId) {
|
||||
if (suppId >= IP8021X_MAX_SUPPS) {
|
||||
IPCOM_LOG1(ERR, "dot1xSuppDelete :: INVALID suppId", suppId);
|
||||
return ERROR;
|
||||
}
|
||||
if (ipcom_ipd_send(IP8021X_PROCESS_NAME, IP8021X_ENCODE_SUPP_INSTANCE(IP8021X_IPD_EVENT_DELETE, suppId)) != IPCOM_SUCCESS) {
|
||||
return ERROR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xSuppConnect
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppConnect(int suppId) {
|
||||
if (suppId >= IP8021X_MAX_SUPPS) {
|
||||
IPCOM_LOG1(ERR, "dot1xSuppConnect :: INVALID suppId", suppId);
|
||||
return ERROR;
|
||||
}
|
||||
if (ipcom_ipd_send(IP8021X_PROCESS_NAME, IP8021X_ENCODE_SUPP_INSTANCE(IP8021X_IPD_EVENT_CONNECT, suppId)) != IPCOM_SUCCESS) {
|
||||
return ERROR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xSuppShutdownAll
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppShutdownAll(void) {
|
||||
if (ipcom_ipd_send(IP8021X_PROCESS_NAME, IPCOM_IPD_MSGTYPE_KILL) != IPCOM_SUCCESS) {
|
||||
return ERROR;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xSuppShow
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xSuppShow(BOOL verbose) {
|
||||
static char idlist[(IP_IFNAMSIZ+8)*IP8021X_MAX_SUPPS];
|
||||
char *token[IP8021X_MAX_SUPPS+1];
|
||||
char *if_name;
|
||||
Ip_u32 namelen;
|
||||
Ip_size_t len = sizeof(idlist);
|
||||
int i, j, inst = -1;
|
||||
|
||||
if (!verbose)
|
||||
{
|
||||
if (ipcom_ipd_send(IP8021X_PROCESS_NAME, IP8021X_IPD_EVENT_LIST) != IPCOM_SUCCESS)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ipcom_sysvar_get("ip8021x.ids", idlist, &len))
|
||||
{
|
||||
IPCOM_LOG0(ERR, "dot1xSuppIdGet :: failed to retrieve idlist sysvar");
|
||||
return ERROR;
|
||||
}
|
||||
token[0] = ipcom_strtok(idlist, ",");
|
||||
i = 0;
|
||||
for (i = 0; i < IP8021X_MAX_SUPPS;)
|
||||
{
|
||||
if (!token[i])
|
||||
break;
|
||||
token[++i] = ipcom_strtok(IP_NULL, ",");
|
||||
}
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
len = strlen(token[j]);
|
||||
if_name = ipcom_strtok(token[j], ".");
|
||||
if (!if_name) {
|
||||
IPCOM_LOG0(ERR, "dot1xSuppIdGet :: INVALID idlist sysvar");
|
||||
return ERROR;
|
||||
}
|
||||
namelen = strlen(if_name);
|
||||
if (len > (namelen + 1)) {
|
||||
inst = ipcom_atoi(&(token[j][namelen+1]));
|
||||
ipcom_ipd_send(IP8021X_PROCESS_NAME, IP8021X_ENCODE_SUPP_INSTANCE(IP8021X_IPD_EVENT_GETSTATUS, inst));
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xSuppGtcUserInput
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* This routine is used to enter the GTC users current tokencode, passcode,
|
||||
* or password. It is a legacy API alternative to using "cmd ip8021x eapcr".
|
||||
*
|
||||
* Parameters:
|
||||
* int devId: supplicant device ID
|
||||
* char * pUserInput: the user's token
|
||||
*
|
||||
* Returns: OK or ERROR
|
||||
*
|
||||
*/
|
||||
|
||||
STATUS dot1xSuppGtcUserInput(int suppId, char * pUserInput) {
|
||||
Ip_u32 instance = suppId;
|
||||
if (!pUserInput) {
|
||||
return ERROR;
|
||||
}
|
||||
if (instance >= IP8021X_MAX_SUPPS) {
|
||||
return ERROR;
|
||||
}
|
||||
if (ipcom_sysvar_set("ip8021x.eap_challenge_response", pUserInput, IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS) {
|
||||
IPCOM_LOG0(CRIT, "Failed to change ip8021x.eap_challenge_response sysvar");
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
return ((ipcom_ipd_send(IP8021X_PROCESS_NAME, IP8021X_ENCODE_SUPP_INSTANCE(IP8021X_IPD_EVENT_EAPCR, instance)) == IPCOM_SUCCESS) ? OK : ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* dot1xLegacyApiList
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC STATUS dot1xLegacyApiList(void) {
|
||||
ipcom_printf("int dot1xSuppIdGet(char *name, int unit)\n");
|
||||
ipcom_printf("int dot1xSuppCreate(int unit, char * pDevName, int mode)\n");
|
||||
ipcom_printf("STATUS dot1xSuppDelete(int suppId)\n");
|
||||
ipcom_printf("STATUS dot1xSuppConnect(int suppId)\n");
|
||||
ipcom_printf("STATUS dot1xSuppShutdownAll(void)\n");
|
||||
ipcom_printf("STATUS dot1xSuppShow(BOOL verbose)\n");
|
||||
ipcom_printf("STATUS dot1xSuppGtcUserInput(int suppId, char * pUserInput)\n");
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,557 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_wpa_ie.c,v $ $Revision: 1.12.28.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_wpa_ie.c,v $
|
||||
* $Author: hxu4 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_err.h>
|
||||
#ifdef IPPRISM
|
||||
#include <ipcom_ipwlan.h>
|
||||
#else
|
||||
#include <ipwlan_wlan.h>
|
||||
#endif
|
||||
|
||||
#include "ip8021x.h"
|
||||
#include "ip8021x_h.h"
|
||||
#include "ip8021x_wpa_ie.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
Ip_u8 ip8021x_wpa_ie_oui[4] = { 0x00, 0x50, 0xf2, 0x01 };
|
||||
|
||||
Ip_u8 ip8021x_wpa_ie_tkip[4] = { 0x00, 0x50, 0xf2, 0x02 };
|
||||
|
||||
Ip_u8 ip8021x_wpa_ie_ccmp[4] = { 0x00, 0x50, 0xf2, 0x04 };
|
||||
|
||||
Ip_u8 ip8021x_wpa_ie_wpa[4] = { 0x00, 0x50, 0xf2, 0x01 };
|
||||
|
||||
Ip_u8 ip8021x_wpa_ie_psk[4] = { 0x00, 0x50, 0xf2, 0x02 };
|
||||
|
||||
|
||||
Ip_u8 ip8021x_wpa2_ie_tkip[4] = { 0x00, 0x0f, 0xac, 0x02 };
|
||||
|
||||
Ip_u8 ip8021x_wpa2_ie_ccmp[4] = { 0x00, 0x0f, 0xac, 0x04 };
|
||||
|
||||
Ip_u8 ip8021x_wpa2_ie_wpa[4] = { 0x00, 0x0f, 0xac, 0x01 };
|
||||
|
||||
Ip_u8 ip8021x_wpa2_ie_psk[4] = { 0x00, 0x0f, 0xac, 0x02 };
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err
|
||||
ip8021x_pkt_put_wpa_ie(Ip8021x_pkt* pkt, Ip8021x_wpa_ie* wpa_ie)
|
||||
{
|
||||
int space_left;
|
||||
int wpa_ie_size;
|
||||
Ip_u8* ptr;
|
||||
|
||||
ip_assert(wpa_ie->wpa_ver == 1 || wpa_ie->wpa_ver == 2);
|
||||
|
||||
space_left = pkt->len-pkt->end;
|
||||
wpa_ie_size = 1+1+4+2+4+2+(wpa_ie->pairwise_cipher_suite_len)*4+2
|
||||
+(wpa_ie->auth_key_mgnt_len)*4;
|
||||
if(wpa_ie->wpa_ver == 2)
|
||||
wpa_ie_size += -4+2; /* WPA2 IEs has no OUI field (-4) but wpa cap field (+2) */
|
||||
|
||||
/* is packet large enough to hold wpa_ie? */
|
||||
if(space_left<wpa_ie_size)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ip8021x_pkt_put_wpa_ie :: packet too small to hold wpa_ie, pkt size: %d, wpa_ie size: %d",
|
||||
space_left, wpa_ie_size);
|
||||
return IPCOM_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Is wpa_ie a valid information element? */
|
||||
if(wpa_ie->pairwise_cipher_suite_len<=0 || wpa_ie->auth_key_mgnt_len<=0)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ip8021x_pkt_put_wpa_ie :: invalid wpa_ie: cipher_len: %d, akm_len: %d",
|
||||
wpa_ie->pairwise_cipher_suite_len, wpa_ie->auth_key_mgnt_len);
|
||||
return IPCOM_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ptr = &pkt->buf[pkt->end];
|
||||
|
||||
*ptr++ = wpa_ie->id;
|
||||
*ptr++ = (Ip_u8)wpa_ie_size-2; /* id and length fields not included wpa ie length count */
|
||||
/* oui, version and group cipher fields */
|
||||
if(wpa_ie->wpa_ver == 1)
|
||||
{
|
||||
ipcom_memcpy(ptr, wpa_ie->oui, sizeof(wpa_ie->oui));
|
||||
ptr += sizeof(wpa_ie->oui);
|
||||
}
|
||||
ipcom_memcpy(ptr, wpa_ie->version, sizeof(wpa_ie->version));
|
||||
ptr += sizeof(wpa_ie->version);
|
||||
ipcom_memcpy(ptr, wpa_ie->grp_cipher_suite, sizeof(wpa_ie->grp_cipher_suite));
|
||||
ptr += sizeof(wpa_ie->grp_cipher_suite);
|
||||
*ptr++ = (Ip_u8)wpa_ie->pairwise_cipher_suite_len;
|
||||
*ptr++ = 0;
|
||||
ipcom_memcpy(ptr, wpa_ie->pairwise_cipher_suite, (wpa_ie->pairwise_cipher_suite_len)*4);
|
||||
ptr += 4*wpa_ie->pairwise_cipher_suite_len;
|
||||
*ptr++ = (Ip_u8)wpa_ie->auth_key_mgnt_len;
|
||||
*ptr++ = 0;
|
||||
ipcom_memcpy(ptr, wpa_ie->auth_key_mgnt, 4*(wpa_ie->auth_key_mgnt_len));
|
||||
ptr += 4*wpa_ie->auth_key_mgnt_len;
|
||||
if(wpa_ie->wpa_ver == 2)
|
||||
{
|
||||
IP_SET_HTONS(ptr, wpa_ie->wpa_cap);
|
||||
ptr += 2;
|
||||
}
|
||||
|
||||
pkt->end += wpa_ie_size;
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa_ie_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_wpa_ie_init(Ip8021x_wpa_ie* wpa_ie, int uni_encr_type, int multi_encr_type, int auth_key_mgnt, Ip_u16 rsn_cap)
|
||||
{
|
||||
ipcom_memset(wpa_ie, 0, sizeof(Ip8021x_wpa_ie));
|
||||
|
||||
switch (auth_key_mgnt)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
case IP_IW_AUTH_ALG_WPA_PSK:
|
||||
case IP_IW_AUTH_ALG_WPA:
|
||||
wpa_ie->wpa_ver = 1;
|
||||
wpa_ie->id = IP8021X_IE_ELEMENT_ID_WPA;
|
||||
ipcom_memcpy(wpa_ie->oui, ip8021x_wpa_ie_oui, sizeof(ip8021x_wpa_ie_oui));
|
||||
ip8021x_wpa_ie_set_encr(wpa_ie, uni_encr_type, multi_encr_type);
|
||||
wpa_ie->wpa_cap = 0x2a00;
|
||||
break;
|
||||
|
||||
case IP_IW_AUTH_ALG_WPA2_PSK:
|
||||
case IP_IW_AUTH_ALG_WPA2:
|
||||
wpa_ie->wpa_ver = 2;
|
||||
wpa_ie->id = IP8021X_IE_ELEMENT_ID_RSN;
|
||||
ip8021x_wpa2_ie_set_encr(wpa_ie, uni_encr_type, multi_encr_type);
|
||||
IP_SET_16HI8(wpa_ie->wpa_cap, IP_GET_16LO8(rsn_cap));
|
||||
IP_SET_16LO8(wpa_ie->wpa_cap, IP_GET_16HI8(rsn_cap));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
ip8021x_wpa_ie_set_auth_key_mgnt(wpa_ie, auth_key_mgnt);
|
||||
wpa_ie->version[0] = 1;
|
||||
wpa_ie->version[1] = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa_ie_set_auth_key_mgnt
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_wpa_ie_set_auth_key_mgnt(Ip8021x_wpa_ie* wpa_ie, int auth_key_mgnt)
|
||||
{
|
||||
|
||||
switch(auth_key_mgnt)
|
||||
{
|
||||
case IP_IW_AUTH_ALG_WPA_PSK:
|
||||
ipcom_memcpy(wpa_ie->auth_key_mgnt, ip8021x_wpa_ie_psk, sizeof(ip8021x_wpa_ie_psk));
|
||||
break;
|
||||
|
||||
case IP_IW_AUTH_ALG_WPA:
|
||||
ipcom_memcpy(wpa_ie->auth_key_mgnt, ip8021x_wpa_ie_wpa, sizeof(ip8021x_wpa_ie_wpa));
|
||||
break;
|
||||
|
||||
case IP_IW_AUTH_ALG_WPA2_PSK:
|
||||
ipcom_memcpy(wpa_ie->auth_key_mgnt, ip8021x_wpa2_ie_psk, sizeof(ip8021x_wpa_ie_psk));
|
||||
break;
|
||||
|
||||
case IP_IW_AUTH_ALG_WPA2:
|
||||
ipcom_memcpy(wpa_ie->auth_key_mgnt, ip8021x_wpa2_ie_wpa, sizeof(ip8021x_wpa_ie_wpa));
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
wpa_ie->auth_key_mgnt_len = 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa_ie_set_pairwise_encr
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_wpa_ie_set_encr(Ip8021x_wpa_ie* wpa_ie, int uni_encr_type, int multi_encr_type)
|
||||
{
|
||||
wpa_ie->pairwise_cipher_suite_len = 1;
|
||||
|
||||
switch(uni_encr_type)
|
||||
{
|
||||
case IP_IW_ENCR_ALG_TKIP:
|
||||
ipcom_memcpy(wpa_ie->pairwise_cipher_suite, ip8021x_wpa_ie_tkip, sizeof(ip8021x_wpa_ie_tkip));
|
||||
break;
|
||||
|
||||
case IP_IW_ENCR_ALG_CCMP:
|
||||
ipcom_memcpy(wpa_ie->pairwise_cipher_suite, ip8021x_wpa_ie_ccmp, sizeof(ip8021x_wpa_ie_ccmp));
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
|
||||
switch(multi_encr_type)
|
||||
{
|
||||
case IP_IW_ENCR_ALG_TKIP:
|
||||
ipcom_memcpy(wpa_ie->grp_cipher_suite, ip8021x_wpa_ie_tkip, sizeof(ip8021x_wpa_ie_tkip));
|
||||
wpa_ie->multicast_encr_type = IP_IW_ENCR_ALG_TKIP;
|
||||
break;
|
||||
|
||||
case IP_IW_ENCR_ALG_CCMP:
|
||||
ipcom_memcpy(wpa_ie->grp_cipher_suite, ip8021x_wpa_ie_ccmp, sizeof(ip8021x_wpa_ie_ccmp));
|
||||
wpa_ie->multicast_encr_type = IP_IW_ENCR_ALG_CCMP;
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_wpa2_ie_set_encr
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ip8021x_wpa2_ie_set_encr(Ip8021x_wpa_ie* wpa_ie, int uni_encr_type, int multi_encr_type)
|
||||
{
|
||||
wpa_ie->pairwise_cipher_suite_len = 1;
|
||||
|
||||
switch(uni_encr_type)
|
||||
{
|
||||
case IP_IW_ENCR_ALG_TKIP:
|
||||
ipcom_memcpy(wpa_ie->pairwise_cipher_suite, ip8021x_wpa2_ie_tkip, sizeof(ip8021x_wpa2_ie_tkip));
|
||||
break;
|
||||
|
||||
case IP_IW_ENCR_ALG_CCMP:
|
||||
ipcom_memcpy(wpa_ie->pairwise_cipher_suite, ip8021x_wpa2_ie_ccmp, sizeof(ip8021x_wpa2_ie_ccmp));
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
|
||||
switch(multi_encr_type)
|
||||
{
|
||||
case IP_IW_ENCR_ALG_TKIP:
|
||||
ipcom_memcpy(wpa_ie->grp_cipher_suite, ip8021x_wpa2_ie_tkip, sizeof(ip8021x_wpa2_ie_tkip));
|
||||
wpa_ie->multicast_encr_type = IP_IW_ENCR_ALG_TKIP;
|
||||
break;
|
||||
|
||||
case IP_IW_ENCR_ALG_CCMP:
|
||||
ipcom_memcpy(wpa_ie->grp_cipher_suite, ip8021x_wpa2_ie_ccmp, sizeof(ip8021x_wpa2_ie_ccmp));
|
||||
wpa_ie->multicast_encr_type = IP_IW_ENCR_ALG_CCMP;
|
||||
break;
|
||||
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ip8021x_verify_wpa_ie
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool
|
||||
ip8021x_verify_wpa_ie(Ip_u8* pIe, Ip8021x_wpa_ie* wpa_ie, int *multicast_encr_type) {
|
||||
Ip_u8* ptr = pIe;
|
||||
Ip_u8 i, ie_len, min_len;
|
||||
Ip_u16 num_uni_suites, num_mgmt_suites;
|
||||
Ip_u8 grp_cipher_suite[4];
|
||||
Ip_bool match = IP_FALSE, tkip_found = IP_FALSE;
|
||||
int wpa_ver; /* WPA version of the received IE (WPA or WPA2) */
|
||||
|
||||
/* Verify WPA/WPA2 IE Id */
|
||||
if ((*ptr != IP8021X_IE_ELEMENT_ID_WPA) && (*ptr != IP8021X_IE_ELEMENT_ID_RSN)){
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG3(ERR, "Invalid WPA IE id %d (expected %d or %d)", *ptr, IP8021X_IE_ELEMENT_ID_WPA, IP8021X_IE_ELEMENT_ID_RSN);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
wpa_ver = ((*ptr == IP8021X_IE_ELEMENT_ID_WPA) ? 1 : 2);
|
||||
ptr++;
|
||||
|
||||
/* Verify WPA/WPA2 IE min length */
|
||||
if (wpa_ver == 1) {
|
||||
/* WPA(22) = OUI(4) + VER(2) + MULTI_CIPH(4) + UNI_CIPH_NUM(2) + UNI_CIPH(4) + AUTH_KEY_MGMT_NUM(2) + AUTH_KEY_MGMT(4)*/
|
||||
min_len = sizeof(wpa_ie->oui) + sizeof(wpa_ie->version) + sizeof(wpa_ie->grp_cipher_suite) +
|
||||
sizeof(wpa_ie->pairwise_cipher_suite_len) + sizeof(wpa_ie->pairwise_cipher_suite[0]) +
|
||||
sizeof(wpa_ie->auth_key_mgnt_len) + sizeof(wpa_ie->auth_key_mgnt[0]);
|
||||
} else {
|
||||
/* WPA2(20) = VER(2) + MULTI_CIPH(4) + UNI_CIPH_NUM(2) + UNI_CIPH(4) + AUTH_KEY_MGMT_NUM(2) + AUTH_KEY_MGMT(4) + RSN_CAP(2)*/
|
||||
min_len = sizeof(wpa_ie->version) + sizeof(wpa_ie->grp_cipher_suite) +
|
||||
sizeof(wpa_ie->pairwise_cipher_suite_len) + sizeof(wpa_ie->pairwise_cipher_suite[0]) +
|
||||
sizeof(wpa_ie->auth_key_mgnt_len) + sizeof(wpa_ie->auth_key_mgnt[0]) + sizeof(wpa_ie->wpa_cap);
|
||||
}
|
||||
|
||||
ie_len = *ptr;
|
||||
if (ie_len < min_len) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG2(ERR, "Invalid WPA IE len %d (expected >= %d)", ie_len, min_len);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
/* Verify WPA IE OUI */
|
||||
if (wpa_ver == 1) {
|
||||
if (ipcom_memcmp(ptr, wpa_ie->oui, sizeof(wpa_ie->oui)) != 0) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG8(ERR, "WPA IE OUI mismatch %.2x %.2x %.2x %.2x (expected %.2x %.2x %.2x %.2x)",
|
||||
ptr[0], ptr[1], ptr[2], ptr[3], wpa_ie->oui[0], wpa_ie->oui[1], wpa_ie->oui[2], wpa_ie->oui[3]);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
ptr += sizeof(wpa_ie->oui);
|
||||
}
|
||||
|
||||
/* Verify WPA/WPA2 IE version (always 1 anyway) */
|
||||
if (ipcom_memcmp(ptr, &wpa_ie->version, sizeof(wpa_ie->version)) != 0) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG4(ERR, "WPA IE version mismatch %.2x %.2x (expected %.2x %.2x)",
|
||||
ptr[0], ptr[1], wpa_ie->version[0], wpa_ie->version[1]);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
ptr += sizeof(wpa_ie->version);
|
||||
|
||||
/* Delay verification of WPA/WPA2 IE multicast cipher suite until we know which unicast suites are indicated */
|
||||
*multicast_encr_type = wpa_ie->multicast_encr_type;
|
||||
ipcom_memcpy(grp_cipher_suite, ptr, sizeof(grp_cipher_suite));
|
||||
ptr += sizeof(grp_cipher_suite);
|
||||
|
||||
|
||||
/* Verify WPA/WPA2 IE # of unicast suites */
|
||||
num_uni_suites = *ptr;
|
||||
if (!num_uni_suites || (num_uni_suites > IP8021X_MAX_CIPHERS)) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG2(ERR, "Too many Unicast cipher suites %d (max %d)", num_uni_suites, IP8021X_MAX_CIPHERS);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
ptr+=2;
|
||||
|
||||
|
||||
/* Re-verify WPA/WPA2 IE length based on # of cipher suites */
|
||||
min_len += (num_uni_suites-1)*sizeof(wpa_ie->pairwise_cipher_suite[0]);
|
||||
if (ie_len < min_len) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG2(ERR, "Invalid WPA IE len %d (expected >= %d)", ie_len, min_len);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* Verify WPA/WPA2 IE Unicast Cipher Suites. Just find one that matches what we support */
|
||||
for (i=0, match = IP_FALSE; i < num_uni_suites; i++) {
|
||||
/* We only support 1 ciph suite in wpa_ie so do a simple comparison */
|
||||
if (ipcom_memcmp(ptr, &wpa_ie->pairwise_cipher_suite[0], 4) == 0)
|
||||
match = IP_TRUE;
|
||||
if ((wpa_ver == 1) && (ipcom_memcmp(ptr, ip8021x_wpa_ie_tkip, sizeof(ip8021x_wpa_ie_tkip)) == 0))
|
||||
tkip_found = IP_TRUE;
|
||||
else if ((wpa_ver == 2) && (ipcom_memcmp(ptr, ip8021x_wpa2_ie_tkip, sizeof(ip8021x_wpa2_ie_tkip)) == 0))
|
||||
tkip_found = IP_TRUE;
|
||||
ptr += 4;
|
||||
}
|
||||
if (!match) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG4(ERR, "Invalid WPA IE Cipher Suites (expected %.2x %.2x %.2x %.2x)",
|
||||
wpa_ie->pairwise_cipher_suite[0], wpa_ie->pairwise_cipher_suite[1],
|
||||
wpa_ie->pairwise_cipher_suite[2], wpa_ie->pairwise_cipher_suite[3]);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* Verify WPA/WPA2 IE multicast cipher suite
|
||||
* Note that if TKIP was included as one of the unicast cipher suites,
|
||||
* it is ok for it to be offered as the multicast cipher suite
|
||||
*/
|
||||
if (ipcom_memcmp(grp_cipher_suite, wpa_ie->grp_cipher_suite, sizeof(wpa_ie->grp_cipher_suite)) != 0) {
|
||||
if (tkip_found) {
|
||||
if ((ipcom_memcmp(grp_cipher_suite, ip8021x_wpa_ie_tkip, sizeof(grp_cipher_suite)) == 0) ||
|
||||
(ipcom_memcmp(grp_cipher_suite, ip8021x_wpa2_ie_tkip, sizeof(grp_cipher_suite)) == 0)) {
|
||||
*multicast_encr_type = IP_IW_ENCR_ALG_TKIP;
|
||||
} else {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
Ip_u8 *ie = ((wpa_ver == 1) ? ip8021x_wpa_ie_tkip : ip8021x_wpa2_ie_tkip);
|
||||
IPCOM_LOG8(ERR, "WPA IE multicast cipher suite mismatch %.2x %.2x %.2x %.2x (expected %.2x %.2x %.2x %.2x)",
|
||||
grp_cipher_suite[0], grp_cipher_suite[1], grp_cipher_suite[2], grp_cipher_suite[3],
|
||||
ie[0], ie[1], ie[2], ie[3]);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
} else {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG8(ERR, "WPA IE multicast cipher suite mismatch %.2x %.2x %.2x %.2x (expected %.2x %.2x %.2x %.2x)",
|
||||
grp_cipher_suite[0], grp_cipher_suite[1], grp_cipher_suite[2], grp_cipher_suite[3],
|
||||
wpa_ie->grp_cipher_suite[0], wpa_ie->grp_cipher_suite[1],
|
||||
wpa_ie->grp_cipher_suite[2], wpa_ie->grp_cipher_suite[3]);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Verify WPA/WPA2 IE # of auth key mgmt suites. */
|
||||
num_mgmt_suites = *ptr;
|
||||
if (!num_mgmt_suites || (num_mgmt_suites > IP8021X_MAX_CIPHERS)) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG2(ERR, "Too many Auth Key Management suites %d (max %d)", num_mgmt_suites, IP8021X_MAX_CIPHERS);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
ptr+=2;
|
||||
|
||||
/* Re-verify WPA/WPA2 IE length based on # of cipher suites */
|
||||
min_len += (num_mgmt_suites-1)*sizeof(wpa_ie->auth_key_mgnt[0]);
|
||||
if (ie_len < min_len) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG2(ERR, "Invalid WPA IE len %d (expected >= %d)", ie_len, min_len);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* Verify WPA/WPA2 IE Auth Key Mgmt Suites. Just find one that matches what we support */
|
||||
for (i=0, match = IP_FALSE; i < num_mgmt_suites; i++) {
|
||||
/* We only support 1 suite in wpa_ie so do a simple comparison */
|
||||
if (ipcom_memcmp(ptr, &wpa_ie->auth_key_mgnt[0], 4) == 0)
|
||||
match = IP_TRUE;
|
||||
#ifdef IPSUPP_DEBUG
|
||||
else
|
||||
IPCOM_LOG4(ERR, "WPA IE Auth Key Management Suite mismatch %.2x %.2x %.2x %.2x",
|
||||
ptr[0], ptr[1], ptr[2], ptr[3]);
|
||||
#endif
|
||||
ptr+=4;
|
||||
|
||||
}
|
||||
if (!match) {
|
||||
#ifdef IPSUPP_DEBUG
|
||||
IPCOM_LOG4(ERR, "Invalid WPA IE Auth Key Management Suites (expected %.2x %.2x %.2x %.2x)",
|
||||
wpa_ie->auth_key_mgnt[0], wpa_ie->auth_key_mgnt[1], wpa_ie->auth_key_mgnt[2], wpa_ie->auth_key_mgnt[3]);
|
||||
#endif
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK INTERNAL API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ip8021x_wpa_ie.h,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ip8021x/src/ip8021x_wpa_ie.h,v $
|
||||
* $Author: myakan $ $Date: 2009-08-13 16:04:56 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP8021X_WPA_IE_H
|
||||
#define IP8021X_WPA_IE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ip8021x_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Maximum number of cipher suites in RSN information elements */
|
||||
#define IP8021X_MAX_CIPHERS 4
|
||||
|
||||
/* Maximum number of authentication and key management suites in RSN information elements */
|
||||
#define IP8021X_MAX_AUTH_KEY 4
|
||||
|
||||
/* Maximum number pairwise key identifiers RSN information elements */
|
||||
#define IP8021X_MAX_PKMID 4
|
||||
|
||||
#define IP8021X_IE_ELEMENT_ID_WPA 221
|
||||
#define IP8021X_IE_ELEMENT_ID_RSN 48
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ip8021x_wpa_ie_st
|
||||
{
|
||||
int wpa_ver;
|
||||
int multicast_encr_type;
|
||||
Ip_u8 id;
|
||||
Ip_u8 len;
|
||||
Ip_u8 oui[4];
|
||||
Ip_u8 version[2];
|
||||
Ip_u8 grp_cipher_suite[4];
|
||||
Ip_u16 pairwise_cipher_suite_len;
|
||||
Ip_u8 pairwise_cipher_suite[4*IP8021X_MAX_CIPHERS];
|
||||
Ip_u16 auth_key_mgnt_len;
|
||||
Ip_u8 auth_key_mgnt[4*IP8021X_MAX_AUTH_KEY];
|
||||
Ip_u16 wpa_cap;
|
||||
} Ip8021x_wpa_ie;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN Ip_u8 ip8021x_wpa_ie_wpa[4];
|
||||
|
||||
IP_EXTERN Ip_u8 ip8021x_wpa_ie_psk[4];
|
||||
|
||||
IP_EXTERN Ip_u8 ip8021x_wpa_ie_tkip[4];
|
||||
|
||||
IP_EXTERN Ip_u8 ip8021x_wpa_ie_ccmp[4];
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err ip8021x_pkt_put_wpa_ie(Ip8021x_pkt* pkt, Ip8021x_wpa_ie* wpa_ie);
|
||||
|
||||
IP_GLOBAL void ip8021x_wpa_ie_init(Ip8021x_wpa_ie* wpa_ie, int uni_encr_type, int multi_encr_type, int auth_key_mgnt, Ip_u16 rsn_cap);
|
||||
|
||||
IP_GLOBAL void ip8021x_wpa_ie_set_auth_key_mgnt(Ip8021x_wpa_ie* wpa_ie, int auth_key_mgnt);
|
||||
|
||||
IP_GLOBAL void ip8021x_wpa_ie_set_encr(Ip8021x_wpa_ie* wpa_ie, int uni_encr_type, int multi_encr_type);
|
||||
IP_GLOBAL void ip8021x_wpa2_ie_set_encr(Ip8021x_wpa_ie* wpa_ie, int uni_encr_type, int multi_encr_type);
|
||||
IP_GLOBAL Ip_bool ip8021x_verify_wpa_ie(Ip_u8* pIe, Ip8021x_wpa_ie* wpa_ie, int *multicast_encr_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,711 @@
|
||||
/* 00comp_ipnet_apps.cdf - IPNet Applications 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
|
||||
--------------------
|
||||
30dec15,wjf Fix defect VXW6-83989
|
||||
25Jan13,lzq Fix defect WIND00400196
|
||||
06dec11,xhs Fix defect WIND00253073
|
||||
19oct11,rjq Add parameter FTPC_BIND_ADDRESS
|
||||
03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
*/
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPAPPL
|
||||
|
||||
Folder FOLDER_TFTP {
|
||||
NAME TFTP Components
|
||||
SYNOPSIS TFTP Components
|
||||
CHILDREN INCLUDE_IPTFTP_COMMON \
|
||||
INCLUDE_IPTFTPC \
|
||||
INCLUDE_IPTFTP_CLIENT_CMD \
|
||||
INCLUDE_IPTFTPS \
|
||||
INCLUDE_TFTP_CLIENT
|
||||
_CHILDREN FOLDER_NET_L5_APPLICATIONS
|
||||
}
|
||||
|
||||
Folder FOLDER_FTP {
|
||||
NAME FTP Components
|
||||
SYNOPSIS FTP Components
|
||||
CHILDREN INCLUDE_FTP \
|
||||
INCLUDE_FTP6 \
|
||||
INCLUDE_IPFTPC \
|
||||
INCLUDE_IPFTPS \
|
||||
INCLUDE_IPFTP_CMD \
|
||||
INCLUDE_IPFTPS_TLS
|
||||
_CHILDREN FOLDER_NET_L5_APPLICATIONS
|
||||
}
|
||||
|
||||
Component INCLUDE_IPDHCPC {
|
||||
NAME DHCP Client
|
||||
SYNOPSIS DHCP Client
|
||||
MODULES ipdhcpc.o
|
||||
CONFIGLETTES ipdhcpc_config.c ipdhcpc_example.c
|
||||
REQUIRES INCLUDE_IPCOM
|
||||
CFG_PARAMS DHCPC_CLIENT_PORT DHCPC_SERVER_PORT DHCPC_REQ_OPTS \
|
||||
DHCPC_CLIENT_ID DHCPC_CLIENT_UUID DHCPC_RFC2131_INIT_DELAY \
|
||||
DHCPC_RFC2131_EXP_BACKOFF DHCPC_DISCOVER_RETRIES \
|
||||
DHCPC_OFFER_TIMEOUT DHCPC_IF_REQ_OPTS_LIST \
|
||||
DHCPC_IF_CLIENT_ID_LIST \
|
||||
DHCPC_INSTALL_OPTION_CALLBACK_HOOK \
|
||||
DHCPC_INSTALL_REPLY_CALLBACK_HOOK \
|
||||
DHCPC_OPTION_CALLBACK_HOOK DHCPC_REPLY_CALLBACK_HOOK \
|
||||
DHCPC_BOOTP_MODE DHCPC_BOOT_FILENAME \
|
||||
DHCPC_SERVER_HOSTNAME DHCPC_OPTION_HOSTNAME \
|
||||
DHCPC_OPTION_NETMASK DHCPC_OPTION_VENDOR_CLASS_ID \
|
||||
DHCPC_OPTION_IPADDRESS_LEASE_TIME \
|
||||
DHCPC_OPTION_VI_VENDOR_CLASS \
|
||||
DHCPC_REMOVE_EXISTING_ADDRESSES \
|
||||
DHCPC_REMOVE_LEASED_ADDRESS \
|
||||
DHCPC_AUTO_DISABLE \
|
||||
DHCPC_TTL \
|
||||
DHCPC_OPTION_MAX_MESSAGE_SIZE \
|
||||
DHCPC_OPTION_USER_SPECIFIED \
|
||||
DHCPC_IF_INFORMATION_ONLY_LIST \
|
||||
DHCPC_FLAGS_BIT_BROADCAST
|
||||
_CHILDREN FOLDER_DHCP
|
||||
}
|
||||
|
||||
Component INCLUDE_IPDNSC {
|
||||
NAME DNS Client
|
||||
SYNOPSIS DNS Client
|
||||
MODULES ipdnsc.o
|
||||
REQUIRES INCLUDE_IPCOM
|
||||
CONFIGLETTES ipdnsc_config.c
|
||||
CFG_PARAMS DNSC_SERVER_PORT DNSC_TIMEOUT DNSC_RETRIES \
|
||||
DNSC_DOMAIN_NAME DNSC_PRIMARY_NAME_SERVER \
|
||||
DNSC_SECONDARY_NAME_SERVER DNSC_TERTIARY_NAME_SERVER \
|
||||
DNSC_QUATERNARY_NAME_SERVER DNSC_IP4_ZONE \
|
||||
DNSC_IP6_ZONE
|
||||
_CHILDREN FOLDER_NET_L5_APPLICATIONS
|
||||
}
|
||||
|
||||
Component INCLUDE_IPFTPC {
|
||||
NAME FTP Client
|
||||
SYNOPSIS FTP Client
|
||||
MODULES ipftpc.o
|
||||
REQUIRES INCLUDE_IPCOM
|
||||
CFG_PARAMS FTPC_BIND_ADDRESS
|
||||
CONFIGLETTES ipftpc_config.c
|
||||
}
|
||||
|
||||
Component INCLUDE_IPFTPS {
|
||||
NAME FTP Server
|
||||
SYNOPSIS FTP Server
|
||||
MODULES ipftps.o
|
||||
REQUIRES INCLUDE_IPCOM
|
||||
CONFIGLETTES ipftps_config.c ipftps_example.c
|
||||
CFG_PARAMS FTPS_AUTH_ATTEMPTS FTPS_SLEEP_TIME FTPS_LOCAL_PORT_BASE \
|
||||
FTPS_PEER_PORT_BASE FTPS_ENABLE_PROXY FTPS_MODE \
|
||||
FTPS_ROOT_DIR FTPS_INITIAL_DIR FTPS_MAX_SESSIONS \
|
||||
FTPS_PORT_NUM FTPS_RECV_TIMEOUT FTPS_SEND_TIMEOUT \
|
||||
FTPS_INACTIVITY_TIMEOUT FTPS_SOCKET_BACKLOG FTPS_SYS_TYPE \
|
||||
FTPS_AUTH_CALLBACK_HOOK FTPS_DATABUF_SIZE
|
||||
}
|
||||
|
||||
Component INCLUDE_IPTFTP_COMMON {
|
||||
NAME TFTP common configurations
|
||||
SYNOPSIS TFTP common configurations
|
||||
MODULES iptftp_common.o
|
||||
REQUIRES INCLUDE_IPCOM
|
||||
CONFIGLETTES iptftps_config.c
|
||||
CFG_PARAMS TFTPS_DIRS TFTPS_RETRANSMIT_TIMEOUT TFTPS_RETRIES
|
||||
}
|
||||
|
||||
Component INCLUDE_IPTFTPC {
|
||||
NAME TFTP Client
|
||||
SYNOPSIS TFTP Client
|
||||
MODULES iptftpc.o
|
||||
REQUIRES INCLUDE_IPCOM INCLUDE_IPTFTP_COMMON
|
||||
CONFIGLETTES iptftpc_config.c
|
||||
}
|
||||
|
||||
Component INCLUDE_IPTFTPS {
|
||||
NAME TFTP Server
|
||||
SYNOPSIS TFTP Server
|
||||
MODULES iptftps.o
|
||||
REQUIRES INCLUDE_IPCOM INCLUDE_IPTFTP_COMMON
|
||||
}
|
||||
|
||||
#ifdef _WRS_CONFIG_IPFTP_USE_TLS
|
||||
Component INCLUDE_IPFTPS_TLS {
|
||||
NAME FTP Server with TLS
|
||||
SYNOPSIS FTP Server with TLS
|
||||
MODULES ipftps_tls.o
|
||||
REQUIRES INCLUDE_IPFTPS INCLUDE_IPSSL
|
||||
CFG_PARAMS FTPS_TLS FTPS_TLS_CERT_FILE FTPS_TLS_KEY_FILE FTPS_TLS_SECRECT_KEY\
|
||||
ENABLE_ADVANCE_FTPS_KEY_PRIVACY
|
||||
_CHILDREN FOLDER_FTP
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************** Configuration Parameters *****************************/
|
||||
|
||||
/* INCLUDE_IPDHCPC configuration parameters */
|
||||
Parameter DHCPC_CLIENT_PORT {
|
||||
NAME DHCP Client Port
|
||||
SYNOPSIS DHCP client port as a quoted string: e.g. "68"
|
||||
TYPE char *
|
||||
DEFAULT "68"
|
||||
}
|
||||
|
||||
Parameter DHCPC_SERVER_PORT {
|
||||
NAME DHCP Server Port
|
||||
SYNOPSIS DHCP server port as a quoted string: e.g. "68"
|
||||
TYPE char *
|
||||
DEFAULT "67"
|
||||
}
|
||||
|
||||
Parameter DHCPC_RFC2131_INIT_DELAY {
|
||||
NAME RFC2131 Initialization Delay identifier
|
||||
SYNOPSIS Enable(1) /disable(0) RFC2131 Initialization Delay identifier.
|
||||
TYPE char *
|
||||
DEFAULT "1"
|
||||
}
|
||||
|
||||
Parameter DHCPC_RFC2131_EXP_BACKOFF {
|
||||
NAME RFC2131 Exponential Back-off Delay
|
||||
SYNOPSIS Enable(1) /disable(0) RFC2131 Exponential Back-off Delay.
|
||||
TYPE char *
|
||||
DEFAULT "1"
|
||||
}
|
||||
|
||||
Parameter DHCPC_DISCOVER_RETRIES {
|
||||
NAME DHCP Client Retries
|
||||
SYNOPSIS Number of DHCP client retries.
|
||||
TYPE char *
|
||||
DEFAULT "4"
|
||||
}
|
||||
|
||||
Parameter DHCPC_OFFER_TIMEOUT {
|
||||
NAME DHCP Offer Time-Out
|
||||
SYNOPSIS DHCP offer time-out in milliseconds.
|
||||
TYPE char *
|
||||
DEFAULT "2000"
|
||||
}
|
||||
|
||||
Parameter DHCPC_INSTALL_OPTION_CALLBACK_HOOK {
|
||||
NAME Install DHCP Client Option Callback Routine
|
||||
SYNOPSIS Determine if the user-defined DHCP client callback routine \
|
||||
as specified by the macro DHCPC_OPTION_CALLBACK_HOOK should \
|
||||
be installed. If FALSE, the DHCPC_OPTION_CALLBACK_HOOK \
|
||||
configuration is not applicable.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_CALLBACK_HOOK {
|
||||
NAME Option Callback Routine
|
||||
SYNOPSIS This user-defined DHCP option processing callback routine \
|
||||
is called once for each option prior to IPDHCPC is acting \
|
||||
on the option, i.e. this callback can be used to change \
|
||||
the contents of the DHCP server reply (caution!). If not \
|
||||
specified, the internal option callback routine will be \
|
||||
used. The DHCPC_INSTALL_OPTION_CALLBACK_HOOK must also be set to \
|
||||
TRUE in order to install this callback routine.
|
||||
TYPE FUNCPTR
|
||||
DEFAULT ipdhcpc_option_default_callback
|
||||
}
|
||||
|
||||
Parameter DHCPC_INSTALL_REPLY_CALLBACK_HOOK {
|
||||
NAME Install DHCP Client Reply Callback Routine
|
||||
SYNOPSIS Determine if the user-defined DHCP client callback routine \
|
||||
as specified by the macro DHCPC_REPLY_CALLBACK_HOOK should \
|
||||
be installed. If FALSE, the DHCPC_REPLY_CALLBACK_HOOK \
|
||||
configuration is not applicable.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
Parameter DHCPC_REPLY_CALLBACK_HOOK {
|
||||
NAME Reply Callback Routine
|
||||
SYNOPSIS This callback can be used to change the contents of the DHCP \
|
||||
server reply (caution!). If not specified, the internal reply \
|
||||
callback routine will be used. The DHCPC_INSTALL_REPLY_CALLBACK_HOOK \
|
||||
must also be set to TRUE in order to install this callback \
|
||||
routine.
|
||||
TYPE FUNCPTR
|
||||
DEFAULT ipdhcpc_reply_default_callback
|
||||
}
|
||||
|
||||
Parameter DHCPC_BOOTP_MODE {
|
||||
NAME BOOTP Mode
|
||||
SYNOPSIS Operate as a BOOTP client only. \
|
||||
That is, do not append a DHCP "message type" \
|
||||
option to requests. "1" to enable, "0" to disable
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter DHCPC_BOOT_FILENAME {
|
||||
NAME DHCP Boot Filename
|
||||
SYNOPSIS Specify an optional filename to use in dhcp/bootp requests.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_SERVER_HOSTNAME {
|
||||
NAME DHCP Server Hostname
|
||||
SYNOPSIS Specify an optional server hostname to use in dhcp/bootp requests.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_IF_REQ_OPTS_LIST {
|
||||
NAME Interface Specific Option: Parameter Request List (55)
|
||||
SYNOPSIS An interface name followed by comma separated list of DHCP \
|
||||
options numbers that the DHCP client wants the server to \
|
||||
provide in the format <ifparam>=<opts>. Each pair of \
|
||||
<ifparam>=<opts> is semicolon separated, e.g. \
|
||||
"eth0=1,2,3,4;eth1=2,3,4,5".
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_IF_CLIENT_ID_LIST {
|
||||
NAME Interface Specific Option: Client Identifier (61)
|
||||
SYNOPSIS A string of characters that the DHCP client wants the server \
|
||||
to identify it by in the format <ifparam>=<id>. Each pair of \
|
||||
<ifparam>=<id> is semicolon separated, e.g. \
|
||||
"eth0=my_red_computer_eth0" or \
|
||||
"eth0=my_red_computer_eth0;eth1=my_blue_computer_eth1".
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_REQ_OPTS {
|
||||
NAME Global Option: Parameter Request List (55)
|
||||
SYNOPSIS A comma separated list of DHCP options numbers that the \
|
||||
DHCP client wants the server to provide, e.g. "1,2,3,4"
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter DHCPC_CLIENT_ID {
|
||||
NAME Global Option: Client Identifier (61)
|
||||
SYNOPSIS A string of characters that the DHCP client wants the server \
|
||||
to identify it by, e.g. "my_red_computer". If DHCPC_CLIENT_UUID \
|
||||
is set "true", it should be defined like "4c:5f:00:ff"
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter DHCPC_CLIENT_UUID {
|
||||
NAME Global Option: Client Identifier type
|
||||
SYNOPSIS Determine if DHCP client identifier type is uuid \
|
||||
If "false", DHCPC_CLIENT_ID parameter should be treated as string \
|
||||
If "true", DHCPC_CLIENT_ID parameter should be treated as char array.
|
||||
TYPE char *
|
||||
DEFAULT "false"
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_HOSTNAME {
|
||||
NAME Global Option: Hostname (12)
|
||||
SYNOPSIS Defines the hostname option to use in requests.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_NETMASK {
|
||||
NAME Global Option: Netmask (1)
|
||||
SYNOPSIS Defines the subnet mask option to use in requests.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_IPADDRESS_LEASE_TIME {
|
||||
NAME IP address lease time
|
||||
SYNOPSIS This option is used in a client request to allow the client to request \
|
||||
a lease time for the IP address. 0 value means no lease time is specified. \
|
||||
The time is in units of seconds.
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_VENDOR_CLASS_ID {
|
||||
NAME Global Option: Vendor Class ID (60)
|
||||
SYNOPSIS Defines the vendor class id option.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_VI_VENDOR_CLASS {
|
||||
NAME Global Option: Vendor Identifying Vendor Class (124)
|
||||
SYNOPSIS Defines the vendor identifying vendor class option. \
|
||||
Expected format: enterprise_number1=data1;enterprise_number2=data2;... \
|
||||
All data fields should be specified in network byte order
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_MAX_MESSAGE_SIZE {
|
||||
NAME Global Option: Maximum DHCP Message Size (57)
|
||||
SYNOPSIS Maximum message size this client is prepared to accept. Must be \
|
||||
at least 576 as per RFC 2131.
|
||||
TYPE char *
|
||||
DEFAULT "576"
|
||||
}
|
||||
|
||||
Parameter DHCPC_OPTION_USER_SPECIFIED {
|
||||
NAME Global Option: User Specified List
|
||||
SYNOPSIS Defines a list of options and associated data not supported \
|
||||
explicitly by other option configuration parameters. \
|
||||
Expected format: <option>=<option_data>. \
|
||||
Each pair of <option_number>=<option_data> is semicolon separated. \
|
||||
In addition, <option_data> must be specified in hex with network byte order. \
|
||||
e.g. "3=C0A80101;4=C0A80102" specifies a router option (3) with address \
|
||||
at 192.168.1.1 and a time server option (4) with address at \
|
||||
192.168.1.2.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_REMOVE_EXISTING_ADDRESSES {
|
||||
NAME Remove Existing Addresses Before Negotiation
|
||||
SYNOPSIS Remove all unicast addresses from the interface before \
|
||||
negotiation begins. "1" to remove, "0" to retain
|
||||
TYPE char *
|
||||
DEFAULT "1"
|
||||
}
|
||||
|
||||
Parameter DHCPC_REMOVE_LEASED_ADDRESS {
|
||||
NAME Remove Leased Address After Expiration
|
||||
SYNOPSIS Remove any leased address from the interface if \
|
||||
the lease expires or DHCP is manually disabled. \
|
||||
"1" to remove, "0" to retain
|
||||
TYPE char *
|
||||
DEFAULT "1"
|
||||
}
|
||||
|
||||
Parameter DHCPC_AUTO_DISABLE {
|
||||
NAME DHCP Auto Disable
|
||||
SYNOPSIS Disable DHCP on the specified interface if another address \
|
||||
is subsequently added via manual configuration. \
|
||||
"1" to turn on, "0" to turn off
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter DHCPC_TTL {
|
||||
NAME DHCP TTL
|
||||
SYNOPSIS Set Time To Live for DHCP packets. May be increased \
|
||||
to interoperate with certain relay agents.
|
||||
TYPE char *
|
||||
DEFAULT "128"
|
||||
}
|
||||
|
||||
Parameter DHCPC_IF_INFORMATION_ONLY_LIST {
|
||||
NAME DHCP information only interface
|
||||
SYNOPSIS Set interface that only receives information.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DHCPC_FLAGS_BIT_BROADCAST {
|
||||
NAME DHCP Flag Field broadcast bit
|
||||
SYNOPSIS Set the value of broadcast bit.
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
/* INCLUDE_IPDNSC configuration parameters */
|
||||
Parameter DNSC_SERVER_PORT {
|
||||
NAME DNS server listening port
|
||||
SYNOPSIS Specifies the port used by IPDNSC for DNS queries, e.g. "53"
|
||||
TYPE char *
|
||||
DEFAULT "53"
|
||||
}
|
||||
|
||||
Parameter DNSC_TIMEOUT {
|
||||
NAME Timeout in seconds when waiting for responses to DNS queries
|
||||
SYNOPSIS Defines the number of seconds before a retry if the DNS \
|
||||
server fails to answer, e.g. "10"
|
||||
TYPE char *
|
||||
DEFAULT "10"
|
||||
}
|
||||
|
||||
Parameter DNSC_RETRIES {
|
||||
NAME Number of retries for DNS queries
|
||||
SYNOPSIS Defines the number of retries on each name server, e.g. "2"
|
||||
TYPE char *
|
||||
DEFAULT "2"
|
||||
}
|
||||
|
||||
Parameter DNSC_DOMAIN_NAME {
|
||||
NAME DNS domain name
|
||||
SYNOPSIS Defines the domain where the local host is located. \
|
||||
If this system variable is not defined, no local domain \
|
||||
is used and the user must provide fully qualified domain \
|
||||
names in address lookups for hosts in the same domain as \
|
||||
the local host.
|
||||
TYPE char *
|
||||
DEFAULT "windriver.com"
|
||||
}
|
||||
|
||||
Parameter DNSC_PRIMARY_NAME_SERVER {
|
||||
NAME DNS primary name server
|
||||
SYNOPSIS Defines the address to the primary name server. If this \
|
||||
system variable is not defined no primary name server is used.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DNSC_SECONDARY_NAME_SERVER {
|
||||
NAME DNS secondary name server
|
||||
SYNOPSIS Defines the address to the secondary name server. If this \
|
||||
system variable is not defined no secondary name server is used.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DNSC_TERTIARY_NAME_SERVER {
|
||||
NAME DNS tertiary name server
|
||||
SYNOPSIS Defines the address to the tertiary name server. If this \
|
||||
system variable is not defined no tertiary name server is used.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DNSC_QUATERNARY_NAME_SERVER {
|
||||
NAME DNS quaternary name server
|
||||
SYNOPSIS Defines the address to the quaternary name server. If this \
|
||||
system variable is not defined no quaternary name server is used.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter DNSC_IP4_ZONE {
|
||||
NAME Zone for IPv4 address to name lookups
|
||||
SYNOPSIS Defines the zone to use for address to name lookups of IPv4 \
|
||||
addresses.
|
||||
TYPE char *
|
||||
DEFAULT "in-addr.arpa"
|
||||
}
|
||||
|
||||
Parameter DNSC_IP6_ZONE {
|
||||
NAME Zone for IPv6 address to name lookups
|
||||
SYNOPSIS Defines the zone to use for address to name lookups of IPv6 \
|
||||
addresses. Set to "ip6.int" to support RFC1886 or to \
|
||||
"ip6.arpa" to support RC3152.
|
||||
TYPE char *
|
||||
DEFAULT "ip6.int"
|
||||
}
|
||||
|
||||
/* INCLUDE_IPFTPC configuration parameters */
|
||||
Parameter FTPC_BIND_ADDRESS {
|
||||
NAME FTP client bind address
|
||||
SYNOPSIS Specify the bind address of FTP client.
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
/* INCLUDE_IPFTPS configuration parameters */
|
||||
Parameter FTPS_AUTH_ATTEMPTS {
|
||||
NAME Authentication attempts before disconnect
|
||||
SYNOPSIS The number of authentication attempts that are allowed \
|
||||
before the server disconnects.
|
||||
TYPE char *
|
||||
DEFAULT "3"
|
||||
}
|
||||
|
||||
Parameter FTPS_SLEEP_TIME {
|
||||
NAME Time to sleep after authentication fail
|
||||
SYNOPSIS Defines how many seconds the server will sleep before \
|
||||
replying to an unsuccessful authentication.
|
||||
TYPE char *
|
||||
DEFAULT "5"
|
||||
}
|
||||
|
||||
Parameter FTPS_LOCAL_PORT_BASE {
|
||||
NAME Local port base number
|
||||
SYNOPSIS Local port base which defines the port range the server \
|
||||
uses for the data connection. A value of 0 instructs the \
|
||||
server to use port 20.
|
||||
TYPE char *
|
||||
DEFAULT "49151"
|
||||
}
|
||||
|
||||
Parameter FTPS_PEER_PORT_BASE {
|
||||
NAME Peer port base number
|
||||
SYNOPSIS Peer port base defines the port range that the client is \
|
||||
allowed to use when setting up the data connection.
|
||||
TYPE char *
|
||||
DEFAULT "1023"
|
||||
}
|
||||
|
||||
Parameter FTPS_ENABLE_PROXY {
|
||||
NAME Enable proxy FTP support
|
||||
SYNOPSIS Specifies whether to enable proxy FTP support.
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter FTPS_MODE {
|
||||
NAME Read/write mode
|
||||
SYNOPSIS Read-only mode disables write access to the file system, \
|
||||
which means that only read commands will be accepted. \
|
||||
Default value is 0, which means read/write access.
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter FTPS_ROOT_DIR {
|
||||
NAME FTP root directory
|
||||
SYNOPSIS Defines the topmost directory that the client can see.
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter FTPS_INITIAL_DIR {
|
||||
NAME FTP initial directory
|
||||
SYNOPSIS Defines the initial directory for an FTP session.
|
||||
TYPE char *
|
||||
DEFAULT IPCOM_FILE_ROOT
|
||||
}
|
||||
|
||||
Parameter FTPS_MAX_SESSIONS {
|
||||
NAME Max number of simultaneous sessions
|
||||
SYNOPSIS Maximum number of simultaneous FTP sessions.
|
||||
TYPE char *
|
||||
DEFAULT "8"
|
||||
}
|
||||
|
||||
Parameter FTPS_PORT_NUM {
|
||||
NAME Server port number
|
||||
SYNOPSIS Server port number.
|
||||
TYPE char *
|
||||
DEFAULT "21"
|
||||
}
|
||||
|
||||
Parameter FTPS_RECV_TIMEOUT {
|
||||
NAME Data receive timeout
|
||||
SYNOPSIS Timeout in seconds when receiving data from the client.
|
||||
TYPE char *
|
||||
DEFAULT "30"
|
||||
}
|
||||
|
||||
Parameter FTPS_SEND_TIMEOUT {
|
||||
NAME Data send timeout
|
||||
SYNOPSIS Timeout in seconds when sending data to the client.
|
||||
TYPE char *
|
||||
DEFAULT "30"
|
||||
}
|
||||
|
||||
Parameter FTPS_INACTIVITY_TIMEOUT {
|
||||
NAME User inactivity timeout
|
||||
SYNOPSIS Timeout in seconds when waiting for a command from the client.
|
||||
TYPE char *
|
||||
DEFAULT "300"
|
||||
}
|
||||
|
||||
Parameter FTPS_SOCKET_BACKLOG {
|
||||
NAME Control socket backlog queue
|
||||
SYNOPSIS Determines the backlog queue length of FTP server control socket. \
|
||||
The default value is 0.
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter FTPS_SYS_TYPE {
|
||||
NAME Reported system type
|
||||
SYNOPSIS Operating system name.
|
||||
TYPE char *
|
||||
DEFAULT "UNIX"
|
||||
}
|
||||
|
||||
Parameter FTPS_AUTH_CALLBACK_HOOK {
|
||||
NAME Authentication callback routine
|
||||
SYNOPSIS User-defined authentication callback routine used by FTP \
|
||||
server. If not specified, internal authentication callback \
|
||||
routine ipftps_authenticate_default_callback will be used.
|
||||
TYPE FUNCPTR
|
||||
DEFAULT ipftps_authenticate_default_callback
|
||||
}
|
||||
|
||||
Parameter FTPS_DATABUF_SIZE {
|
||||
NAME Data transfer buffer size
|
||||
SYNOPSIS Data transfer buffer size used in each FTP session
|
||||
TYPE char *
|
||||
DEFAULT "4096"
|
||||
}
|
||||
|
||||
/* INCLUDE_IPTFTPS configuration parameters */
|
||||
Parameter TFTPS_DIRS {
|
||||
NAME TFTP server working directory
|
||||
SYNOPSIS Specifies tftp server working directory.
|
||||
TYPE char *
|
||||
DEFAULT IPCOM_FILE_ROOT "tftpdir"
|
||||
}
|
||||
|
||||
Parameter TFTPS_RETRANSMIT_TIMEOUT {
|
||||
NAME TFTP retransmit timeout in seconds
|
||||
SYNOPSIS Specifies the time until the first retry is sent. Further \
|
||||
retries use an exponential back-off algorithm.
|
||||
TYPE char *
|
||||
DEFAULT "5"
|
||||
}
|
||||
|
||||
Parameter TFTPS_RETRIES {
|
||||
NAME TFTP number of retries
|
||||
SYNOPSIS Specifies the number of times a tftp message will be \
|
||||
retried if an acknowledgment is not received from the peer.
|
||||
TYPE char *
|
||||
DEFAULT "2"
|
||||
}
|
||||
|
||||
#ifdef _WRS_CONFIG_IPFTP_USE_TLS
|
||||
|
||||
Parameter ENABLE_ADVANCE_FTPS_KEY_PRIVACY {
|
||||
NAME Enable Advance option for FTPS Key Privacy
|
||||
SYNOPSIS If "1", private key will be saved to KEY DB. This will \
|
||||
protect the private key can't be access by others.\
|
||||
If "0", Private key won't be saved to KEY DB.\
|
||||
If want to use KEY DB, need include INCLUDE_IPCOM_USE_RAM_DISK.
|
||||
REQUIRES INCLUDE_IPCOM_USE_KEY_DB
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter FTPS_TLS_KEY_FILE {
|
||||
NAME TLS key file
|
||||
SYNOPSIS
|
||||
REQUIRES INCLUDE_IPSSL
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter FTPS_TLS_CERT_FILE {
|
||||
NAME TLS certificate file
|
||||
SYNOPSIS
|
||||
REQUIRES INCLUDE_IPSSL
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter FTPS_TLS {
|
||||
NAME Enable FTP server with TLS
|
||||
SYNOPSIS
|
||||
REQUIRES INCLUDE_IPSSL
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter FTPS_TLS_SECRECT_KEY {
|
||||
NAME TLS secret key
|
||||
SYNOPSIS
|
||||
REQUIRES INCLUDE_IPSSL
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.5 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipappl/config/common.vxconfig,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPAPPL
|
||||
config SUPPORTS_APPL
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcpc_config.c,v $ $Revision: 1.7.12.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipdhcpc_config.c,v $
|
||||
* $Author: jwang9 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01j,30Dec15,wjf Add for defect VXW6-83989.
|
||||
01i,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01h,04jul09,ggz Added DHCPC ip address lease time
|
||||
01g,11oct07,uol Defect WIND00107491, add DHCP capabilities in bootrom.
|
||||
01f,22jan07,kch Added rfc2131_init_delay, rfc2131_exponential_backoff,
|
||||
discover_retries and offer_timeout sysvars (WIND00086146).
|
||||
01e,03jan07,kch Renamed DHCPC_IFLIST_REQ_OPTS and DHCPC_IFLIST_CLIENT_ID
|
||||
macros to DHCPC_IF_REQ_OPTS_LIST and DHCPC_IF_CLIENT_ID_LIST.
|
||||
01d,01dec06,kch Updated CVS revision log entry.
|
||||
01c,13sep06,kch Refresh with Sept 08, 2006 code drop
|
||||
01b,28aug06,kch Update based on Aug 22, 2006 code drop.
|
||||
01a,07aug06,kch Added ipdhcpc_conf_sysvar_ext[] to support per-interface
|
||||
sysvar configurations.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#if defined(BOOTAPP_DHCPC_REQ_OPTS)
|
||||
#undef DHCPC_REQ_OPTS
|
||||
#define DHCPC_REQ_OPTS BOOTAPP_DHCPC_REQ_OPTS
|
||||
#endif
|
||||
|
||||
#if defined(BOOTAPP_DHCPC_IF_REQ_OPTS_LIST)
|
||||
#undef DHCPC_IF_REQ_OPTS_LIST
|
||||
#define DHCPC_IF_REQ_OPTS_LIST BOOTAPP_DHCPC_IF_REQ_OPTS_LIST
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipdhcpc_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* SYSTEM VARIABLES
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_conf_sysvar
|
||||
*===========================================================================
|
||||
* DHCP Client Configuration Variables
|
||||
*/
|
||||
|
||||
IP_CONST Ipcom_sysvar ipdhcpc_conf_sysvar[] =
|
||||
{
|
||||
#if defined(IP_WB_BUILD)
|
||||
/* DHCP client port (default 68) */
|
||||
{"ipdhcpc.client_port", DHCPC_CLIENT_PORT},
|
||||
|
||||
/* DHCP server port (default 67) */
|
||||
{"ipdhcpc.server_port", DHCPC_SERVER_PORT},
|
||||
|
||||
/* RFC2131 Initialization Delay identifier */
|
||||
/* 1 enabled , 0 disabled */
|
||||
{"ipdhcpc.rfc2131_init_delay", DHCPC_RFC2131_INIT_DELAY},
|
||||
|
||||
/* RFC2131 Exponential Back-off Delay */
|
||||
/* 1 enabled, 0 disabled */
|
||||
{"ipdhcpc.rfc2131_exponential_backoff", DHCPC_RFC2131_EXP_BACKOFF},
|
||||
|
||||
/* Number of DHCP client retries */
|
||||
{"ipdhcpc.discover_retries", DHCPC_DISCOVER_RETRIES},
|
||||
|
||||
/* DHCP offer time-out in milliseconds */
|
||||
{"ipdhcpc.offer_timeout", DHCPC_OFFER_TIMEOUT},
|
||||
|
||||
/* DHCP bootp mode */
|
||||
/* 1 enabled, 0 disabled */
|
||||
{"ipdhcpc.bootp_mode", DHCPC_BOOTP_MODE},
|
||||
|
||||
/* DHCP boot filename */
|
||||
{"ipdhcpc.boot_filename", DHCPC_BOOT_FILENAME},
|
||||
|
||||
/* Global server hostname */
|
||||
{"ipdhcpc.server_hostname", DHCPC_SERVER_HOSTNAME},
|
||||
{"ipdhcpc.client_identifier_uuid", DHCPC_CLIENT_UUID},
|
||||
|
||||
/* Global hostname option */
|
||||
{"ipdhcpc.option.hostname", DHCPC_OPTION_HOSTNAME},
|
||||
|
||||
/* Global netmask option */
|
||||
{"ipdhcpc.option.netmask", DHCPC_OPTION_NETMASK},
|
||||
|
||||
/* IP address lease time option */
|
||||
{"ipdhcpc.option.lease_time", DHCPC_OPTION_IPADDRESS_LEASE_TIME},
|
||||
|
||||
/* Global vendor class identifier option */
|
||||
{"ipdhcpc.option.vendor_class_id", DHCPC_OPTION_VENDOR_CLASS_ID},
|
||||
|
||||
/* Global vendor identifying vendor options option */
|
||||
{"ipdhcpc.option.vendor_identifying_vendor_class", DHCPC_OPTION_VI_VENDOR_CLASS},
|
||||
|
||||
/* Global list of requested DHCP options */
|
||||
{"ipdhcpc.option.requested_options", DHCPC_REQ_OPTS},
|
||||
|
||||
/* Global client identifier */
|
||||
{"ipdhcpc.option.client_identifier", DHCPC_CLIENT_ID},
|
||||
|
||||
/* Global user specified options */
|
||||
{"ipdhcpc.option.user_specified", DHCPC_OPTION_USER_SPECIFIED},
|
||||
|
||||
/* Remove existing unicast addresses before negotiation begins */
|
||||
{"ipdhcpc.remove_existing_addresses", DHCPC_REMOVE_EXISTING_ADDRESSES},
|
||||
|
||||
/* Remove negotiated addresses from interface when lease expires */
|
||||
{"ipdhcpc.remove_leased_address", DHCPC_REMOVE_LEASED_ADDRESS},
|
||||
|
||||
/* Disable DHCP on the interface if a static address is manually applied */
|
||||
{"ipdhcpc.auto_disable", DHCPC_AUTO_DISABLE},
|
||||
|
||||
/* Global DHCP maximum message size */
|
||||
{"ipdhcpc.option.max_message_size", DHCPC_OPTION_MAX_MESSAGE_SIZE},
|
||||
|
||||
/* Global Time To Live (TTL) for DHCP packets */
|
||||
{"ipdhcpc.ttl", DHCPC_TTL},
|
||||
|
||||
/* Set the value of flag field:broadcast bit */
|
||||
{"ipdhcpc.flags.bit.broadcast", DHCPC_FLAGS_BIT_BROADCAST},
|
||||
|
||||
|
||||
/*
|
||||
* Interface specific list of sysvar configurations are defined in
|
||||
* ipdhcpc_conf_sysvar_ext[]
|
||||
*/
|
||||
#endif
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
#if defined(IP_WB_BUILD)
|
||||
/* Interface specific list configurations */
|
||||
IP_CONST Ipcom_sysvar_ext ipdhcpc_conf_sysvar_ext[] =
|
||||
{
|
||||
/*
|
||||
* Interface specific list of requested DHCP options with interface name
|
||||
* followed by comma separated list of DHCP options numbers that the
|
||||
* DHCP client wants the server to provide in the format <ifparam>=<opts>.
|
||||
* Each pair of <ifparam>=<opts> is semicolon separated, e.g.
|
||||
* "eth0=1,2,3,4;eth1=2,3,4,5".
|
||||
*/
|
||||
{"ipdhcpc", "option.requested_options", DHCPC_IF_REQ_OPTS_LIST},
|
||||
|
||||
/*
|
||||
* Interface specific client identifier with a string of characters that
|
||||
* the DHCP client wants the server to identify it by in the format
|
||||
* <ifparam>=<id>. Each pair of <ifparam>=<id> is semicolon separated, e.g.
|
||||
* "eth0=my_red_computer_eth0" or
|
||||
* "eth0=my_red_computer_eth0;eth1=my_blue_computer_eth1".
|
||||
*/
|
||||
{"ipdhcpc", "option.client_identifier", DHCPC_IF_CLIENT_ID_LIST},
|
||||
|
||||
|
||||
/* Interfaces that only receive information
|
||||
* list eth0=enable, or eth0=enable;eth1=enable*/
|
||||
{"ipdhcpc.if", "information_only", DHCPC_IF_INFORMATION_ONLY_LIST},
|
||||
|
||||
{ IP_NULL, IP_NULL, IP_NULL }
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_configure
|
||||
*===========================================================================
|
||||
* Description: Configure DHCP client.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipdhcpc_configure(void)
|
||||
{
|
||||
Ip_err ret;
|
||||
|
||||
ret = ipcom_sysvar_setv(ipdhcpc_conf_sysvar, 0);
|
||||
|
||||
#if defined(IP_WB_BUILD)
|
||||
if (ret == IPCOM_SUCCESS)
|
||||
{
|
||||
/* now configure the interface-specific sysvars */
|
||||
return ipcom_sysvar_ext_setv (ipdhcpc_conf_sysvar_ext, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcpc_config.h,v $ $Revision: 1.17.44.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipdhcpc_config.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2014-12-04 23:32:39 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPDHCPC_CONFIG_H
|
||||
#define IPDHCPC_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_INCLUDE_CMD
|
||||
*===========================================================================
|
||||
* Define to include DHCP Client shell command 'dhcpc'.
|
||||
*/
|
||||
#define IPDHCPC_INCLUDE_CMD
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP_MAX_MESSAGE_SIZE
|
||||
*===========================================================================
|
||||
* Maximum DHCP message size the client is willing to accept.
|
||||
* Minimum valid value is 576 bytes. Including IP and UDP header length.
|
||||
*/
|
||||
#define IPDHCPC_MAX_MESSAGE_SIZE 576
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_CLIENT_ID_MAXSIZE
|
||||
*===========================================================================
|
||||
* Maximum size of the DHCP client-identifier size contents (code 61).
|
||||
*/
|
||||
#define IPDHCPC_CLIENT_ID_MAXSIZE 32
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_RFC2131_INIT_DELAY
|
||||
*===========================================================================
|
||||
* RFC-compliant Congestion Avoidance Initialization Delay.
|
||||
* 1 = enabled, 0 = disabled.
|
||||
*/
|
||||
#define IPDHCPC_RFC2131_INIT_DELAY 1
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_RFC2131_EXP_BACKOFF_DELAY
|
||||
*===========================================================================
|
||||
* RFC-compliant Exponential Back-off Delay between retries.
|
||||
* 1 = enabled, 0 = disabled.
|
||||
*/
|
||||
#define IPDHCPC_RFC2131_EXP_BACKOFF_DELAY 1
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_DISCOVER_RETRIES
|
||||
*===========================================================================
|
||||
* Number of DHCP Client Attempts.
|
||||
*/
|
||||
#define IPDHCPC_DISCOVER_RETRIES 4
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_OFFER_TIMEOUT
|
||||
*===========================================================================
|
||||
* Number of milliseconds to wait for initial offer from Server. Minimum 200.
|
||||
*/
|
||||
#define IPDHCPC_OFFER_TIMEOUT 2000
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_BOOTP_MODE
|
||||
*===========================================================================
|
||||
* Operate as BOOTP client only.
|
||||
* 1 = enabled, 0 = disabled.
|
||||
*/
|
||||
#define IPDHCPC_BOOTP_MODE 0
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_REMOVE_EXISTING_ADDRESSES
|
||||
*===========================================================================
|
||||
* Delete all unicast addresses from the interface before negotiation begins.
|
||||
* 1 = enabled, 0 = disabled.
|
||||
*/
|
||||
#define IPDHCPC_REMOVE_EXISTING_ADDRESSES 1
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_REMOVE_LEASED_ADDRESS
|
||||
*===========================================================================
|
||||
* Delete negotiated addresses from interface when lease expires.
|
||||
* 1 = enabled, 0 = disabled.
|
||||
*/
|
||||
#define IPDHCPC_REMOVE_LEASED_ADDRESS 1
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_AUTO_DISABLE
|
||||
*===========================================================================
|
||||
* Disable DHCP on the interface if a static address is manually applied.
|
||||
* 1 = enabled, 0 = disabled.
|
||||
*/
|
||||
#define IPDHCPC_AUTO_DISABLE 1
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_TTL
|
||||
*===========================================================================
|
||||
* IP Time-To-Live Default Setting. Default is 1. May be increased to
|
||||
* better interoperate with certain DHCP relay agents.
|
||||
*/
|
||||
|
||||
#define IPDHCPC_TTL 1
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_ASSIGN_IP_TIMEOUT
|
||||
*===========================================================================
|
||||
* Number of seconds to wait for an address to be assigned to an interface.
|
||||
* To allow for address collision detection (if enabled)
|
||||
*/
|
||||
#define IPDHCPC_ASSIGN_IP_TIMEOUT 15
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_FLAGS_BIT_BROADCAST
|
||||
*===========================================================================
|
||||
* Set the value of flag field:broadcast bit, default is 0.
|
||||
* 1 = enabled, 0 = disabled.
|
||||
*/
|
||||
#define IPDHCPC_FLAGS_BIT_BROADCAST 0
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDHCPC_SOCK_MIN_RECV_BUFSIZE
|
||||
*===========================================================================
|
||||
* Minimal dhcpc sock recv bufsize
|
||||
*/
|
||||
#define IPDHCPC_SOCK_MIN_RECV_BUFSIZE 16800
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK EXAMPLE SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcpc_example.c,v $ $Revision: 1.11.10.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipdhcpc_example.c,v $
|
||||
* $Author: hxu0 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01h,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01g,04sep09,h_s Fix the callback compile error when using gnu.
|
||||
01f,02oct09,spw Declare option, reply callback only if param not null.
|
||||
01e,02dec08,spw Fix WIND00146283 and add REPLY_CB_EVENT_OFFER case
|
||||
01d,04jun08,spw Change Syslog facility, cleanup
|
||||
01c,11oct07,uol Defect WIND00107491, add DHCP capabilities in bootrom.
|
||||
01b,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01a,11dec06,kch Integrated to VxWorks build infrastructure.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipdhcpc_config.h"
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_CLIB_PROTO
|
||||
#undef IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipdhcpc.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_WB_BUILD) || defined(INCLUDE_BOOT_DHCPC)
|
||||
IP_EXTERN FUNCPTR _ipdhcpc_callback_hook;
|
||||
#endif
|
||||
|
||||
/* typedef to make compiler happy... */
|
||||
typedef Ip_err (*ipdhcpc_option_cb)(Ipdhcpc_handle *handle, Ip_u8 *option);
|
||||
|
||||
#if DHCPC_INSTALL_OPTION_CALLBACK_HOOK == TRUE
|
||||
/*
|
||||
* forward declarations for the user-defined dhcp client callback hooks
|
||||
* to satisfy the compiler.
|
||||
*/
|
||||
#ifdef DHCPC_OPTION_CALLBACK_HOOK
|
||||
Ip_err DHCPC_OPTION_CALLBACK_HOOK (Ipdhcpc_handle *, Ip_u8 *);
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* DHCPC_OPTION_CALLBACK_HOOK is applicable only if
|
||||
* DHCPC_INSTALL_OPTION_CALLBACK_HOOK is set to TRUE. Explicitly re-define
|
||||
* these hooks to NULL so that we don't get compiler errors
|
||||
*/
|
||||
#undef DHCPC_OPTION_CALLBACK_HOOK
|
||||
#define DHCPC_OPTION_CALLBACK_HOOK IP_NULL
|
||||
#endif /* DHCPC_INSTALL_OPTION_CALLBACK_HOOK */
|
||||
|
||||
#if DHCPC_INSTALL_REPLY_CALLBACK_HOOK == TRUE
|
||||
/*
|
||||
* forward declarations for the user-defined dhcp client callback hooks
|
||||
* to satisfy the compiler.
|
||||
*/
|
||||
#ifdef DHCPC_REPLY_CALLBACK_HOOK
|
||||
Ip_err DHCPC_REPLY_CALLBACK_HOOK (Ipdhcpc_handle *, int);
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* DHCPC_REPLY_CALLBACK_HOOK is applicable only if
|
||||
* DHCPC_INSTALL_REPLY_CALLBACK_HOOK is set to TRUE. Explicitly re-define
|
||||
* these hooks to NULL so that we don't get compiler errors
|
||||
*/
|
||||
#undef DHCPC_REPLY_CALLBACK_HOOK
|
||||
#endif /* DHCPC_INSTALL_REPLY_CALLBACK_HOOK */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
Ip_err
|
||||
ipdhcpc_option_default_callback(Ipdhcpc_handle *handle, Ip_u8 *option);
|
||||
|
||||
|
||||
Ip_err
|
||||
ipdhcpc_reply_default_callback(Ipdhcpc_handle *handle, int event);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
*
|
||||
* ipdhcpc_option_default_callback - default dhcp client callback routine
|
||||
*
|
||||
* This is an example implementation of the dhcp client option callback
|
||||
* routine. It is called if no dhcp client option callback routine is
|
||||
* assigned to the macro DHCPC_OPTION_CALLBACK_HOOK.
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
Ip_err
|
||||
ipdhcpc_option_default_callback(Ipdhcpc_handle *handle, Ip_u8 *option)
|
||||
{
|
||||
(void)handle;
|
||||
|
||||
switch (*option)
|
||||
{
|
||||
case IPDHCPC_OPTCODE_VENDOR_ENCAPSULATED_OPTIONS:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Let IPDHCPC act on option */
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
*
|
||||
* ipdhcpc_reply_default_callback - default dhcp client callback routine
|
||||
*
|
||||
* This is an example implementation of the dhcp client reply callback
|
||||
* routine. It is called if no dhcp client option callback routine is
|
||||
* assigned to the macro DHCPC_REPLY_CALLBACK_HOOK.
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
|
||||
Ip_err
|
||||
ipdhcpc_reply_default_callback(Ipdhcpc_handle *handle, int event)
|
||||
{
|
||||
|
||||
/* Informational only in this implementation. */
|
||||
|
||||
if (handle == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case IPDHCPC_REPLY_CB_EVENT_OFFER:
|
||||
|
||||
break;
|
||||
|
||||
case IPDHCPC_REPLY_CB_EVENT_ACK:
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
|
||||
fail:
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* ipdhcpc_option_callback - dhcp client option callback routine
|
||||
*
|
||||
* This routine called once for each option prior to IPDHCPC is acting on the
|
||||
* option, i.e. this callback can be used to change the contents of the DHCP
|
||||
* server reply (caution!)
|
||||
*
|
||||
* .IP <option>
|
||||
* Pointer to start of option, i.e. option[0] = Code; option[1] = Len;
|
||||
* option[2-i] = Optional option data
|
||||
* .IP <handle>
|
||||
* Pointer to request handle
|
||||
*
|
||||
* RETURNS:
|
||||
* IP_TRUE to let IPDHCPC act on the option (recommended) or IP_FALSE if
|
||||
* option should be ignored by IPDHCPC.
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipdhcpc_option_callback(Ipdhcpc_handle *handle, Ip_u8 *option)
|
||||
{
|
||||
ipdhcpc_option_cb dhcpc_cb;
|
||||
/*eliminate warning when compiling with gnu*/
|
||||
#if defined(IP_WB_BUILD) || defined(INCLUDE_BOOT_DHCPC)
|
||||
dhcpc_cb = (NULL!=DHCPC_OPTION_CALLBACK_HOOK) ? DHCPC_OPTION_CALLBACK_HOOK :
|
||||
_ipdhcpc_callback_hook ? _ipdhcpc_callback_hook :
|
||||
ipdhcpc_option_default_callback;
|
||||
#else
|
||||
dhcpc_cb = ipdhcpc_option_default_callback;
|
||||
#endif
|
||||
|
||||
return dhcpc_cb(handle, option);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* ipdhcpc_reply_callback - dhcp client reply callback routine
|
||||
*
|
||||
* this callback can be used to change the contents of the DHCP
|
||||
* server reply (caution!)
|
||||
*
|
||||
* .IP <handle>
|
||||
* Pointer to ipdhcpc handle object, containing, i.e. option[0] = Code; option[1] = Len;
|
||||
* option[2-i] = Optional option data
|
||||
*
|
||||
* .IP <event>
|
||||
* The reply type (ACK, NACK, etc)
|
||||
*
|
||||
* RETURNS:
|
||||
* IPCOM_SUCCESS to let IPDHCPC act on the reply (recommended) or !IPCOM_SUCCESS if
|
||||
* reply should be declined by IPDHCPC.
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipdhcpc_reply_callback(Ipdhcpc_handle *handle, int event)
|
||||
{
|
||||
Ipdhcpc_reply_cb dhcpc_cb;
|
||||
/*eliminate warning when compiling with gnu*/
|
||||
#if defined(IP_WB_BUILD) && defined (DHCPC_REPLY_CALLBACK_HOOK)
|
||||
dhcpc_cb = DHCPC_REPLY_CALLBACK_HOOK;
|
||||
#else
|
||||
dhcpc_cb = ipdhcpc_reply_default_callback;
|
||||
#endif
|
||||
if(dhcpc_cb != IP_NULL)
|
||||
return dhcpc_cb(handle, event);
|
||||
else
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdnsc_config.c,v $ $Revision: 1.12 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipdnsc_config.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01j,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01i,11sep07,dlk Change parameter names for tertiary and quaternary name
|
||||
servers to match those used in 00comp_ipnet_apps.cdf.
|
||||
01h,28feb07,dlk Replace _gethostbyname, _gethostbyaddr function pointers
|
||||
with reentrant versions _ipcom_gethostbyname_r,
|
||||
_ipcom_gethostbyaddr_r.
|
||||
01g,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01f,01dec06,kch Added support for additional configuration parameters.
|
||||
01e,13sep06,kch Refresh with Sept 08, 2006 code drop
|
||||
01d,28aug06,kch Corrected ipcom_gethostbyaddr() prototype declaration.
|
||||
01c,28aug06,tkf Remove dependency on hostLib.
|
||||
01b,23aug06,tkf Add a call to gethostbynameInit() and gethostbynameInit()
|
||||
01a,03aug06,kch Renamed INCLUDE_NSLOOKUP_CMD to INCLUDE_IPNSLOOKUP_CMD.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* DNS client configuration.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_sock2.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
#if defined(INCLUDE_IPNSLOOKUP_CMD) || !defined(IP_WB_BUILD)
|
||||
IP_EXTERN int ipdnsc_cmd_nslookup(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if defined(IP_WB_BUILD)
|
||||
IP_EXTERN FUNCPTR _ipcom_gethostbyname_r;
|
||||
IP_EXTERN FUNCPTR _ipcom_gethostbyaddr_r;
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipdnsc_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdnsc_conf_sysvar
|
||||
*===========================================================================
|
||||
* DNS Client Configuration Variables
|
||||
*/
|
||||
IP_CONST Ipcom_sysvar ipdnsc_conf_sysvar[] =
|
||||
{
|
||||
/* DNS server listening port */
|
||||
IP_SYSVAR( "ipdnsc.port", "53", DNSC_SERVER_PORT),
|
||||
|
||||
/* Timeout in seconds when waiting for responses to DNS queries */
|
||||
IP_SYSVAR( "ipdnsc.timeout", "3", DNSC_TIMEOUT),
|
||||
|
||||
/* Number of retries for DNS queries */
|
||||
IP_SYSVAR( "ipdnsc.retries", "1", DNSC_RETRIES),
|
||||
|
||||
/* DNS domain name */
|
||||
IP_SYSVAR( "ipdnsc.domainname", "interpeak.se", DNSC_DOMAIN_NAME),
|
||||
|
||||
/* DNS primary name server */
|
||||
IP_SYSVAR( "ipdnsc.primaryns", "", DNSC_PRIMARY_NAME_SERVER),
|
||||
|
||||
/* DNS secondary name server */
|
||||
IP_SYSVAR( "ipdnsc.secondaryns", "", DNSC_SECONDARY_NAME_SERVER),
|
||||
|
||||
/* DNS tertiary name server */
|
||||
IP_SYSVAR( "ipdnsc.tertiaryns", "", DNSC_TERTIARY_NAME_SERVER),
|
||||
|
||||
/* DNS quaternary name server */
|
||||
IP_SYSVAR( "ipdnsc.quaternaryns", "", DNSC_QUATERNARY_NAME_SERVER),
|
||||
|
||||
/* Zone for ipv4 address to name lookups */
|
||||
IP_SYSVAR( "ipdnsc.ip4.zone", "in-addr.arpa", DNSC_IP4_ZONE),
|
||||
|
||||
/* Zone for ipv6 address to name lookups */
|
||||
IP_SYSVAR( "ipdnsc.ip6.zone", "ip6.int", DNSC_IP6_ZONE), /* RFC1886: "ip6.int" RFC3152: "ip6.arpa" */
|
||||
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdnsc_configure
|
||||
*===========================================================================
|
||||
* Description: Configure DNS client.
|
||||
* Parameters: None.
|
||||
* Returns: IPCOM_SUCCESS or IPCOM_ERR_XXX if failed.
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipdnsc_configure(void)
|
||||
{
|
||||
Ip_err ret;
|
||||
|
||||
ret = ipcom_sysvar_setv(ipdnsc_conf_sysvar, 0);
|
||||
if(ret != IPCOM_SUCCESS)
|
||||
return ret;
|
||||
|
||||
#if defined(IP_WB_BUILD)
|
||||
/* Initialize _gethostby* func pointers */
|
||||
_ipcom_gethostbyname_r = (FUNCPTR)ipcom_gethostbyname_r;
|
||||
_ipcom_gethostbyaddr_r = (FUNCPTR)ipcom_gethostbyaddr_r;
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPNSLOOKUP_CMD) || !defined(IP_WB_BUILD)
|
||||
ret = ipcom_shell_add_cmd("nslookup", "nslookup [ options ] <modifier...>",
|
||||
"Query Internet name servers interactively",
|
||||
ipdnsc_cmd_nslookup,
|
||||
IPCOM_SHELL_PRIO_SAME, IPCOM_PROC_STACK_DEFAULT);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdnsc_config.h,v $ $Revision: 1.22 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipdnsc_config.h,v $
|
||||
* $Author: jren $ $Date: 2010-10-13 01:07:40 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPDNSC_CONFIG_H
|
||||
#define IPDNSC_CONFIG_H
|
||||
|
||||
#include <ipcom_config.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* DNS Client compile time configuration.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPTESTENGINE
|
||||
#if !defined(IPDNSC_USE_TEST)
|
||||
#define IPDNSC_USE_TEST
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Define to include support for gated-style MD5 authentication. */
|
||||
#ifdef IPCOM_USE_MD5
|
||||
#define IPDNSC_INCLUDE_MD5
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDNSC_CONF_DNS_HOSTS
|
||||
*===========================================================================
|
||||
* A list of known hosts.
|
||||
*
|
||||
*/
|
||||
#define IPDNSC_CONF_DNS_HOSTS { "127.0.0.1", "localhost" }, \
|
||||
{ "::1", "localhost6" }, \
|
||||
{ IP_NULL, IP_NULL }
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPDNSC_CONF_MAX_CACHE_ENTRIES
|
||||
*===========================================================================
|
||||
* The maximum number of entries in the DNS cache.
|
||||
*
|
||||
*/
|
||||
#define IPDNSC_CONF_MAX_CACHE_ENTRIES 32
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftpc_api_config.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipftpc_api_config.h,v $
|
||||
* $Author: jren $ $Date: 2010-08-06 08:11:32 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPC_API_CONFIG_H
|
||||
#define IPFTPC_API_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Define this to enable verbatim console output */
|
||||
/*#define IPFTPC_USE_VERBATIM_CONOUT*/
|
||||
|
||||
/* Define this to remove partially transferred files */
|
||||
/*#define IPFTPC_USE_REMOVE_FILE_ON_ERROR*/
|
||||
|
||||
/* Data transfer buffer size */
|
||||
#define IPFTPC_DATABUFSIZE 4096
|
||||
|
||||
/* FTP command buffer size */
|
||||
#define IPFTPC_SINBUFSIZE 1024
|
||||
|
||||
/* Max no of simultaneous sessions */
|
||||
#define IPFTPC_MAX_SESSIONS 8
|
||||
|
||||
/* Max no of arguments for FTP command */
|
||||
#define IPFTPC_MAX_ARGS 10
|
||||
|
||||
/* Argument delimiters */
|
||||
#define IPFTPC_DELIMITERS " ,|\r\n"
|
||||
|
||||
/* Directory path separators */
|
||||
#define IPFTPC_DIRSEP "/\\"
|
||||
|
||||
/* Timeout when sending data to socket */
|
||||
#define IPFTPC_SEND_TIMEOUT 30
|
||||
|
||||
/* Timeout when receiving data to socket */
|
||||
#define IPFTPC_RECEIVE_TIMEOUT 30
|
||||
|
||||
/* Attempts to bind data socket when using random ports */
|
||||
#define IPFTPC_BIND_ATTEMPTS 5
|
||||
|
||||
/* Version */
|
||||
#define IPFTPC_VERSION_API 1
|
||||
|
||||
/* Transport protocol for FTPC */
|
||||
#undef IPFTPC_USE_SCTP
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftpc_cmd_config.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipftpc_cmd_config.h,v $
|
||||
* $Author: jren $ $Date: 2010-10-21 22:54:15 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPC_CMD_CONFIG_H
|
||||
#define IPFTPC_CMD_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_config.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Test system requires 'IPFTPS_USE_TEST' */
|
||||
#ifdef IPTESTENGINE
|
||||
#if !defined(IPFTPC_USE_TEST)
|
||||
#define IPFTPC_USE_TEST
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Command buffer size */
|
||||
#define IPFTPC_CMDBUFSIZE IP_PATH_MAX
|
||||
|
||||
/* Max no of arguments for FTP command */
|
||||
#define IPFTPC_MAX_ARGS 10
|
||||
|
||||
/* Max length of username and password */
|
||||
#define IPFTPC_MAX_USERNAME 32
|
||||
#define IPFTPC_MAX_PASSWORD 32
|
||||
|
||||
/* Argument delimiters */
|
||||
#define IPFTPC_WHITESPACE " \t\r\n"
|
||||
|
||||
/* Version */
|
||||
#define IPFTPC_VERSIONSTR "1.1.3"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftpc_config.c,v $ $Revision: 1.4.12.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipftpc_config.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01f,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01e,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01d,01dec06,kch Updated CVS revision log entry.
|
||||
01c,13sep06,kch Refresh with Sept 08, 2006 code drop
|
||||
01b,28aug06,kch Update based on Aug 22, 2006 code drop.
|
||||
01a,03aug06,kch Renamed INCLUDE_FTP_CMD to INCLUDE_IPFTP_CMD.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_shell.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
#if defined(INCLUDE_IPFTP_CMD) || !defined(IP_WB_BUILD)
|
||||
IP_EXTERN int ipftpc_cmd_main(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipftpc_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_conf_sysvar
|
||||
*===========================================================================
|
||||
* FTP Client Configuration Variables
|
||||
*/
|
||||
|
||||
IP_CONST Ipcom_sysvar ipftpc_conf_sysvar[] =
|
||||
{
|
||||
/* The FTP client src IPvX address */
|
||||
IP_SYSVAR("ipftpc.bindaddress", IP_NULL, FTPC_BIND_ADDRESS),
|
||||
|
||||
{IP_NULL, IP_NULL}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_configure
|
||||
*===========================================================================
|
||||
* Description: Configure FTP client.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipftpc_configure(void)
|
||||
{
|
||||
Ip_err ret = IPCOM_SUCCESS;
|
||||
|
||||
(void)ipcom_sysvar_setv(ipftpc_conf_sysvar, 0);
|
||||
|
||||
#if defined(INCLUDE_IPFTP_CMD) || !defined(IP_WB_BUILD)
|
||||
ret = ipcom_shell_add_cmd("ftp", "ftp [options] [host]", "FTP client",
|
||||
ipftpc_cmd_main,
|
||||
IPCOM_SHELL_PRIO_SAME,
|
||||
IPCOM_PROC_STACK_DEFAULT);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftps_config.c,v $ $Revision: 1.8.10.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipftps_config.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01h,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01g,19dec,09ggz Added ipftps data socket linger time to sysvar.Defect WIND00127796.
|
||||
01f,08dec08,ggz Added FTPS_SOCKET_BACKLOG parameter for FTP control socket
|
||||
01e,27feb07,kch ipftps.versionstr should not be made configurable
|
||||
(WIND00089286).
|
||||
01d,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01c,01dec06,kch Updated CVS revision log entry.
|
||||
01b,13sep06,kch Refresh with Sept 08, 2006 code drop
|
||||
01a,28aug06,kch Update based on Aug 22, 2006 code drop.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPCOM_IPFTPS_ROOT
|
||||
#define IPCOM_IPFTPS_ROOT IPCOM_FILE_ROOT
|
||||
#endif
|
||||
|
||||
#ifndef FTPS_DATA_SOCKET_LINGER
|
||||
#define FTPS_DATA_SOCKET_LINGER "10" /* Data socket linger time */
|
||||
#endif
|
||||
|
||||
#ifndef FTPS_DATABUF_SIZE
|
||||
#define FTPS_DATABUF_SIZE "4096" /* Data transfer buffer size */
|
||||
#endif
|
||||
|
||||
#ifdef IPFTP_TLS
|
||||
|
||||
#ifdef IPCOM_USE_KEY_DB
|
||||
#define IPFTPS_USE_PRIVACY
|
||||
#else
|
||||
#warning " IPCOM_USE_KEY_DB is not defined !!"
|
||||
#endif
|
||||
|
||||
#ifndef FTPS_TLS
|
||||
#define FTPS_TLS "0"
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_ADVANCE_FTPS_KEY_PRIVACY
|
||||
#define ENABLE_ADVANCE_FTPS_KEY_PRIVACY "0"
|
||||
#endif
|
||||
|
||||
#ifndef FTPS_TLS_KEY_FILE
|
||||
#define FTPS_TLS_KEY_FILE ""
|
||||
#endif
|
||||
|
||||
#ifndef FTPS_TLS_CERT_FILE
|
||||
#define FTPS_TLS_CERT_FILE ""
|
||||
#endif
|
||||
|
||||
#ifndef FTPS_TLS_SECRECT_KEY
|
||||
#define FTPS_TLS_SECRECT_KEY ""
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipftps_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftps_conf_sysvar
|
||||
*===========================================================================
|
||||
* FTP Server Configuration Variables
|
||||
*/
|
||||
|
||||
IP_CONST Ipcom_sysvar ipftps_conf_sysvar[] =
|
||||
{
|
||||
/* Defaults for new sessions */
|
||||
|
||||
/* Auth attempts before disconnect */
|
||||
IP_SYSVAR("ipftps.authentications", "3", FTPS_AUTH_ATTEMPTS),
|
||||
|
||||
/* Time to sleep after auth fail */
|
||||
IP_SYSVAR("ipftps.authsleep", "5", FTPS_SLEEP_TIME),
|
||||
|
||||
/* Use local ports from lportbase+1 */
|
||||
IP_SYSVAR("ipftps.lportbase", "49151", FTPS_LOCAL_PORT_BASE),
|
||||
|
||||
/* Reject peer ports <= pportbase */
|
||||
IP_SYSVAR("ipftps.pportbase", "1023", FTPS_PEER_PORT_BASE),
|
||||
IP_SYSVAR("ipftps.proxy", "0", FTPS_ENABLE_PROXY), /* Disable proxy FTP */
|
||||
IP_SYSVAR("ipftps.readonly", "0", FTPS_MODE), /* Read/write mode */
|
||||
IP_SYSVAR("ipftps.root", "/", FTPS_ROOT_DIR), /* Directory root */
|
||||
IP_SYSVAR("ipftps.dir", IPCOM_IPFTPS_ROOT, FTPS_INITIAL_DIR), /* Initial directory */
|
||||
|
||||
/* General defaults */
|
||||
/* Max no of simultaneous sessions */
|
||||
IP_SYSVAR("ipftps.max_sessions", "8", FTPS_MAX_SESSIONS),
|
||||
IP_SYSVAR("ipftps.port_number", "21", FTPS_PORT_NUM), /* Server port number */
|
||||
IP_SYSVAR("ipftps.receive_timeout", "30", FTPS_RECV_TIMEOUT), /* Data receive timeout */
|
||||
IP_SYSVAR("ipftps.send_timeout", "30", FTPS_SEND_TIMEOUT), /* Data send timeout */
|
||||
|
||||
/* Socket backlog queue number set by listen */
|
||||
IP_SYSVAR("ipftps.socket_backlog", IP_NULL, FTPS_SOCKET_BACKLOG),
|
||||
|
||||
/* Data socket linger time */
|
||||
IP_SYSVAR("ipftps.dsock_linger", IP_NULL, FTPS_DATA_SOCKET_LINGER),
|
||||
|
||||
/* Data transfer buffer size */
|
||||
IP_SYSVAR("ipftps.databuf_size", "4096", FTPS_DATABUF_SIZE),
|
||||
|
||||
/* User inactivity timeout */
|
||||
IP_SYSVAR("ipftps.session_timeout", "300", FTPS_INACTIVITY_TIMEOUT),
|
||||
IP_SYSVAR("ipftps.system", "UNIX", FTPS_SYS_TYPE), /* Reported system type */
|
||||
IP_SYSVAR("ipftps.versionstr", "6.8", "6.8"), /* Reported version */
|
||||
|
||||
#ifdef IPFTP_TLS
|
||||
IP_SYSVAR("ipftps.tls.enable","0",FTPS_TLS),
|
||||
#ifdef IPFTPS_USE_PRIVACY
|
||||
IP_SYSVAR("ipftps.tls.private.enable","0",ENABLE_ADVANCE_FTPS_KEY_PRIVACY),
|
||||
#endif
|
||||
IP_SYSVAR("ipftps.tls.secret.key",IP_NULL,FTPS_TLS_SECRECT_KEY),
|
||||
IP_SYSVAR("ipftps.tls.key_file",IP_NULL,FTPS_TLS_KEY_FILE),
|
||||
IP_SYSVAR("ipftps.tls.cert_file",IP_NULL,FTPS_TLS_CERT_FILE),
|
||||
#endif
|
||||
{IP_NULL, IP_NULL}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftps_configure
|
||||
*===========================================================================
|
||||
* Description: Configure FTP server.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipftps_configure(void)
|
||||
{
|
||||
(void)ipcom_sysvar_setv(ipftps_conf_sysvar, 0);
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftps_config.h,v $ $Revision: 1.7.12.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipftps_config.h,v $
|
||||
* $Author: jren $ $Date: 2017-05-17 07:08:20 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPS_CONFIG_H
|
||||
#define IPFTPS_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_config.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Test system requires 'IPFTPS_USE_TEST' */
|
||||
#ifdef IPTESTENGINE
|
||||
#if !defined(IPFTPS_USE_TEST)
|
||||
#define IPFTPS_USE_TEST
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Data transfer buffer size */
|
||||
#define IPFTPS_DATABUFSIZE 4096
|
||||
|
||||
/* FTP command buffer size */
|
||||
#define IPFTPS_CMDBUFSIZE 1024
|
||||
|
||||
/* Max no of arguments for FTP command */
|
||||
#define IPFTPS_MAX_ARGS 10
|
||||
|
||||
/* Argument delimiters */
|
||||
#define IPFTPS_DELIMITERS " ,|"
|
||||
|
||||
/* PASS cmd argument delimiters */
|
||||
#define IPFTPS_PASS_DELIMITERS "\r\n"
|
||||
|
||||
/* Directory path separators */
|
||||
#define IPFTPS_DIRSEP "/\\"
|
||||
|
||||
/* Attempts to bind data socket when using random ports */
|
||||
#define IPFTPS_BIND_ATTEMPTS 5
|
||||
|
||||
/* Mimic IIS behaviour (send 150 before establishing data connection) */
|
||||
/*#define IPFTPS_USE_IIS_150*/
|
||||
|
||||
|
||||
/* Transport protocol for FTPS */
|
||||
#undef IPFTPS_USE_SCTP
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK EXAMPLE SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftps_example.c,v $ $Revision: 1.12.10.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/ipftps_example.c,v $
|
||||
* $Author: qsun $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01h,08Oct13,qsn Usage update for WIND00420146
|
||||
01g,26jul12,h_x Fix WIND00362583
|
||||
01f,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01e,01dec09,rjq Fix for defect WIND00185613.
|
||||
01d,02oct07,uol Remove default ftp/interpeak username/password.
|
||||
01c,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01b,28dec06,tkf Remove debug statements.
|
||||
01a,11dec06,kch Integrated to VxWorks build infrastructure.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipftps_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IP_PORT_UNIX
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#elif defined(IPCOM_USE_CLIB_PROTO)
|
||||
#undef IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
#include <ipcom.h>
|
||||
#include <ipcom_config.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_auth.h>
|
||||
|
||||
#include "ipftps.h"
|
||||
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
#include <vxWorks.h>
|
||||
#include <private/loginLibP.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* typedef to make compiler happy... */
|
||||
typedef int (*ipftps_cb)(Ipftps_session *session, char *password);
|
||||
|
||||
#if defined(IP_WB_BUILD)
|
||||
/*
|
||||
* forward declarations for the user-defined ftp server authentication
|
||||
* callback hook to satisfy the compiler.
|
||||
*/
|
||||
#ifdef FTPS_AUTH_CALLBACK_HOOK
|
||||
int FTPS_AUTH_CALLBACK_HOOK (Ipftps_session *, char *);
|
||||
#else
|
||||
#undef FTPS_AUTH_CALLBACK_HOOK
|
||||
#define FTPS_AUTH_CALLBACK_HOOK IP_NULL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
ipftps_authenticate_default_callback(Ipftps_session *session, char *password);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* ipftps_authenticate_default_callback - default ftps callback routine
|
||||
*
|
||||
* This is an example implementation of the ftp server authentication
|
||||
* callback routine. It is called if no ftp server callback routine is
|
||||
* assigned to the macro FTPS_AUTH_CALLBACK_HOOK.
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
int
|
||||
ipftps_authenticate_default_callback(Ipftps_session *session, char *password)
|
||||
{
|
||||
/*
|
||||
** This is a simple authentication skeleton,
|
||||
** please modify to suit your purposes.
|
||||
*/
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
#ifdef IPFTPS_USE_TEST
|
||||
if(0)
|
||||
#else
|
||||
if (systemSecurityIsEnabled == FALSE)
|
||||
#endif
|
||||
{
|
||||
#endif
|
||||
if (ipcom_strcmp(session->username, "anonymous") == 0)
|
||||
{
|
||||
/* IPCOM_LOG1(INFO, "Anonymous login with password %s", password); */
|
||||
|
||||
/* Access restrictions apply for anonymous users */
|
||||
session->readonly = 1;
|
||||
}
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
}
|
||||
#endif
|
||||
#ifdef IPFTPS_USE_TEST
|
||||
else if (ipcom_strcmp(session->username, "ftp") == 0 &&
|
||||
ipcom_strcmp(password, "interpeak") == 0)
|
||||
{
|
||||
/* IPCOM_LOG1(INFO, "Hard-coded 'ftp' login with password %s",
|
||||
password); */
|
||||
}
|
||||
#endif
|
||||
#if defined(IP_WB_BUILD)
|
||||
#ifdef INCLUDE_IPCOM_USE_AUTH
|
||||
else if (ipcom_auth_login(session->username, password,
|
||||
IP_NULL, IP_NULL, IP_NULL) == IPCOM_SUCCESS)
|
||||
{
|
||||
/* IPCOM_LOG1(INFO, "User '%s' login", session->username); */
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#ifdef IPCOM_USE_AUTH
|
||||
else if (ipcom_auth_login(session->username, password,
|
||||
IP_NULL, IP_NULL, IP_NULL) == IPCOM_SUCCESS)
|
||||
{
|
||||
/* IPCOM_LOG1(INFO, "User '%s' login", session->username); */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
else
|
||||
{
|
||||
/* IPCOM_LOG2(WARNING, "Login attempt with user: %s, pw: %s",
|
||||
session->username, password); */
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
** Set security parameters individually for the session if the
|
||||
** default values defined as sysvars aren't appropriate:
|
||||
**
|
||||
** readonly: Write commands disallowed.
|
||||
** proxy: Allow that data and control connections
|
||||
** use different IP addresses.
|
||||
** lportbase: Use local ports above this value.
|
||||
** Set to 0 to use port 20.
|
||||
** pportbase: Refuse to connect to peer ports <= this value.
|
||||
** Set to 65535 to entirely disable PORT and EPRT commands.
|
||||
** root: Root directory for the session.
|
||||
*/
|
||||
|
||||
session->readonly = 1; /* Readonly mode */
|
||||
session->proxy = 0; /* Disable proxy FTP */
|
||||
session->lportbase = 49151; /* Use local ports from lportbase+1 */
|
||||
session->pportbase = 1023; /* Reject peer ports <= pportbase */
|
||||
|
||||
/* Limit access to the filesystem */
|
||||
/* Note: using ipcom_strdup is necessary here, internally session->root
|
||||
* points to a buffer that can only hold default/configured content.
|
||||
*/
|
||||
ipftps_free(session->root);
|
||||
if ((session->root = ipcom_strdup("/pub")) == IP_NULL)
|
||||
{
|
||||
IPCOM_LOG(ERR, "Out of memory") IPCOM_END;
|
||||
return 1;
|
||||
}
|
||||
/* Note: session->cwd points to an internally allocated buffer which you can use directly */
|
||||
ipcom_strcpy(session->cwd, "/pub");
|
||||
|
||||
#endif
|
||||
|
||||
/* IPCOM_LOG1(INFO, "User %s logged in", session->username); */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* ipftps_authenticate - ftp server authentication callback routine
|
||||
*
|
||||
* The FTP sessions may be configured individually by setting session options.
|
||||
* This is done after the authentication is complete, and enables clients to
|
||||
* be given permissions according to general policies, local databases or
|
||||
* even a RADIUS request to a remote host. The options are normally set in
|
||||
* the ipftps_authenticate() routine and are accessed through the session
|
||||
* pointer.
|
||||
*
|
||||
* .IP <session>
|
||||
* Session descriptor.
|
||||
* .IP <password>
|
||||
* Password.
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 for successful authentication, 1 otherwise.
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipftps_authenticate(Ipftps_session *session, char *password)
|
||||
{
|
||||
ipftps_cb ftps_cb;
|
||||
|
||||
/*eliminate warning when compiling with gnu*/
|
||||
#if defined(IP_WB_BUILD) && defined(FTPS_AUTH_CALLBACK_HOOK)
|
||||
ftps_cb = FTPS_AUTH_CALLBACK_HOOK;
|
||||
#else
|
||||
ftps_cb = ipftps_authenticate_default_callback;
|
||||
#endif
|
||||
|
||||
return ftps_cb(session, password);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptftpc_config.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/iptftpc_config.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01f,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01e,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01d,01dec06,kch Updated CVS revision log entry.
|
||||
01c,13sep06,kch Refresh with Sept 08, 2006 code drop
|
||||
01b,28aug06,kch Update based on Aug 22, 2006 code drop.
|
||||
01a,03aug06,kch Renamed INCLUDE_TFTP_CLIENT_CMD to INCLUDE_IPTFTP_CLIENT_CMD.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* TFTP client configuration.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_shell.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(INCLUDE_IPTFTP_CLIENT_CMD) || !defined(IP_WB_BUILD)
|
||||
IP_EXTERN int iptftp_cmd_tftp(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err iptftpc_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN IP_CONST Ipcom_sysvar iptftp_conf_sysvar[];
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftpc_configure
|
||||
*===========================================================================
|
||||
* Description: Configure TFTP client.
|
||||
* Parameters: none.
|
||||
* Returns: nothing.
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftpc_configure(void)
|
||||
{
|
||||
Ip_err ret = IPCOM_SUCCESS;
|
||||
|
||||
(void)ipcom_sysvar_setv(iptftp_conf_sysvar, IPCOM_SYSVAR_FLAG_OVERWRITE);
|
||||
|
||||
#if defined(INCLUDE_IPTFTP_CLIENT_CMD) || !defined(IP_WB_BUILD)
|
||||
ret = ipcom_shell_add_cmd("tftp", "tftp [-a] <get|put> <host> ...",
|
||||
"Trivial FTP client",
|
||||
iptftp_cmd_tftp,
|
||||
IPCOM_SHELL_PRIO_SAME, IPCOM_PROC_STACK_DEFAULT);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptftps_config.c,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/config/iptftps_config.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01e,03Aug10,rjq New file for Networking Configuration VSB restructuring.
|
||||
01d,03jan07,kch Updated CVS revision log entry for Jan 03 code drop.
|
||||
01c,01dec06,kch Updated CVS revision log entry.
|
||||
01b,13sep06,kch Refresh with Sept 08, 2006 code drop
|
||||
01a,28aug06,kch Update based on Aug 22, 2006 code drop.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* TFTP server configuration
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define TFTPS_PORT "69 " /* TFTP server listening port */
|
||||
#define TFTPC_PEER_PORT "69 " /* TFTP port used by client to send packets */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err iptftps_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* SYSTEM VARIABLES
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_conf_sysvar
|
||||
*===========================================================================
|
||||
* TFTP Configuration Variables. Both client and server.
|
||||
*/
|
||||
IP_CONST Ipcom_sysvar iptftp_conf_sysvar[] =
|
||||
{
|
||||
/* TFTP server working directory */
|
||||
IP_SYSVAR( "iptftp.dir", IPCOM_FILE_ROOT "tftpdir", TFTPS_DIRS ),
|
||||
|
||||
/* TFTP retransmit timeout in seconds */
|
||||
IP_SYSVAR( "iptftp.timeout", "5", TFTPS_RETRANSMIT_TIMEOUT),
|
||||
|
||||
/* TFTP number of retries */
|
||||
IP_SYSVAR( "iptftp.retries", "2", TFTPS_RETRIES),
|
||||
|
||||
/* TFTP server listening port */
|
||||
IP_SYSVAR( "iptftp.srvPort", TFTPS_PORT, TFTPS_PORT),
|
||||
|
||||
/* TFTP port used by client to send packets */
|
||||
IP_SYSVAR( "iptftp.clntSrvPort", TFTPC_PEER_PORT, TFTPC_PEER_PORT),
|
||||
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftps_configure
|
||||
*===========================================================================
|
||||
* Description: Configure TFTP server
|
||||
* Parameters: none.
|
||||
* Returns: nothing.
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftps_configure(void)
|
||||
{
|
||||
(void)ipcom_sysvar_setv(iptftp_conf_sysvar, IPCOM_SYSVAR_FLAG_OVERWRITE);
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,10 @@
|
||||
IPTARGETS := lib
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include ipappl.mk
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
@@ -0,0 +1,118 @@
|
||||
#############################################################################
|
||||
# IPAPPL.MK
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipappl.mk,v $ $Revision: 1.9.10.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipappl/gmake/ipappl.mk,v $
|
||||
# $Author: svc-cmnet $ $Date: 2013-03-13 07:45:12 $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
ifneq ($(IPPORT),las)
|
||||
ifneq ($(IPPORT),lkm)
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ipappl
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEFINE
|
||||
###########################################################################
|
||||
|
||||
# start DHCP client
|
||||
IPDEFINE += -DIPDHCPC
|
||||
|
||||
ifneq ($(findstring -basic,$(OPT)),-basic)
|
||||
# start DNS client
|
||||
IPDEFINE += -DIPDNSC
|
||||
|
||||
# start TFTP client
|
||||
IPDEFINE += -DIPTFTPC
|
||||
|
||||
# start TFTP server
|
||||
IPDEFINE += -DIPTFTPS
|
||||
|
||||
# start FTP client
|
||||
IPDEFINE += -DIPFTPC
|
||||
|
||||
# start FTP server
|
||||
IPDEFINE += -DIPFTPS
|
||||
endif # ifeq ($(findstring -basic,$(OPT)),-basic)
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
###########################################################################
|
||||
|
||||
IPINCLUDE += -I$(IPAPPL_ROOT)/config
|
||||
IPINCLUDE += -I$(IPAPPL_ROOT)/include
|
||||
|
||||
IPLIBINCLUDE += -I$(IPAPPL_ROOT)/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
###########################################################################
|
||||
|
||||
# Interpeak TFTP server and client
|
||||
ifneq ($(findstring -basic,$(OPT)),-basic)
|
||||
IPLIBOBJECTS_C += iptftps_config.o
|
||||
IPLIBOBJECTS_C += iptftpc_config.o
|
||||
IPLIBOBJECTS += iptftp_common.o
|
||||
IPLIBOBJECTS += iptftps.o
|
||||
IPLIBOBJECTS += iptftpc.o
|
||||
IPLIBOBJECTS += iptftpc_cmd_tftp.o
|
||||
|
||||
# Interpeak FTP server and client
|
||||
IPLIBOBJECTS_C += ipftps_config.o
|
||||
IPLIBOBJECTS_C += ipftpc_config.o
|
||||
IPLIBOBJECTS_C += ipftps_example.o
|
||||
IPLIBOBJECTS += ipftps.o
|
||||
IPLIBOBJECTS += ipftps_tls.o
|
||||
IPLIBOBJECTS += ipftpc.o
|
||||
IPLIBOBJECTS += ipftpc_cmd_ftp.o
|
||||
|
||||
# Interpeak DNS client
|
||||
IPLIBOBJECTS_C += ipdnsc_config.o
|
||||
IPLIBOBJECTS += ipdnsc.o
|
||||
IPLIBOBJECTS += ipdnsc_api.o
|
||||
IPLIBOBJECTS += ipdnsc_cmd_nslookup.o
|
||||
IPLIBOBJECTS += ipdnsc_update.o
|
||||
endif # ifeq ($(findstring -basic,$(OPT)),-basic)
|
||||
|
||||
# Interpeak DHCP client
|
||||
IPLIBOBJECTS_C += ipdhcpc_config.o
|
||||
IPLIBOBJECTS_C += ipdhcpc_example.o
|
||||
IPLIBOBJECTS += ipdhcpc.o
|
||||
IPLIBOBJECTS += ipdhcpc_cmd_dhcpc.o
|
||||
|
||||
# Compiles the xxx_config.o if the $SKIP_CONFIG macro is either not defined
|
||||
# or set to anything other than true.
|
||||
ifneq ($(SKIP_CONFIG),true)
|
||||
IPLIBOBJECTS += $(IPLIBOBJECTS_C)
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
###########################################################################
|
||||
|
||||
IPSRCDIRS += $(IPAPPL_ROOT)/src $(IPAPPL_ROOT)/config
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
###########################################################################
|
||||
|
||||
IPLIBS += $(IPLIBROOT)/libipappl.a
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
###########################################################################
|
||||
# END OF IPAPPL.MK
|
||||
###########################################################################
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipappl.h,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipappl.h,v $
|
||||
* $Author: ulf $ $Date: 2007-10-13 07:04:51 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPAPPL_H
|
||||
#define IPAPPL_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPAPPL_RELEASE 60600
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,466 @@
|
||||
/* ipdhcpc.h - API of DHCP client */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcpc.h,v $ $Revision: 1.29.16.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipdhcpc.h,v $
|
||||
* $Author: jwang9 $ $Date: 2016-05-20 07:17:44 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
* and Jonas Rendel <jonas@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPDHCPC_H
|
||||
#define IPDHCPC_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library contains the API for the DHCP client
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_tmo.h>
|
||||
#include <ipcom_tags.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP option codes
|
||||
*===========================================================================
|
||||
* Option codes automatically handled by IPDHCP.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP option codes - auto
|
||||
*===========================================================================
|
||||
* Option codes handled transparantly by IPDHCPC, i.e. user code does not
|
||||
* need to add/remove/modify these options.
|
||||
*/
|
||||
#define IPDHCPC_OPTCODE_DHCP_MESSAGE_TYPE 53
|
||||
#define IPDHCPC_OPTCODE_DHCP_SERVER_IDENTIFIER 54
|
||||
#define IPDHCPC_OPTCODE_DHCP_MAX_MESSAGE_SIZE 57
|
||||
#define IPDHCPC_OPTCODE_DHCP_CLIENT_IDENTIFIER 61
|
||||
#define IPDHCPC_OPTCODE_END 255
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP option codes - used
|
||||
*===========================================================================
|
||||
* Option codes used by IPDHCPC in some way or another.
|
||||
*/
|
||||
|
||||
#define IPDHCPC_OPTCODE_PAD 0
|
||||
#define IPDHCPC_OPTCODE_SUBNET_MASK 1
|
||||
#define IPDHCPC_OPTCODE_ROUTERS 3
|
||||
#define IPDHCPC_OPTCODE_DOMAIN_NAME_SERVERS 6
|
||||
#define IPDHCPC_OPTCODE_DOMAIN_NAME 15
|
||||
#define IPDHCPC_OPTCODE_DHCP_LEASE_TIME 51
|
||||
#define IPDHCPC_OPTCODE_OPTION_OVERLOAD 52
|
||||
#define IPDHCPC_OPTCODE_DHCP_PARAMETER_REQUEST_LIST 55
|
||||
#define IPDHCPC_OPTCODE_DHCP_MESSAGE 56
|
||||
#define IPDHCPC_OPTCODE_DHCP_RENEWAL_TIME 58
|
||||
#define IPDHCPC_OPTCODE_DHCP_REBINDING_TIME 59
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP option codes - user
|
||||
*===========================================================================
|
||||
* Option codes not read or written by IPDHCPC.
|
||||
*/
|
||||
#define IPDHCPC_OPTCODE_TIME_OFFSET 2
|
||||
#define IPDHCPC_OPTCODE_TIME_SERVERS 4
|
||||
#define IPDHCPC_OPTCODE_NAME_SERVERS 5
|
||||
#define IPDHCPC_OPTCODE_LOG_SERVERS 7
|
||||
#define IPDHCPC_OPTCODE_COOKIE_SERVERS 8
|
||||
#define IPDHCPC_OPTCODE_LPR_SERVERS 9
|
||||
#define IPDHCPC_OPTCODE_IMPRESS_SERVERS 10
|
||||
#define IPDHCPC_OPTCODE_RESOURCE_LOCATION_SERVERS 11
|
||||
#define IPDHCPC_OPTCODE_HOST_NAME 12
|
||||
#define IPDHCPC_OPTCODE_BOOT_SIZE 13
|
||||
#define IPDHCPC_OPTCODE_MERIT_DUMP 14
|
||||
#define IPDHCPC_OPTCODE_SWAP_SERVER 16
|
||||
#define IPDHCPC_OPTCODE_ROOT_PATH 17
|
||||
#define IPDHCPC_OPTCODE_EXTENSIONS_PATH 18
|
||||
#define IPDHCPC_OPTCODE_IP_FORWARDING 19
|
||||
#define IPDHCPC_OPTCODE_NON_LOCAL_SOURCE_ROUTING 20
|
||||
#define IPDHCPC_OPTCODE_POLICY_FILTER 21
|
||||
#define IPDHCPC_OPTCODE_MAX_DGRAM_REASSEMBLY 22
|
||||
#define IPDHCPC_OPTCODE_DEFAULT_IP_TTL 23
|
||||
#define IPDHCPC_OPTCODE_PATH_MTU_AGING_TIMEOUT 24
|
||||
#define IPDHCPC_OPTCODE_PATH_MTU_PLATEAU_TABLE 25
|
||||
#define IPDHCPC_OPTCODE_INTERFACE_MTU 26
|
||||
#define IPDHCPC_OPTCODE_ALL_SUBNETS_LOCAL 27
|
||||
#define IPDHCPC_OPTCODE_BROADCAST_ADDRESS 28
|
||||
#define IPDHCPC_OPTCODE_PERFORM_MASK_DISCOVERY 29
|
||||
#define IPDHCPC_OPTCODE_MASK_SUPPLIER 30
|
||||
#define IPDHCPC_OPTCODE_ROUTER_DISCOVERY 31
|
||||
#define IPDHCPC_OPTCODE_ROUTER_SOLICITATION_ADDRESS 32
|
||||
#define IPDHCPC_OPTCODE_STATIC_ROUTES 33
|
||||
#define IPDHCPC_OPTCODE_TRAILER_ENCAPSULATION 34
|
||||
#define IPDHCPC_OPTCODE_ARP_CACHE_TIMEOUT 35
|
||||
#define IPDHCPC_OPTCODE_IEEE802_3_ENCAPSULATION 36
|
||||
#define IPDHCPC_OPTCODE_DEFAULT_TCP_TTL 37
|
||||
#define IPDHCPC_OPTCODE_TCP_KEEPALIVE_INTERVAL 38
|
||||
#define IPDHCPC_OPTCODE_TCP_KEEPALIVE_GARBAGE 39
|
||||
#define IPDHCPC_OPTCODE_NIS_DOMAIN 40
|
||||
#define IPDHCPC_OPTCODE_NIS_SERVERS 41
|
||||
#define IPDHCPC_OPTCODE_NTP_SERVERS 42
|
||||
#define IPDHCPC_OPTCODE_VENDOR_ENCAPSULATED_OPTIONS 43
|
||||
#define IPDHCPC_OPTCODE_NETBIOS_NAME_SERVERS 44
|
||||
#define IPDHCPC_OPTCODE_NETBIOS_DD_SERVER 45
|
||||
#define IPDHCPC_OPTCODE_NETBIOS_NODE_TYPE 46
|
||||
#define IPDHCPC_OPTCODE_NETBIOS_SCOPE 47
|
||||
#define IPDHCPC_OPTCODE_FONT_SERVERS 48
|
||||
#define IPDHCPC_OPTCODE_X_DISPLAY_MANAGER 49
|
||||
#define IPDHCPC_OPTCODE_DHCP_REQUESTED_ADDRESS 50
|
||||
#define IPDHCPC_OPTCODE_VENDOR_CLASS_IDENTIFIER 60
|
||||
#define IPDHCPC_OPTCODE_TFTP_SERVER_NAME 66
|
||||
#define IPDHCPC_OPTCODE_BOOTFILE_NAME 67
|
||||
#define IPDHCPC_OPTCODE_VI_VENDOR_CLASS 124
|
||||
#define IPDHCPC_OPTCODE_VI_VENDOR_INFORMATION 125
|
||||
#define IPDHCPC_OPTCODE_TFTP_SERVER_ADDRESS 0 /* Fake option code */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP magic cookie
|
||||
*===========================================================================
|
||||
* See RFC 2132.
|
||||
*/
|
||||
|
||||
#define IPDHCPC_MAGIC_COOKIE 0x63825363
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP reply callback event codes
|
||||
*===========================================================================
|
||||
* Possible events to be sent and handled by a DHCP client reply callback.
|
||||
*/
|
||||
|
||||
#define IPDHCPC_REPLY_CB_EVENT_ACK 1 /* Received an ACK */
|
||||
#define IPDHCPC_REPLY_CB_EVENT_NAK 2 /* Received a NAK */
|
||||
#define IPDHCPC_REPLY_CB_EVENT_EXPIRE 3 /* Lease expiration */
|
||||
#define IPDHCPC_REPLY_CB_EVENT_FAIL_IFLOST 4 /* Lost the interface */
|
||||
#define IPDHCPC_REPLY_CB_EVENT_BOOTREPLY 5 /* Received a boot reply */
|
||||
#define IPDHCPC_REPLY_CB_EVENT_OFFER 6 /* Received an offer */
|
||||
#define IPDHCPC_REPLY_CB_EVENT_FAIL_RETRY 7 /* Retries expired */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP reply callback return codes
|
||||
*===========================================================================
|
||||
* Possible return values to be returned by a DHCP client reply callback.
|
||||
*/
|
||||
|
||||
#define IPDHCPC_REPLY_CB_ERROR -1
|
||||
#define IPDHCPC_REPLY_CB_SUCCESS 0
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* RFC2131 3.6 Use of DHCP in clients with multiple interfaces
|
||||
*===========================================================================
|
||||
* A client with multiple network interfaces must use DHCP through each
|
||||
interface independently to obtain configuration information
|
||||
parameters for those separate interfaces.
|
||||
*/
|
||||
#define IPDHCPC_OPTION_DOMAIN_CONF 1
|
||||
#define IPDHCPC_OPTION_DNSSERVER_CONF 2
|
||||
#define IPDHCPC_OPTION_NTPSERVER_CONF 4
|
||||
|
||||
#define IPDHCPC_SNAME_LEN (64)
|
||||
#define IPDHCPC_BOOTFILE_NAME_LEN (128)
|
||||
|
||||
/* Reply callback for DHCP replies. */
|
||||
|
||||
struct Ipdhcpc_handle_priv_struct;
|
||||
struct Ipdhcpc_handle_struct;
|
||||
typedef int (*Ipdhcpc_reply_cb)(struct Ipdhcpc_handle_struct *handle, int event);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_info
|
||||
*===========================================================================
|
||||
* This structure is filled in by the IPDHCPC code upon valid DHCP client
|
||||
* request reply.
|
||||
*/
|
||||
typedef struct Ipdhcpc_info_struct
|
||||
{
|
||||
Ip_err status; /* IPCOM_SUCCESS else IPCOM_ERR_XXX. */
|
||||
|
||||
Ip_u32 ipaddr_n; /* Client IP address (yiaddr). */
|
||||
Ip_u32 serveraddr_n; /* Server IP in network endian. Default = 0 -> broadcast */
|
||||
Ip_u16 serverport_n; /* Server UDP port in network endian. Default = ip_htons(67). */
|
||||
Ip_u16 reserved;
|
||||
|
||||
int optlen; /* Options length excluding cookie. */
|
||||
Ip_u8 *options; /* DHCP options */
|
||||
|
||||
Ip_u8 sname[IPDHCPC_SNAME_LEN]; /* Optional server host name, null terminated string. */
|
||||
|
||||
Ip_u32 bootaddr_n; /* IP address of next bootstrap server (siaddr). */
|
||||
Ip_u8 file[IPDHCPC_BOOTFILE_NAME_LEN]; /* Optional boot file name, null terminated string. */
|
||||
|
||||
Ip_time_t t1; /* Time at which we enter RENEWING state */
|
||||
Ip_time_t t2; /* Time at which we enter REBINDING state */
|
||||
}
|
||||
Ipdhcpc_info;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_handle
|
||||
*===========================================================================
|
||||
* Created and initialized by ipdhcpc_handle_malloc() to prepare for a
|
||||
* DHCP client request. User may modify the handle before calling
|
||||
* ipdhcpc_ifrequest().
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
typedef struct Ipdhcpc_handle_struct
|
||||
{
|
||||
Ip_u32 user_res[2]; /* Reserved for user use. IPDHCPC does not touch it. */
|
||||
|
||||
Ip_u32 ifindex; /* DHCP interface index. Set by ipdhcpc_handle_malloc(). */
|
||||
|
||||
Ip_u32 clientaddr_n; /* Desired IP in network endian else 0. */
|
||||
Ip_u32 serveraddr_n; /* Server IP in network endian. Default = 0 -> broadcast */
|
||||
Ip_u16 serverport_n; /* Server UDP port in network endian. Default = ip_htons(67). */
|
||||
Ip_u16 reserved;
|
||||
Ip_u32 magic_cookie; /* Magic vendor cookie. Default=0x63825363. */
|
||||
|
||||
char file[IPDHCPC_BOOTFILE_NAME_LEN]; /* Optional boot file name, null terminated string. */
|
||||
char sname[IPDHCPC_SNAME_LEN]; /* Optional server host name, null terminated string. */
|
||||
|
||||
/* User callback for the reply. Set to IP_NULL for blocking mode. */
|
||||
Ipdhcpc_reply_cb reply_cb;
|
||||
|
||||
int optlen; /* User options length. */
|
||||
Ip_u8 *options; /* Additional user options. */
|
||||
Ip_u32 option_confvar;/* interface set sysvar of dnsserver ,doname, or ntpserver */
|
||||
|
||||
/***** IPDHCPC info for the user after succesful DHCP server reply. */
|
||||
Ipdhcpc_info info;
|
||||
|
||||
/***** IPDHCPC private info. do not read/write *****/
|
||||
struct Ipdhcpc_handle_priv_struct *priv;
|
||||
}
|
||||
Ipdhcpc_handle;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdhcpc_option_callback - apply user-defined actions based on DHCP option
|
||||
*
|
||||
* This callback routine examines each DHCP option returned by a DHCP server and
|
||||
* can execute user-defined operations for specific options. For example, it can
|
||||
* be implemented to apply a different operation to each of three vendor-specific
|
||||
* options received from the server.
|
||||
*
|
||||
* The callback is executed before any other client action on the server\'s
|
||||
* response and can be used to change the contents of the response before it is
|
||||
* acted on further. For a sample implementation, see 'ipdhcpc_example.c'.
|
||||
*
|
||||
* Parameter:
|
||||
* \is
|
||||
* \i <option>
|
||||
* A pointer to the starting location of an option, where:
|
||||
*
|
||||
* \ml
|
||||
* \m -
|
||||
* <option>[0] is a DHCP option code.
|
||||
* \m -
|
||||
* <option>[1] is the length of the option, in bytes, from the start of the
|
||||
* option to the end of its data portion.
|
||||
* \m -
|
||||
* <option>[2] is the first element containing data for the option.
|
||||
* \me
|
||||
* \i <handle>
|
||||
* A pointer to the request handle passed in ipdhcpc_ifrequest.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: Either 'IP_TRUE', in which case the DHCP client can take further
|
||||
* action on the option, or 'IP_FALSE', in which case the client takes no further
|
||||
* action based on the option.
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipdhcpc_option_callback
|
||||
(
|
||||
Ipdhcpc_handle *handle,
|
||||
Ip_u8 *option
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdhcpc_reply_callback - apply user-defined actions based on DHCP reply
|
||||
*
|
||||
* This callback routine examines each DHCP reply returned by a DHCP server and
|
||||
* can execute user-defined operations for specific replies. For example, it can
|
||||
* be implemented to apply a different operation to NAK's, ACK's, Lease
|
||||
* expiration, etc.
|
||||
*
|
||||
* The callback is executed before any other client action on the server\'s
|
||||
* response and can be used to change the contents of the response before it is
|
||||
* acted on further. For a sample implementation, see 'ipdhcpc_example.c'.
|
||||
*
|
||||
* Parameter:
|
||||
* \is
|
||||
* \i <handle>
|
||||
* A pointer to the ipdhcpc handle
|
||||
* \ie
|
||||
* \is
|
||||
* \i <event>
|
||||
* The reply type
|
||||
* \ie
|
||||
* RETURNS: Either 'IP_TRUE', in which case the DHCP client can take further
|
||||
* action on the option, or 'IP_FALSE', in which case the client takes no further
|
||||
* action based on the option.
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipdhcpc_reply_callback
|
||||
(
|
||||
Ipdhcpc_handle *handle,
|
||||
int event
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdhcpc_renew_get - allow user to send RENEW message before Lease expiration
|
||||
*
|
||||
* This routine gives a way of sending RENEW message before Lease expiration,
|
||||
* it is convenient for someone who can't wait, but wants to renew the lease
|
||||
* immediately.
|
||||
*
|
||||
* Parameter:
|
||||
* \is
|
||||
* \i <ifname>
|
||||
* A pointer to an interface
|
||||
* \ie
|
||||
* RETURNS: Either 'IPCOM_SUCCESS', in which case the DHCP client can send the
|
||||
* RENEW message, or 'IPCOM_ERR_XX', in which case the client fails to send, here
|
||||
* 'IPCOM_ERR_XX' can be IPCOM_ERR_INVALID_ARG, IPCOM_ERR_INVALID_INTERFACE, etc.
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipdhcpc_renew_get
|
||||
(
|
||||
char *ifname
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdhcpc_inform_get - allow user to send INFORM message to server
|
||||
*
|
||||
* This routine gives a way of sending INFORM message, Sometime client already
|
||||
* has an address through other method, just wants to get several parameters
|
||||
* from server, that's what this routine is all about.
|
||||
*
|
||||
*
|
||||
* Parameter:
|
||||
* \is
|
||||
* \i <ifname>
|
||||
* A pointer to an interface.
|
||||
* \ie
|
||||
* \is
|
||||
* \i <addr>
|
||||
* A pointer to an address of the interface.
|
||||
* \ie
|
||||
* RETURNS: Either 'IPCOM_SUCCESS', in which case the DHCP client can send the
|
||||
* RENEW message, or 'IPCOM_ERR_XX', in which case the client fails to send, here
|
||||
* 'IPCOM_ERR_XX' can be IPCOM_ERR_INVALID_ARG, IPCOM_ERR_INVALID_INTERFACE, etc.
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipdhcpc_inform_get
|
||||
(
|
||||
char *ifname,
|
||||
char *addr
|
||||
);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_reply_cb
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipdhcpc_reply_cb
|
||||
(
|
||||
Ipdhcpc_handle *handle,
|
||||
int event
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,524 @@
|
||||
/* ipdnsc.h - Public API of Wind River DNS client */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdnsc.h,v $ $Revision: 1.16.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipdnsc.h,v $
|
||||
* $Author: ulf $ $Date: 2011-11-16 10:33:22 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPDNSC_H
|
||||
#define IPDNSC_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library contains the APIs provided by the WindRiver DNS client.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_tags.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* release
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#define IPDNSC_RELEASE 60500
|
||||
|
||||
|
||||
/* Error codes for lookup functions */
|
||||
#define IPDNSC_HOST_NOT_FOUND 1
|
||||
#define IPDNSC_TRY_AGAIN 2
|
||||
#define IPDNSC_NO_RECOVERY 3
|
||||
#define IPDNSC_NO_DATA 4
|
||||
#define IPDNSC_NO_ADDRESS IPDNSC_NO_DATA
|
||||
|
||||
/* Error codes returned by DNS update API */
|
||||
#define IPDNSC_UPDATE_OK 0 /* success */
|
||||
#define IPDNSC_UPDATE_ERR_GENERAL -1 /* An unexpected general error */
|
||||
#define IPDNSC_UPDATE_ERR_INVALID -2 /* Invalid argument */
|
||||
#define IPDNSC_UPDATE_ERR_MSGSIZE -3 /* An invalid message length */
|
||||
#define IPDNSC_UPDATE_ERR_EPROTOTYPE -4 /* The answer to a query had the wrong domain name */
|
||||
#define IPDNSC_UPDATE_ERR_NOTSUPPORT_TYPE -5 /* Update type is not supported */
|
||||
#define IPDNSC_UPDATE_ERR_NOTSUPPORT_ALG -6 /* Not supported Algorithm */
|
||||
#define IPDNSC_UPDATE_ERR_MD5_DISABLED -7 /* MD5 lib is disabled */
|
||||
#define IPDNSC_UPDATE_ERR_NO_TSIG -8 /* No TSIG */
|
||||
#define IPDNSC_UPDATE_ERR_TSIG_NO_SPACE -9 /* No enough space fro TSIG */
|
||||
#define IPDNSC_UPDATE_ERR_TSIG_BADFORMAT -10 /* Bad TSIG format */
|
||||
#define IPDNSC_UPDATE_ERR_TSIG_BADKEY -11 /* Bad TSIG KEY */
|
||||
#define IPDNSC_UPDATE_ERR_TSIG_SERVER_BADKEY -12 /* Reply key from the server is bad */
|
||||
#define IPDNSC_UPDATE_ERR_TSIG_SERVER_BADTIME -13 /* Reply time from the server is bad */
|
||||
#define IPDNSC_UPDATE_ERR_YXRRSET -14
|
||||
|
||||
/* used by dynamic dns RFC2136 */
|
||||
#define IPDNSC_MAXDNAME 1025 /* maximum domain name */
|
||||
#define IPDNSC_MAXCDNAME 255 /* maximum compressed domain name */
|
||||
#define IPDNSC_MAX_ALG_NAME 128 /* maximum Algorithm name */
|
||||
/* DNS TSIG Algorithm */
|
||||
#define IPDNSC_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
|
||||
|
||||
/* Flags for lookup functions */
|
||||
#define IPDNSC_AI_V4MAPPED 0x00000008
|
||||
#define IPDNSC_AI_ALL 0x00000010
|
||||
#define IPDNSC_AI_ADDRCONFIG 0x00000020
|
||||
#define IPDNSC_AI_DEFAULT (IPDNSC_AI_V4MAPPED | IPDNSC_AI_ADDRCONFIG)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* defined section field */
|
||||
typedef enum Ipdnsc_section_enum {
|
||||
IPDNSC_SECTION_QD = 0, /* Query: Question. */
|
||||
IPDNSC_SECTION_ZN = 0, /* Update: Zone. */
|
||||
IPDNSC_SECTION_AN = 1, /* Query: Answer. */
|
||||
IPDNSC_SECTION_PR = 1, /* Update: Prerequisites. */
|
||||
IPDNSC_SECTION_NS = 2, /* Query: Name servers. */
|
||||
IPDNSC_SECTION_UP = 2, /* Update: Update. */
|
||||
IPDNSC_SECTION_AR = 3, /* Query|Update: Additional records. */
|
||||
IPDNSC_SECTION_MAX = 4
|
||||
}
|
||||
Ipdnsc_section;
|
||||
|
||||
/* Query class codes */
|
||||
typedef enum Ipdnsc_qclass_enum {
|
||||
IPDNSC_QCLASS_INVALID = 0, /* Cookie. */
|
||||
IPDNSC_QCLASS_INET = 1, /* Internet. */
|
||||
/* Query class values which do not appear in resource records */
|
||||
IPDNSC_QCLASS_NONE = 254, /* for prereq. sections in update requests */
|
||||
IPDNSC_QCLASS_ANY = 255, /* Wildcard match. */
|
||||
IPDNSC_QCLASS_MAX = 65536
|
||||
}
|
||||
Ipdnsc_qclass;
|
||||
|
||||
/* Query type codes for resources and queries. */
|
||||
typedef enum Ipdnsc_qtype_enum {
|
||||
IPDNSC_QTYPE_INVALID = 0, /* Cookie. */
|
||||
IPDNSC_QTYPE_A = 1, /* Host address. */
|
||||
IPDNSC_QTYPE_NS = 2, /* Authoritative server. */
|
||||
IPDNSC_QTYPE_MD = 3, /* Mail destination. */
|
||||
IPDNSC_QTYPE_MF = 4, /* Mail forwarder. */
|
||||
IPDNSC_QTYPE_CNAME = 5, /* Canonical name. */
|
||||
IPDNSC_QTYPE_SOA = 6, /* Start of authority zone. */
|
||||
IPDNSC_QTYPE_MB = 7, /* Mailbox domain name. */
|
||||
IPDNSC_QTYPE_MG = 8, /* Mail group member. */
|
||||
IPDNSC_QTYPE_MR = 9, /* Mail rename name. */
|
||||
IPDNSC_QTYPE_NULL = 10, /* Null resource record. */
|
||||
IPDNSC_QTYPE_WKS = 11, /* Well known service. */
|
||||
IPDNSC_QTYPE_PTR = 12, /* Domain name pointer. */
|
||||
IPDNSC_QTYPE_HINFO = 13, /* Host information. */
|
||||
IPDNSC_QTYPE_MINFO = 14, /* Mailbox information. */
|
||||
IPDNSC_QTYPE_MX = 15, /* Mail routing information. */
|
||||
IPDNSC_QTYPE_TXT = 16, /* Text strings. */
|
||||
IPDNSC_QTYPE_RP = 17, /* Responsible person. */
|
||||
IPDNSC_QTYPE_AFSDB = 18, /* AFS cell database. */
|
||||
IPDNSC_QTYPE_X25 = 19, /* X_25 calling address. */
|
||||
IPDNSC_QTYPE_ISDN = 20, /* ISDN calling address. */
|
||||
IPDNSC_QTYPE_RT = 21, /* Router. */
|
||||
IPDNSC_QTYPE_NSAP = 22, /* NSAP address. */
|
||||
IPDNSC_QTYPE_NSAP_PTR = 23, /* Reverse NSAP lookup (deprecated). */
|
||||
IPDNSC_QTYPE_SIG = 24, /* Security signature. */
|
||||
IPDNSC_QTYPE_KEY = 25, /* Security key. */
|
||||
IPDNSC_QTYPE_PX = 26, /* X.400 mail mapping. */
|
||||
IPDNSC_QTYPE_GPOS = 27, /* Geographical position (withdrawn). */
|
||||
IPDNSC_QTYPE_AAAA = 28, /* Ip6 Address. */
|
||||
IPDNSC_QTYPE_LOC = 29, /* Location Information. */
|
||||
IPDNSC_QTYPE_NXT = 30, /* Next domain (security). */
|
||||
IPDNSC_QTYPE_EID = 31, /* Endpoint identifier. */
|
||||
IPDNSC_QTYPE_NIMLOC = 32, /* Nimrod Locator. */
|
||||
IPDNSC_QTYPE_SRV = 33, /* Server Selection. */
|
||||
IPDNSC_QTYPE_ATMA = 34, /* ATM Address */
|
||||
IPDNSC_QTYPE_NAPTR = 35, /* Naming Authority PoinTeR */
|
||||
IPDNSC_QTYPE_KX = 36, /* Key Exchange */
|
||||
IPDNSC_QTYPE_CERT = 37, /* Certification record */
|
||||
IPDNSC_QTYPE_A6 = 38, /* IPv6 address (deprecates AAAA) */
|
||||
IPDNSC_QTYPE_DNAME = 39, /* Non-terminal DNAME (for IPv6) */
|
||||
IPDNSC_QTYPE_SLINK = 40, /* Kitchen sink (experimentatl) */
|
||||
IPDNSC_QTYPE_OPT = 41, /* EDNS0 option (meta-RR) */
|
||||
IPDNSC_QTYPE_APL = 42, /* Address prefix list (RFC3123) */
|
||||
IPDNSC_QTYPE_TKEY = 249, /* Transaction key */
|
||||
IPDNSC_QTYPE_TSIG = 250, /* Transaction signature. */
|
||||
IPDNSC_QTYPE_IXFR = 251, /* Incremental zone transfer. */
|
||||
IPDNSC_QTYPE_AXFR = 252, /* Transfer zone of authority. */
|
||||
IPDNSC_QTYPE_MAILB = 253, /* Transfer mailbox records. */
|
||||
IPDNSC_QTYPE_MAILA = 254, /* Transfer mail agent records. */
|
||||
IPDNSC_QTYPE_ANY = 255, /* Wildcard match. */
|
||||
IPDNSC_QTYPE_ZXFR = 256, /* BIND-specific, nonstandard. */
|
||||
IPDNSC_QTYPE_MAX = 65536
|
||||
}
|
||||
Ipdnsc_qtype;
|
||||
|
||||
/* defined response codes. */
|
||||
typedef enum Ipdnsc_rcode_enum {
|
||||
IPDNSC_RCODE_NOERROR = 0, /* No error occurred. */
|
||||
IPDNSC_RCODE_FORMERR = 1, /* Format error. */
|
||||
IPDNSC_RCODE_SERVFAIL = 2, /* Server failure. */
|
||||
IPDNSC_RCODE_NXDOMAIN = 3, /* Name error. */
|
||||
IPDNSC_RCODE_NOTIMPL = 4, /* Unimplemented. */
|
||||
IPDNSC_RCODE_REFUSED = 5, /* Operation refused. */
|
||||
/* these are for BIND_UPDATE */
|
||||
IPDNSC_RCODE_YXDOMAIN = 6, /* Name exists */
|
||||
IPDNSC_RCODE_YXRRSET = 7, /* RRset exists */
|
||||
IPDNSC_RCODE_NXRRSET = 8, /* RRset does not exist */
|
||||
IPDNSC_RCODE_NOTAUTH = 9, /* Not authoritative for zone */
|
||||
IPDNSC_RCODE_NOTZONE= 10, /* Zone of record different from zone section */
|
||||
/* 11-15 available for assignment */
|
||||
/* The following are TSIG errors */
|
||||
IPDNSC_RCODE_BADSIG = 16,
|
||||
IPDNSC_RCODE_BADKEY = 17,
|
||||
IPDNSC_RCODE_BADTIME = 18,
|
||||
IPDNSC_RCODE_BADMODE = 19,
|
||||
IPDNSC_RCODE_BADNAME = 20,
|
||||
IPDNSC_RCODE_BADALG = 21,
|
||||
IPDNSC_RCODE_MAX = 22
|
||||
}
|
||||
Ipdnsc_rcode;
|
||||
|
||||
/* DNS update operation */
|
||||
typedef enum Ipdnsc_update_operation_enum {
|
||||
IPDNSC_UPOP_DELETE = 0,
|
||||
IPDNSC_UPOP_ADD = 1,
|
||||
IPDNSC_UPOP_MAX = 2
|
||||
}
|
||||
Ipdnsc_update_operation;
|
||||
|
||||
/*
|
||||
* This structure is used for TSIG authenticated messages
|
||||
*/
|
||||
typedef struct Ipdnsc_tsig_key_struct {
|
||||
char name[IPDNSC_MAXDNAME]; /* the name of key must also exist on the DNS server */
|
||||
char alg[IPDNSC_MAX_ALG_NAME]; /* DNS TSIG Algorithm */
|
||||
Ip_u8 *secret; /* base64 secret must also be same with the DNS server */
|
||||
Ip_u32 len; /* the length of secret */
|
||||
}
|
||||
Ipdnsc_tsig_key;
|
||||
|
||||
/*
|
||||
* This RR-like structure is particular to UPDATE.
|
||||
*/
|
||||
typedef struct Ipdnsc_updrec_struct {
|
||||
struct Ipdnsc_updrec_struct *next; /* next update record defined by caller */
|
||||
struct Ipdnsc_updrec_struct *samezone_next; /* point the next update record belongs to a same zone on the nameserver.
|
||||
It should be initialized by NULL. */
|
||||
Ipdnsc_section r_section; /* ZONE/PREREQUISITE/UPDATE */
|
||||
char *r_dname; /* owner of the RR */
|
||||
Ip_u16 r_class; /* class number */
|
||||
Ip_u16 r_type; /* type number */
|
||||
Ip_u32 r_ttl; /* time to live */
|
||||
Ip_u8 *r_data; /* rdata fields as text string */
|
||||
Ip_u32 r_size; /* size of r_data field */
|
||||
Ip_s32 r_opcode; /* type of operation */
|
||||
}
|
||||
Ipdnsc_updrec;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdnsc_api
|
||||
*===========================================================================
|
||||
* For better binary scalability at image build time, access to
|
||||
* the DNS resolver interface may be done through the following
|
||||
* set of function pointers:
|
||||
*/
|
||||
typedef struct Ipdnsc_api_struct
|
||||
{
|
||||
struct Ip_hostent *(*getipnodebyname)(const char *name, int af,
|
||||
int flags, int *error_num);
|
||||
struct Ip_hostent *(*getipnodebyaddr)(const void *src, Ip_size_t len,
|
||||
int af, int *error_num);
|
||||
void (*freehostent)(struct Ip_hostent *he);
|
||||
void (*cache_flush)(void);
|
||||
|
||||
}
|
||||
Ipdnsc_api;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdnsc_getipnodebyname - get host information by node name
|
||||
*
|
||||
* This routine can be used instead of the older standard gethostbyname() routine.
|
||||
* gethostbyname() is inadequate for many applications, first because it provides
|
||||
* no way for the caller to specify anything about the types of addresses desired
|
||||
* (IPv4 only, IPv6 only, IPv4-mapped IPv6 are 'OK', and so forth), and second because
|
||||
* many implementations of this function are not thread safe.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <name>
|
||||
* A pointer to either a node name or a numeric address string (for example, a
|
||||
* dotted-decimal IPv4 address or an IPv6 hex address).
|
||||
* \i <af>
|
||||
* Specifies the address family, either 'IPDNSC_AF_INET' or 'IPDNSC_AF_INET6'.
|
||||
* \i <flags>
|
||||
* Specifies the types of addresses that are searched for and the types of
|
||||
* addresses that are returned. Applications desiring finer control over the
|
||||
* types of addresses searched for and returned can specify other combinations
|
||||
* of the <flags> parameter. A <flags> parameter of '0' implies a strict
|
||||
* interpretation of the <af> parameter:
|
||||
*
|
||||
* If <flags> is '0' and <af> is 'AF_INET', then the caller wants only IPv4
|
||||
* addresses. A query is made for A records. If successful, the IPv4 addresses
|
||||
* are returned and the <h_length> member of the hostent structure is '4',
|
||||
* otherwise the function returns a NULL pointer.
|
||||
*
|
||||
* If <flags> is '0' and if< af> is 'AF_INET6', then the caller wants only IPv6
|
||||
* addresses. A query is made for AAAA records. If successful, the IPv6
|
||||
* addresses are returned and the <h_length> member of the hostent structure is
|
||||
* 16, otherwise the function returns a NULL pointer.
|
||||
*
|
||||
* Other constants can be logically-ORed into the <flags> parameter to modify the
|
||||
* behavior of the function.
|
||||
*
|
||||
* If the 'AI_V4MAPPED' flag is specified along with an <af> of 'AF_INET6', then
|
||||
* the caller will accept IPv4-mapped IPv6 addresses. That is, if no AAAA
|
||||
* records are found then a query is made for A records and any found are
|
||||
* returned as IPv4-mapped IPv6 addresses (<h_length> is 16). The 'AI_V4MAPPED'
|
||||
* flag is ignored unless af equals 'AF_INET6'.
|
||||
*
|
||||
* The 'AI_ALL' flag is used in conjunction with the 'AI_V4MAPPED' flag, and is
|
||||
* only used with the IPv6 address family. When 'AI_ALL' is logically or'd with
|
||||
* 'AI_V4MAPPED' flag then the caller wants all addresses: IPv6 and IPv4-mapped
|
||||
* IPv6. A query is first made for AAAA records and if successful, the IPv6
|
||||
* addresses are returned. Another query is then made for A records and any found
|
||||
* are returned as IPv4-mapped IPv6 addresses. <h_length> is 16. Only if both
|
||||
* queries fail does the function return a NULL pointer. This flag is ignored
|
||||
* unless af equals 'AF_INET6'.
|
||||
*
|
||||
* The 'AI_ADDRCONFIG' flag specifies that a query for AAAA records should occur
|
||||
* only if the node has at least one IPv6 source address configured and a query
|
||||
* for A records should occur only if the node has at least one IPv4 source
|
||||
* address configured. For example, if the node has no IPv6 source addresses
|
||||
* configured and <af> equals 'AF_INET6', and if the node name being looked up
|
||||
* has both AAAA and A records, then:
|
||||
*
|
||||
* \ml
|
||||
* \m -
|
||||
* If only 'AI_ADDRCONFIG' is specified, the function returns a NULL pointer.
|
||||
* \m -
|
||||
* If 'AI_ADDRCONFIG' \| 'AI_V4MAPPED' is specified, the A records are returned
|
||||
* as IPv4-mapped IPv6 addresses.
|
||||
* \me
|
||||
* \i <error_num>
|
||||
* A pointer to an error code. <error_num> value is returned to the caller, via a
|
||||
* pointer, with the appropriate error code in <error_num> to support thread safe
|
||||
* error code returns.
|
||||
*
|
||||
* <error_num> is set to one of the following values:
|
||||
*
|
||||
* \is
|
||||
* \i 'IPDNSC_HOST_NOT_FOUND'
|
||||
* No such host is known.
|
||||
* \i 'IPDNSC_NO_ADDRESS'
|
||||
* The server recognized the request and the name but address is available.
|
||||
* Another type of request to the name server for the domain might return an
|
||||
* answer.
|
||||
* \i 'IPDNSC_NO_RECOVERY'
|
||||
* An unexpected server failure occurred which cannot be recovered.
|
||||
* \i 'IPDNSC_TRY_AGAIN'
|
||||
* A temporary and possibly transient error occurred, such as a failure of a
|
||||
* server to respond.
|
||||
* \ie
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent* ipdnsc_getipnodebyname
|
||||
(
|
||||
const char *name,
|
||||
int af,
|
||||
int flags,
|
||||
int *error_num
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdnsc_getipnodebyaddr - get host information by IP address
|
||||
*
|
||||
* This routine gets host information based on the host\'s IP address. It is
|
||||
* similar to the older standard gethostbyaddr() routine but adds an error number
|
||||
* and is thread safe.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <src>
|
||||
* A pointer to an IPv4 address or an IPv6 address in network endian.
|
||||
* \i <len>
|
||||
* The length of the address, in bytes.
|
||||
* \i <af>
|
||||
* The address family, either 'IPDNSC_AF_INET' or 'IPDNSC_AF_INET6'.
|
||||
* \i <error_num>
|
||||
* A pointer to an error code. <error_num> value is returned to the caller, via a
|
||||
* pointer, with the appropriate error code in <error_num>, to support thread
|
||||
* safe error code returns. The following error conditions may be returned for
|
||||
* <error_num>:
|
||||
*
|
||||
* \is
|
||||
* \i 'IPDNSC_HOST_NOT_FOUND'
|
||||
* No such host is known.
|
||||
* \i 'IPDNSC_NO_ADDRESS'
|
||||
* The server recognized the request and the name but no address is available.
|
||||
* Another type of request to the name server for the domain might return an
|
||||
* answer.
|
||||
* \i 'IPDNSC_NO_RECOVERY'
|
||||
* An unexpected server failure occurred which cannot be recovered.
|
||||
* \i 'IPDNSC_TRY_AGAIN'
|
||||
* A temporary and possibly transient error occurred, such as a failure of a
|
||||
* server to respond.
|
||||
* \ie
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent* ipdnsc_getipnodebyaddr
|
||||
(
|
||||
const void *src,
|
||||
Ip_size_t len,
|
||||
int af,
|
||||
int *error_num
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdnsc_freehostent - free memory allocated for an 'ip_hostent' structure
|
||||
*
|
||||
* This routine frees memory allocated for an 'ip_hostent' structure. An
|
||||
* 'ip_hostent' structure is dynamically allocated by the
|
||||
* ipdnsc_getipnodebyname() and ipdnsc_getipnodebyaddr() functions and must
|
||||
* therefore be freed after use.
|
||||
*
|
||||
* Parameter:
|
||||
* \is
|
||||
* \i <he>
|
||||
* A pointer to an 'ip_hostent' structure.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC void ipdnsc_freehostent
|
||||
(
|
||||
struct Ip_hostent *he
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdnsc_cache_flush - remove all entries in the resolver cache.
|
||||
*
|
||||
* This routine removes all entries in the resolver cache. It is useful after
|
||||
* the name server has been updated with new information about a specific host.
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC void ipdnsc_cache_flush(void);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipdnsc_do_update - build and send Dynamic Updates to correct name server
|
||||
*
|
||||
* This routine handle a complete DNS update process.It separates the linked list of
|
||||
* update records into groups so that all records in a group will belong to a single
|
||||
* zone on the nameserver. It creates a dynamic update packet for each zone and sends
|
||||
* it to the nameservers for that zone. Then it will receive and parse the response.
|
||||
*
|
||||
* Parameter:
|
||||
* \is
|
||||
* \i <update_records>
|
||||
* The pointer to the linked list of update records.
|
||||
* \i <r_buf>
|
||||
* The pointer to the buffer to be filled with the update response packet.
|
||||
* \i <r_buflen>
|
||||
* The length of the r_buf, in bytes.
|
||||
* \i <key>
|
||||
* The pointer to the key to use for authentication. This key must exist on the name server..
|
||||
* \i <error>
|
||||
* error code returned.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
* n (successful), where n is the number of zones updated or -1 (unsuccessful)
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_s32 ipdnsc_do_update
|
||||
(
|
||||
Ipdnsc_updrec *update_records, Ip_u8 *r_buf, Ip_s32* r_buflen, Ipdnsc_tsig_key *key, Ip_s32 *error
|
||||
);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftpc.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipftpc.h,v $
|
||||
* $Author: ulf $ $Date: 2006-09-27 12:23:05 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPC_H
|
||||
#define IPFTPC_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipftpc_api.h"
|
||||
#include "ipftpc_cmd.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* release
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#define IPFTPC_RELEASE 060004
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftpc_api.h,v $ $Revision: 1.9.12.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipftpc_api.h,v $
|
||||
* $Author: hxu0 $ $Date: 2013-04-18 08:48:02 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPC_API_H
|
||||
#define IPFTPC_API_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Select level of verbosity for syslog messages */
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
#if defined(_WRS_CONFIG_IPFTPC_SYSLOG_PRIORITY)
|
||||
#define IPCOM_SYSLOG_PRIORITY _WRS_CONFIG_IPFTPC_SYSLOG_PRIORITY
|
||||
#else
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_WARNING
|
||||
#endif
|
||||
|
||||
|
||||
/* Transport protocol for FTPC */
|
||||
#ifdef IPFTPC_USE_SCTP
|
||||
#define IPFTPC_PROTO IP_IPPROTO_SCTP
|
||||
#else
|
||||
#define IPFTPC_PROTO 0
|
||||
#endif
|
||||
|
||||
/* Error classes */
|
||||
#define IPFTPC_CFTPS 0 /* FTP server error (RFC 959) */
|
||||
#define IPFTPC_CFTPC 1000 /* FTP client error (IPFTPC_Exxx) */
|
||||
#define IPFTPC_CACCEPT 2000 /* Accept failed */
|
||||
#define IPFTPC_CBIND 3000 /* Bind failed */
|
||||
#define IPFTPC_CCONNECT 4000 /* Connect failed */
|
||||
#define IPFTPC_CLISTEN 5000 /* Listen failed */
|
||||
#define IPFTPC_COPEN 6000 /* Open failed */
|
||||
#define IPFTPC_CREAD 7000 /* Read failed */
|
||||
#define IPFTPC_CMUTEX 8000 /* Read failed */
|
||||
#define IPFTPC_CSCLOSE 9000 /* Socket close failed */
|
||||
#define IPFTPC_CSELECT 10000 /* Select failed */
|
||||
#define IPFTPC_CSOCKET 11000 /* Socket failed */
|
||||
#define IPFTPC_CWRITE 12000 /* Write failed */
|
||||
|
||||
#define IPFTPC_GET_C(x) ((x) - IPFTPC_GET_E(x))
|
||||
|
||||
/* Error codes */
|
||||
#define IPFTPC_ESUCCESS 299 /* Success (in the FTP server group
|
||||
so that x / 100 == 2) */
|
||||
#define IPFTPC_EBUSY 901 /* Session is busy */
|
||||
#define IPFTPC_ECONSOLE 902 /* Console write error */
|
||||
#define IPFTPC_EID 903 /* Invalid ID */
|
||||
#define IPFTPC_EINVHOST 904 /* Invalid host */
|
||||
#define IPFTPC_ENOMEM 905 /* Out of memory */
|
||||
#define IPFTPC_EPORT 906 /* Invalid port */
|
||||
#define IPFTPC_ESESSIONMAX 907 /* No more sessions allowed */
|
||||
#define IPFTPC_ETIMEOUT 908 /* Timeout */
|
||||
#ifdef IPFTP_TLS
|
||||
#define IPFTPC_ETLS 909
|
||||
#endif
|
||||
|
||||
#define IPFTPC_GET_E(x) ((x) % 1000)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Session ID */
|
||||
typedef Ip_u16 Ipftpc_id;
|
||||
|
||||
/* Generic IP address */
|
||||
typedef union
|
||||
{
|
||||
struct Ip_sockaddr sa; /* Generic address */
|
||||
struct Ip_sockaddr_in sin; /* IPv4 address */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_sockaddr_in6 sin6; /* IPv6 address */
|
||||
#endif
|
||||
}
|
||||
Ipftpc_addr;
|
||||
|
||||
/* Session attributes */
|
||||
typedef struct Ipftpc_attr
|
||||
{
|
||||
Ip_bool extended; /* Use extended addressing */
|
||||
Ip_bool passive; /* Passive mode */
|
||||
Ip_bool ipcheck; /* Disable proxy FTP */
|
||||
Ip_bool verbose; /* Enable verbose printouts */
|
||||
Ip_bool fb_extended; /* Allow fallback extended->normal */
|
||||
Ip_bool fb_passive; /* Allow fallback passive->active */
|
||||
Ip_u16 pportbase; /* Reject peer ports <= pportbase */
|
||||
Ip_u16 lportbase; /* Use local ports from lportbase+1 */
|
||||
void *data; /* User data */
|
||||
int (*conout)(struct Ipftpc_attr *attr, const char *buf, int len);
|
||||
/* Console input */
|
||||
void (*ctrlin)(struct Ipftpc_attr *attr, const char *buf, int len);
|
||||
/* Control input (if debug) */
|
||||
void (*ctrlout)(struct Ipftpc_attr *attr, const char *buf, int len);
|
||||
/* Control output (if debug) */
|
||||
#ifdef IPFTP_TLS
|
||||
Ip_bool tlsenble;
|
||||
char *certfile;
|
||||
char *keyfile;
|
||||
void *tls;
|
||||
Ip_bool ccc;
|
||||
char prot[4];
|
||||
#endif
|
||||
}
|
||||
Ipftpc_attr;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPFTPC_API_C
|
||||
#include "ipftpc_api_proto.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftpc_cmd.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipftpc_cmd.h,v $
|
||||
* $Author: ulf $ $Date: 2004-02-09 12:15:38 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPC_CMD_H
|
||||
#define IPFTPC_CMD_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPFTPC_CMD_C
|
||||
#include "ipftpc_cmd_proto.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,873 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftpc_cmd_proto.h,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipftpc_cmd_proto.h,v $
|
||||
* $Author: lob $ $Date: 2004-10-01 10:28:33 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPC_CMD_PROTO_H
|
||||
#define IPFTPC_CMD_PROTO_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPFTPC_CMD_C
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_conout
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Print command output console.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* msg Error message.
|
||||
* eno Error number.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_conout(Ipftpc_attr *attr, const char *buf, int len);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_ctrlin
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Print control input to console.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* msg Error message.
|
||||
* eno Error number.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipftpc_ctrlin(Ipftpc_attr *attr, const char *buf, int len);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_ctrlout
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Print control output to console.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* msg Error message.
|
||||
* eno Error number.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipftpc_ctrlout(Ipftpc_attr *attr, const char *buf, int len);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_perror
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Print error message.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* msg Error message.
|
||||
* eno Error number.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipftpc_perror(Ipftpc_vars *vars, const char *msg, int eno);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_setextended
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Set extended mode.
|
||||
*
|
||||
* Parameters
|
||||
* extended New value.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_setextended(Ipftpc_vars *vars, int extended);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_setpassive
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Set passive mode.
|
||||
*
|
||||
* Parameters
|
||||
* passive New value.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_setpassive(Ipftpc_vars *vars, int passive);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_setverbose
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Set verbose mode.
|
||||
*
|
||||
* Parameters
|
||||
* verbose New value.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_setverbose(Ipftpc_vars *vars, int verbose);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_flag
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Prepare for handling flag in command routine.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* func Command routine.
|
||||
* flag Flag.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipftpc_flag(Ipftpc_vars *vars,
|
||||
int (*func)(struct Ipftpc_vars_struct *vars, int argc, char *argv[]),
|
||||
int flag);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_append
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* append command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_append(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_ascii
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* ascii command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_ascii(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_binary
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* binary command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_binary(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_cd
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* cd command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_cd(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_cdup
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* cdup command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_cdup(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_close
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* close command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_close(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_delete
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* delete command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_delete(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_dir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* dir command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_dir(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_extended
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* extended command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_extended(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_family
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* family command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_family(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* get command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_get(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_help
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* help command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_help(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_ipcheck
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* ipcheck command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_ipcheck(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_lbase
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* lbase command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_lbase(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_lcd
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* lcd command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_lcd(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_lpwd
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* lpwd command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_lpwd(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_ls
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* ls command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_ls(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_mkdir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* mkdir command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_mkdir(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_open
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* open command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_open(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_passive
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* passive command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_passive(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_port
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* port command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_port(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_put
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* put command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_put(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_pwd
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* pwd command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_pwd(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_quit
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* quit command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_quit(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_quote
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* quote command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_quote(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_rbase
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* rbase command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_rbase(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_rename
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* rename command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_rename(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_rhelp
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* rhelp command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_rhelp(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_rmdir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* rmdir command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_rmdir(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_rstatus
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* rstatus command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_rstatus(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_status
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* status command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_status(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_system
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* system command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_system(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_do_verbose
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* verbose command.
|
||||
*
|
||||
* Parameters
|
||||
* vars Session variables.
|
||||
* argc No of arguments.
|
||||
* argv Argument vector.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if success, 1 if error, -1 if exit required.
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_do_verbose(Ipftpc_vars *vars, int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_getline
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Get command line.
|
||||
*
|
||||
* Parameters
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipftpc_getline(Ipftpc_vars *vars, const char *prompt, char *buf, int size);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftpc_cmdloop
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Loop and get commands.
|
||||
*
|
||||
* Parameters
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipftpc_cmdloop(Ipftpc_vars *vars);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftps.h,v $ $Revision: 1.8.12.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/ipftps.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2018-08-15 23:33:07 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPS_H
|
||||
#define IPFTPS_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipftps_config.h"
|
||||
#include "ipcom_config.h"
|
||||
#include "ipcom_list.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* release
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#define IPFTPS_RELEASE 060004
|
||||
|
||||
/* Transport protocol for FTPS */
|
||||
#ifdef IPFTPS_USE_SCTP
|
||||
#define IPFTPS_PROTO IP_IPPROTO_SCTP
|
||||
#else
|
||||
#define IPFTPS_PROTO 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* dummy, see below for real struct */
|
||||
struct Ipftps_session;
|
||||
|
||||
/* Socket control block */
|
||||
typedef struct
|
||||
{
|
||||
union Ip_sockaddr_union paddr; /* Peer address */
|
||||
union Ip_sockaddr_union laddr; /* Local address */
|
||||
Ip_fd fd; /* File descriptor */
|
||||
}
|
||||
Ipftps_sockcb;
|
||||
|
||||
/* Command descriptor */
|
||||
typedef struct
|
||||
{
|
||||
const char *name; /* Command name */
|
||||
void (*func)(struct Ipftps_session *, int argc, char *argv[]);
|
||||
/* Command handler */
|
||||
Ip_u8 min; /* Min no of arguments */
|
||||
Ip_u8 max; /* Max no of arguments */
|
||||
Ip_u8 argtype; /* Command argument. 1 if string */
|
||||
Ip_bool login; /* Requires login */
|
||||
const char *help; /* Help text */
|
||||
}
|
||||
Ipftps_cmd;
|
||||
|
||||
/* Session descriptor */
|
||||
typedef struct Ipftps_session
|
||||
{
|
||||
Ipcom_list head; /* List header */
|
||||
Ipftps_sockcb csock; /* Control socket */
|
||||
Ipftps_sockcb dsock; /* Data socket */
|
||||
const Ipftps_cmd *last; /* Last command */
|
||||
char *username; /* Username */
|
||||
char *rnfr; /* Rename from this name */
|
||||
char *root; /* Directory root */
|
||||
char *cwd; /* Current working directory */
|
||||
Ip_u32 trnow; /* Transferred bytes*/
|
||||
Ip_u32 trtotal; /* Total bytes */
|
||||
Ip_u16 pportbase; /* Reject peer ports <= pportbase */
|
||||
Ip_u16 lportbase; /* Use local ports from lportbase+1 */
|
||||
Ip_bool occupied; /* Session has a handler */
|
||||
Ip_bool login; /* Login performed */
|
||||
Ip_bool cwdroot; /* Use root as next CWD */
|
||||
Ip_bool epsvonly; /* Use only extended passive mode */
|
||||
Ip_bool passive; /* Passive mode */
|
||||
Ip_bool binary; /* Binary mode */
|
||||
Ip_bool readonly; /* Readonly mode */
|
||||
Ip_bool proxy; /* Enable proxy FTP */
|
||||
int authentications; /* Number of authentications */
|
||||
int cmdlen; /* Length of current command */
|
||||
int cmdbuflen; /* Length of all commands */
|
||||
char cmdbuf[IPFTPS_CMDBUFSIZE + 1]; /* Command buffer */
|
||||
char name[20]; /* Session name */
|
||||
#ifdef IPFTP_TLS
|
||||
void * tlsopt;
|
||||
#endif
|
||||
}
|
||||
Ipftps_session;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftps_authenticate
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Authenticate user.
|
||||
*
|
||||
* Parameters:
|
||||
* session Session descriptor.
|
||||
* password Password.
|
||||
*
|
||||
* Returns:
|
||||
* 0 if successful authentication, 1 otherwise.
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipftps_authenticate(Ipftps_session *session, char *password);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipftps_get_activesession - Get the current active session number of ftp server
|
||||
*
|
||||
* Get the current active session number of ftp server.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The current active session number
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipftps_get_activesession(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,176 @@
|
||||
/* iptftp.h - Public API of Wind River TFTP */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptftp.h,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/include/iptftp.h,v $
|
||||
* $Author: hsun $ $Date: 2010-11-07 19:57:31 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPTFTP_H
|
||||
#define IPTFTP_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* TFTP public header file.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library contains the APIs provided by the WindRiver TFTP.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* release
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#define IPTFTP_RELEASE 60500
|
||||
|
||||
|
||||
/* TFTP Client error codes */
|
||||
#define IPTFTP_SUCCESS 0
|
||||
#define IPTFTP_ERR_SERVER_ADDR 1
|
||||
#define IPTFTP_ERR_MEMORY_FAIL 2
|
||||
#define IPTFTP_ERR_FILE_OPEN 3
|
||||
#define IPTFTP_ERR_FILE_READ 4
|
||||
#define IPTFTP_ERR_FILE_WRITE 5
|
||||
#define IPTFTP_ERR_TRANSFER_TIMEOUT 6
|
||||
#define IPTFTP_ERR_SOCKET_FAIL 7
|
||||
#define IPTFTP_ERR_ILLEGAL_MESSAGE 8
|
||||
#define IPTFTP_ERR_ERROR_MESSAGE 9
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* iptftp_client_put - transfer a file from the target to a TFTP server
|
||||
*
|
||||
* This routine transfers a file from the target to a TFTP server.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <server>
|
||||
* A pointer to a string with either the Internet address or the hostname of the
|
||||
* TFTP server.
|
||||
* \i <srcfile>
|
||||
* A pointer to a string with the source-file name.
|
||||
* \i <dstfile>
|
||||
* A pointer to a string with the destination-file name.
|
||||
* \i <binary>
|
||||
* A boolean that specifies binary (octet) or 'netascii' mode.
|
||||
* \i <verbose>
|
||||
* A boolean that specifies whether the routine prints status information to the
|
||||
* standard output.
|
||||
* \i <port>
|
||||
* An int that specifies server tftp port other than the default value. If 0 use default.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 'IPTFTP_SUCCESS' or an error code.
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err iptftp_client_put
|
||||
(
|
||||
const char *server,
|
||||
const char *srcfile,
|
||||
const char *dstfile,
|
||||
Ip_bool binary,
|
||||
Ip_bool verbose,
|
||||
int port
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* iptftp_client_get - transfer a file to the target from a TFTP server
|
||||
*
|
||||
* This routine transfers a file to the target from a TFTP server.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <server>
|
||||
* A pointer to a string containing either the Internet address or the hostname
|
||||
* of the TFTP server.
|
||||
* \i <srcfile>
|
||||
* A pointer to a string with the source-file name.
|
||||
* \i <dstfile>
|
||||
* A pointer to a string with the destination-file name.
|
||||
* \i <binary>
|
||||
* A boolean that specifies binary (octet) or 'netascii' mode.
|
||||
* \i <verbose>
|
||||
* A boolean that specifies whether the routine prints status information to the
|
||||
* standard output.
|
||||
* \i <port>
|
||||
* An int that specifies server tftp port other than the default value. If 0 use default.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 'IPTFTP_SUCCESS' or an error code.
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err iptftp_client_get
|
||||
(
|
||||
const char *server,
|
||||
const char *srcfile,
|
||||
const char *dstfile,
|
||||
Ip_bool binary,
|
||||
Ip_bool verbose,
|
||||
int port
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,575 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
* Design and implementation by Zhangqing Luo <Zhangqing.luo@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipdhcpc_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPDHCPC_INCLUDE_CMD
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_time.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_getopt.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_tmo2.h>
|
||||
#include <ipcom_type.h>
|
||||
|
||||
|
||||
#include "ipdhcpc_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPDHCPC_MAX_CMD (sizeof(ipdhcpc_cmd_callback)/sizeof(Ipdhcpc_cmd_cb))
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipdhcpc_cmd_cb_struct
|
||||
{
|
||||
char* cmd;
|
||||
Ip_err(*cmd_cb)(int argc, char *argv[]);
|
||||
|
||||
}
|
||||
Ipdhcpc_cmd_cb;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN Ipdhcpc_data ipdhcpc;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_STATIC void ipdhcpc_printf (const char *format, /*args*/ ...);
|
||||
IP_STATIC void ipdhcpc_errmsg_print (Ip_err code);
|
||||
IP_STATIC void ipdhcpc_state_print (int state);
|
||||
IP_STATIC void ipdhcpc_cmd_print_usage (void);
|
||||
IP_STATIC Ip_err ipdhcpc_handle_cmd_renew (int argc, char *argv[]);
|
||||
IP_STATIC Ip_err ipdhcpc_handle_cmd_inform (int argc, char *argv[]);
|
||||
IP_STATIC Ip_err ipdhcpc_handle_cmd_interface (int argc, char *argv[]);
|
||||
IP_STATIC Ip_err ipdhcpc_handle_cmd_lease (int argc, char *argv[]);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_cmd_cb
|
||||
*===========================================================================
|
||||
* Description: Ipdhcpc command callback struct.
|
||||
*/
|
||||
IP_STATIC Ipdhcpc_cmd_cb ipdhcpc_cmd_callback[] =
|
||||
{
|
||||
{
|
||||
"renew",
|
||||
ipdhcpc_handle_cmd_renew
|
||||
|
||||
},
|
||||
{
|
||||
"inform",
|
||||
ipdhcpc_handle_cmd_inform
|
||||
|
||||
},
|
||||
{
|
||||
"lease",
|
||||
ipdhcpc_handle_cmd_lease
|
||||
|
||||
},
|
||||
{
|
||||
"interface",
|
||||
ipdhcpc_handle_cmd_interface
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_printf
|
||||
*===========================================================================
|
||||
* Description: Format and print the message.
|
||||
* Parameters: message formatted
|
||||
* Returns: -
|
||||
*
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipdhcpc_printf (const char *format, /*args*/ ...)
|
||||
{
|
||||
char *buf;
|
||||
va_list ap;
|
||||
Ip_s32 retval;
|
||||
|
||||
buf = ipcom_malloc(IPCOM_STDIO_BUFSIZE);
|
||||
ip_assert(buf);
|
||||
|
||||
va_start(ap, format);
|
||||
retval = ipcom_vsnprintf(buf, IPCOM_STDIO_BUFSIZE, format, ap);
|
||||
retval = IP_MIN(retval, (int) IPCOM_STDIO_BUFSIZE);
|
||||
va_end(ap);
|
||||
|
||||
if(retval > 0)
|
||||
{
|
||||
(void)ipcom_printf(buf);
|
||||
}
|
||||
|
||||
ipcom_free(buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_errmsg_print
|
||||
*===========================================================================
|
||||
* Description: Prints error messages in clear text.
|
||||
* Parameters: code - error code
|
||||
* Returns: -
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipdhcpc_errmsg_print(Ip_err code)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case IPCOM_ERR_INVALID_ARG:
|
||||
ipdhcpc_printf("failed :: invalid argument"IP_LF);
|
||||
break;
|
||||
case IPCOM_ERR_INVALID_CONFIG:
|
||||
ipdhcpc_printf("failed :: invalid config"IP_LF);
|
||||
break;
|
||||
case IPCOM_ERR_NOT_FOUND:
|
||||
ipdhcpc_printf("failed :: not found"IP_LF);
|
||||
break;
|
||||
case IPCOM_ERR_NO_MEMORY:
|
||||
ipdhcpc_printf("failed :: out of memory"IP_LF);
|
||||
break;
|
||||
case IPCOM_ERR_ALREADY_INSTALLED:
|
||||
ipdhcpc_printf("failed :: already exists"IP_LF);
|
||||
break;
|
||||
case IPCOM_ERR_NOT_OPENED:
|
||||
ipdhcpc_printf("failed :: ipdhcpc not open"IP_LF);
|
||||
break;
|
||||
case IPCOM_ERR_PERMISSION_DENIED:
|
||||
ipdhcpc_printf("failed :: not allowed"IP_LF);
|
||||
break;
|
||||
case IPCOM_ERR_ALREADY_STARTED:
|
||||
ipdhcpc_printf ("failed::already in processing");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_state_print
|
||||
*===========================================================================
|
||||
* Description: Prints state of the dhcp
|
||||
* Parameters: state code
|
||||
* Returns: -
|
||||
*
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipdhcpc_state_print (int state)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case IPDHCPC_STATE_INIT:
|
||||
ipdhcpc_printf(" State: Init"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_INIT_REBOOT:
|
||||
ipdhcpc_printf(" State: Init reboot"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_SELECTING:
|
||||
ipdhcpc_printf(" State: Selecting"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_REBOOTING:
|
||||
ipdhcpc_printf(" State: Rebooting"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_REQUESTING:
|
||||
ipdhcpc_printf(" State: Requesting"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_BOUND:
|
||||
ipdhcpc_printf(" State: Bound"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_RENEWING:
|
||||
ipdhcpc_printf(" State: Renewing"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_REBINDING:
|
||||
ipdhcpc_printf(" State: Rebinding"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_STOPPED:
|
||||
ipdhcpc_printf(" State: Stopped"IP_LF);
|
||||
break;
|
||||
case IPDHCPC_STATE_INFORMING:
|
||||
ipdhcpc_printf(" State: Informing"IP_LF);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_handle_cmd_renew
|
||||
*===========================================================================
|
||||
* Description: Handles the renew command.
|
||||
* Parameters: argc - number of command line arguments
|
||||
* argv - array of command line arguments
|
||||
*
|
||||
* Returns: IPCOM_SUCCESS - the operation was successful
|
||||
* IPCOM_ERR... - failed
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipdhcpc_handle_cmd_renew (int argc, char *argv[])
|
||||
{
|
||||
Ip_err retval = IPCOM_SUCCESS;
|
||||
|
||||
if (argc<1)
|
||||
IPDHCPC_LEAVE(IPCOM_ERR_INVALID_ARG);
|
||||
|
||||
/*got the interface name*/
|
||||
retval = ipdhcpc_renew_get (argv[0]);
|
||||
|
||||
ipdhcpc_printf(IP_LF);
|
||||
ipdhcpc_errmsg_print(retval);
|
||||
|
||||
leave:
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_handle_cmd_inform
|
||||
*===========================================================================
|
||||
* Description: Handles the inform command.
|
||||
* Parameters: argc - number of command line arguments
|
||||
* argv - array of command line arguments
|
||||
*
|
||||
* Returns: IPCOM_SUCCESS - the operation was successful
|
||||
* IPCOM_ERR... - failed
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipdhcpc_handle_cmd_inform (int argc, char *argv[])
|
||||
{
|
||||
Ip_err retval = IPCOM_SUCCESS;
|
||||
|
||||
if (argc<1)
|
||||
IPDHCPC_LEAVE(IPCOM_ERR_INVALID_ARG);
|
||||
|
||||
retval = ipdhcpc_inform_get (argv[0], argv[1]);
|
||||
|
||||
ipdhcpc_printf(IP_LF);
|
||||
ipdhcpc_errmsg_print(retval);
|
||||
|
||||
leave:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_handle_cmd_interface
|
||||
*===========================================================================
|
||||
* Description: Handles the interface command.
|
||||
* Parameters: argc - number of command line arguments
|
||||
* argv - array of command line arguments
|
||||
*
|
||||
* Returns: IPCOM_SUCCESS - the operation was successful
|
||||
* IPCOM_ERR... - failed
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipdhcpc_handle_cmd_interface (int argc, char *argv[])
|
||||
{
|
||||
Ip_err retval = IPCOM_SUCCESS;
|
||||
Ipdhcpc_if *ift = IP_NULL;
|
||||
(void)argc;
|
||||
|
||||
if (ipcom_strcmp ("list", argv[0])==0)
|
||||
{
|
||||
char * status = IP_NULL;
|
||||
int i = 0;
|
||||
IPDHCPC_LOCK();
|
||||
/*show all interfaces status*/
|
||||
for (ift = ipdhcpc.ift_head; ift != IP_NULL; ift = ift->next)
|
||||
{
|
||||
ipdhcpc_printf (""IP_LF);
|
||||
ipdhcpc_printf ("Details about interface"IP_LF);
|
||||
ipdhcpc_printf (" Name: %s"IP_LF, ift->ifname);
|
||||
ipdhcpc_printf (" Index: %d"IP_LF,ift->ifindex);
|
||||
|
||||
ipdhcpc_printf (" HWaddr: ");
|
||||
for (;i<ift->hlen-1; i++)
|
||||
ipdhcpc_printf ("%x%x:",ift->chaddr[i]>>4, ift->chaddr[i]&0xf);
|
||||
|
||||
ipdhcpc_printf ("%x%x",ift->chaddr[i]>>4, ift->chaddr[i]&0xf);
|
||||
|
||||
ipdhcpc_printf (IP_LF);
|
||||
|
||||
status = ift->isdown?"Down":"Up";
|
||||
ipdhcpc_printf (" Status: %s"IP_LF,status);
|
||||
status = ift->information_only?"Enabled":"Disabled";
|
||||
ipdhcpc_printf (" Information Only:%s"IP_LF,status);
|
||||
|
||||
if (ift->handle != IP_NULL)
|
||||
/*show state*/
|
||||
ipdhcpc_state_print (ift->handle->priv->state);
|
||||
ipdhcpc_printf (""IP_LF);
|
||||
}
|
||||
IPDHCPC_UNLOCK();
|
||||
}
|
||||
else
|
||||
retval = IPCOM_ERR_INVALID_ARG;
|
||||
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_errmsg_print (retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_handle_cmd_lease
|
||||
*===========================================================================
|
||||
* Description: Handles the lease command.
|
||||
* Parameters: argc - number of command line arguments
|
||||
* argv - array of command line arguments
|
||||
*
|
||||
* Returns: IPCOM_SUCCESS - the operation was successful
|
||||
* IPCOM_ERR... - failed
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipdhcpc_handle_cmd_lease (int argc, char *argv[])
|
||||
{
|
||||
Ip_err retval = IPCOM_SUCCESS;
|
||||
Ipdhcpc_if *ift = IP_NULL;
|
||||
struct Ip_in_addr addr;
|
||||
(void)argc;
|
||||
|
||||
if (ipcom_strcmp ("list", argv[0])==0)
|
||||
{
|
||||
|
||||
|
||||
IPDHCPC_LOCK();
|
||||
for (ift = ipdhcpc.ift_head; ift != IP_NULL; ift = ift->next)
|
||||
{
|
||||
if (ift->information_only == IP_TRUE)
|
||||
{
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_printf (" Interface %s is in INFORMATION_ONLY MODE, no lease from server"IP_LF, ift->ifname);
|
||||
}
|
||||
|
||||
else if (ift->handle != IP_NULL)
|
||||
{
|
||||
if (ift->handle->priv->state>=IPDHCPC_STATE_BOUND)
|
||||
{
|
||||
ipdhcpc_printf (""IP_LF);
|
||||
ipdhcpc_printf ("Lease:"IP_LF);
|
||||
ipdhcpc_printf (" Index: %d"IP_LF, ift->ifindex);
|
||||
addr.s_addr = ift->handle->info.ipaddr_n;
|
||||
ipdhcpc_printf (" Client address: %s"IP_LF, ipcom_inet_ntoa(addr));
|
||||
addr.s_addr = ift->handle->info.serveraddr_n;
|
||||
ipdhcpc_printf (" Server address: %s"IP_LF,ipcom_inet_ntoa(addr));
|
||||
ipdhcpc_printf (" Duration: %ds"IP_LF, ift->lease.tlease);
|
||||
|
||||
ipdhcpc_printf (""IP_LF);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_printf ("Performing dhcp");
|
||||
ipdhcpc_state_print (ift->handle->priv->state);
|
||||
}
|
||||
}
|
||||
else
|
||||
ipdhcpc_printf ("Not started"IP_LF);
|
||||
}
|
||||
IPDHCPC_UNLOCK();
|
||||
|
||||
}
|
||||
else
|
||||
retval = IPCOM_ERR_INVALID_ARG;
|
||||
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_errmsg_print (retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_cmd_print_usage
|
||||
*===========================================================================
|
||||
* Description: Prints the documentation for the command.
|
||||
* Parameters:
|
||||
* Returns: IPCOM_SUCCESS - the operation was successful
|
||||
*
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipdhcpc_cmd_print_usage(void)
|
||||
{
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_printf ("NAME" IP_LF);
|
||||
ipdhcpc_printf (" dhcpc - Control Interpeak DHCP client"IP_LF);
|
||||
|
||||
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_printf ("SYNOPSIS" IP_LF);
|
||||
ipdhcpc_printf (" dhcpc renew {name}"IP_LF);
|
||||
ipdhcpc_printf (" dhcpc inform {name} [addr] "IP_LF);
|
||||
ipdhcpc_printf (" dhcpc lease list "IP_LF);
|
||||
ipdhcpc_printf (" dhcpc interface list"IP_LF);
|
||||
|
||||
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_printf ("DESCRIPTION" IP_LF);
|
||||
ipdhcpc_printf (" renew Trigger renew event manually."IP_LF);
|
||||
ipdhcpc_printf (" inform Trigger INFORM message. if no address set, select primary address as default"IP_LF);
|
||||
ipdhcpc_printf (" lease List current data in lease database."IP_LF);
|
||||
ipdhcpc_printf (" interface List interfaces used by the dhcp client."IP_LF);
|
||||
|
||||
|
||||
ipdhcpc_printf (IP_LF);
|
||||
ipdhcpc_printf ("EXAMPLES" IP_LF);
|
||||
ipdhcpc_printf (" dhcpc renew eth0"IP_LF);
|
||||
ipdhcpc_printf (" dhcpc inform eth0 128.224.158.82"IP_LF);
|
||||
ipdhcpc_printf (" dhcpc inform eth0"IP_LF);
|
||||
ipdhcpc_printf (" dhcpc lease list"IP_LF);
|
||||
ipdhcpc_printf (" dhcpc interface list"IP_LF);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_cmd_dhcpc
|
||||
*===========================================================================
|
||||
* Description: Shell command used to start,stop and configure the DHCP
|
||||
* server.
|
||||
* Parameters: argc - The number of arguments passed to the command.
|
||||
* argv - The arguments passed to the command.
|
||||
* Returns: 0 = success,
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipdhcpc_cmd_dhcpc(int argc, char **argv)
|
||||
{
|
||||
Ip_err retval;
|
||||
int i;
|
||||
|
||||
retval = IPCOM_ERR_INVALID_ARG;
|
||||
|
||||
if(argc < 2)
|
||||
IPDHCPC_LEAVE(IPCOM_ERR_INVALID_ARG);
|
||||
|
||||
for(i = 0; i < (int)IPDHCPC_MAX_CMD; i++)
|
||||
{
|
||||
if(ipcom_strcmp(argv[1], ipdhcpc_cmd_callback[i].cmd) == 0)
|
||||
{
|
||||
retval = ipdhcpc_cmd_callback[i].cmd_cb(argc-2, &argv[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
leave:
|
||||
if(retval == IPCOM_ERR_INVALID_ARG)
|
||||
ipdhcpc_cmd_print_usage();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* #ifdef IPDHCPC_INCLUDE_CMD */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcpc_h.h,v $ $Revision: 1.6.16.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/ipdhcpc_h.h,v $
|
||||
* $Author: jwang9 $ $Date: 2016-01-04 08:50:32 $
|
||||
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
* and Jonas Rendel <jonas@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPDHCPC_H_H
|
||||
#define IPDHCPC_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_tmo.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_tags.h>
|
||||
#include "ipdhcpc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* DHCP pkt opcode: */
|
||||
#define IPDHCPC_OP_BOOTREQUEST 1
|
||||
#define IPDHCPC_OP_BOOTREPLY 2
|
||||
|
||||
/* DHCP pkt htype & hlen: */
|
||||
#define IPDHCPC_HTYPE_ETHERNET 1
|
||||
#define IPDHCPC_HLEN_ETHERNET 6
|
||||
|
||||
/* DHCP pkt message types: */
|
||||
#define IPDHCPC_MSG_INVALID 0
|
||||
#define IPDHCPC_MSG_DISCOVER 1
|
||||
#define IPDHCPC_MSG_OFFER 2
|
||||
#define IPDHCPC_MSG_REQUEST 3
|
||||
#define IPDHCPC_MSG_DECLINE 4
|
||||
#define IPDHCPC_MSG_ACK 5
|
||||
#define IPDHCPC_MSG_NAK 6
|
||||
#define IPDHCPC_MSG_RELEASE 7
|
||||
#define IPDHCPC_MSG_INFORM 8
|
||||
|
||||
/* DHCP client message bitvalues: */
|
||||
#define IPDHCPC_MB_DISCOVER 0x01
|
||||
#define IPDHCPC_MB_OFFER 0x02
|
||||
#define IPDHCPC_MB_REQUEST 0x04
|
||||
#define IPDHCPC_MB_DECLINE 0x08
|
||||
#define IPDHCPC_MB_ACK 0x10
|
||||
#define IPDHCPC_MB_NAK 0x20
|
||||
#define IPDHCPC_MB_RELEASE 0x40
|
||||
#define IPDHCPC_MB_INFORM 0x80
|
||||
|
||||
/* DHCP client states: */
|
||||
#define IPDHCPC_STATE_INIT 1
|
||||
#define IPDHCPC_STATE_INIT_REBOOT 2
|
||||
#define IPDHCPC_STATE_SELECTING 3
|
||||
#define IPDHCPC_STATE_REBOOTING 4
|
||||
#define IPDHCPC_STATE_REQUESTING 5
|
||||
#define IPDHCPC_STATE_INFORMING 6
|
||||
#define IPDHCPC_STATE_BOUND 7
|
||||
#define IPDHCPC_STATE_RENEWING 8
|
||||
#define IPDHCPC_STATE_REBINDING 9
|
||||
#define IPDHCPC_STATE_STOPPED 10
|
||||
#define IPDHCPC_STATE_ASSIGNING 11
|
||||
|
||||
/*DHCP event states*/
|
||||
#define IPDHCPC_IF_EVENT_INFORM 1
|
||||
#define IPDHCPC_IF_EVENT_RENEW 2
|
||||
|
||||
/* DHCP ports. */
|
||||
#define IPDHCPC_SERVER_PORT 67
|
||||
#define IPDHCPC_CLIENT_PORT 68
|
||||
|
||||
/* Minimum BOOTP header length. RFC1542:p5 */
|
||||
#define IPDHCPC_PKT_MINLEN 300
|
||||
#define IPDHCPC_RAW_HSIZE (sizeof(Ipcom_udp_header) + sizeof(Ipcom_ip_header))
|
||||
/* DHCP Header size without options, as per RFC 2131 */
|
||||
#define IPDHCPC_MESSAGE_DHCP_HEADER_SIZE ip_offsetof(Ipdhcpc_pkt, options)
|
||||
/* DHCP Header size including IP, UDP, DHCP */
|
||||
#define IPDHCPC_MESSAGE_HEADER_SIZE (IPDHCPC_RAW_HSIZE + IPDHCPC_MESSAGE_DHCP_HEADER_SIZE)
|
||||
/* DHCP Max size of one option. Arbitrary. Used to alloc buffer holding options from sysvar struct */
|
||||
#define IPDHCPC_MAX_OPTION_SIZE (ipdhcpc.max_message_size - IPDHCPC_MESSAGE_HEADER_SIZE)
|
||||
#define IPDHCPC_LEFT_OPTION_SPACE(occupy_byte) (IPDHCPC_MAX_OPTION_SIZE - occupy_byte)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* DHCP FLAGS FIELD
|
||||
*===========================================================================
|
||||
* See RFC 2132.
|
||||
*/
|
||||
|
||||
#define IPDHCPC_FLAGS_BROADCAST 0X8000
|
||||
|
||||
/*
|
||||
* DHCP mode of operation
|
||||
*===========================================================================
|
||||
* Defines the different modes the client can operate in.
|
||||
*/
|
||||
#define IPDHCPC_MODE_ALLOC_DYNAMIC 1
|
||||
#define IPDHCPC_MODE_REUSE_DYNAMIC 2
|
||||
#define IPDHCPC_MODE_RELEASE_DYNAMIC 3
|
||||
#define IPDHCPC_MODE_INFORM_STATIC 4
|
||||
|
||||
/* overload option value */
|
||||
#define IPDHCPC_OVERLOAD_NONE (0)
|
||||
#define IPDHCPC_OVERLOAD_FILE (1)
|
||||
#define IPDHCPC_OVERLOAD_SNAME (2)
|
||||
#define IPDHCPC_OVERLOAD_BOTH (3)
|
||||
|
||||
#define IPDHCPC_OPT_CODE (0)
|
||||
#define IPDHCPC_OPT_LEN (1)
|
||||
#define IPDHCPC_OPT_DATA (2)
|
||||
#define IPDHCPC_OPT_MIN_LEN (2)
|
||||
|
||||
#define IPDHCPC_PKT_HDR_SNAME_LEN (64)
|
||||
#define IPDHCPC_PKT_HDR_FILE_LEN (128)
|
||||
|
||||
/* MACROS */
|
||||
#define IPDHCPC_LEAVE(xerrval) do { retval = xerrval; goto leave; } while(0)
|
||||
|
||||
#define IPDHCPC_ISLOCKED_ASSERT() ip_assert(ipdhcpc.code_mutex_count == 1)
|
||||
#define IPDHCPC_LOCK() do { ipcom_mutex_lock(ipdhcpc.code_mutex); \
|
||||
ip_assert(ipdhcpc.code_mutex_count == 0); \
|
||||
ipdhcpc.code_mutex_count++; \
|
||||
} while(0)
|
||||
|
||||
#define IPDHCPC_UNLOCK() do { ip_assert(ipdhcpc.code_mutex_count == 1); \
|
||||
ipdhcpc.code_mutex_count--; \
|
||||
ipcom_mutex_unlock(ipdhcpc.code_mutex); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define IPDHCPC_ISINIT(handle) (IPDHCPC_STATE_BOUND > ((handle)->priv->state))
|
||||
|
||||
|
||||
#define IPDHCPC_MAX_CID_LEN (254) /*the maximum length of option 61 is 255, the data is filled 0 at the beginning, so the real length is 255-1*/
|
||||
|
||||
#define IPDHCPC_CID_CFG_DELIMITER ":"
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_handle_priv
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdhcpc_handle_priv_struct
|
||||
{
|
||||
struct Ipdhcpc_handle_struct *next;
|
||||
|
||||
Ipcom_tmo tmo;
|
||||
int tmo_ignore;
|
||||
Ipcom_tmo tmo_t2;
|
||||
int tmo2_ignore;
|
||||
int retrans_counter;
|
||||
int mode;
|
||||
int state;
|
||||
Ip_u32 xid_n;
|
||||
Ip_u16 in_optlen;
|
||||
Ip_u8 msgtype;
|
||||
Ip_u8 pad;
|
||||
|
||||
/* Cached server info. */
|
||||
Ip_u32 serverid_n; /* Server IP address */
|
||||
Ip_u32 gw_n; /* Gateway IP address */
|
||||
Ip_u32 yiaddr; /* 'your' (client) IP address */
|
||||
}
|
||||
Ipdhcpc_handle_priv;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_options
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdhcpc_options_struct
|
||||
{
|
||||
Ip_u8 optcode;
|
||||
Ip_u8 minlen;
|
||||
Ip_u8 maxlen;
|
||||
Ip_u8 msgmust;
|
||||
Ip_u8 msgmustnot;
|
||||
}
|
||||
Ipdhcpc_options;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_pkt
|
||||
*===========================================================================
|
||||
*/
|
||||
IP_PACKED typedef struct Ipdhcpc_pkt_struct
|
||||
{
|
||||
Ip_u8 op;
|
||||
Ip_u8 htype;
|
||||
Ip_u8 hlen;
|
||||
Ip_u8 hops;
|
||||
Ip_u32 xid;
|
||||
Ip_u16 secs;
|
||||
Ip_u16 flags;
|
||||
Ip_u32 ciaddr; /* Client IP address */
|
||||
Ip_u32 yiaddr; /* 'your' (client) IP address. */
|
||||
Ip_u32 siaddr; /* IP address of next server to use in bootstrap */
|
||||
Ip_u32 giaddr; /* Relay agent IP address */
|
||||
Ip_u8 chaddr[16]; /* Client hardware address. */
|
||||
char sname[IPDHCPC_PKT_HDR_SNAME_LEN]; /* Optional server host name */
|
||||
char file[IPDHCPC_PKT_HDR_FILE_LEN]; /* Boot file name */
|
||||
Ip_u8 options[1];
|
||||
}
|
||||
Ipdhcpc_pkt;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_lease
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdhcpc_lease_struct
|
||||
{
|
||||
Ip_time_t t1;
|
||||
Ip_time_t t2;
|
||||
Ip_time_t tlease;
|
||||
}
|
||||
Ipdhcpc_lease;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_if
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdhcpc_if_struct
|
||||
{
|
||||
struct Ipdhcpc_if_struct *next;
|
||||
Ip_u32 ifindex;
|
||||
char ifname[IP_IFNAMSIZ];
|
||||
int num_opened;
|
||||
|
||||
/* ifopen configuration. */
|
||||
|
||||
/* Time stuff. */
|
||||
Ip_time_t time_addr_req; /* same as time when ifopen() was made. */
|
||||
|
||||
/* Interface stuff. */
|
||||
Ip_u8 chaddr[16]; /* Client hardware address. */
|
||||
Ip_u8 hlen;
|
||||
Ip_u8 pad;
|
||||
|
||||
/* Config. */
|
||||
char *clientid;
|
||||
|
||||
/* Interface lease. */
|
||||
Ipdhcpc_handle *handle;
|
||||
Ipdhcpc_lease lease;
|
||||
Ip_u8 clientid_len;
|
||||
Ip_bool isdown;
|
||||
|
||||
/*whether or not it is in inform only mode*/
|
||||
Ip_bool information_only;
|
||||
}
|
||||
Ipdhcpc_if;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_data
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdhcpc_data_struct
|
||||
{
|
||||
Ip_bool opened;
|
||||
|
||||
Ipcom_mutex code_mutex; /* Mutex to protect IPDHCPC global data. */
|
||||
int code_mutex_count;
|
||||
|
||||
Ip_fd fd;
|
||||
Ip_fd ipd_fd;
|
||||
Ip_fd rt_fd;
|
||||
Ip_fd pkt_fd;
|
||||
|
||||
char buf[16];
|
||||
struct Ip_sockaddr_in addr;
|
||||
Ip_u32 last_brd_ifindex;
|
||||
int open_interfaces;
|
||||
|
||||
Ip_u8 *in_raw;
|
||||
Ipdhcpc_pkt *in_pkt;
|
||||
Ip_ssize_t in_pkt_len;
|
||||
Ipdhcpc_pkt *out_pkt;
|
||||
Ipdhcpc_if *ift_head;
|
||||
Ipdhcpc_handle *handle_head;
|
||||
Ip_u16 max_message_size;
|
||||
Ip_bool shut_down;
|
||||
Ip_bool cid_uuid_type;
|
||||
}
|
||||
Ipdhcpc_data;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_ifopen
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
typedef struct Ipdhcpc_ifopen_struct
|
||||
{
|
||||
Ip_u32 api_version; /* Currently version 1. Used for future compability. */
|
||||
char clientid[IPDHCPC_CLIENT_ID_MAXSIZE+1]; /* must be null terminated! */
|
||||
Ip_tag conf[1]; /* None available, included for future compability. */
|
||||
}
|
||||
Ipdhcpc_ifopen;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdhcpc_cmd_dhcpc
|
||||
*===========================================================================
|
||||
* Description: Install IPDHCPC shell commands
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#ifdef IPDHCPC_INCLUDE_CMD
|
||||
IP_GLOBAL int ipdhcpc_cmd_dhcpc(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_ifopen
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipdhcpc_ifopen(Ip_u32 ifindex, Ipdhcpc_ifopen *config);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_ifclose
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipdhcpc_ifclose(Ip_u32 ifindex);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_if_isopen
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipdhcpc_if_isopen(Ip_u32 ifindex);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_ifrequest
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipdhcpc_ifrequest(Ip_u32 ifindex, Ipdhcpc_handle *handle);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_iflease
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipdhcpc_iflease(Ip_u32 ifindex, Ipdhcpc_handle *handle);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_ifunlease
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipdhcpc_ifunlease(Ip_u32 ifindex, Ipdhcpc_handle **handlep);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_handle_malloc
|
||||
*===========================================================================
|
||||
* Description: Mallocate and initialize a DHCP client request handle for
|
||||
* use with ipdhcpc_ifrequest().
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipdhcpc_handle_malloc(Ip_u32 ifindex,
|
||||
int mode,
|
||||
Ipdhcpc_handle **handlep);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_handle_free
|
||||
*===========================================================================
|
||||
* Description: Free a DHCP client handle.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipdhcpc_handle_free(Ip_u32 ifindex, Ipdhcpc_handle *handle);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_option_sprintf
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipdhcpc_option_sprintf(Ip_u8 *option, char *buf, int buflen);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_option_find
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u8 *ipdhcpc_option_find(Ipdhcpc_handle *handle, Ip_u8 code);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_option_get_first
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u8 *ipdhcpc_option_get_first(Ip_u8 *options);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdhcpc_option_limit_get_next
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u8 *
|
||||
ipdhcpc_option_limit_get_next(Ip_u8 * options, Ip_u16 *size);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdnsc_cmd_nslookup.c,v $ $Revision: 1.23.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/ipdnsc_cmd_nslookup.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* nslookup shell command.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipdnsc_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_getopt.h>
|
||||
|
||||
#include "ipdnsc.h"
|
||||
#include "ipdnsc_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC int ipdnsc_cmd_nslookup(int argc, char **argv);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipdnsc_ping_print_usage
|
||||
*===========================================================================
|
||||
* Description: Prints usage information for the nslookup shell command.
|
||||
* Parameters: None.
|
||||
* Returns: Nothing.
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipdnsc_nslookup_print_usage(void)
|
||||
{
|
||||
ipcom_printf("\n");
|
||||
ipcom_printf("NAME\n");
|
||||
ipcom_printf(" nslookup - query Internet name servers\n");
|
||||
ipcom_printf("\n");
|
||||
ipcom_printf("SYNOPSIS\n");
|
||||
ipcom_printf(" nslookup [-f] [-c] [-v version] [-t timeout] [-r retries] host [nameserver]\n");
|
||||
ipcom_printf("\n");
|
||||
ipcom_printf("DESCRIPTION\n");
|
||||
ipcom_printf(" nslookup queries an Internet name server for information abouts hosts.\n");
|
||||
ipcom_printf(" host may be a domain name or an Internet v4 or v6 address.\n");
|
||||
ipcom_printf(" [nameserver] is optional and provides the possibility to use a\n");
|
||||
ipcom_printf(" nameserver other than the default. [nameserver] must be specified\n");
|
||||
ipcom_printf(" by its Internet address.\n");
|
||||
ipcom_printf("\n");
|
||||
ipcom_printf(" -f Flush the DNS resolver cache and then exit immediately.\n");
|
||||
ipcom_printf(" -c Use the DNS resolver's local cache. Default is to always\n");
|
||||
ipcom_printf(" perform the name server lookup and not use the cache.\n");
|
||||
ipcom_printf(" -v version\n");
|
||||
ipcom_printf(" Specifies the type of address that is requested in a\n");
|
||||
ipcom_printf(" name to address lookup. Allowed versions are 4 and 6.\n");
|
||||
ipcom_printf(" If the -v flag is not given, nslookup first tries to find an\n");
|
||||
ipcom_printf(" ipv6 address and then, if not found, an ipv4 address.\n");
|
||||
ipcom_printf(" -t timeout\n");
|
||||
ipcom_printf(" Specifies how long to wait for an answer from the nameserver\n");
|
||||
ipcom_printf(" before retrying.\n");
|
||||
ipcom_printf(" -r retries\n");
|
||||
ipcom_printf(" Specifies the number of retries to use if the nameserver\n");
|
||||
ipcom_printf(" fails to answer.\n");
|
||||
#ifdef IPDNSC_USE_TEST
|
||||
ipcom_printf(" -u do dns update test.\n");
|
||||
#endif
|
||||
ipcom_printf("\n");
|
||||
ipcom_printf("RETURN VALUES\n");
|
||||
ipcom_printf(" The nslookup command will exit with 0 on success, and non-zero on errors.\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_cmd_nslookup
|
||||
*===========================================================================
|
||||
* Description: Shell command nslookup.
|
||||
* Parameters: argc - number of arguments.
|
||||
* argv - list of arguments.
|
||||
* Returns: 0 = success.
|
||||
* -1 = failed.
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipdnsc_cmd_nslookup(int argc, char **argv)
|
||||
{
|
||||
struct Ip_hostent *he1, *he2 = IP_NULL;
|
||||
struct Ip_in_addr host_addr;
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_in6_addr host_addr6;
|
||||
#endif
|
||||
Ipdnsc_ns_spec dns;
|
||||
int address_lookup, use_cache, i, version, host_family = IP_AF_INET;
|
||||
Ip_s32 err_num = IPDNSC_NO_RECOVERY;
|
||||
char buf[40];
|
||||
|
||||
if(argc <= 1)
|
||||
{
|
||||
/* Interactive mode not supported - user must supply a hostname or internet
|
||||
address and optionally a name server */
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/* Get the default name server parameters */
|
||||
if (ipdnsc_default(&dns))
|
||||
{
|
||||
ipcom_printf("Could not find name server.\n");
|
||||
return -1;
|
||||
}
|
||||
/* Use only the primary name server */
|
||||
ipcom_memset(&dns.secondary_dns.addr, 0, sizeof(dns.secondary_dns.addr));
|
||||
dns.secondary_dns.family = 0;
|
||||
ipcom_memset(&dns.tertiary_dns.addr, 0, sizeof(dns.tertiary_dns.addr));
|
||||
dns.tertiary_dns.family = 0;
|
||||
ipcom_memset(&dns.quaternary_dns.addr, 0, sizeof(dns.quaternary_dns.addr));
|
||||
dns.quaternary_dns.family = 0;
|
||||
address_lookup = IP_FALSE;
|
||||
use_cache = IP_FALSE;
|
||||
version = 0;
|
||||
|
||||
ipcom_getopt_clear();
|
||||
while ((i = ipcom_getopt(argc, argv, "umnfcv:t:r:")) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 'f':
|
||||
ipdnsc_cache_flush();
|
||||
return 0;
|
||||
case 'c':
|
||||
use_cache = IP_TRUE;
|
||||
break;
|
||||
case 'v':
|
||||
version = ipcom_atoi(ip_optarg);
|
||||
if(version != 4 && version != 6)
|
||||
{
|
||||
ipcom_printf("Version must be either 4 or 6\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 't':
|
||||
dns.timeout = ipcom_atoi(ip_optarg);
|
||||
if(dns.timeout < 1 || dns.timeout > 60)
|
||||
{
|
||||
ipcom_printf("Timeout must be between 1 and 60 seconds\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
dns.retry = ipcom_atoi(ip_optarg);
|
||||
if (dns.retry < 0 || dns.retry > 5)
|
||||
{
|
||||
ipcom_printf("Retries must be between 0 and 5.\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
#ifdef IPDNSC_USE_TEST
|
||||
case 'u':
|
||||
ipdnsc_test_update();
|
||||
return 0;
|
||||
case 'm': /* test ipdnsc_getipnodebyaddr */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
{
|
||||
struct Ip_hostent *he_v4mappedv6 = IP_NULL;
|
||||
struct Ip_in6_addr ipaddr;
|
||||
int error_num, addr_num = 0;
|
||||
/* Set the address */
|
||||
(void)ipcom_inet_pton(IP_AF_INET6, "::ffff:10.1.2.46", &ipaddr);
|
||||
he_v4mappedv6 = ipdnsc_getipnodebyaddr(&ipaddr, IPDNSC_IN6ADDRSZ, IP_AF_INET6, &error_num);
|
||||
if(he_v4mappedv6 != IP_NULL)
|
||||
{
|
||||
/* Print the hostname */
|
||||
ipcom_printf("Name: %s\n", he_v4mappedv6->h_name);
|
||||
/* Print the addresses */
|
||||
if(he_v4mappedv6->h_addr_list != IP_NULL)
|
||||
while(he_v4mappedv6->h_addr_list[addr_num] != IP_NULL)
|
||||
{
|
||||
if(ipcom_inet_ntop(he_v4mappedv6->h_addrtype, he_v4mappedv6->h_addr_list[addr_num], buf, sizeof(buf)))
|
||||
{
|
||||
if(!addr_num)
|
||||
ipcom_printf("Address: %s\n", buf);
|
||||
else
|
||||
ipcom_printf(" %s\n", buf);
|
||||
}
|
||||
addr_num++;
|
||||
}
|
||||
ipdnsc_hostent_free(he_v4mappedv6);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
case 'n': /* test ipdnsc_getipnodebyname */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
{
|
||||
struct Ip_hostent *he_v4mappedv6 = IP_NULL;
|
||||
int error_num, addr_num = 0;
|
||||
he_v4mappedv6 = ipdnsc_getipnodebyname("v4mappedv6.interpeak.se", IP_AF_INET6, IPDNSC_AI_V4MAPPED | IPDNSC_AI_ALL, &error_num);
|
||||
if(he_v4mappedv6 != IP_NULL)
|
||||
{
|
||||
/* Print the hostname */
|
||||
ipcom_printf("Name: %s\n", he_v4mappedv6->h_name);
|
||||
/* Print the addresses */
|
||||
if(he_v4mappedv6->h_addr_list != IP_NULL)
|
||||
while(he_v4mappedv6->h_addr_list[addr_num] != IP_NULL)
|
||||
{
|
||||
if(ipcom_inet_ntop(he_v4mappedv6->h_addrtype, he_v4mappedv6->h_addr_list[addr_num], buf, sizeof(buf)))
|
||||
{
|
||||
if(!addr_num)
|
||||
ipcom_printf("Address: %s\n", buf);
|
||||
else
|
||||
ipcom_printf(" %s\n", buf);
|
||||
}
|
||||
addr_num++;
|
||||
}
|
||||
ipdnsc_hostent_free(he_v4mappedv6);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
#endif
|
||||
default:
|
||||
ipcom_printf("'%c' is a unknown switch\n", i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the hostname or host address */
|
||||
if(argv[ip_optind])
|
||||
{
|
||||
/* Check if first argument is a presentation form ipv4 or ipv6 address */
|
||||
if(ipcom_inet_pton(IP_AF_INET, argv[ip_optind], &host_addr) > 0)
|
||||
{
|
||||
address_lookup = IP_TRUE;
|
||||
host_family = IP_AF_INET;
|
||||
}
|
||||
#ifdef IPCOM_USE_INET6
|
||||
else if(ipcom_inet_pton(IP_AF_INET6, argv[ip_optind], &host_addr6) > 0)
|
||||
{
|
||||
address_lookup = IP_TRUE;
|
||||
host_family = IP_AF_INET6;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_printf("Interactive mode not supported.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get the optional name server */
|
||||
if(argv[ip_optind+1])
|
||||
{
|
||||
/* Configure the primary DNS */
|
||||
dns.primary_dns.family = IP_AF_INET;
|
||||
if (ipcom_inet_pton (dns.primary_dns.family,
|
||||
argv[ip_optind+1],
|
||||
&dns.primary_dns.addr) != 1)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET6
|
||||
dns.primary_dns.family = IP_AF_INET6;
|
||||
if(ipdnsc_get_ipv6_addrconfig(&dns.primary_dns.addr.inaddr6, &dns.primary_dns.ifindex, argv[ip_optind+1]) < 0)
|
||||
#endif
|
||||
/* Bad address */
|
||||
dns.primary_dns.family = 0;
|
||||
}
|
||||
|
||||
if(dns.primary_dns.family == 0)
|
||||
{
|
||||
ipcom_printf("Name server must be an internet address in presentation form.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Lookup the address of the DNS server. Never use the cache */
|
||||
he1 = ipdnsc_resolve_addr((Ip_u8 *)&dns.primary_dns.addr, dns.primary_dns.family, IP_FALSE, &dns, &err_num);
|
||||
if(!he1)
|
||||
{
|
||||
if(ipcom_inet_ntop(dns.primary_dns.family, &dns.primary_dns.addr, buf, sizeof(buf)))
|
||||
{
|
||||
ipcom_printf("*** Can't find server name for address %s : ", buf);
|
||||
}
|
||||
|
||||
switch(err_num)
|
||||
{
|
||||
case IPDNSC_HOST_NOT_FOUND:
|
||||
ipcom_printf("Non-existent host/domain.\n");
|
||||
break;
|
||||
case IPDNSC_TRY_AGAIN:
|
||||
ipcom_printf("Try Again.\n");
|
||||
break;
|
||||
case IPDNSC_NO_RECOVERY:
|
||||
ipcom_printf("No Recovery.\n");
|
||||
break;
|
||||
case IPDNSC_NO_DATA:
|
||||
ipcom_printf("No Data.\n");
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("Unknown(%d)\n", err_num);
|
||||
break;
|
||||
}
|
||||
/* Print the hostname */
|
||||
ipcom_printf("Server: unknown\n");
|
||||
/* Print the address */
|
||||
if(ipcom_inet_ntop(dns.primary_dns.family, &dns.primary_dns.addr, buf, sizeof(buf)))
|
||||
ipcom_printf("Address: %s\n", buf);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Print the hostname */
|
||||
ipcom_printf("Server: %s\n", he1->h_name);
|
||||
/* Print the address */
|
||||
if(ipcom_inet_ntop(he1->h_addrtype, he1->h_addr_list[0], buf, sizeof(buf)))
|
||||
{
|
||||
ipcom_printf("Address: %s\n", buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipdnsc_hostent_free(he1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
ipcom_printf("\n");
|
||||
|
||||
/* Lookup the hostname or host address. */
|
||||
if(address_lookup)
|
||||
{
|
||||
if(host_family == IP_AF_INET)
|
||||
{
|
||||
he2 = ipdnsc_resolve_addr((Ip_u8 *)&host_addr, host_family, use_cache, &dns, &err_num);
|
||||
}
|
||||
#ifdef IPCOM_USE_INET6
|
||||
else if(host_family == IP_AF_INET6)
|
||||
{
|
||||
he2 = ipdnsc_resolve_addr((Ip_u8 *)&host_addr6, host_family, use_cache, &dns, &err_num);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if(version == 4)
|
||||
{
|
||||
host_family = IP_AF_INET;
|
||||
he2 = ipdnsc_resolve_name((Ip_u8 *)argv[ip_optind], host_family, use_cache, &dns, &err_num);
|
||||
}
|
||||
else if(version == 6)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET6
|
||||
host_family = IP_AF_INET6;
|
||||
he2 = ipdnsc_resolve_name((Ip_u8 *)argv[ip_optind], host_family, use_cache, &dns, &err_num);
|
||||
#else
|
||||
he2 = IP_NULL;
|
||||
err_num = IPDNSC_NO_RECOVERY;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef IPCOM_USE_INET6
|
||||
/* First try to find a v6 address */
|
||||
host_family = IP_AF_INET6;
|
||||
he2 = ipdnsc_resolve_name((Ip_u8 *)argv[ip_optind], host_family, use_cache, &dns, &err_num);
|
||||
if(!he2 && (err_num == IPDNSC_HOST_NOT_FOUND || err_num == IPDNSC_NO_ADDRESS))
|
||||
{
|
||||
host_family = IP_AF_INET;
|
||||
/* If not found try a v4 address */
|
||||
he2 = ipdnsc_resolve_name((Ip_u8 *)argv[ip_optind], host_family, use_cache, &dns, &err_num);
|
||||
}
|
||||
#else
|
||||
host_family = IP_AF_INET;
|
||||
he2 = ipdnsc_resolve_name((Ip_u8 *)argv[ip_optind], host_family, use_cache, &dns, &err_num);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(!he2)
|
||||
{
|
||||
ipcom_printf("*** %s can't find %s : ", he1 != IP_NULL ? he1->h_name : buf, argv[ip_optind]);
|
||||
switch(err_num)
|
||||
{
|
||||
case IPDNSC_HOST_NOT_FOUND:
|
||||
ipcom_printf("Non-existent host/domain.\n");
|
||||
break;
|
||||
case IPDNSC_TRY_AGAIN:
|
||||
ipcom_printf("Try Again.\n");
|
||||
break;
|
||||
case IPDNSC_NO_RECOVERY:
|
||||
ipcom_printf("No Recovery.\n");
|
||||
break;
|
||||
case IPDNSC_NO_DATA:
|
||||
ipcom_printf("No Data.\n");
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("Unknown(%d)\n", err_num);
|
||||
break;
|
||||
}
|
||||
ipcom_printf("\n");
|
||||
ipdnsc_hostent_free(he1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print the hostname */
|
||||
ipcom_printf("Name: %s\n", he2->h_name);
|
||||
/* Print the addresses */
|
||||
i=0;
|
||||
if(he2->h_addr_list != IP_NULL)
|
||||
while(he2->h_addr_list[i] != IP_NULL)
|
||||
{
|
||||
if(ipcom_inet_ntop(he2->h_addrtype, he2->h_addr_list[i], buf, sizeof(buf)))
|
||||
{
|
||||
if(!i)
|
||||
ipcom_printf("Address: %s\n", buf);
|
||||
else
|
||||
ipcom_printf(" %s\n", buf);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/* Print the aliases */
|
||||
i=0;
|
||||
if(he2->h_aliases != IP_NULL)
|
||||
while(he2->h_aliases[i] != IP_NULL)
|
||||
{
|
||||
if(!i)
|
||||
ipcom_printf("Aliases: %s\n", he2->h_aliases[i]);
|
||||
else
|
||||
ipcom_printf(" %s\n", he2->h_aliases[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
ipcom_printf("\n");
|
||||
|
||||
ipdnsc_hostent_free(he1);
|
||||
ipdnsc_hostent_free(he2);
|
||||
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
ipdnsc_nslookup_print_usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdnsc_h.h,v $ $Revision: 1.12.10.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/ipdnsc_h.h,v $
|
||||
* $Author: jren $ $Date: 2015-11-16 02:52:29 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPDNSC_H_H
|
||||
#define IPDNSC_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* DNS client local header file.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipdnsc.h>
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Syslog facility */
|
||||
#ifdef IPCOM_SYSLOG_FACILITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_NONE
|
||||
|
||||
/* Syslog priority */
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
#if defined(_WRS_CONFIG_IPDNSC_SYSLOG_PRIORITY)
|
||||
#define IPCOM_SYSLOG_PRIORITY _WRS_CONFIG_IPDNSC_SYSLOG_PRIORITY
|
||||
#else
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_WARNING
|
||||
#endif
|
||||
|
||||
/* Query flags */
|
||||
#define IPDNSC_QR_FLAG 0x8000
|
||||
#define IPDNSC_OPCODE_FLAG 0x7800
|
||||
#define IPDNSC_UP_FLAG 0x2800
|
||||
#define IPDNSC_AA_FLAG 0x0400
|
||||
#define IPDNSC_TC_FLAG 0x0200
|
||||
#define IPDNSC_RD_FLAG 0x0100
|
||||
#define IPDNSC_RA_FLAG 0x0080
|
||||
#define IPDNSC_ZERO_FLAG 0x0040
|
||||
#define IPDNSC_RCODE_FLAG 0x000f
|
||||
|
||||
/* Query return codes */
|
||||
#define IPDNSC_OK 0 /* General OK */
|
||||
#define IPDNSC_ERR_GENERAL -1 /* General error */
|
||||
#define IPDNSC_SERV_TIMEOUT -2 /* Server did not respond in time */
|
||||
#define IPDNSC_SERV_NONAME -3 /* The name in the query does not exist */
|
||||
#define IPDNSC_SERV_FORMAT -4 /* Format error */
|
||||
#define IPDNSC_SERV_FAIL -5 /* Name server error */
|
||||
#define IPDNSC_SERV_NOTIMPL -6 /* Not implemented */
|
||||
#define IPDNSC_SERV_REFUSED -7 /* Refused */
|
||||
#define IPDNSC_SERV_YXRRSET -8 /*exist*/
|
||||
/* MAX name server number */
|
||||
#define IPDNSC_MAX_NAMESERVER 3
|
||||
|
||||
/* DNS defaults */
|
||||
#define IPDNSC_DEFAULT_DNS_PORT 53
|
||||
#define IPDNSC_DEFAULT_DNS_TIMEOUT 10
|
||||
#define IPDNSC_DEFAULT_DNS_RETRY 2
|
||||
|
||||
/* Maximum size */
|
||||
#define IPDNSC_MAXLABEL 63
|
||||
#define IPDNSC_MAXPKT 512
|
||||
|
||||
/* Internet address lengths */
|
||||
#define IPDNSC_INADDRSZ 4
|
||||
#define IPDNSC_IN6ADDRSZ 16
|
||||
|
||||
/* Maximum length of a FQDN */
|
||||
#define IPDNSC_MAXNAME 255
|
||||
|
||||
/* The delimiter between the address and the interface for scoped addresses
|
||||
* ex FE80::200:30FF:FE40:5060%eth0
|
||||
*/
|
||||
#define IPDNSC_IF_DELIMITER '%'
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdnsc_hdr
|
||||
*===========================================================================
|
||||
* DNS protocol header structure.
|
||||
*/
|
||||
#include "ipcom_align16.h"
|
||||
typedef IP_PACKED1 struct Ipdnsc_hdr_struct
|
||||
{
|
||||
Ip_u16 id; /* identification */
|
||||
Ip_u16 flags; /* flags */
|
||||
Ip_u16 no_ques; /* number of questions */
|
||||
Ip_u16 no_answ; /* number of answers */
|
||||
Ip_u16 no_auth; /* number of authority records */
|
||||
Ip_u16 no_addi; /* number of resource records */
|
||||
}
|
||||
IP_PACKED2 Ipdnsc_hdr;
|
||||
#include "ipcom_align16.h"
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdnsc_ns_addr
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdnsc_ns_addr_struct
|
||||
{
|
||||
Ip_s32 family;
|
||||
union
|
||||
{
|
||||
struct Ip_in_addr inaddr; /* Network endian */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_in6_addr inaddr6; /* Network endian */
|
||||
#endif
|
||||
} addr;
|
||||
#ifdef IPCOM_USE_INET6
|
||||
Ip_u32 ifindex; /* Interface index for link local v6 addresses */
|
||||
#endif
|
||||
Ip_u16 port; /* Network endian */
|
||||
Ip_u16 pad;
|
||||
}
|
||||
Ipdnsc_ns_addr;
|
||||
|
||||
/* store name server address parsed from response records */
|
||||
typedef struct Ipdnsc_record_addr_struct {
|
||||
struct Ipdnsc_record_addr_struct *next;
|
||||
Ipdnsc_ns_addr ns_addr;
|
||||
}
|
||||
Ipdnsc_record_addr;
|
||||
|
||||
/* store ns addresses which belong to a same zone */
|
||||
typedef struct Ipdnsc_record_ns_struct {
|
||||
struct Ipdnsc_record_ns_struct *next;
|
||||
char *name;
|
||||
Ip_u32 flags;
|
||||
Ipdnsc_record_addr *rr_addrs;
|
||||
}
|
||||
Ipdnsc_record_ns;
|
||||
|
||||
/* all zones have been separated */
|
||||
typedef struct Ipdnsc_record_nsset_struct {
|
||||
Ipdnsc_record_ns *head;
|
||||
}
|
||||
Ipdnsc_record_nsset;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdnsc_ns_spec
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdnsc_ns_spec_struct
|
||||
{
|
||||
Ip_s32 timeout;
|
||||
Ip_s32 retry;
|
||||
Ipdnsc_ns_addr primary_dns;
|
||||
Ipdnsc_ns_addr secondary_dns;
|
||||
Ipdnsc_ns_addr tertiary_dns;
|
||||
Ipdnsc_ns_addr quaternary_dns;
|
||||
}
|
||||
Ipdnsc_ns_spec;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdnsc_cache
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
typedef struct Ipdnsc_cache_struct
|
||||
{
|
||||
struct Ipdnsc_cache_struct *next;
|
||||
Ip_u32 type;
|
||||
Ip_u32 expire;
|
||||
struct Ip_hostent *he;
|
||||
}
|
||||
Ipdnsc_cache;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipdnsc_data
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipdnsc_data_struct
|
||||
{
|
||||
Ip_bool init;
|
||||
Ipcom_mutex mutex;
|
||||
Ipdnsc_cache *cache_head;
|
||||
Ip_u32 cache_entries;
|
||||
}
|
||||
Ipdnsc_data;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN Ipdnsc_data ipdnsc;
|
||||
IP_GLOBAL Ip_u32 ipdnsc_get_time(void);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_create_query(Ip_u8 *dname, Ip_u16 type, Ip_u16 class, Ip_u8 *buf);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_send_wait(Ip_u8 *s_buf, Ip_s32 s_size, Ip_u8 *r_buf, Ip_s32 *r_size, Ipdnsc_ns_addr *dns_addr, Ip_s32 timeout);
|
||||
IP_GLOBAL struct Ip_hostent* ipdnsc_resolve_addr(Ip_u8 *addr, Ip_s32 family, Ip_s32 use_cache,
|
||||
Ipdnsc_ns_spec *dns, Ip_s32 *error_num);
|
||||
IP_GLOBAL struct Ip_hostent* ipdnsc_resolve_name(Ip_u8 *name, Ip_s32 family, Ip_s32 use_cache,
|
||||
Ipdnsc_ns_spec *dns, Ip_s32 *error_num);
|
||||
IP_GLOBAL void ipdnsc_hostent_free(struct Ip_hostent *he);
|
||||
IP_GLOBAL struct Ip_hostent* ipdnsc_hostent_create(Ip_s32 type);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_hostent_insert_addr(struct Ip_hostent *he, char *addr);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_hostent_insert_alias(struct Ip_hostent *he, char *name);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_hostent_insert_name(struct Ip_hostent *he, char *name);
|
||||
IP_GLOBAL struct Ip_hostent* ipdnsc_hostent_copy(struct Ip_hostent *he);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_default(Ipdnsc_ns_spec *dns);
|
||||
IP_GLOBAL void ipdnsc_dns_tick(void);
|
||||
IP_GLOBAL int ipdnsc_dns_init(void);
|
||||
IP_GLOBAL int ipdnsc_cmd_nslookup(int argc, char **argv);
|
||||
IP_GLOBAL Ip_err ipdnsc_start(void);
|
||||
#ifdef IPCOM_USE_INET6
|
||||
IP_GLOBAL Ip_s32 ipdnsc_get_ipv6_addrconfig(struct Ip_in6_addr *addr6, Ip_u32 *ifindex, char *addrstr);
|
||||
#endif
|
||||
IP_GLOBAL Ip_s32 ipdnsc_samename(const char *a, const char *b);
|
||||
IP_GLOBAL void ipdnsc_free_nsrrset(Ipdnsc_record_nsset *nsrrsp);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_mkupdate(Ipdnsc_updrec *rrecp_in, Ip_u8 *buf, Ip_s32 buflen, Ip_s32 *error);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_get_soa(const char *dname, Ip_u16 qclass, char *zname,
|
||||
Ip_size_t zsize, char *mname, Ip_size_t msize, Ipdnsc_record_nsset *nsrrsp, Ip_s32 *error);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_get_ns(char *zname, Ip_u16 qclass, Ipdnsc_record_nsset *nsrrsp, Ip_s32 *error);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_get_glue(Ip_u16 qclass, Ipdnsc_record_nsset *nsrrsp, Ip_s32 *error);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_satisfy(const char *mname, Ipdnsc_record_nsset *nsrrsp, Ipdnsc_ns_addr *addrs);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_send_update(Ip_u8 *s_buf, Ip_s32 s_buflen, Ip_u8 *r_buf, Ip_s32 *r_buflen,
|
||||
Ipdnsc_ns_addr *dns_addr, Ip_u32 dns_count, Ip_s32 *error);
|
||||
IP_GLOBAL Ip_s32 ipdnsc_send_update_signed(const Ip_u8 *s_buf, Ip_s32 s_buflen, Ip_u8 *r_buf, Ip_s32 *r_buflen,
|
||||
Ipdnsc_ns_addr *dns_addr, Ip_u32 dns_count, Ipdnsc_tsig_key *key, Ip_s32 *error);
|
||||
#ifdef IPDNSC_USE_TEST
|
||||
IP_GLOBAL void ipdnsc_test_update(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipftps_h.h,v $ $Revision: 1.11.12.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/ipftps_h.h,v $
|
||||
* $Author: hxu0 $ $Date: 2013-04-18 08:48:02 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Ulf Olofsson <ulf@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPFTPS_H_H
|
||||
#define IPFTPS_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipftps_config.h"
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipftps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/* Syslog facility code */
|
||||
#ifdef IPCOM_SYSLOG_FACILITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPFTP
|
||||
|
||||
/* Select level of verbosity for syslog messages if it is not defined */
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
#if defined(_WRS_CONFIG_IPFTPS_SYSLOG_PRIORITY)
|
||||
#define IPCOM_SYSLOG_PRIORITY _WRS_CONFIG_IPFTPS_SYSLOG_PRIORITY
|
||||
#else
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_WARNING
|
||||
#endif
|
||||
|
||||
/* Telnet */
|
||||
#define IPFTPS_SE 240
|
||||
#define IPFTPS_NOP 241
|
||||
#define IPFTPS_DM 242
|
||||
#define IPFTPS_BRK 243
|
||||
#define IPFTPS_IP 244
|
||||
#define IPFTPS_AO 245
|
||||
#define IPFTPS_AYT 246
|
||||
#define IPFTPS_EC 247
|
||||
#define IPFTPS_EL 248
|
||||
#define IPFTPS_GA 249
|
||||
#define IPFTPS_SB 250
|
||||
#define IPFTPS_WILL 251
|
||||
#define IPFTPS_WONT 252
|
||||
#define IPFTPS_DO 253
|
||||
#define IPFTPS_DONT 254
|
||||
#define IPFTPS_IAC 255
|
||||
|
||||
/* Line terminator */
|
||||
#define CL "\r\n"
|
||||
|
||||
/* Source code line string */
|
||||
#define __LINESTR(line) #line
|
||||
#define __LINESTR_(line) __LINESTR(line)
|
||||
#define __LINESTR__ __LINESTR_(__LINE__)
|
||||
|
||||
/* Create log messages */
|
||||
#undef IPCOM_SYSLOG_BODY
|
||||
#ifdef IP_DEBUG
|
||||
#define IPCOM_SYSLOG_BODY(x) "%s at " __FILE__ "(" __LINESTR__ "): " x, \
|
||||
(session == IP_NULL ? "ipftps" : session->name)
|
||||
#else
|
||||
#define IPCOM_SYSLOG_BODY(x) "%s: " x, \
|
||||
(session == IP_NULL ? "ipftps" : session->name)
|
||||
#endif
|
||||
|
||||
/* Time values */
|
||||
#define IPFTPS_MONTHS (30L * IPFTPS_DAYS)
|
||||
#define IPFTPS_DAYS (24L * IPFTPS_HOURS)
|
||||
#define IPFTPS_HOURS (60L * IPFTPS_MINUTES)
|
||||
#define IPFTPS_MINUTES (60L)
|
||||
|
||||
/* Max length of IP address string */
|
||||
#define IPFTPS_IPV4_MAXLEN \
|
||||
sizeof("255.255.255.255")
|
||||
#define IPFTPS_IPV6_MAXLEN \
|
||||
sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
|
||||
|
||||
/* IPv4/IPv6 macros */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
|
||||
#define IPFTPS_AFMAX 2
|
||||
#define IPFTPS_AFSTR "(1,2)"
|
||||
#define IPFTPS_IP_MAXLEN IPFTPS_IPV6_MAXLEN
|
||||
#define IPFTPS_PORT(s) *((s)->sa.sa_family == IP_AF_INET ? \
|
||||
&(s)->sin.sin_port : \
|
||||
&(s)->sin6.sin6_port)
|
||||
#define IPFTPS_SOCKADDRLEN(s) ((s)->sa.sa_family == IP_AF_INET ? \
|
||||
sizeof((s)->sin) : \
|
||||
sizeof((s)->sin6))
|
||||
#define IPFTPS_ADDRCMP(a1,a2) ((a1)->sa.sa_family != (a2)->sa.sa_family || \
|
||||
((a1)->sa.sa_family == IP_AF_INET ? \
|
||||
ipcom_memcmp(&(a1)->sin.sin_addr, &(a2)->sin.sin_addr, \
|
||||
sizeof((a1)->sin.sin_addr)) : \
|
||||
ipcom_memcmp(&(a1)->sin6.sin6_addr, &(a2)->sin6.sin6_addr, \
|
||||
sizeof((a1)->sin6.sin6_addr))) != 0)
|
||||
#else
|
||||
|
||||
#define IPFTPS_AFMAX 1
|
||||
#define IPFTPS_AFSTR "(1)"
|
||||
#define IPFTPS_IP_MAXLEN IPFTPS_IPV4_MAXLEN
|
||||
#define IPFTPS_PORT(s) ((s)->sin.sin_port)
|
||||
#define IPFTPS_SOCKADDRLEN(s) (sizeof((s)->sin))
|
||||
#define IPFTPS_ADDRCMP(a1,a2) ((a1)->sa.sa_family != (a2)->sa.sa_family || \
|
||||
ipcom_memcmp(&(a1)->sin.sin_addr, &(a2)->sin.sin_addr, \
|
||||
sizeof((a1)->sin.sin_addr)) != 0)
|
||||
|
||||
#ifndef IP_AF_INET6
|
||||
#define IP_AF_INET6 -1 /* Dummy to avoid #ifdefs */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Liberal free */
|
||||
#define ipftps_free(x) \
|
||||
if ((x) != IP_NULL) do {ipcom_free(x); (x) = IP_NULL; (void)(x);} while (0)
|
||||
|
||||
/* A string and its length */
|
||||
#define ipftps_strandlen(x) x, ipcom_strlen(x)
|
||||
|
||||
/*!! to work with ipcom410. */
|
||||
#ifndef IP_ERRNO_ENOTDIR
|
||||
#define IP_ERRNO_ENOTDIR 20
|
||||
#endif
|
||||
|
||||
/* IPLITE/IPNET does not support write select */
|
||||
#if !defined(IPCOM_SOCK_IPCOM)
|
||||
#define IPFTPS_USE_WRITESELECT
|
||||
#endif
|
||||
|
||||
#ifdef IPFTP_TLS
|
||||
#define IPFTPS_CTRL_FLAG 0
|
||||
#define IPFTPS_DATA_FLAG 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPFTPS_C
|
||||
|
||||
#ifdef IPFTP_TLS
|
||||
IP_GLOBAL void
|
||||
ipftps_free_tls(void);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipftps_free_tls_session(Ipftps_session *session);
|
||||
|
||||
IP_GLOBAL int
|
||||
ipftps_init_tls(Ipftps_session *session);
|
||||
|
||||
IP_GLOBAL int
|
||||
ipftps_init_tls_session(Ipftps_session *session);
|
||||
|
||||
IP_GLOBAL int
|
||||
ipftps_create_new_tls_csession(Ipftps_session *session);
|
||||
|
||||
IP_GLOBAL int
|
||||
ipftps_create_new_tls_dsession(Ipftps_session *session, int *eno);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipftps_tls_close_session(Ipftps_session *session, int option);
|
||||
|
||||
IP_GLOBAL int
|
||||
ipftps_tls_send(Ipftps_session *session, Ip_fd fd,char *buf, int buflen);
|
||||
|
||||
IP_GLOBAL int
|
||||
ipftps_tls_read(Ipftps_session *session, Ip_fd fd,char *buf, int buflen, int *len);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipftps_tls_set_flag(Ipftps_session *session, int option,Ip_bool flag);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipftps_tls_shutdown(Ipftps_session *session,int option);
|
||||
|
||||
IP_GLOBAL void
|
||||
ipftps_tls_set_ccc(Ipftps_session *session, Ip_bool flag);
|
||||
|
||||
IP_GLOBAL Ip_bool
|
||||
ipftps_tls_get_ccc(Ipftps_session *session);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftps_session
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* FTP session handler subprocess.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IPCOM_PROCESS(ipftps_session);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftps_main
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* FTP main process.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IPCOM_PROCESS(ipftps_main);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipftps_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Start FTP daemon.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipftps_create(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptftp_h.h,v $ $Revision: 1.9.12.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/iptftp_h.h,v $
|
||||
* $Author: jren $ $Date: 2019-04-02 08:29:40 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPTFTP_H_H
|
||||
#define IPTFTP_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sock.h>
|
||||
#ifdef IPCOM_USE_INET6
|
||||
#include <ipcom_sock6.h>
|
||||
#endif
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Syslog facility */
|
||||
#ifdef IPCOM_SYSLOG_FACILITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPTFTP
|
||||
|
||||
/* Syslog priority */
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
#if defined(_WRS_CONFIG_IPTFTP_SYSLOG_PRIORITY)
|
||||
#define IPCOM_SYSLOG_PRIORITY _WRS_CONFIG_IPTFTP_SYSLOG_PRIORITY
|
||||
#else
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_WARNING
|
||||
#endif
|
||||
|
||||
/* Directory separator character */
|
||||
#define IPTFTP_DIR_SEP '/'
|
||||
#define IPTFTP_DIR_SEP_STRING "/"
|
||||
|
||||
|
||||
/* tftp port */
|
||||
#define IPTFTP_PORT 69
|
||||
|
||||
/* tftp maximum packet size */
|
||||
#define IPTFTP_MAX_PACKET 516
|
||||
|
||||
/* TFTP opcodes */
|
||||
#define IPTFTP_OPCODE_RRQ 1
|
||||
#define IPTFTP_OPCODE_WRQ 2
|
||||
#define IPTFTP_OPCODE_DATA 3
|
||||
#define IPTFTP_OPCODE_ACK 4
|
||||
#define IPTFTP_OPCODE_ERR 5
|
||||
|
||||
/* TFTP Error codes */
|
||||
#define IPTFTP_ERRCODE_NOTDEFINED 0
|
||||
#define IPTFTP_ERRCODE_FILENOTFOUND 1
|
||||
#define IPTFTP_ERRCODE_ACCESSVIOLATION 2
|
||||
#define IPTFTP_ERRCODE_DISKFULL 3
|
||||
#define IPTFTP_ERRCODE_ILLEGALTFTPOP 4
|
||||
#define IPTFTP_ERRCODE_UNKNKOWNTRANSFERID 5
|
||||
#define IPTFTP_ERRCODE_FILEALREADYEXISTS 6
|
||||
#define IPTFTP_ERRCODE_NOSUCHUSER 7
|
||||
|
||||
/* TFTP Error messages */
|
||||
#define IPTFTP_ERRMSG_INCOMPLETEMSG "Incomplete message."
|
||||
#define IPTFTP_ERRMSG_INVALIDOPCODE "Invalid opcode."
|
||||
#define IPTFTP_ERRMSG_INVALIDMODE "Invalid mode."
|
||||
#define IPTFTP_ERRMSG_COULDNOTOPENFILE "Could not open file."
|
||||
#define IPTFTP_ERRMSG_COULDNOTCREATEFILE "Could not create file."
|
||||
#define IPTFTP_ERRMSG_FILEREADERROR "File read error."
|
||||
#define IPTFTP_ERRMSG_INCORRECTSRCPORT "Incorrect source port."
|
||||
#define IPTFTP_ERRMSG_FAILEDTOCHANGEDIR "Failed to change directory."
|
||||
#define IPTFTP_ERRMSG_INVALIDLINEDELIMITER "Invalid line delimiter received."
|
||||
#define IPTFTP_ERRMSG_FILEWRITEERROR "File write error."
|
||||
#define IPTFTP_ERRMSG_FILEABOVEWORKINGDIR "Could not access file aboved working directory."
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct Ip_in_addr addr;
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_in6_addr addr6;
|
||||
#endif
|
||||
}
|
||||
Iptftp_addr;
|
||||
|
||||
|
||||
typedef struct Iptftp_struct
|
||||
{
|
||||
Ip_s32 family; /* Internet address family */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
Ip_u32 ifindex; /* Interface index for link local v6 addresses */
|
||||
#endif
|
||||
Iptftp_addr peer_addr; /* Peer address (network endian) */
|
||||
Ip_u16 peer_port; /* Peer port */
|
||||
Ip_u16 opcode; /* Read or Write request */
|
||||
Ip_bool binary; /* True for octet mode */
|
||||
Ip_bool verbose; /* True for statistics and error message stdio printing */
|
||||
Ip_u32 nbytes; /* The number of bytes transfer in the connection */
|
||||
Ip_s32 dirlen; /* Length of the server working directory */
|
||||
char file[256]; /* Filename with absolute path */
|
||||
/* ancillary data buffer */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
char controlbuf[IP_CMSG_SPACE(sizeof(struct Ip_in6_pktinfo))];
|
||||
#else
|
||||
char controlbuf[IP_CMSG_SPACE(sizeof(struct Ip_in_pktinfo))];
|
||||
#endif
|
||||
Ip_socklen_t controllen; /* ancillary data len */
|
||||
}
|
||||
Iptftp;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err iptftp_sendto(Ip_fd sock, Iptftp *tftp, char *buf, Ip_s32 len);
|
||||
IP_GLOBAL Ip_err iptftp_bind_zero(Ip_fd sock, Ip_s32 family);
|
||||
IP_GLOBAL Ip_s32 iptftp_recvfrom(Ip_fd sock, Iptftp *tftp, char *buf, Ip_s32 bufsize);
|
||||
IP_GLOBAL void iptftp_send_err(Ip_fd sock, Iptftp *tftp, Ip_u16 err_code, char *err_msg);
|
||||
IP_GLOBAL Ip_err iptftp_receive_loop(Ip_fd sock, IP_FILE *fp, char **err_msg, Ip_u16 *err_code, Iptftp *tftp);
|
||||
IP_GLOBAL Ip_err iptftp_send_loop(Ip_fd sock, IP_FILE *fp, char **err_msg, Ip_u16 *err_code, Iptftp *tftp);
|
||||
IP_GLOBAL void iptftp_strip_path(char *path);
|
||||
IP_GLOBAL int iptftp_cmd_tftp(int argc, char **argv);
|
||||
#ifdef IPTESTENGINE
|
||||
IP_GLOBAL void iptftp_create_file(char *fullPath);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,550 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptftpc.c,v $ $Revision: 1.27.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/iptftpc.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* TFTP client implementation.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_time.h>
|
||||
#include <ipcom_getopt.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sock2.h>
|
||||
|
||||
#include "iptftp_h.h"
|
||||
#include "iptftp.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err iptftpc_create(void);
|
||||
IP_PUBLIC Ip_err iptftpc_start(void);
|
||||
IP_PUBLIC const char *iptftpc_version(void);
|
||||
|
||||
IP_STATIC Ip_err iptftp_client_send_file(const char *src, Iptftp *tftp);
|
||||
IP_STATIC Ip_err iptftp_client_receive_file(const char *dst, Iptftp *tftp);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_client_send_file
|
||||
*===========================================================================
|
||||
* Description: Internal send function for TFTP client
|
||||
* Parameters: src - name of the file to send
|
||||
* tftp - TFTP structure
|
||||
* Returns: IPTFTP_SUCCESS for success and a TFTP error code for failures.
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
iptftp_client_send_file(const char *src, Iptftp *tftp)
|
||||
{
|
||||
Ip_fd sock = IP_INVALID_SOCKET;
|
||||
IP_FILE *fp;
|
||||
char *err_msg = IP_NULL;
|
||||
Ip_u16 err_code = 0;
|
||||
Ip_err retval;
|
||||
|
||||
if(tftp->binary)
|
||||
fp = ipcom_fopen(src, "rb");
|
||||
else
|
||||
fp = ipcom_fopen(src, "r");
|
||||
if(!fp)
|
||||
{
|
||||
retval = IPTFTP_ERR_FILE_OPEN;
|
||||
IPCOM_LOG1(ERR, "iptftp_client_send_file :: Could not open file: \"%s\"", src);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Get a udp socket, and bind to port 0 */
|
||||
sock = ipcom_socket(tftp->family, IP_SOCK_DGRAM, 0);
|
||||
if (sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
retval = IPTFTP_ERR_SOCKET_FAIL;
|
||||
IPCOM_LOG0(ERR, "iptftp_client_send_file :: ipcom_socket() failed");
|
||||
goto err;
|
||||
}
|
||||
if (iptftp_bind_zero(sock, tftp->family) != IPCOM_SUCCESS)
|
||||
{
|
||||
retval = IPTFTP_ERR_SOCKET_FAIL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Send the file */
|
||||
retval = iptftp_send_loop(sock, fp, &err_msg, &err_code, tftp);
|
||||
|
||||
err:
|
||||
/* Send error */
|
||||
if(err_msg)
|
||||
iptftp_send_err(sock, tftp, err_code, err_msg);
|
||||
|
||||
if(fp != IP_NULL)
|
||||
(void)ipcom_fclose(fp);
|
||||
if(sock != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(sock);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_client_receive_file
|
||||
*===========================================================================
|
||||
* Description: Internal receive function for TFTP client
|
||||
* Parameters: dst - name of the file to receive
|
||||
* tftp - TFTP structure
|
||||
* Returns: IPTFTP_SUCCESS for success and a TFTP error code for failures.
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
iptftp_client_receive_file(const char *dst, Iptftp *tftp)
|
||||
{
|
||||
Ip_fd sock = IP_INVALID_SOCKET;
|
||||
IP_FILE *fp;
|
||||
char *err_msg = IP_NULL;
|
||||
Ip_u16 err_code = 0;
|
||||
Ip_err retval;
|
||||
|
||||
if(tftp->binary)
|
||||
fp = ipcom_fopen(dst, "wb");
|
||||
else
|
||||
fp = ipcom_fopen(dst, "w");
|
||||
if(!fp)
|
||||
{
|
||||
retval = IPTFTP_ERR_FILE_OPEN;
|
||||
IPCOM_LOG1(ERR, "iptftp_client_receive_file :: Could not create file: \"%s\"", dst);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Get a udp socket, and bind to port 0 */
|
||||
sock = ipcom_socket(tftp->family, IP_SOCK_DGRAM, 0);
|
||||
if (sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
retval = IPTFTP_ERR_SOCKET_FAIL;
|
||||
IPCOM_LOG0(ERR, "iptftp_client_receive_file :: ipcom_socket() failed");
|
||||
goto err;
|
||||
}
|
||||
if(iptftp_bind_zero(sock, tftp->family) != IPCOM_SUCCESS)
|
||||
{
|
||||
retval = IPTFTP_ERR_SOCKET_FAIL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Receive the file */
|
||||
retval = iptftp_receive_loop(sock, fp, &err_msg, &err_code, tftp);
|
||||
|
||||
err:
|
||||
/* Receive error */
|
||||
if(err_msg)
|
||||
iptftp_send_err(sock, tftp, err_code, err_msg);
|
||||
|
||||
if(fp != IP_NULL)
|
||||
(void)ipcom_fclose(fp);
|
||||
if(sock != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(sock);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_client_get
|
||||
*===========================================================================
|
||||
* Description: See iptftp.h for description.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftp_client_get(const char *server, const char *srcfile, const char *dstfile,
|
||||
Ip_bool binary, Ip_bool verbose, int port)
|
||||
{
|
||||
Iptftp *tftp;
|
||||
Ip_err ret;
|
||||
char dst[256];
|
||||
|
||||
#ifdef IPCOM_USE_TIME
|
||||
Ip_u32 msec, sec;
|
||||
#endif
|
||||
struct Ip_addrinfo *res = IP_NULL;
|
||||
|
||||
ip_assert(srcfile != IP_NULL);
|
||||
|
||||
tftp = ipcom_malloc(sizeof(*tftp));
|
||||
if(tftp == IP_NULL)
|
||||
return IPTFTP_ERR_MEMORY_FAIL;
|
||||
ipcom_memset(tftp, 0, sizeof(*tftp));
|
||||
tftp->opcode = IPTFTP_OPCODE_RRQ;
|
||||
tftp->binary = binary;
|
||||
tftp->verbose = verbose;
|
||||
|
||||
|
||||
if(port == 0) /* No passed port number check the sysvar */
|
||||
tftp->peer_port = (Ip_u16)ipcom_sysvar_get_as_int("iptftp.clntSrvPort", IPTFTP_PORT);
|
||||
else
|
||||
tftp->peer_port = (Ip_u16) port;
|
||||
|
||||
if (ipcom_getaddrinfo(server, IP_NULL, IP_NULL, &res) == 0)
|
||||
{
|
||||
tftp->family = res->ai_addr->sa_family;
|
||||
#ifdef IPCOM_USE_INET
|
||||
if(tftp->family == IP_AF_INET)
|
||||
{
|
||||
ipcom_memcpy(&tftp->peer_addr.addr,
|
||||
&((struct Ip_sockaddr_in *)res->ai_addr)->sin_addr,
|
||||
sizeof(tftp->peer_addr.addr));
|
||||
goto server_ok;
|
||||
}
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if(tftp->family == IP_AF_INET6)
|
||||
{
|
||||
ipcom_memcpy(&tftp->peer_addr.addr6,
|
||||
&((struct Ip_sockaddr_in6 *)res->ai_addr)->sin6_addr,
|
||||
sizeof(tftp->peer_addr.addr6));
|
||||
tftp->ifindex = ((struct Ip_sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
|
||||
goto server_ok;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
ret = IPTFTP_ERR_SERVER_ADDR;
|
||||
goto exit;
|
||||
|
||||
server_ok:
|
||||
if(ipcom_strlen(srcfile) >= sizeof(tftp->file))
|
||||
{
|
||||
ret = IPTFTP_ERR_FILE_OPEN;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_strcpy(tftp->file, srcfile);
|
||||
}
|
||||
|
||||
if(!dstfile)
|
||||
{
|
||||
ipcom_strcpy(dst, tftp->file);
|
||||
iptftp_strip_path(dst);
|
||||
}
|
||||
else
|
||||
ipcom_strcpy(dst, dstfile);
|
||||
|
||||
#ifdef IPCOM_USE_TIME
|
||||
msec = (Ip_u32)ipcom_times(IP_NULL);
|
||||
#endif
|
||||
ret = iptftp_client_receive_file(dst, tftp);
|
||||
if(ret == IPTFTP_SUCCESS)
|
||||
{
|
||||
#ifdef IPCOM_USE_TIME
|
||||
msec = (Ip_u32)ipcom_times(IP_NULL) - msec;
|
||||
sec = msec / 1000;
|
||||
msec = (msec % 1000) / 100; /* Tenths of second */
|
||||
if(verbose)
|
||||
ipcom_printf("Transfer completed: %ld bytes in %ld.%ld seconds."IP_LF, tftp->nbytes, sec, msec);
|
||||
#else
|
||||
if(verbose)
|
||||
ipcom_printf("Transfer completed: %ld bytes."IP_LF, tftp->nbytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
exit:
|
||||
if(res != IP_NULL)
|
||||
ipcom_freeaddrinfo(res);
|
||||
ipcom_free(tftp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_client_put
|
||||
*===========================================================================
|
||||
* Description: See iptftp.h for description.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftp_client_put(const char *server, const char *srcfile, const char *dstfile,
|
||||
Ip_bool binary, Ip_bool verbose, int port)
|
||||
{
|
||||
Iptftp *tftp;
|
||||
Ip_err ret;
|
||||
char dst[256];
|
||||
|
||||
#ifdef IPCOM_USE_TIME
|
||||
Ip_u32 msec, sec;
|
||||
#endif
|
||||
struct Ip_addrinfo *res = IP_NULL;
|
||||
|
||||
ip_assert(srcfile != IP_NULL);
|
||||
|
||||
tftp = ipcom_malloc(sizeof(*tftp));
|
||||
if(tftp == IP_NULL)
|
||||
return IPTFTP_ERR_MEMORY_FAIL;
|
||||
ipcom_memset(tftp, 0, sizeof(*tftp));
|
||||
tftp->opcode = IPTFTP_OPCODE_WRQ;
|
||||
tftp->binary = binary;
|
||||
tftp->verbose = verbose;
|
||||
|
||||
|
||||
if(port == 0) /* No passed port number check the sysvar */
|
||||
tftp->peer_port = (Ip_u16)ipcom_sysvar_get_as_int("iptftp.clntSrvPort", IPTFTP_PORT);
|
||||
else
|
||||
tftp->peer_port = (Ip_u16) port;
|
||||
|
||||
if (ipcom_getaddrinfo(server, IP_NULL, IP_NULL, &res) == 0
|
||||
&& res != IP_NULL && res->ai_addr != IP_NULL)
|
||||
{
|
||||
tftp->family = res->ai_addr->sa_family;
|
||||
#ifdef IPCOM_USE_INET
|
||||
if(tftp->family == IP_AF_INET)
|
||||
{
|
||||
ipcom_memcpy(&tftp->peer_addr.addr,
|
||||
&((struct Ip_sockaddr_in *)res->ai_addr)->sin_addr,
|
||||
sizeof(tftp->peer_addr.addr));
|
||||
goto server_ok;
|
||||
}
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if(tftp->family == IP_AF_INET6)
|
||||
{
|
||||
ipcom_memcpy(&tftp->peer_addr.addr6,
|
||||
&((struct Ip_sockaddr_in6 *)res->ai_addr)->sin6_addr,
|
||||
sizeof(tftp->peer_addr.addr6));
|
||||
tftp->ifindex = ((struct Ip_sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
|
||||
goto server_ok;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
ret = IPTFTP_ERR_SERVER_ADDR;
|
||||
goto exit;
|
||||
|
||||
server_ok:
|
||||
if(!dstfile)
|
||||
{
|
||||
ipcom_strcpy(dst, srcfile);
|
||||
iptftp_strip_path(dst);
|
||||
}
|
||||
else
|
||||
ipcom_strcpy(dst, dstfile);
|
||||
|
||||
if(ipcom_strlen(dst) >= sizeof(tftp->file))
|
||||
{
|
||||
ret = IPTFTP_ERR_FILE_OPEN;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_strcpy(tftp->file, dst);
|
||||
}
|
||||
|
||||
#ifdef IPCOM_USE_TIME
|
||||
msec = (Ip_u32)ipcom_times(IP_NULL);
|
||||
#endif
|
||||
ret = iptftp_client_send_file(srcfile, tftp);
|
||||
if(ret == IPTFTP_SUCCESS)
|
||||
{
|
||||
#ifdef IPCOM_USE_TIME
|
||||
msec = (Ip_u32)ipcom_times(IP_NULL) - msec;
|
||||
sec = msec / 1000;
|
||||
msec = (msec % 1000) / 100; /* Tenths of second */
|
||||
if(verbose)
|
||||
ipcom_printf("Transfer completed: %ld bytes in %ld.%ld seconds."IP_LF, tftp->nbytes, sec, msec);
|
||||
#else
|
||||
if(verbose)
|
||||
ipcom_printf("Transfer completed: %ld bytes."IP_LF, tftp->nbytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
exit:
|
||||
if(res != IP_NULL)
|
||||
ipcom_freeaddrinfo(res);
|
||||
ipcom_free(tftp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_create_file
|
||||
*===========================================================================
|
||||
*
|
||||
* Description:
|
||||
* create file in local target.
|
||||
*
|
||||
* WARNING--This function is designed to be used for test
|
||||
* purposes. It is of utmost importance that this function
|
||||
* is disabled before deploying the TFTP client. This is
|
||||
* done by not defining IPTESTENGINE.
|
||||
*
|
||||
* Parameters:
|
||||
* fullPath - full directory
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
#ifdef IPTESTENGINE
|
||||
IP_GLOBAL void
|
||||
iptftp_create_file(char *fullPath)
|
||||
{
|
||||
int mode = IP_O_RDWR | IP_O_CREAT
|
||||
#ifdef IP_O_BINARY
|
||||
| IP_O_BINARY
|
||||
#endif
|
||||
;
|
||||
Ip_fd fd;
|
||||
Ip_fd sock = -1;
|
||||
Iptftp tftp;
|
||||
|
||||
if ((fd = ipcom_fileopen(fullPath, mode,
|
||||
IP_S_IRUSR | IP_S_IWUSR |
|
||||
IP_S_IRGRP | IP_S_IROTH)) < 0)
|
||||
return;
|
||||
|
||||
else
|
||||
{
|
||||
static const char data[] = "\r\n\n\n\r\r\n";
|
||||
int datalen = strlen(data);
|
||||
int len = 50;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i += datalen)
|
||||
{
|
||||
int writelen = IP_MIN(datalen, len - i);
|
||||
|
||||
if (ipcom_filewrite(fd, data, writelen) != writelen)
|
||||
{
|
||||
(void)ipcom_fileclose(fd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
(void)ipcom_fileclose(fd);
|
||||
}
|
||||
|
||||
ipcom_memset(&tftp,0,sizeof(tftp));
|
||||
tftp.family = IP_AF_UNSPEC;
|
||||
iptftp_send_err(sock, &tftp, IPTFTP_ERRCODE_UNKNKOWNTRANSFERID, IPTFTP_ERRMSG_INCORRECTSRCPORT);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftpc_create
|
||||
*===========================================================================
|
||||
* Description: TFTP Client create function.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS or an IPCOM_ERR_XXX error code.
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftpc_create(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftpc_start
|
||||
*===========================================================================
|
||||
* Description: TFTP Client start function.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS or an IPCOM_ERR_XXX error code.
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftpc_start(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftpc_version
|
||||
*===========================================================================
|
||||
* Description: Get TFTP client version string.
|
||||
* Parameters: none.
|
||||
* Returns: TFTP client version.
|
||||
*/
|
||||
IP_PUBLIC const char *
|
||||
iptftpc_version(void)
|
||||
{
|
||||
return "@(#) IPTFTPC $Name: VXWORKS_ITER40_2019102207 $ - INTERPEAK_COPYRIGHT_STRING";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptftpc_cmd_tftp.c,v $ $Revision: 1.6.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/iptftpc_cmd_tftp.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_getopt.h>
|
||||
|
||||
#include "iptftp.h"
|
||||
#include "iptftp_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC int iptftp_cmd_tftp(int argc, char **argv);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_cmd_tftp
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
iptftp_cmd_tftp(int argc, char **argv)
|
||||
{
|
||||
Ip_bool binary = IP_TRUE;
|
||||
char *src = IP_NULL, *dst = IP_NULL;
|
||||
Ip_s32 i;
|
||||
Ip_u16 operation = IPTFTP_OPCODE_RRQ;
|
||||
Ip_err ret;
|
||||
Ipcom_getopt opt;
|
||||
int port = 0;
|
||||
int command_index;
|
||||
int src_index;
|
||||
int dst_index;
|
||||
int port_index;
|
||||
|
||||
ipcom_getopt_clear_r(&opt);
|
||||
while ((i = ipcom_getopt_r(argc, argv, "ac:", &opt)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 'a':
|
||||
binary = IP_FALSE;
|
||||
break;
|
||||
#ifdef IPTESTENGINE
|
||||
case 'c':
|
||||
iptftp_create_file(argv[opt.optind - 1]);
|
||||
return 0;
|
||||
#endif
|
||||
default:
|
||||
ipcom_printf("Unknown switch"IP_LF);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - opt.optind < 3)
|
||||
{
|
||||
/* Interactive mode not supported */
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/* Get port index */
|
||||
port_index = opt.optind+1;
|
||||
|
||||
/* Get the operation */
|
||||
if (port_index < argc)
|
||||
{
|
||||
port = ipcom_atoi(argv[port_index]);
|
||||
/* no port specified */
|
||||
if((port <= 0) || (port > 0xFFFF))
|
||||
{
|
||||
command_index = opt.optind + 1;
|
||||
src_index = opt.optind + 2;
|
||||
dst_index = opt.optind + 3;
|
||||
port = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
command_index = opt.optind + 2;
|
||||
src_index = opt.optind + 3;
|
||||
dst_index = opt.optind + 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if (command_index < argc)
|
||||
{
|
||||
if (!ipcom_strcmp(argv[command_index], "GET") || !ipcom_strcmp(argv[command_index], "get"))
|
||||
operation = IPTFTP_OPCODE_RRQ;
|
||||
else if (!ipcom_strcmp(argv[command_index], "PUT") || !ipcom_strcmp(argv[command_index], "put"))
|
||||
operation = IPTFTP_OPCODE_WRQ;
|
||||
else
|
||||
goto usage;
|
||||
}
|
||||
/* Get the source file and optionally the destination file */
|
||||
if (src_index < argc)
|
||||
src = argv[src_index];
|
||||
if (dst_index < argc)
|
||||
dst = argv[dst_index];
|
||||
|
||||
/* Call the tftp api */
|
||||
if (operation == IPTFTP_OPCODE_RRQ)
|
||||
ret = iptftp_client_get(argv[opt.optind], src, dst, binary, IP_TRUE, port);
|
||||
else
|
||||
ret = iptftp_client_put(argv[opt.optind], src, dst, binary, IP_TRUE, port);
|
||||
|
||||
switch(ret)
|
||||
{
|
||||
case IPTFTP_SUCCESS:
|
||||
break;
|
||||
case IPTFTP_ERR_SERVER_ADDR:
|
||||
ipcom_printf("Unknown host: %s"IP_LF, argv[opt.optind]);
|
||||
break;
|
||||
case IPTFTP_ERR_MEMORY_FAIL:
|
||||
ipcom_printf("Out of memory."IP_LF);
|
||||
break;
|
||||
case IPTFTP_ERR_FILE_OPEN:
|
||||
if (operation == IPTFTP_OPCODE_RRQ)
|
||||
ipcom_printf("Could not create file: %s"IP_LF, dst == IP_NULL ? src : dst);
|
||||
else
|
||||
ipcom_printf("Could not open file: %s"IP_LF, src);
|
||||
break;
|
||||
case IPTFTP_ERR_FILE_READ:
|
||||
ipcom_printf("Could not read from file: %s"IP_LF, src);
|
||||
break;
|
||||
case IPTFTP_ERR_FILE_WRITE:
|
||||
ipcom_printf("Could not write to file: %s"IP_LF, dst == IP_NULL ? src : dst);
|
||||
break;
|
||||
case IPTFTP_ERR_TRANSFER_TIMEOUT:
|
||||
ipcom_printf("Timeout in TFTP transfer."IP_LF);
|
||||
break;
|
||||
case IPTFTP_ERR_SOCKET_FAIL:
|
||||
ipcom_printf("Socket operation failed."IP_LF);
|
||||
break;
|
||||
case IPTFTP_ERR_ILLEGAL_MESSAGE:
|
||||
ipcom_printf("Illegal TFTP message received."IP_LF);
|
||||
break;
|
||||
case IPTFTP_ERR_ERROR_MESSAGE:
|
||||
ipcom_printf("Received error message during transfer."IP_LF);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
usage:
|
||||
ipcom_printf("usage: tftp [-a] <host [port]> <get|put> <source> [destination]"IP_LF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,924 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: iptftps.c,v $ $Revision: 1.25.10.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipappl/src/iptftps.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* TFTP server implementation.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_ipd.h>
|
||||
|
||||
#include "iptftp_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Specifies if TFTP write requests are permitted */
|
||||
#define IPTFTP_SERVER_ALLOW_UPLOAD
|
||||
|
||||
/* Specifies if TFTP read requests are permitted */
|
||||
#define IPTFTP_SERVER_ALLOW_DOWNLOAD
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err iptftps_create(void);
|
||||
IP_PUBLIC Ip_err iptftps_start(void);
|
||||
IP_PUBLIC const char *iptftps_version(void);
|
||||
|
||||
IP_STATIC IPCOM_PROCESS(iptftps);
|
||||
IP_STATIC Ip_err iptftp_server_spawn_handler(Iptftp *tftp);
|
||||
IP_STATIC Ip_err iptftp_server_parse_request(Ip_fd sock, Ip_s32 family, Iptftp *tftp);
|
||||
IP_STATIC void iptftp_server_send_file(Iptftp *tftp);
|
||||
IP_STATIC void iptftp_server_receive_file(Iptftp *tftp);
|
||||
IP_STATIC IPCOM_PROCESS(iptftp_server_handler);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_server_handler
|
||||
*===========================================================================
|
||||
* Description: Spawned TFTP handler.
|
||||
* Parameters: none.
|
||||
* Returns: nothing.
|
||||
*/
|
||||
IP_STATIC
|
||||
IPCOM_PROCESS(iptftp_server_handler)
|
||||
{
|
||||
Ip_bool ipc_opened = IP_FALSE;
|
||||
Ipcom_ipc ipc;
|
||||
Iptftp *ipc_tftp = IP_NULL;
|
||||
|
||||
ipcom_proc_init();
|
||||
|
||||
if (ipcom_ipc_open(&ipc, "iptftps", -1) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_handler :: ipcom_ipc_open(\"ipwebsd\") failed");
|
||||
goto exit;
|
||||
}
|
||||
ipc_opened = IP_TRUE;
|
||||
|
||||
ipc_tftp = ipcom_ipc_malloc(sizeof(*ipc_tftp));
|
||||
if (ipc_tftp == IP_NULL)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_handler :: ipcom_ipc_malloc() failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Get info from tftp server. */
|
||||
if (ipcom_ipc_send(&ipc, ipc_tftp) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_handler :: ipcom_ipc_send() failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ipc_tftp = IP_NULL;
|
||||
|
||||
/* Wait for reply. */
|
||||
if (ipcom_ipc_receive(IP_NULL, &ipc_tftp, -1) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_handler :: ipcom_ipc_receive() failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (ipc_tftp->opcode == IPTFTP_OPCODE_RRQ)
|
||||
{
|
||||
iptftp_server_send_file(ipc_tftp);
|
||||
}
|
||||
else if (ipc_tftp->opcode == IPTFTP_OPCODE_WRQ)
|
||||
{
|
||||
iptftp_server_receive_file(ipc_tftp);
|
||||
}
|
||||
|
||||
exit:
|
||||
if (ipc_opened)
|
||||
(void)ipcom_ipc_close(&ipc);
|
||||
if (ipc_tftp != IP_NULL)
|
||||
ipcom_ipc_free(ipc_tftp);
|
||||
|
||||
ipcom_proc_exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_server_spawn_handler
|
||||
*===========================================================================
|
||||
* Description: Called by the tftp server to spawn a new handler for each
|
||||
* connection
|
||||
* Parameters: sock - The socket the connection arrived on.
|
||||
* family - The Internet address family.
|
||||
* srv_handle - handle for ipcom call messages
|
||||
* Returns: IPCOM_SUCCESS or IPCOM_ERR_FAILED
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
iptftp_server_spawn_handler(Iptftp *tftp)
|
||||
{
|
||||
/* Spawn a tftp handler */
|
||||
if (ipcom_proc_create("iptftp_server_handler", (Ipcom_proc_func)iptftp_server_handler, IPCOM_PROC_STACK_DEFAULT, IP_NULL))
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_spawn_handler :: ipcom_proc_create() failed");
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wait for a message from the handler */
|
||||
Iptftp *ipc_tftp;
|
||||
|
||||
if (ipcom_ipc_receive(IP_NULL, &ipc_tftp, -1) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_spawn_handler :: ipcom_ipc_receive() failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Respond to handler */
|
||||
ipcom_memcpy(ipc_tftp, tftp, sizeof(*tftp));
|
||||
if (ipcom_ipc_send(IPCOM_IPC_SENDER, ipc_tftp) != IPCOM_SUCCESS)
|
||||
{
|
||||
ipcom_ipc_free(ipc_tftp);
|
||||
IPCOM_LOG0(ERR, "iptftp_server_spawn_handler :: ipcom_ipc_send() failed");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
|
||||
err:
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_server_dirindex
|
||||
*===========================================================================
|
||||
*
|
||||
* Description:
|
||||
* Calculate level of directory path.
|
||||
*
|
||||
* Parameters:
|
||||
* path Directory path.
|
||||
*
|
||||
* Returns:
|
||||
* minimum subdirectory level.
|
||||
*/
|
||||
IP_STATIC int
|
||||
iptftp_server_dirindex(char *path)
|
||||
{
|
||||
int level = 0;
|
||||
int min = 0;
|
||||
char *start;
|
||||
char *stop;
|
||||
char *cp;
|
||||
|
||||
cp = path;
|
||||
|
||||
while (*cp != '\0')
|
||||
{
|
||||
char c;
|
||||
|
||||
start = cp;
|
||||
cp += ipcom_strcspn(cp, IPTFTP_DIR_SEP_STRING);
|
||||
stop = cp;
|
||||
cp += ipcom_strspn(cp, IPTFTP_DIR_SEP_STRING);
|
||||
c = *stop;
|
||||
*stop = '\0';
|
||||
|
||||
if (ipcom_strcmp(start, "..") == 0)
|
||||
{
|
||||
level--;
|
||||
}
|
||||
else if (*start != '\0' && ipcom_strcmp(start, ".") != 0)
|
||||
{
|
||||
level++;
|
||||
}
|
||||
|
||||
*stop = c;
|
||||
|
||||
if (level < min)
|
||||
{
|
||||
min = level;
|
||||
}
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_server_parse_request
|
||||
*===========================================================================
|
||||
* Description: Parses a tftp request and calls the request handler
|
||||
* Parameters: sock - socket descriptor the request arrived on.
|
||||
* family - Internet address family for the request.
|
||||
* tftp - TFTP structure.
|
||||
* Returns: IPCOM_SUCCESS if ok and an IPCOM_ERR_XXX error code for
|
||||
* failures.
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
iptftp_server_parse_request(Ip_fd sock, Ip_s32 family, Iptftp *tftp)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET
|
||||
struct Ip_sockaddr_in sa;
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_sockaddr_in6 sa6;
|
||||
#endif
|
||||
char buf[IPTFTP_MAX_PACKET];
|
||||
Ip_s32 i, len;
|
||||
char *err_msg = IP_NULL;
|
||||
struct Ip_msghdr msghdr;
|
||||
struct Ip_iovec iov;
|
||||
Ip_err ret = IPCOM_SUCCESS;
|
||||
|
||||
/* Get the message from the socket */
|
||||
tftp->controllen = sizeof(tftp->controlbuf);
|
||||
msghdr.msg_controllen = tftp->controllen;
|
||||
msghdr.msg_control = tftp->controlbuf;
|
||||
msghdr.msg_flags = 0;
|
||||
msghdr.msg_iov = &iov;
|
||||
msghdr.msg_iovlen = 1;
|
||||
iov.iov_base = buf;
|
||||
iov.iov_len = sizeof(buf);
|
||||
|
||||
/* Get this connection's first packet */
|
||||
switch (family)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET
|
||||
case IP_AF_INET:
|
||||
msghdr.msg_name = &sa;
|
||||
msghdr.msg_namelen = sizeof(sa);
|
||||
len = (Ip_s32)ipcom_recvmsg(sock, &msghdr, 0);
|
||||
if (len < 0)
|
||||
{
|
||||
ret = IPCOM_ERR_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
tftp->peer_port = ip_ntohs(sa.sin_port);
|
||||
ipcom_memcpy(&tftp->peer_addr.addr, &sa.sin_addr, sizeof(tftp->peer_addr.addr));
|
||||
tftp->family = IP_AF_INET;
|
||||
break;
|
||||
#endif /* IPCOM_USE_INET */
|
||||
|
||||
#ifdef IPCOM_USE_INET6
|
||||
case IP_AF_INET6:
|
||||
msghdr.msg_name = &sa6;
|
||||
msghdr.msg_namelen = sizeof(sa6);
|
||||
len = (Ip_s32)ipcom_recvmsg(sock, &msghdr, 0);
|
||||
if (len < 0)
|
||||
{
|
||||
ret = IPCOM_ERR_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
tftp->peer_port = ip_ntohs(sa6.sin6_port);
|
||||
ipcom_memcpy(&tftp->peer_addr.addr6, &sa6.sin6_addr, sizeof(tftp->peer_addr.addr6));
|
||||
tftp->ifindex = sa6.sin6_scope_id;
|
||||
tftp->family = IP_AF_INET6;
|
||||
break;
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
|
||||
default:
|
||||
ret = IPCOM_ERR_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Sanity checking */
|
||||
if (len < 6)
|
||||
{
|
||||
/* Not enough characters */
|
||||
err_msg = IPTFTP_ERRMSG_INCOMPLETEMSG;
|
||||
goto exit;
|
||||
}
|
||||
if (buf[len-1] != '\0')
|
||||
{
|
||||
/* No null char at end */
|
||||
err_msg = IPTFTP_ERRMSG_INCOMPLETEMSG;
|
||||
goto exit;
|
||||
}
|
||||
for (i = 2; i < len; i++)
|
||||
if (buf[i] == '\0')
|
||||
break;
|
||||
if (i < 3)
|
||||
{
|
||||
/* First char is null char */
|
||||
err_msg = IPTFTP_ERRMSG_INCOMPLETEMSG;
|
||||
goto exit;
|
||||
}
|
||||
if (i > (len-3))
|
||||
{
|
||||
/* Only one null char or two trailing null chars */
|
||||
err_msg = IPTFTP_ERRMSG_INCOMPLETEMSG;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Check opcode */
|
||||
tftp->opcode = (Ip_u16)(buf[0]*256 + buf[1]);
|
||||
if (tftp->opcode != IPTFTP_OPCODE_RRQ && tftp->opcode != IPTFTP_OPCODE_WRQ)
|
||||
{
|
||||
err_msg = IPTFTP_ERRMSG_INVALIDOPCODE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Check mode */
|
||||
if (!ipcom_strcasecmp(&buf[i+1], "netascii"))
|
||||
tftp->binary = IP_FALSE;
|
||||
else if (!ipcom_strcasecmp(&buf[i+1], "octet"))
|
||||
tftp->binary = IP_TRUE;
|
||||
else
|
||||
{
|
||||
err_msg = IPTFTP_ERRMSG_INVALIDMODE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (tftp->dirlen + 1 + ipcom_strlen(&buf[2]) >= sizeof(tftp->file))
|
||||
{
|
||||
ret = IPCOM_ERR_REACHED_MAX;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Check for trespassing */
|
||||
if (iptftp_server_dirindex(&buf[2]) < 0)
|
||||
{
|
||||
/* Peeked above root directory */
|
||||
iptftp_send_err(sock, tftp, IPTFTP_ERRCODE_ACCESSVIOLATION,
|
||||
IPTFTP_ERRMSG_FILEABOVEWORKINGDIR);
|
||||
|
||||
return IPCOM_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
/* Append filename to server directory */
|
||||
if (buf[2] == IPTFTP_DIR_SEP)
|
||||
{
|
||||
ipcom_strcpy(&tftp->file[tftp->dirlen], &buf[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
tftp->file[tftp->dirlen] = IPTFTP_DIR_SEP;
|
||||
ipcom_strcpy(&tftp->file[tftp->dirlen+1], &buf[2]);
|
||||
}
|
||||
|
||||
exit:
|
||||
if (err_msg != IP_NULL)
|
||||
iptftp_send_err(sock, tftp, IPTFTP_ERRCODE_ILLEGALTFTPOP, err_msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_server_send_file
|
||||
*===========================================================================
|
||||
* Description: TFTP server internal send function.
|
||||
* Parameters: tftp - TFTP structure.
|
||||
* Returns: nothing.
|
||||
*/
|
||||
IP_STATIC void
|
||||
iptftp_server_send_file(Iptftp *tftp)
|
||||
{
|
||||
Ip_fd sock;
|
||||
IP_FILE *fp = IP_NULL;
|
||||
char *err_msg = IP_NULL;
|
||||
Ip_u16 err_code = 0;
|
||||
|
||||
/* Get a udp socket, and bind to port 0 */
|
||||
sock = ipcom_socket(tftp->family, IP_SOCK_DGRAM, 0);
|
||||
if (sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_send_file :: ipcom_socket() failed");
|
||||
goto err;
|
||||
}
|
||||
if (iptftp_bind_zero(sock, tftp->family) != IPCOM_SUCCESS)
|
||||
goto err;
|
||||
|
||||
#ifdef IPTFTP_SERVER_ALLOW_DOWNLOAD
|
||||
/* Open the file */
|
||||
if (tftp->binary)
|
||||
fp = ipcom_fopen(tftp->file, "rb");
|
||||
else
|
||||
fp = ipcom_fopen(tftp->file, "r");
|
||||
#endif
|
||||
if (!fp)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "iptftp_server_send_file :: Could not open file: \"%s\"", tftp->file);
|
||||
err_code = IPTFTP_ERRCODE_FILENOTFOUND;
|
||||
err_msg = IPTFTP_ERRMSG_COULDNOTOPENFILE;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Start the send loop */
|
||||
(void)iptftp_send_loop(sock, fp, &err_msg, &err_code, tftp);
|
||||
|
||||
err:
|
||||
/* Send error */
|
||||
if (err_msg)
|
||||
iptftp_send_err(sock, tftp, err_code, err_msg);
|
||||
|
||||
/* Terminate connection */
|
||||
if (fp != IP_NULL)
|
||||
(void)ipcom_fclose(fp);
|
||||
if (sock != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(sock);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_server_receive_file
|
||||
*===========================================================================
|
||||
* Description: TFTP server internal receive function.
|
||||
* Parameters: tftp - TFTP structure.
|
||||
* Returns: nothing.
|
||||
*/
|
||||
IP_STATIC void
|
||||
iptftp_server_receive_file(Iptftp *tftp)
|
||||
{
|
||||
Ip_fd sock;
|
||||
IP_FILE *fp = IP_NULL;
|
||||
Ip_u16 err_code = 0;
|
||||
char *err_msg = IP_NULL;
|
||||
char *buf = IP_NULL;
|
||||
/* Get a udp socket, and bind to port 0 */
|
||||
sock = ipcom_socket(tftp->family, IP_SOCK_DGRAM, 0);
|
||||
if (sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftp_server_receive_file :: ipcom_socket() failed");
|
||||
goto err;
|
||||
}
|
||||
if (iptftp_bind_zero(sock, tftp->family) != IPCOM_SUCCESS)
|
||||
goto err;
|
||||
|
||||
#ifdef IPTFTP_SERVER_ALLOW_UPLOAD
|
||||
/* Create the file */
|
||||
buf = ipcom_sysvar_get ("iptftps.allow.upload", IP_NULL, IP_NULL);
|
||||
|
||||
if (buf)
|
||||
{
|
||||
if(ipcom_strcasecmp(buf,"enable")==0)
|
||||
{
|
||||
if (tftp->binary)
|
||||
fp = ipcom_fopen(tftp->file, "wb");
|
||||
else
|
||||
fp = ipcom_fopen(tftp->file, "w");
|
||||
}
|
||||
ipcom_free(buf);
|
||||
buf=IP_NULL;
|
||||
}
|
||||
#endif
|
||||
if (!fp)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "iptftp_server_receive_file :: Could not create file: \"%s\"", tftp->file);
|
||||
err_code = IPTFTP_ERRCODE_ACCESSVIOLATION;
|
||||
err_msg = IPTFTP_ERRMSG_COULDNOTCREATEFILE;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Start the receive loop */
|
||||
(void)iptftp_receive_loop(sock, fp, &err_msg, &err_code, tftp);
|
||||
|
||||
err:
|
||||
/* Send error */
|
||||
if (err_msg)
|
||||
iptftp_send_err(sock, tftp, err_code, err_msg);
|
||||
|
||||
/* Terminate connection */
|
||||
if (fp != IP_NULL)
|
||||
(void)ipcom_fclose(fp);
|
||||
if (sock != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(sock);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftp_server_init
|
||||
*===========================================================================
|
||||
* Description: Initialize TFTP server.
|
||||
* Parameters: tftp - TFTP structure.
|
||||
* Returns: IPCOM_SUCCESS or an IPCOM_ERR_XXX error code for failures.
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
iptftp_server_init(Iptftp *tftp)
|
||||
{
|
||||
Ip_err ret = IPCOM_SUCCESS;
|
||||
char *dir;
|
||||
struct Ip_stat stat_buf;
|
||||
|
||||
/* Create the default directory */
|
||||
dir = ipcom_sysvar_get("iptftp.dir", IP_NULL, IP_NULL);
|
||||
if (dir == IP_NULL)
|
||||
{
|
||||
ipcom_strcpy(tftp->file, IPCOM_FILE_ROOT "tftpdir");
|
||||
}
|
||||
else if (ipcom_strlen(dir) >= sizeof(tftp->file))
|
||||
{
|
||||
IPCOM_LOG1(ERR, "TFTP server directory \"%s\" is too long!", dir);
|
||||
ret = IPCOM_ERR_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_strcpy(tftp->file, dir);
|
||||
}
|
||||
tftp->dirlen = (Ip_s32)ipcom_strlen(tftp->file);
|
||||
|
||||
/* Create the default TFTP directory if it does not exist. */
|
||||
if (ipcom_stat(tftp->file, &stat_buf) != 0)
|
||||
{
|
||||
if (ipcom_mkdir(tftp->file, 0777) == 0)
|
||||
{
|
||||
IPCOM_LOG1(INFO, "created TFTP server directory \"%s\"",
|
||||
tftp->file);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPCOM_LOG2(ERR, "iptftp_server_init :: ipcom_mkdir(\"%s\") - %s",
|
||||
tftp->file, ipcom_strerror(ipcom_errno));
|
||||
ret = IPCOM_ERR_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
if (dir != IP_NULL)
|
||||
ipcom_free(dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftps
|
||||
*===========================================================================
|
||||
* Description: TFTP server damon. Listens for connections and spawns
|
||||
* child processes for each connection.
|
||||
* Parameters: none.
|
||||
* Returns: nothing.
|
||||
*/
|
||||
IP_STATIC
|
||||
IPCOM_PROCESS(iptftps)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET
|
||||
struct Ip_sockaddr_in sa;
|
||||
Ip_fd sock = IP_INVALID_SOCKET;
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
struct Ip_sockaddr_in6 sa6;
|
||||
Ip_fd sock6 = IP_INVALID_SOCKET;
|
||||
#endif
|
||||
Ip_fd max_sock, ipd_sock = IP_INVALID_SOCKET;
|
||||
Ip_fd_set *read_set = IP_NULL;
|
||||
Iptftp *tftp;
|
||||
Ip_err err;
|
||||
int on = 1;
|
||||
|
||||
ipcom_proc_init();
|
||||
tftp = ipcom_malloc(sizeof(*tftp));
|
||||
if (tftp == IP_NULL)
|
||||
{
|
||||
err = IPCOM_ERR_NO_MEMORY;
|
||||
IPCOM_LOG0(ERR, "iptftps :: ipcom_malloc(tftp) failed");
|
||||
goto fail;
|
||||
}
|
||||
ipcom_memset(tftp, 0, sizeof(*tftp));
|
||||
|
||||
/* Install IPC. */
|
||||
err = ipcom_ipc_install();
|
||||
if (err != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftps :: ipcom_ipc_install() failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Initialize tftp server */
|
||||
err = iptftp_server_init(tftp);
|
||||
if (err != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftps :: iptftp_server_init() failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Get read set. */
|
||||
read_set = ipcom_malloc(sizeof(Ip_fd_set));
|
||||
if (read_set == IP_NULL)
|
||||
{
|
||||
err = IPCOM_ERR_NO_MEMORY;
|
||||
IPCOM_LOG0(ERR, "iptftps :: ipcom_malloc(read_set) failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = IPCOM_ERR_SOCKCALLFAILED;
|
||||
#ifdef IPCOM_USE_INET
|
||||
/* Get a udp socket, bind to the tftp port */
|
||||
sock = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, 0);
|
||||
if (sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftps :: ipcom_socket() failed");
|
||||
#ifndef IPCOM_USE_INET6
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enable ancillary data */
|
||||
if (ipcom_setsockopt(sock, IP_IPPROTO_IP, IP_IP_PKTINFO, &on, sizeof(on)) < 0)
|
||||
{
|
||||
#ifndef IPLITE
|
||||
IPCOM_LOG2(INFO, "iptftps :: ipcom_setsockopt(IP_IP_PKTINFO) failed, errno = %d (%s)",
|
||||
ipcom_errno, ipcom_strerror(ipcom_errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
ipcom_memset(&sa, 0, sizeof(sa));
|
||||
IPCOM_SA_LEN_SET(&sa, sizeof(struct Ip_sockaddr_in));
|
||||
sa.sin_family = IP_AF_INET;
|
||||
sa.sin_port = ip_htons(IPTFTP_PORT);
|
||||
sa.sin_addr.s_addr = IP_INADDR_ANY;
|
||||
if (ipcom_bind(sock, (struct Ip_sockaddr *)&sa, sizeof(sa)) == IP_SOCKERR)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "iptftps :: ipcom_bind() failed, errno = %d", ipcom_errno);
|
||||
#ifdef IPCOM_USE_INET6
|
||||
ipcom_socketclose(sock);
|
||||
sock = IP_INVALID_SOCKET;
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* IPCOM_USE_INET */
|
||||
|
||||
#ifdef IPCOM_USE_INET6
|
||||
/* Get a udp v6 socket, bind to the tftp port */
|
||||
sock6 = ipcom_socket(IP_AF_INET6, IP_SOCK_DGRAM, 0);
|
||||
if (sock6 == IP_INVALID_SOCKET)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftps :: ipcom_socket(INET6) failed");
|
||||
#ifndef IPCOM_USE_INET
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enable ancillary data */
|
||||
if (ipcom_setsockopt(sock6, IP_IPPROTO_IPV6, IP_IPV6_RECVPKTINFO, &on, sizeof(on)) < 0)
|
||||
{
|
||||
#ifndef IPLITE
|
||||
IPCOM_LOG2(INFO, "iptftps :: ipcom_setsockopt(IP_IPV6_RECVPKTINFO) failed, errno = %d (%s)",
|
||||
ipcom_errno, ipcom_strerror(ipcom_errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
ipcom_memset(&sa6, 0, sizeof(sa6));
|
||||
IPCOM_SA_LEN_SET(&sa6, sizeof(sa6));
|
||||
sa6.sin6_family = IP_AF_INET6;
|
||||
sa6.sin6_port = ip_htons(IPTFTP_PORT);
|
||||
if (ipcom_bind(sock6, (struct Ip_sockaddr *)&sa6, sizeof(sa6)) == IP_SOCKERR)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftps :: ipcom_bind(INET6) failed");
|
||||
#ifdef IPCOM_USE_INET
|
||||
ipcom_socketclose(sock6);
|
||||
sock6 = IP_INVALID_SOCKET;
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
|
||||
/* IPD init. */
|
||||
if (ipcom_ipd_init("iptftps", IPCOM_SUCCESS, &ipd_sock) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0 (ERR, "iptftps :: ipcom_ipd_init() failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
max_sock = ipd_sock;
|
||||
#ifdef IPCOM_USE_INET
|
||||
max_sock = IP_MAX(max_sock, sock);
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
max_sock = IP_MAX(max_sock, sock6);
|
||||
#endif
|
||||
max_sock++;
|
||||
|
||||
/* Start the iptftps select loop */
|
||||
IPCOM_LOG0(DEBUG, "iptftps :: listening for connections");
|
||||
for (;;)
|
||||
{
|
||||
Ip_s32 num;
|
||||
|
||||
IP_FD_ZERO(read_set);
|
||||
IP_FD_SET(ipd_sock, read_set);
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (sock != IP_INVALID_SOCKET)
|
||||
IP_FD_SET(sock, read_set);
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (sock6 != IP_INVALID_SOCKET)
|
||||
IP_FD_SET(sock6, read_set);
|
||||
#endif
|
||||
|
||||
/* Wait for a connection */
|
||||
num = ipcom_socketselect(max_sock, read_set, IP_NULL, IP_NULL, IP_NULL);
|
||||
if (num == IP_SOCKERR)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "iptftps :: ipcom_socketselect() failed, errno = %d", ipcom_errno);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#ifdef IPCOM_USE_INET
|
||||
/* Check for connection on ipv4 socket*/
|
||||
if (num > 0 && sock != IP_INVALID_SOCKET && IP_FD_ISSET(sock, read_set))
|
||||
{
|
||||
num--;
|
||||
if (iptftp_server_parse_request(sock, IP_AF_INET, tftp) == IPCOM_SUCCESS)
|
||||
{
|
||||
if (iptftp_server_spawn_handler(tftp) != IPCOM_SUCCESS)
|
||||
IPCOM_LOG0(ERR, "iptftps :: iptftp_server_spawn_handler failed");
|
||||
}
|
||||
else
|
||||
IPCOM_LOG0(ERR, "iptftps :: iptftp_server_parse_request(INET4) failed");
|
||||
}
|
||||
#endif /* IPCOM_USE_INET */
|
||||
|
||||
#ifdef IPCOM_USE_INET6
|
||||
/* Check for connection on ipv6 socket*/
|
||||
if (num > 0 && sock6 != IP_INVALID_SOCKET && IP_FD_ISSET(sock6, read_set))
|
||||
{
|
||||
num--;
|
||||
if (iptftp_server_parse_request(sock6, IP_AF_INET6, tftp) == IPCOM_SUCCESS)
|
||||
{
|
||||
if (iptftp_server_spawn_handler(tftp) != IPCOM_SUCCESS)
|
||||
IPCOM_LOG0(ERR, "iptftps :: iptftp_server_spawn_handler() failed");
|
||||
}
|
||||
else
|
||||
IPCOM_LOG0(ERR, "iptftps :: iptftp_server_parse_request(INET6) failed");
|
||||
}
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
|
||||
/* Check for connection on ipd socket*/
|
||||
if (num > 0 && IP_FD_ISSET(ipd_sock, read_set))
|
||||
{
|
||||
int event;
|
||||
|
||||
event = ipcom_ipd_input(ipd_sock);
|
||||
switch(event)
|
||||
{
|
||||
case IPCOM_IPD_EVENT_RECONFIGURE:
|
||||
IPCOM_LOG0(INFO, "received IPD reconfigure message");
|
||||
/* Initialize tftp server */
|
||||
if (iptftp_server_init(tftp) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "iptftps :: iptftp_server_init() failed");
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case IPCOM_IPD_EVENT_KILL:
|
||||
IPCOM_LOG0(INFO, "received IPD kill message");
|
||||
goto fail;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fail:
|
||||
if (tftp != IP_NULL)
|
||||
ipcom_free(tftp);
|
||||
if (read_set != IP_NULL)
|
||||
ipcom_free(read_set);
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (sock != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(sock);
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (sock6 != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(sock6);
|
||||
#endif
|
||||
if (ipd_sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
ip_assert(err != IPCOM_SUCCESS);
|
||||
(void)ipcom_ipd_init("iptftps", err, &ipd_sock);
|
||||
}
|
||||
if (ipd_sock != IP_INVALID_SOCKET)
|
||||
(void)ipcom_ipd_exit("iptftps", ipd_sock);
|
||||
(void)ipcom_ipc_uninstall();
|
||||
|
||||
ipcom_proc_exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftps_create
|
||||
*===========================================================================
|
||||
* Description: TFTP server create function.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS or an IPCOM_ERR_XXX error code.
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftps_create(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftps_start
|
||||
*===========================================================================
|
||||
* Description: TFTP server start function.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS or an IPCOM_ERR_XXX error code.
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptftps_start(void)
|
||||
{
|
||||
return ipcom_proc_create("iptftps", (Ipcom_proc_func)iptftps, IPCOM_PROC_STACK_DEFAULT, IP_NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptftps_version
|
||||
*===========================================================================
|
||||
* Description: Get TFTP server version string.
|
||||
* Parameters: none.
|
||||
* Returns: TFTP server version.
|
||||
*/
|
||||
IP_PUBLIC const char *
|
||||
iptftps_version(void)
|
||||
{
|
||||
return "@(#) IPTFTPS $Name: VXWORKS_ITER40_2019102207 $ - INTERPEAK_COPYRIGHT_STRING";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,33 @@
|
||||
/* 01ipcavium.cdf - IPCAVIUM 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.
|
||||
*/
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPCAVIUM
|
||||
Component INCLUDE_IPCAVIUM
|
||||
{
|
||||
NAME Hardware crypto offload for Cavium.
|
||||
_CHILDREN FOLDER_CRYPTO
|
||||
SYNOPSIS Enables the Cavium crypto offload
|
||||
CONFIGLETTES ipcavium_config.c
|
||||
MODULES ipcavium_ipsec.o
|
||||
REQUIRES INCLUDE_IPHWCRYPTO INCLUDE_IPCAVIUM_CMD
|
||||
}
|
||||
|
||||
/* This is a hidden component */
|
||||
Component INCLUDE_IPCAVIUM_CMD
|
||||
{
|
||||
NAME cavium
|
||||
SYNOPSIS cavium test command
|
||||
MODULES ipcavium_ipsec.o
|
||||
_CHILDREN FOLDER_NOT_VISIBLE
|
||||
REQUIRES INCLUDE_IPCOM_SHELL_CMD
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.5 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcavium/config/common.vxconfig,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPCAVIUM
|
||||
config SUPPORTS_CAVIUM
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcavium_config.c,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcavium/config/ipcavium_config.c,v $
|
||||
* $Author: markus $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* IPCAVIUM - Hardware crypto support product - configuration.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcavium_config.h"
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN int ipcavium_cmd_cavium(int argc, char **argv);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipcavium_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_conf_sysvar
|
||||
*===========================================================================
|
||||
* Cavium configuration Variables
|
||||
*/
|
||||
IP_CONST Ipcom_sysvar ipcavium_conf_sysvar[] =
|
||||
{
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_configure
|
||||
*===========================================================================
|
||||
* Description: Product configure hook. Called by IPCOM at startup.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS = ok
|
||||
* IPCOM_ERR_FAILED = error
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipcavium_configure(void)
|
||||
{
|
||||
Ip_err ret;
|
||||
|
||||
ret = ipcom_sysvar_setv(ipcavium_conf_sysvar, 0);
|
||||
if(ret != IPCOM_SUCCESS)
|
||||
return ret;
|
||||
|
||||
#if defined(INCLUDE_IPCAVIUM_CMD) || !defined(IP_PORT_VXWORKS)
|
||||
ret = ipcom_shell_add_cmd("cavium", "cavium [cmd] <modifier...>", "Test Cavium hardware crypto",
|
||||
(Ipcom_shell_cmd_type)ipcavium_cmd_cavium,
|
||||
IPCOM_PRIORITY_DEFAULT, IPCOM_PROC_STACK_DEFAULT);
|
||||
if(ret != IPCOM_SUCCESS)
|
||||
return ret;
|
||||
#endif /* defined(INCLUDE_IPCAVIUM_CMD) || !defined(IP_PORT_VXWORKS) */
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcavium_config.h,v $ $Revision: 1.1.1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcavium/config/ipcavium_config.h,v $
|
||||
* $Author: markus $ $Date: 2008-12-17 08:08:03 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCAVIUM_CONFIG_H
|
||||
#define IPCAVIUM_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_config.h>
|
||||
#ifdef IPCRYPTO
|
||||
#include <ipcrypto_config.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_STATISTICS
|
||||
*===========================================================================
|
||||
* Define this macro to include usage and error statistics.
|
||||
*/
|
||||
#define IPCAVIUM_USE_STATISTICS
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_IPSEC_ESP_CBC_ENGINE
|
||||
*===========================================================================
|
||||
* Define this macro to register device as the default engine for IPSEC
|
||||
* ESP in IPHWCRYPTO.
|
||||
*/
|
||||
|
||||
#define IPCAVIUM_USE_IPSEC_ESP_CBC_ENGINE
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_DIGEST_ENGINE
|
||||
*===========================================================================
|
||||
* Define this macro to register device as the default engine for message
|
||||
* digests in IPHWCRYPTO.
|
||||
*/
|
||||
#define IPCAVIUM_USE_DIGEST_ENGINE
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_CIPHER_ENGINE
|
||||
*===========================================================================
|
||||
* Define this macro to register device as the default engine for ciphers
|
||||
* in IPHWCRYPTO.
|
||||
*/
|
||||
#define IPCAVIUM_USE_CIPHER_ENGINE
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_RANDOM_ENGINE
|
||||
*===========================================================================
|
||||
* Define this macro to register device as the default engine for random
|
||||
* number generation in IPHWCRYPTO.
|
||||
*/
|
||||
#define IPCAVIUM_USE_RANDOM_ENGINE
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_DH_ENGINE
|
||||
*===========================================================================
|
||||
* Define this macro to register device as the default engine for Diffie-
|
||||
* Hellman operations in IPHWCRYPTO.
|
||||
*/
|
||||
#define IPCAVIUM_USE_DH_ENGINE
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_RSA_ENGINE
|
||||
*===========================================================================
|
||||
* Define this macro to register device as the default engine for RSA
|
||||
* operations in IPHWCRYPTO.
|
||||
*/
|
||||
#define IPCAVIUM_USE_RSA_ENGINE
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCAVIUM_USE_DSA_ENGINE
|
||||
*===========================================================================
|
||||
* Define this macro to register device as the default engine for DSA
|
||||
* operations in IPHWCRYPTO.
|
||||
*/
|
||||
#define IPCAVIUM_USE_DSA_ENGINE
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,10 @@
|
||||
IPTARGETS := lib
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include ipcavium.mk
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
@@ -0,0 +1,118 @@
|
||||
#############################################################################
|
||||
# IPCAVIUM.MK
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcavium.mk,v $ $Revision: 1.8 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcavium/gmake/ipcavium.mk,v $
|
||||
# $Author: ulf $ $Date: 2009-06-08 11:03:34 $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ipcavium
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEFINE
|
||||
###########################################################################
|
||||
|
||||
IPDEFINE += -DIPCAVIUM
|
||||
|
||||
|
||||
#############################################################################
|
||||
# IPLIBDEFINE
|
||||
###########################################################################
|
||||
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
###########################################################################
|
||||
|
||||
IPINCLUDE += -I$(IPCAVIUM_ROOT)/config
|
||||
IPINCLUDE += -I$(IPCAVIUM_ROOT)/include
|
||||
|
||||
IPLIBINCLUDE += -I$(IPCAVIUM_ROOT)/src
|
||||
IPLIBINCLUDE += -I$(IPIPSEC_ROOT)/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
###########################################################################
|
||||
|
||||
# Configuration
|
||||
#IPLIBOBJECTS_C += ipcavium_config.o
|
||||
|
||||
# Compiles the xxx_config.o if the $SKIP_CONFIG macro is either not defined
|
||||
# or set to anything other than true.
|
||||
#ifneq ($(SKIP_CONFIG),true)
|
||||
#IPLIBOBJECTS += $(IPLIBOBJECTS_C)
|
||||
#endif
|
||||
|
||||
# Interpeak Cavium hardware crypto
|
||||
#IPLIBOBJECTS += ipcavium.o
|
||||
IPLIBOBJECTS += ipcavium_ipsec.o
|
||||
|
||||
ifeq ($(IPPORT),lkm)
|
||||
IPLIBOBJECTS += ipcavium_crypto_api.o
|
||||
endif
|
||||
|
||||
ifeq ($(IPPORT),vxworks)
|
||||
ifneq ($(IPCOMPILER),diab)
|
||||
ifneq ($(OCTEON_ROOT),)
|
||||
IPLIBOBJECTS += ipcavium_crypto_api.o
|
||||
IPLIBCFLAGS += -march=octeon
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(IPPORT),las)
|
||||
#IPLIBOBJECTS += ipcavium_cmd_cavium.o
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
###########################################################################
|
||||
|
||||
IPSRCDIRS += $(IPCAVIUM_ROOT)/src $(IPCAVIUM_ROOT)/config
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
###########################################################################
|
||||
|
||||
IPLIBS += $(IPLIBROOT)/libipcavium.a
|
||||
|
||||
|
||||
#############################################################################
|
||||
# BINARIES
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(IPPORT),lasx)
|
||||
# Path to binaries
|
||||
IPCMDDIR := $(IPOBJDIR)/bin
|
||||
|
||||
# List of shell commands to build
|
||||
IPCAVIUMSHELLCMDS = cavium
|
||||
_IPCAVIUMSHELLCMDS = $(addprefix $(IPCMDDIR)/,$(IPCAVIUMSHELLCMDS))
|
||||
|
||||
bin: $(_IPCAVIUMSHELLCMDS)
|
||||
|
||||
$(IPOBJDIR)/ipcavium_cmd_%.o: $(IPCAVIUM_ROOT)/src/ipcavium_cmd_%.c
|
||||
@$(IPECHO) "+++ Compiling IPCAVIUM shell command $<"
|
||||
$(IPVERB)$(IPCC) -Dipcavium_cmd_$*=ipcom_cmd_entry_point $(IPCFLAGS) -I$(IPIPSEC_ROOT)/src -o $@ $<
|
||||
|
||||
$(IPCMDDIR)/cavium: $(IPOBJDIR)/ipcavium_cmd_cavium.o $(IPOBJDIR)/ipcom_shell_cmd_stub.o
|
||||
@$(IPECHO) "+++ Linking IPCAVIUM shell command $@"
|
||||
$(IPVERB)$(IPLD) -o $@ $(IPLDFLAGS) $^ $(IPLIBS) $(IPLIBS) $(IPLIBS) $(IPLASTLIBS)
|
||||
endif
|
||||
|
||||
###########################################################################
|
||||
# END OF IPCAVIUM.MK
|
||||
###########################################################################
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,768 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcavium_ipsec.c,v $ $Revision: 1.11 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcavium/src/ipcavium_ipsec.c,v $
|
||||
* $Author: markus $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* #include "ipcavium_config.h" */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_os.h>
|
||||
|
||||
#include <iphwcrypto.h>
|
||||
|
||||
#ifdef IPIPSEC2
|
||||
#include <ipipsec_h.h>
|
||||
#endif
|
||||
|
||||
/* #include "ipcavium.h" */
|
||||
/* #include "ipcavium_h.h" */
|
||||
|
||||
#ifdef IP_PORT_LKM
|
||||
extern unsigned long octeon_crypto_enable(unsigned long *state);
|
||||
extern void octeon_crypto_disable(unsigned long *state, unsigned long crypto_flags);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Syslog facility */
|
||||
#ifdef IPCOM_SYSLOG_FACILITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCAVIUM
|
||||
|
||||
/* Syslog priority */
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
#ifdef IP_DEBUG
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_DEBUG
|
||||
#else
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_LOG_WARNING
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* OCTEON_OPENSSL
|
||||
*===========================================================================
|
||||
* External prototypes for linkage with Cavium Networks crypto library
|
||||
*
|
||||
*/
|
||||
|
||||
IP_EXTERN int DES_ede3_cbc_md5_decrypt(Ip_u8 *des_key,
|
||||
Ip_u16 auth_keylen, Ip_u8 *auth_key,
|
||||
Ip_u8 *des_iv, Ip_u8 *pktptr,
|
||||
Ip_u16 pktlen, Ip_u8 *outptr,
|
||||
Ip_u16 *outlen, Ip_u8 compdigest);
|
||||
|
||||
IP_EXTERN int DES_ede3_cbc_md5_encrypt(Ip_u8 *des_key,
|
||||
Ip_u16 auth_keylen, Ip_u8 *auth_key,
|
||||
Ip_u8 *espheader, Ip_u8 *des_iv,
|
||||
Ip_u8 *pktptr, Ip_u16 pktlen,
|
||||
Ip_u8 *outptr, Ip_u16 *outlen);
|
||||
|
||||
IP_EXTERN int DES_ede3_cbc_sha1_decrypt(Ip_u8 *des_key,
|
||||
Ip_u16 sha1_keylen, Ip_u8 *sha1_key,
|
||||
Ip_u8 *des_iv, Ip_u8 *pktptr,
|
||||
Ip_u16 pktlen, Ip_u8 *outptr,
|
||||
Ip_u16 *outlen, Ip_u8 compdigest);
|
||||
|
||||
IP_EXTERN int DES_ede3_cbc_sha1_encrypt(Ip_u8 *des_key,
|
||||
Ip_u16 sha1_keylen, Ip_u8 *sha1_key,
|
||||
Ip_u8 *espheader, Ip_u8 *des_iv,
|
||||
Ip_u8 *pktptr, Ip_u16 pktlen,
|
||||
Ip_u8 *outptr, Ip_u16 *outlen);
|
||||
|
||||
IP_EXTERN int AES_cbc_md5_decrypt(Ip_u16 aes_key_len, Ip_u8 *aes_key,
|
||||
Ip_u16 auth_keylen, Ip_u8 *auth_key,
|
||||
Ip_u8 *aes_iv, Ip_u8 *pktptr,
|
||||
Ip_u16 pktlen, Ip_u8 *outptr,
|
||||
Ip_u16 *outlen, Ip_u8 compdigest);
|
||||
|
||||
IP_EXTERN int AES_cbc_md5_encrypt(Ip_u16 aes_key_len, Ip_u8 *aes_key,
|
||||
Ip_u16 auth_keylen, Ip_u8 *auth_key,
|
||||
Ip_u8 *espheader, Ip_u8 *aes_iv,
|
||||
Ip_u8 *pktptr, Ip_u16 pktlen,
|
||||
Ip_u8 *outptr, Ip_u16 *outlen);
|
||||
|
||||
IP_EXTERN int AES_cbc_sha1_decrypt(Ip_u16 aes_key_len, Ip_u8 *aes_key,
|
||||
Ip_u16 sha1_keylen, Ip_u8 *sha1_key,
|
||||
Ip_u8 *aes_iv, Ip_u8 *pktptr,
|
||||
Ip_u16 pktlen, Ip_u8 *outptr,
|
||||
Ip_u16 *outlen, Ip_u8 compdigest);
|
||||
|
||||
IP_EXTERN int AES_cbc_sha1_encrypt(Ip_u16 aes_key_len, Ip_u8 *aes_key,
|
||||
Ip_u16 sha1_keylen, Ip_u8 *sha1_key,
|
||||
Ip_u8 *espheader, Ip_u8 *aes_iv,
|
||||
Ip_u8 *pktptr, Ip_u16 pktlen,
|
||||
Ip_u8 *outptr, Ip_u16 *outlen);
|
||||
|
||||
IP_EXTERN int AES_cbc_sha1_encrypt_fast(Ip_u16 aes_key_len, Ip_u8 *aes_key,
|
||||
Ip_u8 *espheader, Ip_u8 *aes_iv,
|
||||
Ip_u8 *pktptr, Ip_u16 pktlen,
|
||||
Ip_u8 *outptr,
|
||||
Ip_u8 *ictx, Ip_u8 *octx);
|
||||
|
||||
IP_EXTERN int AES_cbc_sha1_decrypt_fast(Ip_u16 aes_key_len, Ip_u8 *aes_key,
|
||||
Ip_u8 *aes_iv, Ip_u8 *pktptr,
|
||||
Ip_u16 pktlen, Ip_u8 *outptr,
|
||||
Ip_u8 *ictx, Ip_u8 *octx);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipcavium_create(void);
|
||||
IP_PUBLIC Ip_err ipcavium_configure(void);
|
||||
IP_PUBLIC Ip_err ipcavium_start(void);
|
||||
IP_PUBLIC const char *ipcavium_version(void);
|
||||
IP_PUBLIC int ipcavium_cmd_cavium(int argc, char **argv);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int ipcavium_num_esp_3des_md5 = 0;
|
||||
IP_GLOBAL int ipcavium_num_esp_3des_sha1 = 0;
|
||||
IP_GLOBAL int ipcavium_num_esp_aes_md5 = 0;
|
||||
IP_GLOBAL int ipcavium_num_esp_aes_sha1 = 0;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPIPSEC2
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_crypto
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP processing
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* digest - pointer the message autentication code.
|
||||
* alg - algorithm
|
||||
* enc - encrypt(1) or decrypt(0)
|
||||
* Returns: 1 = ok
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_crypto(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest, int alg, int enc)
|
||||
{
|
||||
#ifdef IP_PORT_LKM
|
||||
unsigned long octeon_cop2_state[48];
|
||||
unsigned long crypto_flags;
|
||||
#endif
|
||||
Ip_u16 outlen;
|
||||
int ret;
|
||||
Ip_u8 hmac[12];
|
||||
Ip_u8 iv[IPIPSEC_MAX_IV_SIZE];
|
||||
|
||||
/* Because the IPSec daemons set hard affinity to a reserved CPU we do not risk preemption */
|
||||
#ifdef IP_PORT_LKM
|
||||
crypto_flags = octeon_crypto_enable(octeon_cop2_state);
|
||||
#endif
|
||||
|
||||
if (!enc)
|
||||
{
|
||||
/* Save original MAC. */
|
||||
ipcom_memcpy(hmac, data + length - sa->authlen, sizeof(hmac));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Must copy IV. IV update done in IPHWCRYPTO */
|
||||
ipcom_memcpy(iv, sa->iv, sa->ivlen);
|
||||
}
|
||||
|
||||
switch (alg)
|
||||
{
|
||||
case IPHWCRYPTO_ENGINE_ESP_3DES_CBC_MD5:
|
||||
if (enc)
|
||||
ret = DES_ede3_cbc_md5_encrypt(sa->ekey,
|
||||
sa->akeylen, sa->akey,
|
||||
data, iv,
|
||||
data + sa->hdrlen,
|
||||
length - sa->hdrlen,
|
||||
data, &outlen);
|
||||
else
|
||||
ret = DES_ede3_cbc_md5_decrypt(sa->ekey,
|
||||
sa->akeylen, sa->akey,
|
||||
sa->iv, data, length,
|
||||
data, &outlen, 0);
|
||||
if (ret == 0)
|
||||
ipcavium_num_esp_3des_md5++;
|
||||
break;
|
||||
case IPHWCRYPTO_ENGINE_ESP_3DES_CBC_SHA1:
|
||||
if (enc)
|
||||
ret = DES_ede3_cbc_sha1_encrypt(sa->ekey,
|
||||
sa->akeylen, sa->akey,
|
||||
data, iv,
|
||||
data + sa->hdrlen,
|
||||
length - sa->hdrlen,
|
||||
data, &outlen);
|
||||
else
|
||||
ret = DES_ede3_cbc_sha1_decrypt(sa->ekey,
|
||||
sa->akeylen, sa->akey,
|
||||
sa->iv, data, length,
|
||||
data, &outlen, 0);
|
||||
if (ret == 0)
|
||||
ipcavium_num_esp_3des_sha1++;
|
||||
break;
|
||||
case IPHWCRYPTO_ENGINE_ESP_AES_CBC_MD5:
|
||||
if (enc)
|
||||
ret = AES_cbc_md5_encrypt(sa->ekeylen, sa->ekey,
|
||||
sa->akeylen, sa->akey,
|
||||
data, iv,
|
||||
data + sa->hdrlen,
|
||||
length - sa->hdrlen,
|
||||
data, &outlen);
|
||||
else
|
||||
ret = AES_cbc_md5_decrypt(sa->ekeylen, sa->ekey,
|
||||
sa->akeylen, sa->akey,
|
||||
sa->iv, data, length,
|
||||
data, &outlen, 0);
|
||||
if (ret == 0)
|
||||
ipcavium_num_esp_aes_md5++;
|
||||
break;
|
||||
case IPHWCRYPTO_ENGINE_ESP_AES_CBC_SHA1:
|
||||
if (enc)
|
||||
ret = AES_cbc_sha1_encrypt_fast(sa->ekeylen, sa->ekey,
|
||||
data, iv,
|
||||
data + sa->hdrlen,
|
||||
length - sa->hdrlen,
|
||||
data,
|
||||
(Ip_u8 *)&((Ipipsec_sa *)sa->ipsec_sa)->auth->i_ctx, (Ip_u8 *)&((Ipipsec_sa *)sa->ipsec_sa)->auth->o_ctx);
|
||||
else
|
||||
ret = AES_cbc_sha1_decrypt_fast(sa->ekeylen, sa->ekey,
|
||||
sa->iv, data, length,
|
||||
data,
|
||||
(Ip_u8 *)&((Ipipsec_sa *)sa->ipsec_sa)->auth->i_ctx, (Ip_u8 *)&((Ipipsec_sa *)sa->ipsec_sa)->auth->o_ctx);
|
||||
if (ret == 0)
|
||||
ipcavium_num_esp_aes_sha1++;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (enc)
|
||||
{
|
||||
/* OCTEON places MAC at the end of the packet */
|
||||
ipcom_memcpy(digest, data + length, sa->authlen);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* OCTEON places MAC at the end of the packet */
|
||||
ipcom_memcpy(digest, data + length - sa->authlen, sa->authlen);
|
||||
|
||||
/* Restore original MAC. The IPSec module will verify the MAC */
|
||||
ipcom_memcpy(data + length - sa->authlen, hmac, sizeof(hmac));
|
||||
}
|
||||
|
||||
#ifdef IP_PORT_LKM
|
||||
octeon_crypto_disable(octeon_cop2_state, crypto_flags);
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
IPCOM_LOG2(ERR, "ipcavium_ipsec_esp_crypto() :: %s error for algorithm %d",
|
||||
enc ? "encrypt" : "decrypt", alg);
|
||||
#ifdef IP_PORT_LKM
|
||||
octeon_crypto_disable(octeon_cop2_state, crypto_flags);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_3des_cbc_md5_input
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP input processing using 3DES-CBC-MD5.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_3des_cbc_md5_input(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_3DES_CBC_MD5, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_3des_cbc_md5_output
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP output processing using 3DES-CBC-MD5.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_3des_cbc_md5_output(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_3DES_CBC_MD5, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_3des_cbc_sha1_input
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP input processing using 3DES-CBC-SHA1.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_3des_cbc_sha1_input(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_3DES_CBC_SHA1, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_3des_cbc_sha1_output
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP output processing using 3DES-CBC-SHA1.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_3des_cbc_sha1_output(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_3DES_CBC_SHA1, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_aes_cbc_md5_input
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP input processing using AES-CBC-MD5.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_aes_cbc_md5_input(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_AES_CBC_MD5, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_aes_cbc_md5_output
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP output processing using AES-CBC-MD5.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_aes_cbc_md5_output(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_AES_CBC_MD5, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_aes_cbc_sha1_input
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP input processing using AES-CBC-SHA1.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_aes_cbc_sha1_input(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_AES_CBC_SHA1, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_ipsec_esp_aes_cbc_sha1_output
|
||||
*===========================================================================
|
||||
* Description: IPSEC ESP output processing using AES-CBC-SHA1.
|
||||
* Parameters: data - pointer to the packet data.
|
||||
* length - length of the packet.
|
||||
* sa - pointer to the sa (security association).
|
||||
* param - pointer to ipsec parameters.
|
||||
* digest - pointer the message autentication code.
|
||||
* pkt - pointer to the packet structure.
|
||||
* Returns: 2 = kept
|
||||
* 1 = ok
|
||||
* 0 = timeout
|
||||
* -1 = error
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcavium_ipsec_esp_aes_cbc_sha1_output(Ip_u8 *data,
|
||||
Ip_u32 length,
|
||||
Iphwcrypto_esp_cbc_sa *sa,
|
||||
Ip_u8 *digest,
|
||||
Ipipsec_param *param,
|
||||
Ipcom_pkt *pkt)
|
||||
{
|
||||
(void)param;
|
||||
(void)pkt;
|
||||
return ipcavium_ipsec_esp_crypto(data, length, sa, digest,
|
||||
IPHWCRYPTO_ENGINE_ESP_AES_CBC_SHA1, 1);
|
||||
}
|
||||
#endif /* IPIPSEC2 */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_cmd_cavium
|
||||
*===========================================================================
|
||||
* Description: cavium shell command.
|
||||
* Parameters: argc - number of arguments.
|
||||
* argv - pointer to array of arguments.
|
||||
* Returns: 0 = success
|
||||
* -1 = fail
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcavium_cmd_cavium(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
usage:
|
||||
ipcom_printf("Usage: cavium <cmd>"IP_LF);
|
||||
ipcom_printf(IP_LF);
|
||||
ipcom_printf(" Commands: stat - Print stats"IP_LF);
|
||||
ipcom_printf(" clr - Clear stats"IP_LF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ipcom_strcmp(argv[1], "clr") == 0)
|
||||
{
|
||||
ipcavium_num_esp_3des_md5 = 0;
|
||||
ipcavium_num_esp_3des_sha1 = 0;
|
||||
ipcavium_num_esp_aes_md5 = 0;
|
||||
ipcavium_num_esp_aes_sha1 = 0;
|
||||
}
|
||||
else if (ipcom_strcmp(argv[1], "stat") == 0)
|
||||
{
|
||||
ipcom_printf("ESP-MD5-3DES --- %d\n", ipcavium_num_esp_3des_md5);
|
||||
ipcom_printf("ESP-SHA1-3DES -- %d\n", ipcavium_num_esp_3des_sha1);
|
||||
ipcom_printf("ESP-MD5-AES ---- %d\n", ipcavium_num_esp_aes_md5);
|
||||
ipcom_printf("ESP-SHA1-AES --- %d\n", ipcavium_num_esp_aes_sha1);
|
||||
}
|
||||
else
|
||||
goto usage;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_version
|
||||
*===========================================================================
|
||||
* Description: Returns the version string of the product.
|
||||
* Parameters: none.
|
||||
* Returns: pointer to the version string.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC const char *
|
||||
ipcavium_version(void)
|
||||
{
|
||||
return "@(#) IPCAVIUM $Name: VXWORKS_ITER40_2019102207 $ - INTERPEAK_COPYRIGHT_STRING";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_create
|
||||
*===========================================================================
|
||||
* Description: Product create hook. Called by IPCOM at startup.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS = ok
|
||||
* IPCOM_ERR_... = error
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipcavium_create(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_configure
|
||||
*===========================================================================
|
||||
* Description: Product configure hook. Called by IPCOM at startup.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS = ok
|
||||
* IPCOM_ERR_FAILED = error
|
||||
*
|
||||
*/
|
||||
#ifndef IP_PORT_VXWORKS
|
||||
IP_PUBLIC Ip_err
|
||||
ipcavium_configure(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcavium_start
|
||||
*===========================================================================
|
||||
* Description: Product start hook. Called by IPCOM at startup.
|
||||
* Parameters: none.
|
||||
* Returns: IPCOM_SUCCESS = ok
|
||||
* IPCOM_ERR_FAILED = error
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipcavium_start(void)
|
||||
{
|
||||
Ip_err ret;
|
||||
const char *engine_id = "octeon";
|
||||
const char *engine_name = "Cavium OCTEON hardware crypto support";
|
||||
|
||||
/* Add an engine to iphwcrypto */
|
||||
ret = iphwcrypto_engine_add(engine_id, engine_name);
|
||||
if (ret != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcavium_create() :: iphwcrypto_engine_add() failed with error %s", ipcom_err_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef IPIPSEC2
|
||||
/* 3DES-CBC-MD5 */
|
||||
ret = iphwcrypto_ipsec_engine_add_esp(engine_id, IPHWCRYPTO_ENGINE_ESP_3DES_CBC_MD5, ipcavium_ipsec_esp_3des_cbc_md5_input, ipcavium_ipsec_esp_3des_cbc_md5_output);
|
||||
if (ret != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcavium_create() :: iphwcrypto_ipsec_engine_add_esp(IPHWCRYPTO_ENGINE_ESP_3DES_CBC_MD5) failed with error %s", ipcom_err_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 3DES-CBC-SHA1 */
|
||||
ret = iphwcrypto_ipsec_engine_add_esp(engine_id, IPHWCRYPTO_ENGINE_ESP_3DES_CBC_SHA1, ipcavium_ipsec_esp_3des_cbc_sha1_input, ipcavium_ipsec_esp_3des_cbc_sha1_output);
|
||||
if (ret != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcavium_create() :: iphwcrypto_ipsec_engine_add_esp(IPHWCRYPTO_ENGINE_ESP_3DES_CBC_SHA1) failed with error %s", ipcom_err_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* AES-CBC-MD5 */
|
||||
ret = iphwcrypto_ipsec_engine_add_esp(engine_id, IPHWCRYPTO_ENGINE_ESP_AES_CBC_MD5, ipcavium_ipsec_esp_aes_cbc_md5_input, ipcavium_ipsec_esp_aes_cbc_md5_output);
|
||||
if (ret != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcavium_create() :: iphwcrypto_ipsec_engine_add_esp(IPHWCRYPTO_ENGINE_ESP_AES_CBC_MD5) failed with error %s", ipcom_err_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* AES-CBC-SHA1 */
|
||||
ret = iphwcrypto_ipsec_engine_add_esp(engine_id, IPHWCRYPTO_ENGINE_ESP_AES_CBC_SHA1, ipcavium_ipsec_esp_aes_cbc_sha1_input, ipcavium_ipsec_esp_aes_cbc_sha1_output);
|
||||
if (ret != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcavium_create() :: iphwcrypto_ipsec_engine_add_esp(IPHWCRYPTO_ENGINE_ESP_AES_CBC_SHA1) failed with error %s", ipcom_err_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Register esp handlers */
|
||||
ret = iphwcrypto_ipsec_engine_register_esp(engine_id);
|
||||
if (ret != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcavium_create() :: iphwcrypto_engine_register_esp() failed with error %s", ipcom_err_string(ret));
|
||||
return ret;
|
||||
}
|
||||
#endif /* IPIPSEC2 */
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,195 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: Makefile,v $ $Revision: 1.64.10.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/Makefile,v $
|
||||
# $Author: svc-cmnet $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# GENERAL
|
||||
#############################################################################
|
||||
|
||||
# RTOS port
|
||||
IPPORT = vxworks
|
||||
|
||||
ifeq ($(COMP_IPNET_PATH),)
|
||||
IPGMAKE = yes
|
||||
else
|
||||
# Building from within the VxWorks build system
|
||||
IPGMAKE = no
|
||||
IPPORT = vxworks
|
||||
|
||||
ifndef __DEFS_VSBVARS_MK_INCLUDED
|
||||
include $(WIND_BASE)/target/h/make/defs.vsbvars.mk
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(VSB_MAKE_CONFIG_FILE)),)
|
||||
include $(VSB_MAKE_CONFIG_FILE)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# CONFIGURATION
|
||||
#############################################################################
|
||||
ifeq ($(IPGMAKE),yes)
|
||||
|
||||
# IPBUILD = debug | speed | debugspeed | size
|
||||
IPBUILD = debug
|
||||
|
||||
# IPVERBOSE = no | yes
|
||||
IPVERBOSE = no
|
||||
|
||||
# IPCOM_USE_INET6 = yes | no
|
||||
IPCOM_USE_INET6 = yes
|
||||
|
||||
# FEATURE_SET = msp | gpp (vxworks only)
|
||||
FEATURE_SET = msp
|
||||
|
||||
endif
|
||||
#############################################################################
|
||||
# IPMAKEFILE
|
||||
#############################################################################
|
||||
# If you move/rename this Makefile, please specify full filename!
|
||||
|
||||
#export IPMAKEFILE := /my/new/location/Makefile
|
||||
|
||||
|
||||
#############################################################################
|
||||
# FEATURE SET BUILD
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(WIND_IPNET),true)
|
||||
include $(BASE_ROOT)/config.mk
|
||||
ifneq ($(FEATURE_SET),)
|
||||
include $(WIND_BASE)/config/common/defs.component
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WIND_IPLITE),true)
|
||||
include $(BASE_ROOT)/config.mk
|
||||
ifneq ($(FEATURE_SET),)
|
||||
include $(WIND_BASE)/config/common/defs.component
|
||||
endif
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT PATHS
|
||||
#############################################################################
|
||||
|
||||
BASE_ROOT ?= $(CURDIR)/..
|
||||
|
||||
IPCOM_ROOT ?= $(CURDIR)
|
||||
|
||||
ifeq ($(IPGMAKE),yes)
|
||||
#PRODLIST_START
|
||||
|
||||
#IPNET_ROOT = $(BASE_ROOT)/ipnet2
|
||||
#IPLITE_ROOT = $(BASE_ROOT)/iplite2
|
||||
#IPTCP_ROOT = $(BASE_ROOT)/iptcp
|
||||
|
||||
#IP8021X_ROOT = $(BASE_ROOT)/ip8021x
|
||||
#IPAPPL_ROOT = $(BASE_ROOT)/ipappl
|
||||
#IPDHCPR_ROOT = $(BASE_ROOT)/ipdhcpr
|
||||
#IPDHCPS6_ROOT = $(BASE_ROOT)/ipdhcps6
|
||||
#IPDHCPS_ROOT = $(BASE_ROOT)/ipdhcps
|
||||
#IPDIAMETER_ROOT = $(BASE_ROOT)/ipdiameter
|
||||
#IPROHC_ROOT = $(BASE_ROOT)/iprohc
|
||||
#IPEAP_ROOT = $(BASE_ROOT)/ipeap
|
||||
#IPEMANATE_ROOT = $(BASE_ROOT)/ipemanate
|
||||
#IPFIREWALL_ROOT = $(BASE_ROOT)/ipfirewall
|
||||
#IPFREESCALE_ROOT = $(BASE_ROOT)/ipfreescale
|
||||
#IPHWCRYPTO_ROOT = $(BASE_ROOT)/iphwcrypto
|
||||
#IPIKE_ROOT = $(BASE_ROOT)/ipike
|
||||
#IPIPSEC_ROOT = $(BASE_ROOT)/ipipsec-$(IPPORT)
|
||||
#IPIPSEC_ROOT = $(BASE_ROOT)/ipipsec2
|
||||
#IPL2TP_ROOT = $(BASE_ROOT)/ipl2tp
|
||||
#IPLDAPC_ROOT = $(BASE_ROOT)/ipldapc
|
||||
#IPMCP_ROOT = $(BASE_ROOT)/ipmcp
|
||||
#IPMIP_ROOT = $(BASE_ROOT)/ipmip
|
||||
#IPMIP4_ROOT = $(BASE_ROOT)/ipmip4
|
||||
#IPMIP6CN_ROOT = $(BASE_ROOT)/ipmip6cn
|
||||
#IPMIP6HA_ROOT = $(BASE_ROOT)/ipmip6ha
|
||||
#IPMIP6MN_ROOT = $(BASE_ROOT)/ipmip6mn
|
||||
#IPMIP6PM_ROOT = $(BASE_ROOT)/ipmip6pm
|
||||
#IPMIP6_ROOT = $(BASE_ROOT)/ipmip6
|
||||
#IPMIPFA_ROOT = $(BASE_ROOT)/ipmipfa
|
||||
#IPMIPHA_ROOT = $(BASE_ROOT)/ipmipha
|
||||
#IPMIPMN_ROOT = $(BASE_ROOT)/ipmipmn
|
||||
#IPMIPPM_ROOT = $(BASE_ROOT)/ipmippm
|
||||
#IPMPLS_ROOT = $(BASE_ROOT)/ipmpls
|
||||
#IPNETPERF_ROOT = $(BASE_ROOT)/ipnetperf
|
||||
#IPNGC_ROOT = $(BASE_ROOT)/ipngc
|
||||
#IPPPP_ROOT = $(BASE_ROOT)/ipppp
|
||||
#IPPRISM_ROOT = $(BASE_ROOT)/ipprism-$(IPPORT)
|
||||
#IPRADIUS_ROOT = $(BASE_ROOT)/ipradius
|
||||
#IPRIPNG_ROOT = $(BASE_ROOT)/ipripng
|
||||
#IPRIP_ROOT = $(BASE_ROOT)/iprip
|
||||
#IPSCTP_ROOT = $(BASE_ROOT)/ipsctp
|
||||
#IPSNMP_ROOT = $(BASE_ROOT)/ipsnmp
|
||||
#IPSNTP_ROOT = $(BASE_ROOT)/ipsntp
|
||||
#IPNTP_ROOT = $(BASE_ROOT)/ipntp
|
||||
#IPSSH_ROOT = $(BASE_ROOT)/ipssh
|
||||
#IPSSLPROXY_ROOT = $(BASE_ROOT)/ipsslproxy
|
||||
#IPSSL_ROOT = $(BASE_ROOT)/ipssl2
|
||||
#IPWEBS_ROOT = $(BASE_ROOT)/ipwebs
|
||||
ifneq ($(IPNAE),yes)
|
||||
#IPXINC_ROOT = $(BASE_ROOT)/ipxinc
|
||||
#IPROUTE2_ROOT = $(BASE_ROOT)/iproute2
|
||||
#VXCOMPAT_ROOT = $(BASE_ROOT)/vxcompat
|
||||
#VXMUX_ROOT = $(BASE_ROOT)/vxmux
|
||||
#IPBRIDGE_ROOT = $(BASE_ROOT)/ipbridge
|
||||
#VXCOREIP_ROOT = $(BASE_ROOT)/vxcoreip
|
||||
#VXDOT1X_ROOT = $(BASE_ROOT)/vxdot1x
|
||||
#WRNAD_ROOT = $(BASE_ROOT)/wrnad
|
||||
endif
|
||||
|
||||
# Choose one of ipcrypto or ipmcrypto:
|
||||
#IPCRYPTO_ROOT = $(BASE_ROOT)/ipmcrypto
|
||||
#IPCRYPTO_ROOT = $(BASE_ROOT)/ipcrypto
|
||||
|
||||
#PRODLIST_END
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# IPOBJDIR
|
||||
#############################################################################
|
||||
# Object/library/binary directory.
|
||||
|
||||
ifeq ($(WIND_IPNET),true)
|
||||
IPOBJDIR = $(WR_IPCOM_LIB_DIR)/objipcom$(OPT)
|
||||
else
|
||||
ifeq ($(WIND_IPLITE),true)
|
||||
IPOBJDIR = $(WR_IPCOM_LIB_DIR)/objipcom$(OPT)
|
||||
else
|
||||
ifeq ($(IPPORT),lkm)
|
||||
IPOBJDIR = $(IPCOM_ROOT)/obj-$(IPPORT)-$(IPTARGET)-$(IPVER)-gcc-$(IPBUILD)
|
||||
else
|
||||
ifeq ($(IPPORT),las)
|
||||
IPOBJDIR = $(IPCOM_ROOT)/obj-$(IPPORT)-$(IPTARGET)-$(IPVER)-gcc-$(IPBUILD)
|
||||
else
|
||||
ifeq ($(IPPORT),rtcore)
|
||||
IPOBJDIR = $(IPCOM_ROOT)/obj-$(IPPORT)-$(IPVER)-$(IPCOMPILER)-$(IPBUILD)
|
||||
else
|
||||
IPOBJDIR = $(IPCOM_ROOT)/$(IPNAEOBJ)obj-$(IPPORT)-$(IPTARGET)-$(IPVER)-$(IPCOMPILER)-$(IPBUILD)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# DO NOT EDIT BELOW!
|
||||
#############################################################################
|
||||
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_defs.mk
|
||||
|
||||
|
||||
#############################################################################
|
||||
# END OF Makefile
|
||||
#############################################################################
|
||||
@@ -0,0 +1,50 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_arm.mk,v $ $Revision: 1.2.74.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/arch/arm/gmake/ipcom_arm.mk,v $
|
||||
# $Author: hxie $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
IPCOM_ARCH := yes
|
||||
|
||||
#############################################################################
|
||||
# DESCRIPTION
|
||||
#############################################################################
|
||||
# IPCOM ARM arch GNU makefile template.
|
||||
|
||||
#############################################################################
|
||||
# ARMARCH7M supports thumb2 instruction only, so here we disable ASM code
|
||||
# for this kind CPU
|
||||
#############################################################################
|
||||
ifneq ($(CPU),ARMARCH7M)
|
||||
|
||||
#############################################################################
|
||||
# IPDEFINE
|
||||
#############################################################################
|
||||
|
||||
IPDEFINE += -DIPCOM_USE_ASM
|
||||
|
||||
|
||||
#############################################################################
|
||||
# FILE
|
||||
#############################################################################
|
||||
|
||||
IPLIBOBJECTS += ipcom_arm.o
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEPENDENCIES
|
||||
#############################################################################
|
||||
|
||||
IPASDIRS += $(IPCOM_ROOT)/arch/arm/src
|
||||
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# END OF ipcom_arm.mk
|
||||
#############################################################################
|
||||
|
||||
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_arm.s,v $ $Revision: 1.3.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/arch/arm/src/ipcom_arm.s,v $
|
||||
* $Author: zluo0 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kjonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01a,25Aug10,hfc fix for defect WIND00220454
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
Assembler version of Internet checksum routines used in IPNET
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
/* Include to defined endian macros */
|
||||
#define _ASMLANGUAGE
|
||||
#include "vxWorks.h"
|
||||
#include "asm.h"
|
||||
#include "regs.h"
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
#define BIG_ENDIAN_ARM
|
||||
#endif
|
||||
|
||||
.file "ipcom_arm.s"
|
||||
.text
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_update2_asm
|
||||
*===========================================================================
|
||||
* Description: Calculates the Internet checksum for a buffer.
|
||||
* Parameters: r0 - Pointer to the buffer to calculate checksum for. Must
|
||||
* be word or halfword aligned.
|
||||
* r1 - Length of the buffer
|
||||
* Returns: r0 = 32-bit partial checksum
|
||||
*
|
||||
*/
|
||||
.align 2
|
||||
.global ipcom_in_checksum_update2_asm
|
||||
|
||||
ipcom_in_checksum_update2_asm:
|
||||
stmfd sp!, {r4,r5,r6,r7,lr}
|
||||
mov r2, r0
|
||||
movs r4, r0, lsl #30
|
||||
mov r0, #0
|
||||
beq .chksum_aligned
|
||||
/* r0 is not a multiple of 4 */
|
||||
cmp r1, #2
|
||||
bls .chksum_bytes
|
||||
ldrh r0, [r2], #2
|
||||
sub r1, r1, #2
|
||||
|
||||
.chksum_aligned:
|
||||
movs r7, r1, lsr #5
|
||||
beq .chksum_1_word
|
||||
sub r1, r1, r7, lsl #5
|
||||
|
||||
.chksum_8_words:
|
||||
ldmia r2!, {r3,r4,r5,r6}
|
||||
adds r0, r0, r3
|
||||
adcs r0, r0, r4
|
||||
adcs r0, r0, r5
|
||||
adcs r0, r0, r6
|
||||
ldmia r2!, {r3,r4,r5,r6}
|
||||
adcs r0, r0, r3
|
||||
adcs r0, r0, r4
|
||||
adcs r0, r0, r5
|
||||
adcs r0, r0, r6
|
||||
adccs r0, r0, #0
|
||||
subs r7, r7, #1
|
||||
bne .chksum_8_words
|
||||
|
||||
.chksum_1_word:
|
||||
cmp r1, #4
|
||||
blo .chksum_bytes
|
||||
ldr r3, [r2], #4
|
||||
adds r0, r0, r3
|
||||
adccs r0, r0, #0
|
||||
subs r1, r1, # 4
|
||||
b .chksum_1_word
|
||||
|
||||
.chksum_bytes:
|
||||
/* Take care of the last 0-3 bytes */
|
||||
cmp r1, #0
|
||||
beq .chk_done
|
||||
ldrb r4, [r2], #1
|
||||
#ifdef BIG_ENDIAN_ARM
|
||||
adds r0, r0, r4, lsl #8
|
||||
#else
|
||||
adds r0, r0, r4
|
||||
#endif
|
||||
adccs r0, r0, #0
|
||||
cmp r1, #1
|
||||
beq .chk_done
|
||||
ldrb r4, [r2], #1
|
||||
#ifdef BIG_ENDIAN_ARM
|
||||
adds r0, r0, r4
|
||||
#else
|
||||
adds r0, r0, r4, lsl #8
|
||||
#endif
|
||||
adccs r0, r0, #0
|
||||
cmp r1, #2
|
||||
beq .chk_done
|
||||
ldrb r4, [r2], #1
|
||||
#ifdef BIG_ENDIAN_ARM
|
||||
adds r0, r0, r4, lsl #8
|
||||
#else
|
||||
adds r0, r0, r4
|
||||
#endif
|
||||
adccs r0, r0, #0
|
||||
|
||||
.chk_done:
|
||||
ldmfd sp!, {r4,r5,r6,r7,pc}
|
||||
|
||||
.size ipcom_in_checksum_update2_asm, .-ipcom_in_checksum_update2_asm
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_memcpy_asm
|
||||
*===========================================================================
|
||||
* Description: Calculates the Internet checksum while copying a buffer.
|
||||
* Parameters: r0 - Pointer to the destination buffer. Can have any
|
||||
* alignment.
|
||||
* r1 - Pointer to the source buffer. Can have any alignment.
|
||||
* r2 - Number of bytes to copy
|
||||
* Returns: r0 = 32-bit partial checksum
|
||||
*
|
||||
*/
|
||||
dst .req r3
|
||||
src .req r1
|
||||
sum .req r0
|
||||
|
||||
.align 2
|
||||
.global ipcom_in_checksum_memcpy_asm
|
||||
|
||||
ipcom_in_checksum_memcpy_asm:
|
||||
stmfd sp!, {r4,r5,r6,r7,r8,r9,r10,lr}
|
||||
|
||||
mov dst, r0
|
||||
eor sum, sum, sum
|
||||
eor r10,r10,r10
|
||||
/* r9 will be 1 if the checksum must be swapped */
|
||||
and r9, src, #1
|
||||
/* Less than 4 bytes is copied byte for byte */
|
||||
cmp r2, #4
|
||||
blt .cpy_epilog
|
||||
b .calculate_no_of_extra_swap
|
||||
|
||||
.align_dst:
|
||||
ands r8, dst, #3
|
||||
beq .dst_aligned
|
||||
/* dst not word aligned, keep copy one byte until dst is word
|
||||
aligned */
|
||||
sub r7, r2, #1
|
||||
mov r2, #1
|
||||
bl .cpy_byte
|
||||
mov r2, r7
|
||||
b .align_dst
|
||||
|
||||
.dst_aligned:
|
||||
/* dst is always word aligned at this point, src can have any
|
||||
alignment at this point */
|
||||
tst src, #3
|
||||
bne .cpy_unaligned
|
||||
|
||||
movs r8, r2, lsr #5
|
||||
sub r2, r2, r8, lsl #5
|
||||
blne .cpy_32_bytes_aligned
|
||||
|
||||
movs r8, r2, lsr #2
|
||||
sub r2, r2, r8, lsl #2
|
||||
blne .cpy_4_bytes_aligned
|
||||
|
||||
.cpy_epilog:
|
||||
bl .cpy_bytes
|
||||
/* Check if the bytes must be swapped in the checksum, this is
|
||||
the case if the src pointer passed to
|
||||
ipcom_in_checksum_memcpy_asm was odd */
|
||||
/* In big endian the last swap is not required if src is odd unaligned
|
||||
and vice versa */
|
||||
|
||||
cmp r9, #1
|
||||
moveq r0, r0, ror #8
|
||||
|
||||
|
||||
mov r4, r0, lsr #16
|
||||
mov r0, r0, lsl #16
|
||||
add r0, r4, r0, lsr #16
|
||||
|
||||
ldmfd sp!, {r4,r5,r6,r7,r8,r9,r10,pc}
|
||||
|
||||
/* Subroutine for copy unaligned buffers */
|
||||
.cpy_unaligned:
|
||||
movs r8, r2, lsr #3
|
||||
|
||||
beq .cpy_epilog
|
||||
sub r2, r2, r8, lsl #3
|
||||
|
||||
cmp r10,#2
|
||||
moveq r0,r0, ror #8
|
||||
|
||||
cmp r10,#3
|
||||
moveq r0, r0, ror #8
|
||||
|
||||
and r7, src, #3
|
||||
sub src, src, r7
|
||||
ldr r4, [src], #4
|
||||
tst r7, #1
|
||||
beq .cpy_2_bytes_unaligned
|
||||
tst r7, #2
|
||||
bne .cpy_3_bytes_unaligned
|
||||
|
||||
.cpy_1_byte_unaligned:
|
||||
ldmia src!, {r5,r6}
|
||||
#ifdef BIG_ENDIAN_ARM
|
||||
mov r4, r4, lsl #8
|
||||
orr r4, r4, r5, lsr #24
|
||||
mov r5, r5, lsl #8
|
||||
orr r5, r5, r6, lsr #24
|
||||
#else
|
||||
mov r4, r4, lsr #8
|
||||
orr r4, r4, r5, lsl #24
|
||||
mov r5, r5, lsr #8
|
||||
orr r5, r5, r6, lsl #24
|
||||
#endif
|
||||
adds sum, sum, r4
|
||||
adcs sum, sum, r5
|
||||
adccs sum, sum, #0
|
||||
stmia dst!, {r4,r5}
|
||||
mov r4, r6
|
||||
subs r8, r8, #1
|
||||
bne .cpy_1_byte_unaligned
|
||||
b .cpy_unaligned_epilog
|
||||
|
||||
.cpy_3_bytes_unaligned:
|
||||
ldmia src!, {r5,r6}
|
||||
#ifdef BIG_ENDIAN_ARM
|
||||
mov r4, r4, lsl #24
|
||||
orr r4, r4, r5, lsr #8
|
||||
mov r5, r5, lsl #24
|
||||
orr r5, r5, r6, lsr #8
|
||||
#else
|
||||
mov r4, r4, lsr #24
|
||||
orr r4, r4, r5, lsl #8
|
||||
mov r5, r5, lsr #24
|
||||
orr r5, r5, r6, lsl #8
|
||||
#endif
|
||||
adds sum, sum, r4
|
||||
adcs sum, sum, r5
|
||||
adccs sum, sum, #0
|
||||
stmia dst!, {r4,r5}
|
||||
mov r4, r6
|
||||
subs r8, r8, #1
|
||||
bne .cpy_3_bytes_unaligned
|
||||
b .cpy_unaligned_epilog
|
||||
|
||||
.cpy_2_bytes_unaligned:
|
||||
ldmia src!, {r5,r6}
|
||||
#ifdef BIG_ENDIAN_ARM
|
||||
mov r4, r4, lsl #16
|
||||
orr r4, r4, r5, lsr #16
|
||||
mov r5, r5, lsl #16
|
||||
orr r5, r5, r6, lsr #16
|
||||
#else
|
||||
mov r4, r4, lsr #16
|
||||
orr r4, r4, r5, lsl #16
|
||||
mov r5, r5, lsr #16
|
||||
orr r5, r5, r6, lsl #16
|
||||
#endif
|
||||
adds sum, sum, r4
|
||||
adcs sum, sum, r5
|
||||
adccs sum, sum, #0
|
||||
stmia dst!, {r4,r5}
|
||||
mov r4, r6
|
||||
subs r8, r8, #1
|
||||
bne .cpy_2_bytes_unaligned
|
||||
|
||||
.cpy_unaligned_epilog:
|
||||
sub src, src, #4
|
||||
add src, src, r7
|
||||
/* the 1 & 3 bytes unaligned cases must swap the bytes of the
|
||||
checksum since the byte copy logic assumes that it is
|
||||
swapped and it will be swapped back after the byte copy */
|
||||
cmp r9, #1
|
||||
moveq r0, r0, ror #8
|
||||
|
||||
cmp r10,#1
|
||||
moveq r0, r0, ror #8
|
||||
|
||||
cmp r10,#3
|
||||
moveq r0, r0, ror #8
|
||||
|
||||
b .cpy_epilog
|
||||
|
||||
/* Subroutine for copy aligned buffers */
|
||||
.cpy_32_bytes_aligned:
|
||||
/* Copy 32 byte per round */
|
||||
ldmia src!, {r4,r5,r6,r7}
|
||||
adds sum, sum, r4
|
||||
adcs sum, sum, r5
|
||||
adcs sum, sum, r6
|
||||
adcs sum, sum, r7
|
||||
stmia dst!, {r4,r5,r6,r7}
|
||||
ldmia src!, {r4,r5,r6,r7}
|
||||
adcs sum, sum, r4
|
||||
adcs sum, sum, r5
|
||||
adcs sum, sum, r6
|
||||
adcs sum, sum, r7
|
||||
stmia dst!, {r4,r5,r6,r7}
|
||||
adccs sum, sum, #0
|
||||
subs r8, r8, #1
|
||||
bne .cpy_32_bytes_aligned
|
||||
mov pc, lr
|
||||
|
||||
.cpy_4_bytes_aligned:
|
||||
/* Copy 4 byte per round */
|
||||
ldr r4, [src], #4
|
||||
adds sum, sum, r4
|
||||
adccs sum, sum, #0
|
||||
str r4, [dst], #4
|
||||
subs r8, r8, #1
|
||||
bne .cpy_4_bytes_aligned
|
||||
mov pc, lr
|
||||
|
||||
/* Subroutine for copy byte for byte */
|
||||
.cpy_bytes:
|
||||
/* Fold the 32-bit csum so carry does not have to be checked
|
||||
when summing the left-over bytes */
|
||||
cmp r2, #0
|
||||
moveq pc, lr
|
||||
mov r4, r0, lsr #16
|
||||
mov r0, r0, lsl #16
|
||||
add r0, r4, r0, lsr #16
|
||||
|
||||
.cpy_byte:
|
||||
ldrb r4, [src], #1
|
||||
tst src, #1
|
||||
#ifdef BIG_ENDIAN_ARM
|
||||
addeq sum, sum, r4
|
||||
addne sum, sum, r4, lsl #8
|
||||
#else
|
||||
addeq sum, sum, r4, lsl #8
|
||||
addne sum, sum, r4
|
||||
#endif
|
||||
strb r4, [dst], #1
|
||||
|
||||
subs r2, r2, #1
|
||||
bne .cpy_byte
|
||||
mov pc, lr
|
||||
|
||||
.calculate_no_of_extra_swap:
|
||||
ands r8,dst, #3
|
||||
beq .dst_aligned /* if dst is aligned no need for extra byte swap */
|
||||
|
||||
/* at this stage dst is unaligned odd(1 or 3 bytes) or unaligned by halfword */
|
||||
ands r7, src, #3
|
||||
beq .src_is_even
|
||||
cmp r7,#2
|
||||
beq .src_is_even
|
||||
|
||||
cmp r8,r7
|
||||
bne .set_flags_to_r10
|
||||
b .align_dst
|
||||
|
||||
|
||||
.src_is_even:
|
||||
cmp r8,#2
|
||||
beq .align_dst
|
||||
/* at this src is even, aligned(0,4, ..) or unaligned (2,6,..)
|
||||
but dst is odd unaligned. This require 2 extra swap
|
||||
*/
|
||||
mov r10,#3
|
||||
/* r10 = 3 indicates src is even, align or half word align and dst is odd unaligned. */
|
||||
b .align_dst
|
||||
|
||||
.set_flags_to_r10:
|
||||
|
||||
cmp r7,#3
|
||||
addeq r10,r10,#1
|
||||
cmp r8, #3
|
||||
addeq r10,r10,#1
|
||||
|
||||
cmp r7,#2
|
||||
addeq r10,r10,#1
|
||||
cmp r8,#2
|
||||
addeq r10,r10,#1
|
||||
|
||||
cmp r7,#3
|
||||
beq .align_dst
|
||||
cmp r8,#3
|
||||
beq .align_dst
|
||||
|
||||
cmp r8,#1
|
||||
addeq r10,r10,#1
|
||||
|
||||
cmp r7,#1
|
||||
addeq r10,r10,#1
|
||||
|
||||
/*
|
||||
r10 = 2, indicates src is 3 byte unaligned and dst is 2 byte unaligned or vice versa.
|
||||
r10 = 1, indicates src is 1 byte unaligned and dst is 2 byte unaligned or vice versa
|
||||
*/
|
||||
|
||||
b .align_dst
|
||||
|
||||
|
||||
.size ipcom_in_checksum_memcpy_asm, .-ipcom_in_checksum_memcpy_asm
|
||||
@@ -0,0 +1,45 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_arch.mk,v $ $Revision: 1.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/arch/gmake/ipcom_arch.mk,v $
|
||||
# $Author: lob $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# DESCRIPTION
|
||||
#############################################################################
|
||||
# IPCOM common arch GNU makefile template.
|
||||
|
||||
-include $(IPCOM_ROOT)/arch/$(IPARCH)/gmake/ipcom_$(IPARCH).mk
|
||||
|
||||
|
||||
#############################################################################
|
||||
# IPDEFINE
|
||||
#############################################################################
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
#############################################################################
|
||||
# IPCOM arch object:
|
||||
|
||||
ifneq ($(IPCOM_ARCH),yes)
|
||||
IPLIBOBJECTS += ipcom_arch.o
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
#############################################################################
|
||||
|
||||
IPSRCDIRS += $(IPCOM_ROOT)/arch/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# END OF IPCOM_ARCH.MK
|
||||
#############################################################################
|
||||
@@ -0,0 +1,52 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_powerpc.mk,v $ $Revision: 1.3 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/arch/powerpc/gmake/ipcom_powerpc.mk,v $
|
||||
# $Author: ulf $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
IPCOM_ARCH := yes
|
||||
|
||||
#############################################################################
|
||||
# DESCRIPTION
|
||||
#############################################################################
|
||||
# IPCOM powerpc arch GNU makefile template.
|
||||
|
||||
|
||||
#############################################################################
|
||||
# IPDEFINE
|
||||
#############################################################################
|
||||
|
||||
IPDEFINE += -DIPCOM_USE_ASM
|
||||
|
||||
|
||||
#############################################################################
|
||||
# FILE
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(IPPORT),vxworks)
|
||||
IPLIBOBJECTS += ipcom_powerpc_vxworks.o
|
||||
else
|
||||
ifeq ($(IPCOMPILER),ghs)
|
||||
IPLIBOBJECTS += ipcom_powerpc_ghs.o
|
||||
else
|
||||
IPLIBOBJECTS += ipcom_powerpc_gcc.o
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEPENDENCIES
|
||||
#############################################################################
|
||||
|
||||
IPASDIRS += $(IPCOM_ROOT)/arch/powerpc/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# END OF IPCOM_POWERPC.MK
|
||||
#############################################################################
|
||||
|
||||
@@ -0,0 +1,500 @@
|
||||
###############################################################################
|
||||
# INTERPEAK SOURCE FILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_powerpc_gcc.s,v $ $Revision: 1.5 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/arch/powerpc/src/ipcom_powerpc_gcc.s,v $
|
||||
# $Author: lob $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# Copyright (C) 1995-98 by ENEA DATA AB. All rights reserved.
|
||||
# Written by Anders Hagstrom for INET.
|
||||
# Copyright Interpeak AB 2000-2004 <www.interpeak.se>. All rights reserved.
|
||||
###############################################################################
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# DESCRIPTION
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# CONFIGURATION
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# SECTION
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
.text
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# DEFINES
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# TYPES
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# EXTERN PROTOTYPES
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# LOCAL PROTOTYPES
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# DATA
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# STATIC FUNCTIONS
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# GLOBAL FUNCTIONS
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# PUBLIC FUNCTIONS
|
||||
#############################################################################
|
||||
#
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# ipcom_in_checksum_update2_asm
|
||||
#############################################################################
|
||||
# Prototype: IP_PUBLIC Ip_u32
|
||||
# ipcom_in_checksum_update2_asm(void *pbuf, Ip_size_t bytes);
|
||||
# Description: Computes the internet checksum (RFC 1071). NOTE
|
||||
# it does not compute the 1 complement checksum.
|
||||
# Parameters: 16bit aligned pbuf and bytes > 20
|
||||
# Returns: A standard internet checksum..
|
||||
#
|
||||
.globl ipcom_in_checksum_update2_asm
|
||||
ipcom_in_checksum_update2_asm:
|
||||
andi. r6,r3,0x2 #Check if halfword or word alignment.
|
||||
li r5,0 #Init checksum.
|
||||
beq+ 1f
|
||||
lhz r5,0(r3) #Get first halword to get word align.
|
||||
addi r3,r3,2 #Move pointer.
|
||||
subi r4,r4,2 #Compensate numBytes.
|
||||
1:
|
||||
andi. r6,r4,0xc #Extract extra word accesses.
|
||||
srawi r7,r4,4 #numBytes / 16.
|
||||
|
||||
cmpi cr1,r6,0x8
|
||||
addic r7,r7,1 #Compensate loop counter, clear carry.
|
||||
subi r3,r3,4 #Compensate for lwzu.
|
||||
mtspr ctr,r7 #Setup loop counter.
|
||||
beq chk0 #Branch if no extra word.
|
||||
bgt cr1,chk3 #Branch if 3 extra word.
|
||||
blt cr1,chk1 #Branch if 1 extra word.
|
||||
b chk2 #2 extra word required.
|
||||
chk_loop:
|
||||
lwzu r6,4(r3)
|
||||
adde r5,r5,r6 #Add to checksum.
|
||||
chk3:
|
||||
lwzu r7,4(r3)
|
||||
adde r5,r5,r7 #Add to checksum.
|
||||
chk2:
|
||||
lwzu r6,4(r3)
|
||||
adde r5,r5,r6 #Add to checksum.
|
||||
chk1:
|
||||
lwzu r7,4(r3)
|
||||
adde r5,r5,r7 #Add to checksum.
|
||||
chk0:
|
||||
bc 16,0,chk_loop
|
||||
|
||||
addi r3,r3,4 #Update pointer.
|
||||
|
||||
# Handle trailing halfword.
|
||||
andi. r7,r4,2
|
||||
beq+ no_halfword
|
||||
lhz r6,0(r3) #Load last halfword.
|
||||
addi r3,r3,2 #Update pointer.
|
||||
adde r5,r5,r6 #Add to checksum.
|
||||
no_halfword:
|
||||
|
||||
# Handle trailing byte.
|
||||
andi. r7,r4,1
|
||||
beq+ no_byte
|
||||
lbz r6,0(r3) #Load last byte.
|
||||
rlwinm r6,r6,8,16,23 #Shift left 8 times.
|
||||
adde r5,r5,r6 #Add to checksum.
|
||||
no_byte:
|
||||
|
||||
# Convert checksum from 32 bit to 16 bit.
|
||||
|
||||
rlwinm r6,r5,16,16,31 #Extract high part of checksum.
|
||||
rlwinm r5,r5,0,16,31 #Truncate high part of checksum.
|
||||
adde r5,r5,r6 #High part + low part + carry.
|
||||
rlwinm r6,r5,16,16,31 #Extract carry from checksum.
|
||||
rlwinm r5,r5,0,16,31 #Truncate high part of checksum.
|
||||
add r3,r5,r6 #Add carry to low part.
|
||||
blr
|
||||
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# ipcom_memcpy_asm
|
||||
#############################################################################
|
||||
# Prototype: IP_PUBLIC void *
|
||||
# ipcom_memcpy_asm(void *s1, const void *s2, Ip_size_t n);
|
||||
# Description: Copy data.
|
||||
# Parameters:
|
||||
# Returns:
|
||||
#
|
||||
.globl ipcom_memcpy_asm
|
||||
ipcom_memcpy_asm:
|
||||
cmpli cr0,r5,17 #Threshold for byte copy.
|
||||
xor r8,r3,r4 #Compare dest and src.
|
||||
mr r6,r3 #Leave r3 (dest) as return value.
|
||||
blt- byte_copy
|
||||
andi. r7,r8,1 #Check for same byte alignment.
|
||||
bne- byte_copy #Byte copy if even/odd alignment.
|
||||
|
||||
andi. r7,r6,1 #Check for leading odd address.
|
||||
beq+ check_hword_align
|
||||
lbz r7,0(r4) #Copy one byte to get halfword align.
|
||||
subi r5,r5,1 #Decrement numBytes.
|
||||
stb r7,0(r6)
|
||||
addi r4,r4,1 #Move pointers.
|
||||
addi r6,r6,1
|
||||
check_hword_align:
|
||||
|
||||
andi. r7,r8,2 #Check for same halfword alignment.
|
||||
beq+ word_align #Word copy if possible.
|
||||
|
||||
# Do halfword copy.
|
||||
subi r4,r4,2 #Compensate pointers for lhzu/sthu.
|
||||
subi r6,r6,2
|
||||
srawi r8,r5,4 #numBytes / 16.
|
||||
rlwinm. r5,r5,0,28,31 #Calculate trailing bytes.
|
||||
mtspr ctr,r8
|
||||
hword_loop:
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
bc 16,0,hword_loop
|
||||
|
||||
beqlr #Done if numBytes = 0.
|
||||
addi r4,r4,1 #Move pointers.
|
||||
addi r6,r6,1
|
||||
b byte_copy_cont #Continue with trailing bytes.
|
||||
|
||||
# Do word copy.
|
||||
|
||||
word_align:
|
||||
andi. r7,r6,2 #Check for leading halfword address.
|
||||
beq- word_copy
|
||||
lhz r7,0(r4) #Copy halfword to get word align.
|
||||
subi r5,r5,2 #Decrement numBytes.
|
||||
sth r7,0(r6)
|
||||
subi r4,r4,2 #Compensate pointers for lwzu/stwu.
|
||||
subi r6,r6,2
|
||||
b word_copy_cont
|
||||
|
||||
word_copy:
|
||||
subi r4,r4,4 #Compensate pointers for lwzu/stwu.
|
||||
subi r6,r6,4
|
||||
word_copy_cont:
|
||||
andi. r7,r5,0xc #Extract extra word accesses.
|
||||
srawi r8,r5,4 #numBytes / 16.
|
||||
cmpi cr1,r7,0x8
|
||||
addi r8,r8,1 #Compensate loop counter.
|
||||
mtspr ctr,r8
|
||||
beq wcopy0 #Branch if no extra word.
|
||||
bgt cr1,wcopy3 #Branch if 3 extra word.
|
||||
blt cr1,wcopy1 #Branch if 1 extra word.
|
||||
b wcopy2 #2 extra word required.
|
||||
|
||||
word_loop:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r6)
|
||||
wcopy3:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r6)
|
||||
wcopy2:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r6)
|
||||
wcopy1:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r6)
|
||||
wcopy0:
|
||||
bc 16,0,word_loop
|
||||
|
||||
rlwinm. r5,r5,0,30,31 #Calculate number of trailing bytes.
|
||||
addi r4,r4,3 #Move pointers.
|
||||
addi r6,r6,3
|
||||
beqlr #Done if numBytes = 0.
|
||||
b byte_copy_cont #Continue with trailing bytes.
|
||||
byte_copy:
|
||||
subi r4,r4,1 #Move pointers.
|
||||
subi r6,r6,1
|
||||
byte_copy_cont:
|
||||
andi. r7,r5,0x3 #Extract extra byte accesses.
|
||||
srawi r8,r5,2 #numBytes / 4.
|
||||
cmpi cr1,r7,2
|
||||
addi r8,r8,1 #Compensate loop counter.
|
||||
mtspr ctr,r8
|
||||
beq bcopy0 #Branch if no extra byte.
|
||||
bgt cr1,bcopy3 #Branch if 3 extra byte.
|
||||
blt cr1,bcopy1 #Branch if 1 extra byte.
|
||||
b bcopy2 #2 extra byte required.
|
||||
byte_loop:
|
||||
lbzu r7,1(r4)
|
||||
stbu r7,1(r6)
|
||||
bcopy3:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r6)
|
||||
bcopy2:
|
||||
lbzu r7,1(r4)
|
||||
stbu r7,1(r6)
|
||||
bcopy1:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r6)
|
||||
bcopy0:
|
||||
bc 16,0,byte_loop
|
||||
blr
|
||||
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# ipcom_in_checksum_memcpy_asm
|
||||
#############################################################################
|
||||
# Prototype: IP_PUBLIC Ip_u32
|
||||
# ipcom_in_checksum_memcpy(void *dst, void *src, Ip_size_t len);
|
||||
# Description: Copy data and calculate internet checksum.
|
||||
# Parameters:
|
||||
# Returns:
|
||||
#
|
||||
.globl ipcom_in_checksum_memcpy_asm
|
||||
ipcom_in_checksum_memcpy_asm:
|
||||
xor r6,r6,r6 # Interpeak always use 0 as initial checksum
|
||||
cmpli cr0,r5,17 #Threshold for byte copy.
|
||||
li r12,0 #Clear byte swap flag.
|
||||
xor r8,r3,r4 #Compare dest and src.
|
||||
addic r5,r5,0 #Make dummy add to clear carry.
|
||||
blt- scpy_byte_copy
|
||||
andi. r7,r8,1 #Check for same byte alignment.
|
||||
bne- scpy_byte_copy #Byte copy if even/odd alignment.
|
||||
|
||||
andi. r7,r3,1 #Check for leading odd address.
|
||||
beq+ scpy_check_hword_align
|
||||
lbz r7,0(r4) #Copy one byte to get halfword align.
|
||||
subi r5,r5,1 #Decrement numBytes.
|
||||
li r12,1 #Set flag.
|
||||
rlwinm r8,r6,8,16,23 #Swap bytes for intitial checksum.
|
||||
rlwinm r6,r6,24,24,31
|
||||
or r6,r6,r8
|
||||
stb r7,0(r3)
|
||||
adde r6,r6,r7 #Add to checksum.
|
||||
addi r4,r4,1 #Move pointers.
|
||||
addi r3,r3,1
|
||||
scpy_check_hword_align:
|
||||
|
||||
andi. r7,r8,2 #Check for same halfword alignment.
|
||||
beq+ scpy_word_align #Word copy if possible.
|
||||
|
||||
# Do halfword copy.
|
||||
|
||||
andi. r7,r5,0x6 #Extract extra word accesses.
|
||||
subi r4,r4,2 #Compensate pointers for lhzu/sthu.
|
||||
subi r3,r3,2
|
||||
srawi r8,r5,3 #numBytes / 8.
|
||||
cmpi cr1,r7,0x4
|
||||
addi r8,r8,1 #Compensate loop counter.
|
||||
mtspr ctr,r8
|
||||
beq scpy_hwcopy0 #Branch if no extra hword.
|
||||
bgt cr1,scpy_hwcopy3 #Branch if 3 extra hword.
|
||||
blt cr1,scpy_hwcopy1 #Branch if 1 extra hword.
|
||||
b scpy_hwcopy2 #2 extra hword required.
|
||||
|
||||
scpy_hword_loop:
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r3)
|
||||
adde r6,r6,r7 #Add to checksum.
|
||||
scpy_hwcopy3:
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_hwcopy2:
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r3)
|
||||
adde r6,r6,r7 #Add to checksum.
|
||||
scpy_hwcopy1:
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_hwcopy0:
|
||||
bc 16,0,scpy_hword_loop
|
||||
|
||||
rlwinm. r5,r5,0,31,31 #Check for trailing byte.
|
||||
beq+ scpy_end #Done if numBytes = 0.
|
||||
addi r4,r4,1 #Move pointers.
|
||||
addi r3,r3,1
|
||||
b scpy_trailing_bytes #Continue with trailing bytes.
|
||||
|
||||
# Do word copy.
|
||||
|
||||
scpy_word_align:
|
||||
andi. r7,r3,2 #Check for leading halfword address.
|
||||
beq- scpy_word_copy
|
||||
lhz r7,0(r4) #Copy halfword to get word align.
|
||||
subi r5,r5,2 #Decrement numBytes.
|
||||
sth r7,0(r3)
|
||||
adde r6,r6,r7 #Add to checksum.
|
||||
subi r4,r4,2 #Compensate pointers for lwzu/stwu.
|
||||
subi r3,r3,2
|
||||
b scpy_word_copy_cont
|
||||
|
||||
scpy_word_copy:
|
||||
subi r4,r4,4 #Compensate pointers for lwzu/stwu.
|
||||
subi r3,r3,4
|
||||
scpy_word_copy_cont:
|
||||
andi. r7,r5,0xc #Extract extra word accesses.
|
||||
srawi r8,r5,4 #numBytes / 16.
|
||||
cmpi cr1,r7,0x8
|
||||
addi r8,r8,1 #Compensate loop counter.
|
||||
mtspr ctr,r8
|
||||
beq scpy_wcopy0 #Branch if no extra word.
|
||||
bgt cr1,scpy_wcopy3 #Branch if 3 extra word.
|
||||
blt cr1,scpy_wcopy1 #Branch if 1 extra word.
|
||||
b scpy_wcopy2 #2 extra word required.
|
||||
|
||||
scpy_word_loop:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r3)
|
||||
adde r6,r6,r7 #Add to checksum.
|
||||
scpy_wcopy3:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_wcopy2:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r3)
|
||||
adde r6,r6,r7 #Add to checksum.
|
||||
scpy_wcopy1:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_wcopy0:
|
||||
bc 16,0,scpy_word_loop
|
||||
|
||||
rlwinm. r5,r5,0,30,31 #Calculate number of trailing bytes.
|
||||
addi r4,r4,3 #Move pointers.
|
||||
addi r3,r3,3
|
||||
beq scpy_end #Done if numBytes = 0.
|
||||
b scpy_trailing_bytes #Continue with trailing bytes.
|
||||
|
||||
# Byte copy, bytes are not swaped.
|
||||
# Four bytes for each loop, trailing bytes are copied later.
|
||||
scpy_byte_copy:
|
||||
subi r4,r4,1 #Move pointers.
|
||||
subi r3,r3,1
|
||||
srawi r8,r5,2 #numBytes / 4.
|
||||
rlwinm r5,r5,0,30,31 #Calculate number of trailing bytes.
|
||||
addi r8,r8,1 #Compensate loop counter.
|
||||
mtspr ctr,r8
|
||||
b scpy_bcopy0
|
||||
scpy_byte_loop:
|
||||
lbzu r7,1(r4)
|
||||
rlwinm r8,r7,8,16,23 #Shift left 8 times.
|
||||
stbu r7,1(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_bcopy3:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_bcopy2:
|
||||
lbzu r7,1(r4)
|
||||
rlwinm r8,r7,8,16,23 #Shift left 8 times.
|
||||
stbu r7,1(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_bcopy1:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r3)
|
||||
adde r6,r6,r8 #Add to checksum.
|
||||
scpy_bcopy0:
|
||||
bc 16,0,scpy_byte_loop
|
||||
|
||||
# Copy trailing bytes, byte swap is checked.
|
||||
scpy_trailing_bytes:
|
||||
mr r9,r12 #Copy swap flag.
|
||||
trailing_loop:
|
||||
cmpli cr0,r5,0 #Test loop counter.
|
||||
subi r5,r5,1
|
||||
beq- scpy_trailing_end
|
||||
cmpli cr0,r9,0
|
||||
lbzu r7,1(r4)
|
||||
stbu r7,1(r3)
|
||||
bne no_shift
|
||||
rlwinm r7,r7,8,16,23 #Shift left 8 times.
|
||||
no_shift:
|
||||
xori r9,r9,1 #Toggle flag.
|
||||
adde r6,r6,r7 #Add to checksum.
|
||||
b trailing_loop
|
||||
scpy_trailing_end:
|
||||
|
||||
scpy_end:
|
||||
cmpli cr0,r12,0 #Test swap flag.
|
||||
|
||||
# Convert checksum from 32 bit to 16 bit.
|
||||
|
||||
rlwinm r7,r6,16,16,31 #Extract high part of checksum.
|
||||
rlwinm r6,r6,0,16,31 #Truncate high part of checksum.
|
||||
adde r6,r6,r7 #High part + low part + carry.
|
||||
rlwinm r7,r6,16,16,31 #Extract carry from checksum.
|
||||
rlwinm r6,r6,0,16,31 #Truncate high part of checksum.
|
||||
add r3,r6,r7 #Add carry to low part.
|
||||
|
||||
# Check if bytes has been swaped, swap if needed.
|
||||
beqlr #Return if no swap.
|
||||
rlwinm r4,r3,24,24,31 #Swap bytes.
|
||||
rlwinm r3,r3,8,16,23
|
||||
or r3,r3,r4
|
||||
blr
|
||||
|
||||
.end
|
||||
|
||||
|
||||
#
|
||||
#############################################################################
|
||||
# END OF FILE
|
||||
#############################################################################
|
||||
#
|
||||
@@ -0,0 +1,409 @@
|
||||
#define _ASMLANGUAGE
|
||||
#include "vxWorks.h"
|
||||
#include "asm.h"
|
||||
#include "regs.h"
|
||||
.text
|
||||
.align 2
|
||||
|
||||
.globl ipcom_in_checksum_update2_asm
|
||||
ipcom_in_checksum_update2_asm:
|
||||
andi. r6,r3,0x2
|
||||
li r5,0
|
||||
beq+ 1f
|
||||
lhz r5,0(r3)
|
||||
addi r3,r3,2
|
||||
subi r4,r4,2
|
||||
1:
|
||||
andi. r6,r4,0xc
|
||||
srawi r7,r4,4
|
||||
cmpi cr1,r6,0x8
|
||||
addic r7,r7,1
|
||||
subi r3,r3,4
|
||||
mtspr 9,r7
|
||||
beq chk0
|
||||
bgt cr1,chk3
|
||||
blt cr1,chk1
|
||||
b chk2
|
||||
|
||||
chk_loop:
|
||||
lwzu r6,4(r3)
|
||||
adde r5,r5,r6
|
||||
|
||||
chk3:
|
||||
lwzu r7,4(r3)
|
||||
adde r5,r5,r7
|
||||
|
||||
chk2:
|
||||
lwzu r6,4(r3)
|
||||
adde r5,r5,r6
|
||||
|
||||
chk1:
|
||||
lwzu r7,4(r3)
|
||||
adde r5,r5,r7
|
||||
|
||||
chk0:
|
||||
bc 16,0,chk_loop
|
||||
|
||||
addi r3,r3,4
|
||||
andi. r7,r4,2
|
||||
beq+ no_halfword
|
||||
|
||||
lhz r6,0(r3)
|
||||
addi r3,r3,2
|
||||
adde r5,r5,r6
|
||||
|
||||
no_halfword:
|
||||
andi. r7,r4,1
|
||||
beq+ no_byte
|
||||
|
||||
lbz r6,0(r3)
|
||||
rlwinm r6,r6,8,16,23
|
||||
adde r5,r5,r6
|
||||
|
||||
no_byte:
|
||||
rlwinm r6,r5,16,16,31
|
||||
rlwinm r5,r5,0,16,31
|
||||
adde r5,r5,r6
|
||||
rlwinm r6,r5,16,16,31
|
||||
rlwinm r5,r5,0,16,31
|
||||
add r3,r5,r6
|
||||
blr
|
||||
|
||||
.globl ipcom_memcpy_asm
|
||||
ipcom_memcpy_asm:
|
||||
cmpli cr0,r5,17
|
||||
xor r8,r3,r4
|
||||
mr r6,r3
|
||||
blt- byte_copy
|
||||
|
||||
andi. r7,r8,1
|
||||
bne- byte_copy
|
||||
|
||||
andi. r7,r6,1
|
||||
beq+ check_hword_align
|
||||
|
||||
lbz r7,0(r4)
|
||||
subi r5,r5,1
|
||||
stb r7,0(r6)
|
||||
addi r4,r4,1
|
||||
addi r6,r6,1
|
||||
|
||||
check_hword_align:
|
||||
andi. r7,r8,2
|
||||
beq+ word_align
|
||||
|
||||
subi r4,r4,2
|
||||
subi r6,r6,2
|
||||
srawi r8,r5,4
|
||||
rlwinm. r5,r5,0,28,31
|
||||
mtspr 9,r8
|
||||
|
||||
hword_loop:
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r6)
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r6)
|
||||
bc 16,0,hword_loop
|
||||
|
||||
beqlr
|
||||
|
||||
addi r4,r4,1
|
||||
addi r6,r6,1
|
||||
b byte_copy_cont
|
||||
|
||||
word_align:
|
||||
andi. r7,r6,2
|
||||
beq- word_copy
|
||||
|
||||
lhz r7,0(r4)
|
||||
subi r5,r5,2
|
||||
sth r7,0(r6)
|
||||
subi r4,r4,2
|
||||
subi r6,r6,2
|
||||
b word_copy_cont
|
||||
|
||||
word_copy:
|
||||
subi r4,r4,4
|
||||
subi r6,r6,4
|
||||
|
||||
word_copy_cont:
|
||||
andi. r7,r5,0xc
|
||||
srawi r8,r5,4
|
||||
cmpi cr1,r7,0x8
|
||||
addi r8,r8,1
|
||||
mtspr 9,r8
|
||||
beq wcopy0
|
||||
bgt cr1,wcopy3
|
||||
blt cr1,wcopy1
|
||||
b wcopy2
|
||||
|
||||
word_loop:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r6)
|
||||
|
||||
wcopy3:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r6)
|
||||
|
||||
wcopy2:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r6)
|
||||
wcopy1:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r6)
|
||||
|
||||
wcopy0:
|
||||
bc 16,0,word_loop
|
||||
|
||||
rlwinm. r5,r5,0,30,31
|
||||
addi r4,r4,3
|
||||
addi r6,r6,3
|
||||
beqlr
|
||||
b byte_copy_cont
|
||||
|
||||
byte_copy:
|
||||
subi r4,r4,1
|
||||
subi r6,r6,1
|
||||
byte_copy_cont:
|
||||
andi. r7,r5,0x3
|
||||
srawi r8,r5,2
|
||||
cmpi cr1,r7,2
|
||||
addi r8,r8,1
|
||||
mtspr 9,r8
|
||||
beq bcopy0
|
||||
bgt cr1,bcopy3
|
||||
blt cr1,bcopy1
|
||||
b bcopy2
|
||||
|
||||
byte_loop:
|
||||
lbzu r7,1(r4)
|
||||
stbu r7,1(r6)
|
||||
|
||||
bcopy3:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r6)
|
||||
|
||||
bcopy2:
|
||||
lbzu r7,1(r4)
|
||||
stbu r7,1(r6)
|
||||
|
||||
bcopy1:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r6)
|
||||
|
||||
bcopy0:
|
||||
bc 16,0,byte_loop
|
||||
|
||||
blr
|
||||
|
||||
.globl ipcom_in_checksum_memcpy_asm
|
||||
ipcom_in_checksum_memcpy_asm:
|
||||
xor r6,r6,r6
|
||||
cmpli cr0,r5,17
|
||||
li r12,0
|
||||
xor r8,r3,r4
|
||||
addic r5,r5,0
|
||||
blt- scpy_byte_copy
|
||||
|
||||
andi. r7,r8,1
|
||||
bne- scpy_byte_copy
|
||||
|
||||
andi. r7,r3,1
|
||||
beq+ scpy_check_hword_align
|
||||
|
||||
lbz r7,0(r4)
|
||||
subi r5,r5,1
|
||||
li r12,1
|
||||
stb r7,0(r3)
|
||||
adde r6,r6,r7
|
||||
addi r4,r4,1
|
||||
addi r3,r3,1
|
||||
|
||||
scpy_check_hword_align:
|
||||
andi. r7,r8,2
|
||||
beq+ scpy_word_align
|
||||
|
||||
andi. r7,r5,0x6
|
||||
subi r4,r4,2
|
||||
subi r3,r3,2
|
||||
srawi r8,r5,3
|
||||
cmpi cr1,r7,0x4
|
||||
addi r8,r8,1
|
||||
mtspr 9,r8
|
||||
beq scpy_hwcopy0
|
||||
bgt cr1,scpy_hwcopy3
|
||||
blt cr1,scpy_hwcopy1
|
||||
b scpy_hwcopy2
|
||||
|
||||
scpy_hword_loop:
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r3)
|
||||
adde r6,r6,r7
|
||||
|
||||
scpy_hwcopy3:
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_hwcopy2:
|
||||
lhzu r7,2(r4)
|
||||
sthu r7,2(r3)
|
||||
adde r6,r6,r7
|
||||
|
||||
scpy_hwcopy1:
|
||||
lhzu r8,2(r4)
|
||||
sthu r8,2(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_hwcopy0:
|
||||
bc 16,0,scpy_hword_loop
|
||||
|
||||
rlwinm. r5,r5,0,31,31
|
||||
beq+ scpy_end
|
||||
|
||||
addi r4,r4,1
|
||||
addi r3,r3,1
|
||||
b scpy_trailing_bytes
|
||||
|
||||
scpy_word_align:
|
||||
andi. r7,r3,2
|
||||
beq- scpy_word_copy
|
||||
|
||||
lhz r7,0(r4)
|
||||
subi r5,r5,2
|
||||
sth r7,0(r3)
|
||||
adde r6,r6,r7
|
||||
subi r4,r4,2
|
||||
subi r3,r3,2
|
||||
b scpy_word_copy_cont
|
||||
|
||||
scpy_word_copy:
|
||||
subi r4,r4,4
|
||||
subi r3,r3,4
|
||||
|
||||
scpy_word_copy_cont:
|
||||
andi. r7,r5,0xc
|
||||
srawi r8,r5,4
|
||||
cmpi cr1,r7,0x8
|
||||
addi r8,r8,1
|
||||
mtspr 9,r8
|
||||
beq scpy_wcopy0
|
||||
bgt cr1,scpy_wcopy3
|
||||
blt cr1,scpy_wcopy1
|
||||
b scpy_wcopy2
|
||||
|
||||
scpy_word_loop:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r3)
|
||||
adde r6,r6,r7
|
||||
|
||||
scpy_wcopy3:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_wcopy2:
|
||||
lwzu r7,4(r4)
|
||||
stwu r7,4(r3)
|
||||
adde r6,r6,r7
|
||||
|
||||
scpy_wcopy1:
|
||||
lwzu r8,4(r4)
|
||||
stwu r8,4(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_wcopy0:
|
||||
bc 16,0,scpy_word_loop
|
||||
|
||||
rlwinm. r5,r5,0,30,31
|
||||
addi r4,r4,3
|
||||
addi r3,r3,3
|
||||
beq scpy_end
|
||||
b scpy_trailing_bytes
|
||||
|
||||
scpy_byte_copy:
|
||||
subi r4,r4,1
|
||||
subi r3,r3,1
|
||||
srawi r8,r5,2
|
||||
rlwinm r5,r5,0,30,31
|
||||
addi r8,r8,1
|
||||
mtspr 9,r8
|
||||
b scpy_bcopy0
|
||||
|
||||
scpy_byte_loop:
|
||||
lbzu r7,1(r4)
|
||||
rlwinm r8,r7,8,16,23
|
||||
stbu r7,1(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_bcopy3:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_bcopy2:
|
||||
lbzu r7,1(r4)
|
||||
rlwinm r8,r7,8,16,23
|
||||
stbu r7,1(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_bcopy1:
|
||||
lbzu r8,1(r4)
|
||||
stbu r8,1(r3)
|
||||
adde r6,r6,r8
|
||||
|
||||
scpy_bcopy0:
|
||||
bc 16,0,scpy_byte_loop
|
||||
|
||||
scpy_trailing_bytes:
|
||||
li r9,0
|
||||
|
||||
trailing_loop:
|
||||
cmpli cr0,r5,0
|
||||
subi r5,r5,1
|
||||
beq- scpy_trailing_end
|
||||
|
||||
cmpli cr0,r9,0
|
||||
lbzu r7,1(r4)
|
||||
stbu r7,1(r3)
|
||||
bne no_shift
|
||||
|
||||
rlwinm r7,r7,8,16,23
|
||||
|
||||
no_shift:
|
||||
xori r9,r9,1
|
||||
adde r6,r6,r7
|
||||
b trailing_loop
|
||||
|
||||
scpy_trailing_end:
|
||||
|
||||
scpy_end:
|
||||
cmpli cr0,r12,0
|
||||
rlwinm r7,r6,16,16,31
|
||||
rlwinm r6,r6,0,16,31
|
||||
adde r6,r6,r7
|
||||
rlwinm r7,r6,16,16,31
|
||||
rlwinm r6,r6,0,16,31
|
||||
add r3,r6,r7
|
||||
|
||||
beqlr
|
||||
rlwinm r4,r3,24,24,31
|
||||
rlwinm r3,r3,8,16,23
|
||||
or r3,r3,r4
|
||||
blr
|
||||
|
||||
.end
|
||||
|
||||
|
||||
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_arch.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/arch/src/ipcom_arch.c,v $
|
||||
* $Author: kenneth $ $Date: 2004-09-23 06:34:43 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#if defined(IP_PORT_INTEGRITY) && !defined(IP_TARGET_PPC)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_CPY_32_BITS_ALIGNED
|
||||
*===========================================================================
|
||||
* Description: Copies 32-bits of data where the source and destination
|
||||
* addresses both are aligned on a 32-bit boundary.
|
||||
*
|
||||
*/
|
||||
#define IPCOM_CPY_32_BITS_ALIGNED \
|
||||
data = *dst_u32++ = *src_u32++; \
|
||||
chksum += (Ip_u16) data + (data >> 16); \
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_CPY_32_BITS_UNALIGNED
|
||||
*===========================================================================
|
||||
* Description: Copies 32-bits of data where the source and destination
|
||||
* addresses cannot be aligned on a 32-bit boundary at the same
|
||||
* time. Data is read and written in 32-bit chunks at a 32-bit
|
||||
* boundary.
|
||||
*
|
||||
*/
|
||||
#ifdef IP_BIG_ENDIAN
|
||||
#define IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2) \
|
||||
data = src_data << shift1; \
|
||||
src_data = *src_u32++; \
|
||||
data = (src_data >> shift2) | data; \
|
||||
chksum += (Ip_u16) data; \
|
||||
*dst_u32++ = data; \
|
||||
chksum += (data >> 16);
|
||||
#else /* IP_LITTLE_ENDIAN */
|
||||
#define IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2) \
|
||||
data = src_data >> shift1; \
|
||||
src_data = *src_u32++; \
|
||||
data = (src_data << shift2) | data; \
|
||||
chksum += (Ip_u16) data; \
|
||||
*dst_u32++ = data; \
|
||||
chksum += (data >> 16);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_UNALIGNED_CPY_LOOP
|
||||
*===========================================================================
|
||||
* Description: Copies data as long as a full 32-bit word can be written.
|
||||
*
|
||||
*/
|
||||
#define IPCOM_UNALIGNED_CPY_LOOP(shift1, shift2) \
|
||||
i = (len - octet_unalignment) >> 5; \
|
||||
while (i--) \
|
||||
{ \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
} \
|
||||
i = ((len - octet_unalignment) & 0x1f) >> 2; \
|
||||
while (i--) \
|
||||
{ \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC void *
|
||||
ipcom_memcpy_asm(void *s1, const void *s2, Ip_size_t n);
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_update2_asm(void *pbuf, Ip_size_t bytes);
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_memcpy_asm(void *dst, void *src, Ip_size_t len);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memcpy_asm
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void *
|
||||
ipcom_memcpy_asm(void *s1, const void *s2, Ip_size_t n)
|
||||
{
|
||||
return memcpy(s1, s2, n);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_update2_asm
|
||||
*===========================================================================
|
||||
* Description: Computes the internet checksum (RFC 1071). NOTE
|
||||
* it does not compute the 1 complement checksum.
|
||||
* Parameters: pbuf and bytes.
|
||||
* Returns: A standard internet checksum..
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_update2_asm(void *pbuf, Ip_size_t bytes)
|
||||
{
|
||||
Ip_u32 nwords;
|
||||
Ip_u16 *buf;
|
||||
Ip_u32 sum;
|
||||
|
||||
buf = (Ip_u16 *) pbuf;
|
||||
sum = 0;
|
||||
|
||||
for (nwords = (Ip_u32)bytes >> 5; nwords > 0; nwords--)
|
||||
{
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
}
|
||||
for (nwords = (Ip_u32)(bytes & 0x1f) >> 1; nwords > 0; nwords--)
|
||||
sum += *buf++;
|
||||
|
||||
/* Add left-over byte, if any. */
|
||||
if (bytes & 0x01)
|
||||
sum += *buf & ip_htons(0xff00);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_memcpy_asm
|
||||
*===========================================================================
|
||||
* Description: Copies data and calculate the internet checksum at the same
|
||||
* time.
|
||||
* Parameters: dst - Destination buffer.
|
||||
* src - Source buffer.
|
||||
* len - Number of octets to copy.
|
||||
* Returns: The intermediate internet checksum, use
|
||||
* ipcom_in_checksum_finish() to get the actual checksum.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_memcpy_asm(void *dst, void *src, Ip_size_t len)
|
||||
{
|
||||
#if defined(IPBOUNDS) || defined(__BOUNDS_CHECKING_ON)
|
||||
(void)ipcom_memcpy(dst, src, len);
|
||||
return ipcom_in_checksum_update2_asm(dst, len);
|
||||
#else
|
||||
Ip_u8 *dst_u8;
|
||||
Ip_u8 *src_u8;
|
||||
Ip_u32 *dst_u32;
|
||||
Ip_u32 *src_u32;
|
||||
Ip_u32 data;
|
||||
Ip_u32 src_data;
|
||||
Ip_u32 chksum = 0;
|
||||
int i;
|
||||
int initial_octets;
|
||||
int octet_unalignment = 0;
|
||||
Ip_bool dst_addr_is_odd = (int) dst & 0x1;
|
||||
|
||||
initial_octets = IP_MIN(((-(int) dst) & 0x3), (int) len);
|
||||
if (initial_octets == 0)
|
||||
{
|
||||
dst_u32 = (Ip_u32 *) dst;
|
||||
src_u32 = (Ip_u32 *) src;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_u8 = (Ip_u8 *) dst;
|
||||
src_u8 = (Ip_u8 *) src;
|
||||
for (i = 0; i < initial_octets; ++i)
|
||||
{
|
||||
/* Copy initial octets (so that dst will be 32-bit aligned) */
|
||||
data = *dst_u8++ = *src_u8++;
|
||||
#ifdef IP_BIG_ENDIAN
|
||||
if ((i ^ dst_addr_is_odd) & 0x1)
|
||||
chksum += data;
|
||||
else
|
||||
chksum += data << 8;
|
||||
#else /* IP_LITTLE_ENDIAN */
|
||||
if ((i ^ dst_addr_is_odd) & 0x1)
|
||||
chksum += data << 8;
|
||||
else
|
||||
chksum += data;
|
||||
#endif
|
||||
}
|
||||
dst_u32 = (Ip_u32 *) dst_u8;
|
||||
src_u32 = (Ip_u32 *) src_u8;
|
||||
len -= initial_octets;
|
||||
}
|
||||
/* dst is now 32-bit aligned */
|
||||
|
||||
if (((int) dst_u32 & 0x3) == ((int) src_u32 & 0x3))
|
||||
{
|
||||
/* Both src and dst is now on an even 32-bit boundary */
|
||||
i = (len >> 5);
|
||||
while (i--)
|
||||
{
|
||||
/* Big main copy loop */
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
}
|
||||
|
||||
i = (len & 0x1f) >> 2;
|
||||
while (i--)
|
||||
{
|
||||
/* Small main copy loop */
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
}
|
||||
|
||||
len -= len & ~0x3;
|
||||
}
|
||||
else if (len >= 4)
|
||||
{
|
||||
/* dst and src cannot be aligned */
|
||||
octet_unalignment = (int) src_u32 & 0x3;
|
||||
src_u32 = (Ip_u32 *) ((Ip_u8 *) src_u32 - octet_unalignment);
|
||||
src_data = *src_u32++;
|
||||
/* src is now 32-bit aligned */
|
||||
|
||||
switch (octet_unalignment)
|
||||
{
|
||||
case 1:
|
||||
IPCOM_UNALIGNED_CPY_LOOP(8, 24);
|
||||
break;
|
||||
case 2:
|
||||
IPCOM_UNALIGNED_CPY_LOOP(16, 16);
|
||||
break;
|
||||
case 3:
|
||||
IPCOM_UNALIGNED_CPY_LOOP(24, 8);
|
||||
break;
|
||||
default:
|
||||
IP_PANIC();
|
||||
break;
|
||||
}
|
||||
--src_u32;
|
||||
len -= ((len - octet_unalignment) & ~0x3);
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
/* Copy data that cannot be written in 32-bit chunks */
|
||||
src_u8 = (Ip_u8 *) src_u32 + octet_unalignment;
|
||||
dst_u8 = (Ip_u8 *) dst_u32;
|
||||
for (i = 0; i < (int) len; ++i)
|
||||
{
|
||||
data = *dst_u8++ = *src_u8++;
|
||||
#ifdef IP_BIG_ENDIAN
|
||||
if (i & 0x1)
|
||||
chksum += data;
|
||||
else
|
||||
chksum += data << 8;
|
||||
#else /* IP_LITTLE_ENDIAN */
|
||||
if (i & 0x1)
|
||||
chksum += data << 8;
|
||||
else
|
||||
chksum += data;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (dst_addr_is_odd)
|
||||
{
|
||||
/* The checksum has the low and hi bytes swaped */
|
||||
return (((Ip_u8 *) &chksum)[0] << 8)
|
||||
+ ((Ip_u8 *) &chksum)[1]
|
||||
+ (((Ip_u8 *) &chksum)[2] << 8)
|
||||
+ ((Ip_u8 *) &chksum)[3];
|
||||
}
|
||||
|
||||
return chksum;
|
||||
#endif /* #if defined(IPBOUNDS) || defined(__BOUNDS_CHECKING_ON) */
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_arch_empty_file;
|
||||
#endif /* IP_PORT_INTEGRITY */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,537 @@
|
||||
/* 00comp_ipcom.cdf - IPCom Component configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2010,2012 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
|
||||
--------------------
|
||||
02a,13mar08,rjq Detach INCLUDE_SHELL from TELNETS and SSH
|
||||
01z,12nov22,j_y Added IPCOM_USER_SHELL_FUNCTION
|
||||
01y,12nov12,rjq Change the default user ID to be 0xFFFFFFFF.
|
||||
01x,02feb12,lzq Added INCLUDE_USE_WAITIF
|
||||
01w,19aug10,ggz Added SHA256 hash and salt support
|
||||
01v,08jun09,ggz Fix for defect WIND00167365
|
||||
01u,01may09,ggz Added hashing capability for ipcom auth
|
||||
01t,17apr09,rme Removed INCLUDE_USE_NATIVE_SHELL dependency on
|
||||
INCLUDE_SHELL_INTERP_CMD.
|
||||
01s,03Sep08,brg Added ipcom_drv_mux.o for custom ARP hook support.
|
||||
01r,10sep07,mze INCLUDE_IPCOM_FS_SELECTION changed to SELECT_IPCOM_FS
|
||||
01q,04jul07,rme Replaced INCLUDE_IPCOM_SHELL_SELECTION with FOLDER_SHELLS
|
||||
Also updated 00comp_ipnet_apps.cdf INCLUDE_IPTELNETS
|
||||
01p,07feb07,tkf Added INCLUDE_USE_NATIVE_SHELL dependency on
|
||||
INCLUDE_SHELL_INTERP_CMD.
|
||||
01o,29jan07,tkf Added INCLUDE_USE_NATIVE_SHELL and
|
||||
INCLUDE_IPCOM_SHELL_SELECTION. Also changed some component
|
||||
attributes of INCLUDE_USE_IPCOM_SHELL.
|
||||
01n,20jan07,tkf Remove dependency on INCLUDE_XBD_RAMDRV Not required (WIND00085813).
|
||||
01m,19jan07,tkf Add INCLUDE_IPCOM_USE_RAM_DISK (WIND00085813).
|
||||
01l,08jan07,kch Added ipcom_ipd_config.c configlette to INCLUDE_IPCOM.
|
||||
01k,08jan07,kch Removed duplicate ipcom_config.c configlette from
|
||||
INCLUDE_IPCOM_USE_AUTH.
|
||||
01j,07jan07,tkf Adjust INCLUDE_IPCOM_USE_VXSHELL_CMD component to accomodate
|
||||
changes in latest code drop.
|
||||
01i,13dec06,tkf INCLUDE_IPCOM_USE_VXSHELL_CMD.
|
||||
01h,23sep06,kch Moved INCLUDE_IPCOM_USE_AUTH_RADIUS to 02comp_ipnet_radius.cdf.
|
||||
01g,28aug06,kch Added SELECT_IPCOM_AUTHENTICATION to corrected IPCom
|
||||
authentication configuration support.
|
||||
01f,11aug06,tkf Remove INCLUDE_USE_IPCOM_SHELL dependency requirement on
|
||||
INCLUDE_IPTELNETS.
|
||||
01e,10aug06,kch Moved syslogd to 'IPNet Shell Commands' folder.
|
||||
01d,02jul06,kch Added ipcom_drv_eth.o module to INCLUDE_IPCOM component.
|
||||
01c,30jun06,dlk Added INCLUDE_IPCOM_USE_SYSLOGD.
|
||||
01b,25jun06,dlk Make INCLUDE_IPCOM require INCLUDE_SOCKLIB and
|
||||
INCLUDE_COMMON_NET. Specify initialization order for
|
||||
INCLUDE_IPCOM in 00init_usernetwork.cdf, not here.
|
||||
01a,22may06,kch created.
|
||||
*/
|
||||
|
||||
Component INCLUDE_IPCOM {
|
||||
NAME VxWorks IPCOM
|
||||
SYNOPSIS VxWorks IPCOM
|
||||
MODULES ipcom_vxworks.o ipcom_drv_eth.o ipcom_drv_mux.o
|
||||
CONFIGLETTES ipcom_config.c ipcom_ipd_config.c
|
||||
LINK_SYMS ipcom_register_dev_name_mapping
|
||||
INIT_RTN ipcom_create ();
|
||||
REQUIRES INCLUDE_IPCOM_USR
|
||||
CFG_PARAMS IPCOM_ENABLE_USER_SHELL \
|
||||
IPCOM_START_SHELL
|
||||
}
|
||||
|
||||
Parameter IPCOM_ENABLE_USER_SHELL {
|
||||
NAME Enable IPCOM user shell
|
||||
SYNOPSIS Enable IPCOM user shell
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
Parameter IPCOM_START_SHELL {
|
||||
NAME IPCOM user start shell function
|
||||
SYNOPSIS IPCOM user start shell function
|
||||
TYPE FUNCPTR
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_USE_AUTH {
|
||||
NAME Use Authentication
|
||||
SYNOPSIS Use Authentication
|
||||
MODULES ipcom_auth.o ipcom_auth_login.o
|
||||
REQUIRES INCLUDE_IPCOM_USR
|
||||
}
|
||||
|
||||
Component INCLUDE_CUSTOM_PW_HASH {
|
||||
NAME Use Custom Password Hash Function
|
||||
SYNOPSIS Use Custom Password Hash Function
|
||||
REQUIRES INCLUDE_IPCOM_USE_AUTH
|
||||
CFG_PARAMS IPCOM_AUTH_HASH_HOOK
|
||||
}
|
||||
|
||||
Selection SELECT_IPCOM_AUTHENTICATION {
|
||||
NAME IPCOM authentication configurations
|
||||
SYNOPSIS IPCOM authentication configurations
|
||||
COUNT 0-
|
||||
CHILDREN INCLUDE_IPCOM_AUTH_1 \
|
||||
INCLUDE_IPCOM_AUTH_2 \
|
||||
INCLUDE_IPCOM_AUTH_3 \
|
||||
INCLUDE_IPCOM_AUTH_4 \
|
||||
INCLUDE_IPCOM_AUTH_5 \
|
||||
INCLUDE_IPCOM_AUTH_6
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_AUTH_1 {
|
||||
NAME Auth configuration #1
|
||||
SYNOPSIS Auth configuration #1
|
||||
REQUIRES INCLUDE_IPCOM_USE_AUTH
|
||||
CFG_PARAMS AUTH_USER_NAME1 AUTH_USER_PASSWD1 AUTH_USER_PASSWD1_SALT \
|
||||
AUTH_USER_ID1 AUTH_USER_PASSWD1_HASH
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_AUTH_2 {
|
||||
NAME Auth configuration #2
|
||||
SYNOPSIS Auth configuration #2
|
||||
REQUIRES INCLUDE_IPCOM_USE_AUTH
|
||||
CFG_PARAMS AUTH_USER_NAME2 AUTH_USER_PASSWD2 AUTH_USER_PASSWD2_SALT \
|
||||
AUTH_USER_ID2 AUTH_USER_PASSWD2_HASH
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_AUTH_3 {
|
||||
NAME Auth configuration #3
|
||||
SYNOPSIS Auth configuration #3
|
||||
REQUIRES INCLUDE_IPCOM_USE_AUTH
|
||||
CFG_PARAMS AUTH_USER_NAME3 AUTH_USER_PASSWD3 AUTH_USER_PASSWD3_SALT \
|
||||
AUTH_USER_ID3 AUTH_USER_PASSWD3_HASH
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_AUTH_4 {
|
||||
NAME Auth configuration #4
|
||||
SYNOPSIS Auth configuration #4
|
||||
REQUIRES INCLUDE_IPCOM_USE_AUTH
|
||||
CFG_PARAMS AUTH_USER_NAME4 AUTH_USER_PASSWD4 AUTH_USER_PASSWD4_SALT \
|
||||
AUTH_USER_ID4 AUTH_USER_PASSWD4_HASH
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_AUTH_5 {
|
||||
NAME Auth configuration #5
|
||||
SYNOPSIS Auth configuration #5
|
||||
REQUIRES INCLUDE_IPCOM_USE_AUTH
|
||||
CFG_PARAMS AUTH_USER_NAME5 AUTH_USER_PASSWD5 AUTH_USER_PASSWD5_SALT \
|
||||
AUTH_USER_ID5 AUTH_USER_PASSWD5_HASH
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_AUTH_6 {
|
||||
NAME Auth configuration #6
|
||||
SYNOPSIS Auth configuration #6
|
||||
REQUIRES INCLUDE_IPCOM_USE_AUTH
|
||||
CFG_PARAMS AUTH_USER_NAME6 AUTH_USER_PASSWD6 AUTH_USER_PASSWD6_SALT \
|
||||
AUTH_USER_ID6 AUTH_USER_PASSWD6_HASH
|
||||
}
|
||||
|
||||
Component INCLUDE_USE_IPCOM_SHELL {
|
||||
NAME Uses IPCOM-specific shell
|
||||
SYNOPSIS Uses IPCOM-specific shell
|
||||
MODULES ipcom_shell.o
|
||||
LINK_SYMS ipcom_start_shell
|
||||
REQUIRES INCLUDE_IPCOM
|
||||
CFG_PARAMS IPCOM_SHELL_PROMPT
|
||||
}
|
||||
|
||||
Component INCLUDE_USE_NATIVE_SHELL {
|
||||
NAME Uses native VxWorks shell
|
||||
SYNOPSIS Uses native VxWorks shell
|
||||
MODULES ipcom_pshell.o
|
||||
LINK_SYMS ipcom_start_shell_native
|
||||
REQUIRES INCLUDE_IPCOM INCLUDE_SHELL INCLUDE_SHELL_INTERP_CMD
|
||||
CFG_PARAMS IPCOM_SHELL_PROMPT
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_USE_VXSHELL_CMD {
|
||||
NAME IPCOM VxShell Command
|
||||
SYNOPSIS IP shell command to enter the VxWorks shell. The command blocks \
|
||||
until the VxWorks shell exits.
|
||||
MODULES ipcom_cmd_vxshell.o
|
||||
LINK_SYMS ipcom_cmd_vxshell
|
||||
REQUIRES INCLUDE_SHELL
|
||||
}
|
||||
|
||||
Selection SELECT_IPCOM_SHELL {
|
||||
NAME Select the shell type to use
|
||||
SYNOPSIS Select the shell type to use
|
||||
COUNT 1-1
|
||||
CHILDREN INCLUDE_USE_IPCOM_SHELL \
|
||||
INCLUDE_USE_NATIVE_SHELL
|
||||
DEFAULTS INCLUDE_USE_NATIVE_SHELL
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_USE_RAM_DISK {
|
||||
NAME IPCOM RAM Disk Support
|
||||
SYNOPSIS Initialize VxWorks RAM Disk.
|
||||
MODULES ipcom_ramdisk.o
|
||||
LINK_SYMS vxfs_ramdisk_init
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_FS_IPCOM {
|
||||
NAME IPCOM uses IPCOM-specific file system
|
||||
SYNOPSIS IPCOM uses IPCOM-specific file system
|
||||
MODULES ipcom_file.o
|
||||
LINK_SYMS ipcom_file_proc_exit
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_FS_NATIVE {
|
||||
NAME IPCOM uses native VxWorks file system
|
||||
SYNOPSIS IPCOM uses native VxWorks file system
|
||||
REQUIRES INCLUDE_IPCOM_USE_RAM_DISK
|
||||
}
|
||||
|
||||
Selection SELECT_IPCOM_FS {
|
||||
NAME IPCOM File System
|
||||
SYNOPSIS Select the IPCOM File System Type to use
|
||||
COUNT 1-1
|
||||
CHILDREN INCLUDE_IPCOM_FS_NATIVE \
|
||||
INCLUDE_IPCOM_FS_IPCOM
|
||||
DEFAULTS INCLUDE_IPCOM_FS_NATIVE
|
||||
}
|
||||
|
||||
Component INCLUDE_IPTELNETS {
|
||||
NAME TELNET Server
|
||||
SYNOPSIS TELNET Server
|
||||
MODULES ipcom_telnet.o
|
||||
REQUIRES INCLUDE_IPCOM INCLUDE_IPNET
|
||||
_CHILDREN FOLDER_TELNET
|
||||
CONFIGLETTES ipcom_telnets_config.c
|
||||
CFG_PARAMS IPCOM_TELNET_PORT \
|
||||
IPCOM_TELNET_MAX_CLIENTS \
|
||||
IPCOM_TELNET_IDLE_TIMEOUT
|
||||
}
|
||||
|
||||
|
||||
Component INCLUDE_IPCOM_USR {
|
||||
NAME IPCOM user side functions
|
||||
SYNOPSIS IPCOM user side functions
|
||||
INIT_RTN ipcom_usr_create ();
|
||||
_CHILDREN FOLDER_NOT_VISIBLE
|
||||
}
|
||||
|
||||
|
||||
Component INCLUDE_USE_WAITIF {
|
||||
NAME Wait for an address available
|
||||
SYNOPSIS Wait for an address at VxWorks startup
|
||||
MODULES ipcom_waitif.o
|
||||
INIT_RTN ipcom_waitif_address ();
|
||||
REQUIRES INCLUDE_IPCOM
|
||||
_CHILDREN FOLDER_NET_CORE
|
||||
}
|
||||
|
||||
|
||||
/******************** Configuration Parameters *****************************/
|
||||
|
||||
/* INCLUDE_IPCOM_AUTH_1 configuration parameters */
|
||||
Parameter AUTH_USER_NAME1 {
|
||||
NAME User name #1
|
||||
SYNOPSIS User name
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD1 {
|
||||
NAME Password #1
|
||||
SYNOPSIS Password
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD1_SALT {
|
||||
NAME Password salt #1
|
||||
SYNOPSIS Password salt
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_ID1 {
|
||||
NAME Userid #1
|
||||
SYNOPSIS Userid. If userid is 0xFFFFFFFF then next available \
|
||||
user ID will automatically be allocated.
|
||||
TYPE uint
|
||||
DEFAULT 0xFFFFFFFF
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD1_HASH {
|
||||
NAME Password #1 format
|
||||
SYNOPSIS Use this parameter to specify the type of the entred password. \
|
||||
Set to TRUE if the password is hashed. Set to FALSE if the password \
|
||||
is in a cleartext format.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
/* INCLUDE_IPCOM_AUTH_2 configuration parameters */
|
||||
Parameter AUTH_USER_NAME2 {
|
||||
NAME User name #2
|
||||
SYNOPSIS User name
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD2 {
|
||||
NAME Password #2
|
||||
SYNOPSIS Password
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD2_SALT {
|
||||
NAME Password salt #2
|
||||
SYNOPSIS Password salt
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_ID2 {
|
||||
NAME Userid #2
|
||||
SYNOPSIS Userid. If userid is 0xFFFFFFFF then next available \
|
||||
user ID will automatically be allocated.
|
||||
TYPE uint
|
||||
DEFAULT 0xFFFFFFFF
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD2_HASH {
|
||||
NAME Password #2 format
|
||||
SYNOPSIS Use this parameter to specify the type of the entred password. \
|
||||
Set to TRUE if the password is hashed. Set to FALSE if the password \
|
||||
is in a cleartext format.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
/* INCLUDE_IPCOM_AUTH_3 configuration parameters */
|
||||
Parameter AUTH_USER_NAME3 {
|
||||
NAME User name #3
|
||||
SYNOPSIS User name
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD3 {
|
||||
NAME Password #3
|
||||
SYNOPSIS Password
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD3_SALT {
|
||||
NAME Password salt #3
|
||||
SYNOPSIS Password salt
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_ID3 {
|
||||
NAME Userid #3
|
||||
SYNOPSIS Userid. If userid is 0xFFFFFFFF then next available \
|
||||
user ID will automatically be allocated.
|
||||
TYPE uint
|
||||
DEFAULT 0xFFFFFFFF
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD3_HASH {
|
||||
NAME Password #3 format
|
||||
SYNOPSIS Use this parameter to specify the type of the entred password. \
|
||||
Set to TRUE if the password is hashed. Set to FALSE if the password \
|
||||
is in a cleartext format.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
/* INCLUDE_IPCOM_AUTH_4 configuration parameters */
|
||||
Parameter AUTH_USER_NAME4 {
|
||||
NAME User name #4
|
||||
SYNOPSIS User name
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD4 {
|
||||
NAME Password #4
|
||||
SYNOPSIS Password
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD4_SALT {
|
||||
NAME Password salt #4
|
||||
SYNOPSIS Password salt
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_ID4 {
|
||||
NAME Userid #4
|
||||
SYNOPSIS Userid. If userid is 0xFFFFFFFF then next available \
|
||||
user ID will automatically be allocated.
|
||||
TYPE uint
|
||||
DEFAULT 0xFFFFFFFF
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD4_HASH {
|
||||
NAME Password #4 format
|
||||
SYNOPSIS Use this parameter to specify the type of the entred password. \
|
||||
Set to TRUE if the password is hashed. Set to FALSE if the password \
|
||||
is in a cleartext format.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
/* INCLUDE_IPCOM_AUTH_5 configuration parameters */
|
||||
Parameter AUTH_USER_NAME5 {
|
||||
NAME User name #5
|
||||
SYNOPSIS User name
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD5 {
|
||||
NAME Password #5
|
||||
SYNOPSIS Password
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD5_SALT {
|
||||
NAME Password salt #5
|
||||
SYNOPSIS Password salt
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_ID5 {
|
||||
NAME Userid #5
|
||||
SYNOPSIS Userid. If userid is 0xFFFFFFFF then next available \
|
||||
user ID will automatically be allocated.
|
||||
TYPE uint
|
||||
DEFAULT 0xFFFFFFFF
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD5_HASH {
|
||||
NAME Password #5 format
|
||||
SYNOPSIS Use this parameter to specify the type of the entred password. \
|
||||
Set to TRUE if the password is hashed. Set to FALSE if the password \
|
||||
is in a cleartext format.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
/* INCLUDE_IPCOM_AUTH_6 configuration parameters */
|
||||
Parameter AUTH_USER_NAME6 {
|
||||
NAME User name #6
|
||||
SYNOPSIS User name
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD6 {
|
||||
NAME Password #6
|
||||
SYNOPSIS Password
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD6_SALT {
|
||||
NAME Password salt #6
|
||||
SYNOPSIS Password salt
|
||||
TYPE char *
|
||||
DEFAULT NULL
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_ID6 {
|
||||
NAME Userid #6
|
||||
SYNOPSIS Userid. If userid is 0xFFFFFFFF then next available \
|
||||
user ID will automatically be allocated.
|
||||
TYPE uint
|
||||
DEFAULT 0xFFFFFFFF
|
||||
}
|
||||
|
||||
Parameter AUTH_USER_PASSWD6_HASH {
|
||||
NAME Password #6 format
|
||||
SYNOPSIS Use this parameter to specify the type of the entred password. \
|
||||
Set to TRUE if the password is hashed. Set to FALSE if the password \
|
||||
is in a cleartext format.
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
Parameter IPCOM_AUTH_HASH_HOOK {
|
||||
NAME User defined hash routine
|
||||
SYNOPSIS Use this pointer to define a user defined hashing function. \
|
||||
The default function is ipcom_auth_default_hash_rtn, the \
|
||||
same function used when INCLUDE_CUSTOM_PW_HASH is not \
|
||||
included.
|
||||
TYPE Ipcom_auth_hash_hook
|
||||
DEFAULT ipcom_auth_default_hash_rtn
|
||||
}
|
||||
|
||||
/* INCLUDE_USE_IPCOM_SHELL configuration parameters */
|
||||
|
||||
Parameter IPCOM_SHELL_PROMPT {
|
||||
NAME IPCOM Shell Prompt
|
||||
SYNOPSIS The prompt displayed by the shell when it is waiting for \
|
||||
commands. Supported special characters are: \
|
||||
"\p" - shell process name \
|
||||
"\P" - shell process id \
|
||||
"\i" - the IP address of the target \
|
||||
"\w" - the current working directory \
|
||||
"\W" - the basename of the current working directory \
|
||||
"\V" - ipcom_getenv("VR")
|
||||
TYPE char *
|
||||
DEFAULT "\\i$\\w>"
|
||||
}
|
||||
|
||||
/* INCLUDE_IPTELNETS configuration parameters */
|
||||
Parameter IPCOM_TELNET_PORT {
|
||||
NAME IPCOM TELNET port
|
||||
SYNOPSIS IPCOM TELNET server port in host endian.
|
||||
TYPE char *
|
||||
DEFAULT "23"
|
||||
}
|
||||
|
||||
Parameter IPCOM_TELNET_MAX_CLIENTS {
|
||||
NAME Maximum number of simultaneous TELNET clients
|
||||
SYNOPSIS IPCOM_TELNET_MAX_CLIENTS controls the maximum number of simultaneous \
|
||||
telnet clients. If set to 0, the number is unlimited.
|
||||
TYPE char *
|
||||
DEFAULT "0"
|
||||
}
|
||||
|
||||
Parameter IPCOM_TELNET_IDLE_TIMEOUT {
|
||||
NAME Idle timeout for telnet client
|
||||
SYNOPSIS Idle timeout(in minutes) for telnet client. If no any input during \
|
||||
this period, the telnet client will be auto logout. If set to 0, the \
|
||||
telnet client won't be logout.
|
||||
TYPE char *
|
||||
DEFAULT "360"
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/* 01comp_sec_key_db.cdf - Secure Key DB configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2009 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
|
||||
--------------------
|
||||
*/
|
||||
|
||||
Folder KEY_DATABASE {
|
||||
NAME Key Database
|
||||
SYNOPSIS Key Database
|
||||
CHILDREN INCLUDE_IPCOM_USE_KEY_DB \
|
||||
INCLUDE_IPCRYPTO_USE_KEY_DB_EXAMPLE_KEYS \
|
||||
INCLUDE_IPCOM_KEY_DB_CMD
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_USE_KEY_DB {
|
||||
NAME IPCOM key database support
|
||||
SYNOPSIS The IPCOM key database stores keys in encrypted format. \
|
||||
Please note that the IPCOM_KEY_DB_KEY_ENCRYPTING_KEY parameter \
|
||||
must be explicitly set.
|
||||
MODULES ipcom_key_db.o
|
||||
LINK_SYMS ipcom_key_db_buf_get
|
||||
CFG_PARAMS IPCOM_KEY_DB_KEY_ENCRYPTING_KEY IPCOM_KEY_DB_FILE_ROOT
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCRYPTO_USE_KEY_DB_EXAMPLE_KEYS {
|
||||
NAME IPCOM key database example keys
|
||||
SYNOPSIS Example RSA and DSA keys to use for demos and testing. Must not be \
|
||||
used in deployed systems.
|
||||
REQUIRES INCLUDE_IPCOM_USE_KEY_DB
|
||||
}
|
||||
|
||||
Component INCLUDE_IPCOM_KEY_DB_CMD {
|
||||
NAME IPCOM key database shell command
|
||||
SYNOPSIS Shell command to manipulate the IPCOM key database.
|
||||
REQUIRES INCLUDE_IPCOM_USE_KEY_DB INCLUDE_IPCOM_SHELL_CMD
|
||||
}
|
||||
|
||||
Parameter IPCOM_KEY_DB_KEY_ENCRYPTING_KEY {
|
||||
NAME Key Encrypting Key
|
||||
SYNOPSIS Key used to encrypt keys in the IPCOM key database. \
|
||||
This parameter should be set to a random string of at least 40 characters, \
|
||||
containing both lower and upper case, numbers and special characters. \
|
||||
IPCOM_KEY_DB_KEY_ENCRYPTING_KEY has no default value on purpose. This \
|
||||
will force each customer to set a unique value.
|
||||
TYPE char *
|
||||
}
|
||||
|
||||
Parameter IPCOM_KEY_DB_FILE_ROOT {
|
||||
NAME Key DB file root
|
||||
SYNOPSIS Top directory where the key DB directory structure shall be created. \
|
||||
For backwards compatibility reasons the default \
|
||||
value is set to /ram. In deployed systems the key db file root would
|
||||
be set to a directory in a persistent file system, e.g. /flash
|
||||
TYPE char *
|
||||
DEFAULT "/ram"
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
This file contains updated descriptions for some vxWorks components
|
||||
defined in 00Forwarder.cdf. It updates those definitions with new ones needed
|
||||
to support the coprocessor abstraction.
|
||||
*/
|
||||
|
||||
|
||||
Component INCLUDE_P4080_VXB_FORWARDER {
|
||||
NAME P4080 VxBus Driver forwarder support
|
||||
SYNOPSIS Enables forwarding offload support. This is required when \
|
||||
libraries are built with IPCOM_USE_FORWARDER defined. This component \
|
||||
requires either the INCLUDE_P4080_VXB_END VxBus network driver.
|
||||
|
||||
CONFIGLETTES ipcom_config.c
|
||||
_CHILDREN FOLDER_DRIVERS
|
||||
|
||||
INIT_RTN ipcom_reserve_fw_cpu();
|
||||
_INIT_ORDER usrInit
|
||||
INIT_AFTER INCLUDE_BASE_KERNEL
|
||||
INIT_BEFORE INCLUDE_KERNEL
|
||||
LINK_SYMS ipcom_forwarder_create
|
||||
_DEFAULTS FOLDER_DRIVERS
|
||||
}
|
||||
|
||||
Component INCLUDE_P4080_FORWARDER_AMP_DATAPLANE {
|
||||
NAME P4080 S-AMP forwarder acceleration core
|
||||
SYNOPSIS Enable for a VB image that runs a forwarder acceleration \
|
||||
engine task in the P4080 supervised AMP system. Requires libaries built with \
|
||||
IPCOM_USE_FORWARDER, IPCOM_FORWARDER_AMP, and IPCOM_USE_P4080_FORWARDER \
|
||||
defined.
|
||||
|
||||
CONFIGLETTES ipcom_config.c
|
||||
_CHILDREN FOLDER_DRIVERS
|
||||
|
||||
INIT_RTN ipcom_forwarder_core_start();
|
||||
|
||||
_INIT_ORDER usrRoot
|
||||
INIT_BEFORE usrNetworkInit
|
||||
PROTOTYPE extern void ipcom_forwarder (void);
|
||||
LINK_SYMS ipcom_forwarder
|
||||
_DEFAULTS FOLDER_DRIVERS
|
||||
}
|
||||
|
||||
Parameter P4080_FORWARDER_CACHE_SIZE {
|
||||
NAME Forwarder flow cache size
|
||||
SYNOPSIS Number of entries in the FW cache. Allowed values are 256 \
|
||||
to 65536. This value is rounded upwards to the nearest power of 2; for \
|
||||
example, 4000 is rounded upwards to 4096.
|
||||
TYPE UINT
|
||||
_CFG_PARAMS INCLUDE_P4080_VXB_FORWARDER
|
||||
DEFAULT 4000
|
||||
}
|
||||
|
||||
Parameter P4080_FORWARDER_MTU {
|
||||
NAME Nominal MTU for forwarder-capable network ports (1500 or 9000)
|
||||
SYNOPSIS All network ports in the system that support forwarding \
|
||||
acceleration use this value as the nominal maximum MTU. \
|
||||
The value should be 1500 or 9000.
|
||||
TYPE UINT
|
||||
_CFG_PARAMS INCLUDE_P4080_VXB_FORWARDER
|
||||
DEFAULT 1500
|
||||
}
|
||||
|
||||
Parameter P4080_FORWARDER_NUMA_POOL_BASE {
|
||||
NAME Base Address of shared memory pool NUMA
|
||||
SYNOPSIS Base Address of the shared memory pool named NUMA \
|
||||
used among the forwarders.
|
||||
_CFG_PARAMS INCLUDE_P4080_VXB_FORWARDER INCLUDE_P4080_FORWARDER_AMP_DATAPLANE
|
||||
DEFAULT 0xFC000000
|
||||
}
|
||||
|
||||
Parameter P4080_FORWARDER_NUMA_POOL_SIZE {
|
||||
NAME Size of shared memory pool NUMA
|
||||
SYNOPSIS Base Address of the shared memory pool named NUMA \
|
||||
used among the forwarders.
|
||||
_CFG_PARAMS INCLUDE_P4080_VXB_FORWARDER INCLUDE_P4080_FORWARDER_AMP_DATAPLANE
|
||||
DEFAULT 0x00800000
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.4 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/config/common.vxconfig,v $
|
||||
# $Author: rboden $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPFORWARDER
|
||||
config SUPPORTS_FORWARDER
|
||||
bool
|
||||
default y
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,806 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_config.h,v $ $Revision: 1.211.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/config/ipcom_config.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:13 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_CONFIG_H
|
||||
#define IPCOM_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Generic IPCOM Configuration. Also see config/ipcom_config.c.
|
||||
*
|
||||
* Also see port/<rtos>/config/ipcom_pconfig.h for RTOS port specific config.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 PORT CONFIGURATION
|
||||
****************************************************************************
|
||||
* Port configuration reside in port/<rtos>/config/ipcom_pconfig.h.
|
||||
* Note:
|
||||
* Do not EDIT the macros in this section, they only reside here because
|
||||
* they must be defined before including ipcom_pconfig.h
|
||||
*/
|
||||
|
||||
/* Valid IPCOM_USE_FILE, IPCOM_USE_SOCK, IPCOM_USE_SHELL #if values: */
|
||||
#define IPCOM_FILE_NONE 1
|
||||
#define IPCOM_FILE_IPCOM 2
|
||||
#define IPCOM_FILE_NATIVE 3
|
||||
|
||||
#define IPCOM_SOCK_IPLITE 1
|
||||
#define IPCOM_SOCK_IPNET 2
|
||||
#define IPCOM_SOCK_IPCOM 3 /* IPNET or IPLITE */
|
||||
#define IPCOM_SOCK_NATIVE 4
|
||||
#define IPCOM_SOCK_NONE 5
|
||||
|
||||
#define IPCOM_SHELL_NONE 1
|
||||
#define IPCOM_SHELL_MINI 2
|
||||
#define IPCOM_SHELL_IPCOM 3
|
||||
#define IPCOM_SHELL_NATIVE 4
|
||||
|
||||
#define IPCOM_NETIF_IPCOM 1
|
||||
#define IPCOM_NETIF_NATIVE 2
|
||||
|
||||
#define IPCOM_ENV_NONE 1
|
||||
#define IPCOM_ENV_IPCOM 2
|
||||
#define IPCOM_ENV_NATIVE 3
|
||||
|
||||
/* Port specific configuration. */
|
||||
#include "ipcom_pconfig.h"
|
||||
|
||||
#ifndef IPCOM_NO_SA_LEN
|
||||
#define IPCOM_USE_SA_LEN 1
|
||||
#endif
|
||||
|
||||
#ifndef IPCOM_USE_FILE
|
||||
#define IPCOM_USE_FILE IPCOM_FILE_NATIVE
|
||||
#endif
|
||||
#if defined(IP_SIZE) && !defined(IPCRYPTO) && !defined(IPTFTPC) && !defined(IPTFTPS) && !defined(IPFTPC) && !defined(IPFTPS)
|
||||
#undef IPCOM_USE_FILE
|
||||
#define IPCOM_USE_FILE IPCOM_FILE_NONE
|
||||
#endif
|
||||
|
||||
#ifndef IPCOM_USE_SOCK
|
||||
#if defined(IPNET) && defined(IPLITE)
|
||||
#error cant_define_IPNET_and_IPLITE___choose_one
|
||||
#elif defined(IPNET)
|
||||
#define IPCOM_USE_SOCK IPCOM_SOCK_IPNET
|
||||
#elif defined(IPLITE)
|
||||
#define IPCOM_USE_SOCK IPCOM_SOCK_IPLITE
|
||||
#elif defined(IP_PORT_OSE5)
|
||||
#define IPCOM_USE_SOCK IPCOM_SOCK_IPCOM
|
||||
#else
|
||||
#define IPCOM_USE_SOCK IPCOM_SOCK_NATIVE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef IP_PORT_LKM
|
||||
#define IPCOM_USE_SHELL IPCOM_SHELL_NONE
|
||||
#else
|
||||
/* Remove shell if IPBUILD=size and IPSSH is not included in the build */
|
||||
#if defined(IP_SIZE) && !defined(IPSSH)
|
||||
#ifdef IPCOM_USE_SHELL
|
||||
#undef IPCOM_USE_SHELL
|
||||
#endif
|
||||
#define IPCOM_USE_SHELL IPCOM_SHELL_NONE
|
||||
#endif /* defined(IP_SIZE) && !defined(IPSSH) */
|
||||
#ifndef IPCOM_USE_SHELL
|
||||
#define IPCOM_USE_SHELL IPCOM_SHELL_IPCOM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 FEATURES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* #define IP_ASSERT */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IP_LW_DEBUG
|
||||
*===========================================================================
|
||||
* Define to include Light Weight debug features
|
||||
#define IP_LW_DEBUG
|
||||
*/
|
||||
|
||||
#ifdef IP_LW_DEBUG
|
||||
#define IPCOM_FWD_PKT_POOL_DEBUG
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_NAE_HW_TX_CHKSUM
|
||||
*===========================================================================
|
||||
* Define when hardware has the ability to calculate TCP chksum on transmit
|
||||
#define IPCOM_NAE_HW_TX_CHKSUM
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#if defined(IPCOM_NAE_HW_TX_CHKSUM) && !defined(IPCOM_FORWARDER_NAE)
|
||||
#define IPCOM_FORWARDER_NAE
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_MAX_NAE
|
||||
*===========================================================================
|
||||
* Maximum number of NAE:s that is supported.
|
||||
*/
|
||||
#ifndef IPCOM_MAX_NAE
|
||||
#define IPCOM_MAX_NAE 8
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_NAE_UTIL
|
||||
*===========================================================================
|
||||
* Define to include nae utility functions:
|
||||
* nae_ping
|
||||
* nae_util
|
||||
* nae_topple
|
||||
* nae_enable
|
||||
* nae_disable
|
||||
*/
|
||||
#ifndef IP_PORT_UNIX
|
||||
#define IPCOM_NAE_UTIL
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_NAE_RAMLOG
|
||||
*===========================================================================
|
||||
* Define to enable "per NAE" ramlog. Use 'nae_ramlog <nae id>' to display log
|
||||
#define IPCOM_NAE_RAMLOG
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* MIPC_POW_DEBUG
|
||||
*===========================================================================
|
||||
* Define to enable MIPC over Cavium POW debug printouts
|
||||
#define MIPC_POW_DEBUG
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_MIPS_CALLSTACK
|
||||
*===========================================================================
|
||||
* Define to enable callstack evaluator for MIPS targets
|
||||
#define IPCOM_MIPS_CALLSTACK
|
||||
*/
|
||||
|
||||
|
||||
/* Automatically define IPCOM_NAE_DEBUG if sub-defines are set */
|
||||
#if defined(IPCOM_NAE_RAMLOG) || defined(IPCOM_MIPS_CALLSTACK)
|
||||
#ifndef IPCOM_NAE_DEBUG
|
||||
#define IPCOM_NAE_DEBUG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_FORWARDER
|
||||
*===========================================================================
|
||||
* Define to include Multi-core polling forwarders.
|
||||
#define IPCOM_USE_FORWARDER
|
||||
*/
|
||||
|
||||
/* Enable automatically if a forwarder type's been defined */
|
||||
#if defined(IPCOM_FORWARDER_NAE) || defined(IPCOM_FORWARDER_AMP) || defined(IPCOM_FORWARDER_SMP)
|
||||
#define IPCOM_USE_FORWARDER
|
||||
#define IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_FORWARDER_VLAN
|
||||
*===========================================================================
|
||||
* Define to include VLAN (Virtual LAN) support for Multi-core polling forwarders
|
||||
#define IPCOM_USE_FORWARDER_VLAN
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_FORWARDER_VLAN_STACKING
|
||||
*===========================================================================
|
||||
* Define to include VLAN stacking support for Multi-core polling forwarders
|
||||
#define IPCOM_USE_FORWARDER_VLAN_STACKING
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_COMPONENT_VLAN_STACKING_FORWARDER
|
||||
#define IPCOM_USE_FORWARDER_VLAN_STACKING
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* SVLAN_SC_FWD_TABLE
|
||||
*===========================================================================
|
||||
* Define to enable establishing fast forward table on a SC VLAN port
|
||||
#define SVLAN_SC_FWD_TABLE
|
||||
*/
|
||||
#ifdef IPCOM_USE_FORWARDER_VLAN_STACKING
|
||||
#define SVLAN_SC_FWD_TABLE
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
*===========================================================================
|
||||
* Define to use ways in the forwarding cache.
|
||||
*
|
||||
* Cache ways are used to handle collisions, i.e. when two or more flows use
|
||||
* the same cache entry. When more than one cache way is configured there are
|
||||
* alternative entries for colliding flows. Three definitions control how
|
||||
* cache ways are used. Only one of these should typically be defined.
|
||||
*
|
||||
* IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
* When defined 6 consecutive cache entries are avalaible to colliding flows
|
||||
* This works for most application. The other defines are available for
|
||||
* experimental use only.
|
||||
*
|
||||
* IPCOM_FORWARDER_CACHE_WAYS
|
||||
* Define when more or less entries should be available to colliding flows.
|
||||
*
|
||||
* IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT
|
||||
* A variant of cache ways is called "true cache ways". This reserves a number
|
||||
* of cache entries for a set of flows. This is just a variant the would potentially
|
||||
* allow a larger forwarding cache.
|
||||
|
||||
Define one of the three below to use cache ways
|
||||
#define IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#define IPCOM_FORWARDER_CACHE_WAYS (4)
|
||||
#define IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT (2)
|
||||
|
||||
Define this to use upper bits rather than lower bits (experimental use only)
|
||||
#define IPCOM_FORWARDER_USE_UPPER_TAG_BITS
|
||||
*/
|
||||
|
||||
/* #define IPCOM_USE_FORWARDER_CACHE_WAYS */
|
||||
/* #define IPCOM_FORWARDER_CACHE_WAYS (3) */
|
||||
/* #define IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT (2) */
|
||||
|
||||
/* FIXME:
|
||||
- Move parts of this to autoconf?
|
||||
- Move _WRS_CONFIG switch to port/vxworks?
|
||||
*/
|
||||
|
||||
#if defined(IPCOM_FORWARDER_CACHE_WAYS) && defined(IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT)
|
||||
#if IPCOM_FORWARDER_CACHE_WAYS != (1<<IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT)
|
||||
#error "IPCOM_FORWARDER_CACHE_WAYS != (1<<IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT)"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(IPCOM_USE_FORWARDER_CACHE_WAYS) && !defined(IPCOM_FORWARDER_CACHE_WAYS)
|
||||
#define IPCOM_FORWARDER_CACHE_WAYS (6)
|
||||
#endif
|
||||
|
||||
#if defined(IPCOM_FORWARDER_CACHE_WAYS) && !defined(IPCOM_USE_FORWARDER_CACHE_WAYS)
|
||||
#define IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#endif
|
||||
|
||||
#ifndef IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT
|
||||
#define IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT (0)
|
||||
#endif
|
||||
|
||||
#if IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT > 0
|
||||
#ifndef IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#define IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#undef IPCOM_FORWARDER_CACHE_WAYS
|
||||
#define IPCOM_FORWARDER_CACHE_WAYS (1 << IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define IPCOM_FORWARDER_TRUE_CACHE_WAYS (1 << IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT)
|
||||
|
||||
/* The multi-core polling forwarders are supported only in MSP installations */
|
||||
#if !defined (IPNET_MSP_DISTRIBUTION)
|
||||
#undef IPCOM_USE_FORWARDER
|
||||
#undef IPCOM_USE_FORWARDER_VLAN
|
||||
#undef IPCOM_USE_FORWARDER_IPSEC
|
||||
#undef IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#undef IPCOM_USE_FORWARDER_VLAN_STACKING
|
||||
#endif
|
||||
|
||||
#ifndef IPCOM_USE_FORWARDER
|
||||
#if defined(IPCOM_USE_FORWARDER_VLAN) || \
|
||||
defined(IPCOM_USE_FORWARDER_IPSEC) || \
|
||||
defined(IPCOM_USE_FORWARDER_CACHE_WAYS) || \
|
||||
defined(IPCOM_USE_FORWARDER_VLAN_STACKING)
|
||||
#define IPCOM_USE_FORWARDER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_USE_FORWARDER
|
||||
|
||||
#if defined(IP_PORT_VXWORKS)
|
||||
#if defined (__i386) || defined (__386)
|
||||
#define IPCOM_USE_NEHALEM_FORWARDER
|
||||
#define IPCOM_USE_NEHALEM_HYPERTHREAD
|
||||
|
||||
/* Use a common transmit routine for both forwarder and NAE */
|
||||
#define ipcom_forwarder_tx_fw ipcom_forwarder_tx
|
||||
|
||||
/* The selective invalidation mechanism doesn't support VLAN forwarding */
|
||||
#ifndef IPCOM_USE_FORWARDER_VLAN
|
||||
#define IPCOM_FORWARDER_SELECTIVE_INVAL
|
||||
#endif
|
||||
|
||||
#elif defined(_WRS_MIPS_N32_ABI)
|
||||
#define IPCOM_USE_OCTEON_FORWARDER
|
||||
|
||||
#else
|
||||
/* else, assume p4080 */
|
||||
#define IPCOM_USE_P4080_FORWARDER
|
||||
#define IPCOM_PORTABLE_IPC_SPINLOCK
|
||||
#endif /* defined (__i386) || defined (__386) */
|
||||
|
||||
#endif /* defined(IPCOM_PORT_VXWORKS) */
|
||||
|
||||
/*
|
||||
* For now, we assume an AMP forwarder in uniprocessor builds,
|
||||
* and a non-AMP forwarder in SMP builds.
|
||||
*/
|
||||
#if !defined(IPCOM_FORWARDER_SMP) && !defined(IPCOM_FORWARDER_AMP) && !defined(IPCOM_FORWARDER_NAE)
|
||||
#ifdef IPCOM_USE_SMP
|
||||
#define IPCOM_FORWARDER_SMP
|
||||
#else /* IPCOM_USE_SMP */
|
||||
#define IPCOM_FORWARDER_AMP
|
||||
#endif /* IPCOM_USE_SMP */
|
||||
#endif /* !defined(IPCOM_FORWARDER_SMP) && !defined(IPCOM_FORWARDER_AMP) && !defined(IPCOM_FORWARDER_NAE) */
|
||||
|
||||
#if defined(IPCOM_USE_NEHALEM_FORWARDER) || defined(IPCOM_USE_P4080_FORWARDER)
|
||||
#define IPCOM_FORWARDER_AMP
|
||||
#endif
|
||||
|
||||
|
||||
#define IPCOM_USE_HW_CHECKSUM_TX_DISABLED
|
||||
|
||||
#ifndef IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#define IPCOM_USE_FORWARDER_CACHE_WAYS
|
||||
#define IPCOM_FORWARDER_CACHE_WAYS (6)
|
||||
#define IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT (0)
|
||||
#define IPCOM_FORWARDER_TRUE_CACHE_WAYS (1 << IPCOM_FORWARDER_TRUE_CACHE_WAYS_SHIFT)
|
||||
#endif /* IPCOM_USE_FORWARDER_CACHE_WAYS */
|
||||
|
||||
#endif /* IPCOM_USE_FORWARDER */
|
||||
|
||||
#ifdef IPCOM_USE_FORWARDER
|
||||
/* #define IPCOM_USE_STANDARD_MIPC */
|
||||
#endif /* IPCOM_USE_FORWARDER */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_NAE_MULTICAST_MULTISEG
|
||||
*===========================================================================
|
||||
* Define to include multi-segment multi-port packet transmission on
|
||||
* Intel Nehalem/Westmere forwarder
|
||||
#define IPCOM_NAE_MULTICAST_MULTISEG
|
||||
*/
|
||||
#if defined(IPCOM_USE_FORWARDER_VLAN_STACKING) && defined(IPCOM_USE_NEHALEM_FORWARDER)
|
||||
#define IPCOM_NAE_MULTICAST_MULTISEG
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_FLOAT
|
||||
*===========================================================================
|
||||
* Define if want to support floating point and math operations.
|
||||
*/
|
||||
#if defined(IPSSL) || \
|
||||
defined(IPCRYPTO) || \
|
||||
defined(IPSSLPROXY) || \
|
||||
defined(IPIKE) || \
|
||||
defined(IPNTP) || \
|
||||
defined(IPNGC) || \
|
||||
defined(IPNETSNMP) || \
|
||||
defined(IPNETPERF) || \
|
||||
defined(ZEBOS)
|
||||
#define IPCOM_USE_FLOAT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_TIME
|
||||
*===========================================================================
|
||||
* Define if your RTOS port has implemented port/<rtos>/src/ipcom_time.c.
|
||||
*/
|
||||
#define IPCOM_USE_TIME
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_INET
|
||||
*===========================================================================
|
||||
* Define if your stack supports IPv4 and you want IPCOM IPv4 support.
|
||||
*/
|
||||
#ifndef IPCOM_EXCLUDE_INET
|
||||
#define IPCOM_USE_INET
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_INET6
|
||||
*===========================================================================
|
||||
* Define if your stack supports IPv6 and you want IPCOM IPv6 support.
|
||||
* Note: IPNET and IPLITE set this define in the makefile if IPv6 is
|
||||
* included in the release (e.g. see ipnet2/make/ipnet6.mk)
|
||||
*
|
||||
*/
|
||||
#if defined(IP_PORT_UNIX) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE \
|
||||
&& defined(IP_PORT_LINUX)
|
||||
#define IPCOM_USE_INET6
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_SYSVAR
|
||||
*===========================================================================
|
||||
* Define for system variables.
|
||||
*/
|
||||
#define IPCOM_USE_SYSVAR
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_MD5
|
||||
*===========================================================================
|
||||
* Define for MD5 support to IPRIP, IPTCP, IPPPP and IPNET.
|
||||
*/
|
||||
#ifndef IP_PORT_LKM
|
||||
# if defined(IPCRYPTO) || defined(IPMCRYPTO) || \
|
||||
(defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65) || \
|
||||
defined(IP_PORT_OSE5)
|
||||
# define IPCOM_USE_MD5
|
||||
# endif
|
||||
#endif /* #ifndef IP_PORT_LKM */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_MIB2
|
||||
*===========================================================================
|
||||
* Define for mib-2 support
|
||||
#define IPCOM_USE_MIB2
|
||||
*/
|
||||
#if defined(VXCOMPAT) || (defined(IPSNMP) || defined(IPEMANATE) || defined(WRSNMP)) && (defined(IPNET) || defined(IPLITE))
|
||||
#define IPCOM_USE_MIB2
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
* IPCOM_USE_MIB2_NEW
|
||||
*===========================================================================
|
||||
* Define to include support for the new IP version independent MIBs:
|
||||
* RFC4022, RFC4113, RFC4292 and RFC4293
|
||||
#define IPCOM_USE_MIB2_NEW
|
||||
*/
|
||||
#if defined(VXCOMPAT) || defined(WRSNMP) && defined(IPNET)
|
||||
#define IPCOM_USE_MIB2_NEW
|
||||
#endif
|
||||
|
||||
/* IPCOM_USE_MIB2_NEW requires IPCOM_USE_MIB2 */
|
||||
#if defined(IPCOM_USE_MIB2_NEW) && !defined(IPCOM_USE_MIB2)
|
||||
#undef IPCOM_USE_MIB2_NEW
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_MIB2_CMD
|
||||
*===========================================================================
|
||||
* Define to include MIB-2 test command
|
||||
*/
|
||||
#ifdef IPCOM_USE_MIB2_NEW
|
||||
#define IPCOM_USE_MIB2_CMD
|
||||
#endif
|
||||
|
||||
/* IPCOM_USE_MIB2_CMD requires IPCOM_USE_MIB2_NEW */
|
||||
#if defined(IPCOM_USE_MIB2_CMD) && !defined(IPCOM_USE_MIB2_NEW)
|
||||
#undef IPCOM_USE_MIB2_CMD
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_SMPTEST_CMD
|
||||
*===========================================================================
|
||||
* Define to include SMP test command
|
||||
#define IPCOM_USE_SMPTEST_CMD
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_VR_MAX
|
||||
*===========================================================================
|
||||
* Maximum number of virtualized entries, e.g. sysvars, routes etc.
|
||||
* Not relevant on the LKM port.
|
||||
*/
|
||||
#if defined(_WRS_CONFIG_COMPONENT_VIRTUAL_ROUTER) || !defined(IP_PORT_VXWORKS)
|
||||
#define IPCOM_VR_MAX 8
|
||||
#else
|
||||
#define IPCOM_VR_MAX 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_ENV
|
||||
*===========================================================================
|
||||
* Define for process specific environment variables. If set to IPCOM_ENV_NONE,
|
||||
* environment variables are implemented using sysvars, i.e. global.
|
||||
*/
|
||||
#if !defined(IPCOM_USE_ENV)
|
||||
#if defined(IP_PORT_VXWORKS) || defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
#define IPCOM_USE_ENV IPCOM_ENV_NATIVE
|
||||
#else
|
||||
#define IPCOM_USE_ENV IPCOM_ENV_IPCOM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_KEY_DB
|
||||
*===========================================================================
|
||||
* Define to enable a key database that provides basic protection for public
|
||||
* keys and pre-shared keys.
|
||||
*/
|
||||
#if defined(IPCRYPTO) || defined(IPMCRYPTO)
|
||||
# define IPCOM_USE_KEY_DB
|
||||
# define IPCOM_USE_KEY_DB_CMD
|
||||
# define IPCOM_USE_KEY_DB_CMD_VERIFY
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 SERVICES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM EGD
|
||||
*===========================================================================
|
||||
* Interpeak Entropy Gathering Daemon used for ipcom_random().
|
||||
* If not defined, a simplistic pseudo-random routine is used
|
||||
* to generate the random numbers in ipcom_random().
|
||||
* For code, see ipcom/port/src/ipcom_random.c
|
||||
*/
|
||||
#if defined(IPSSL) || defined(IPCRYPTO) || defined(IPMCRYPTO)
|
||||
#define IPCOM_USE_EGD
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_SYSLOG_PRIO_DEFAULT
|
||||
*===========================================================================
|
||||
* Initial syslog system build-time priority. Changing these levels change
|
||||
* the compiled in log level for all products.
|
||||
*/
|
||||
#if defined(_WRS_CONFIG_IPCOM_DEFAULT_SYSLOG_PRIORITY)
|
||||
# define IPCOM_SYSLOG_PRIO_DEFAULT _WRS_CONFIG_IPCOM_DEFAULT_SYSLOG_PRIORITY
|
||||
#elif defined(IP_DEBUG)
|
||||
# define IPCOM_SYSLOG_PRIO_DEFAULT 7 /* IPCOM_LOG_DEBUG2 */
|
||||
#else
|
||||
# define IPCOM_SYSLOG_PRIO_DEFAULT 3 /* IPCOM_LOG_WARNING */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
*===========================================================================
|
||||
* Initial IPCOM syslog build-time priority.
|
||||
*/
|
||||
#define IPCOM_SYSLOG_IPCOM_PRIORITY IPCOM_SYSLOG_PRIO_DEFAULT
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_LOG_USE_OF_DEPRECATED_API
|
||||
*===========================================================================
|
||||
* Log use of deprecated APIs. Only first call will be logged.
|
||||
*/
|
||||
#ifdef IP_DEBUG
|
||||
#define IPCOM_LOG_USE_OF_DEPRECATED_API
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM SYSLOG
|
||||
*===========================================================================
|
||||
* Define to enable use of syslogs using the syslog daemon.
|
||||
*/
|
||||
#if !defined(IPCOM_SYSLOG) \
|
||||
&& !defined(IP_PORT_OSECK) \
|
||||
&& !defined(IP_PORT_LKM) \
|
||||
&& !defined(IP_SIZE) \
|
||||
&& !defined(IPBASIC) \
|
||||
&& !defined(IPCOM_FORWARDER_NAE) \
|
||||
&& !defined(IPCOM_FORWARDER_AMP) \
|
||||
&& !defined(IPLITE)
|
||||
#define IPCOM_USE_SYSLOG
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM AUTH
|
||||
*===========================================================================
|
||||
* Enable IPCOM authentication - ipcom_auth.h
|
||||
*/
|
||||
#if defined(IPSSH) /* So IPSSH can use the default AUTH function */ \
|
||||
|| (!defined(IP_PORT_OSECK) \
|
||||
&& !defined(IP_PORT_LKM) \
|
||||
&& !defined(IPBASIC) \
|
||||
&& !defined(IPCOM_FORWARDER_NAE) \
|
||||
&& !defined(IPCOM_FORWARDER_AMP))
|
||||
#define IPCOM_USE_AUTH
|
||||
#endif
|
||||
|
||||
/* Use RADIUS client to lookup user & password. */
|
||||
#if defined(IPCOM_USE_AUTH) && defined(IPRADIUS) && (defined(IPNET) || defined(IPLITE))
|
||||
#define IPCOM_USE_AUTH_RADIUS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM TELNET
|
||||
*===========================================================================
|
||||
* IPCOM telnet server. Also see ipcom_telnets_config.c for telnet port.
|
||||
*/
|
||||
|
||||
/* Define to start the interpeak telnet server. */
|
||||
#if (IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM || IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE) \
|
||||
&& (defined(IPTCP) || IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE || defined(IPLITE)) \
|
||||
&& !defined(IP_PORT_OSE5) \
|
||||
&& !defined(OSE_REFSYS) \
|
||||
&& !defined(IP_PORT_INTEGRITY)
|
||||
#define IPTELNETS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM FILE
|
||||
*===========================================================================
|
||||
* Interpeak memory file system.
|
||||
*/
|
||||
|
||||
/* Maximum number of open files with IPCOM memory filesystem: ipcom_file.c.
|
||||
* (used if compiled with IPCOM_USE_FILE == IPCOM_FILE_IPCOM
|
||||
* Note: the actual max is three lower due to unused 0-2 slots.
|
||||
*/
|
||||
#define IPCOM_FILE_FD_SETSIZE 64
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_DRV
|
||||
*===========================================================================
|
||||
* Generic IPCOM PPP and Ethernet driver configuration.
|
||||
*/
|
||||
|
||||
/* Default PPP baudrate in ipcom_drv_ppp.c used by IPNET/IPLITE. */
|
||||
#define IPCOM_DRV_PPP_BAUDRATE 38400
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_GETLINE_HISTORY_FILENAME
|
||||
*===========================================================================
|
||||
* Filename where the IPCOM getline will save the history when an IPCOM
|
||||
* shell exits.
|
||||
*/
|
||||
#define IPCOM_GETLINE_HISTORY_FILENAME ".ipcom_getline_history"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 AUTO configuration
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_autoconf.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 MORE configuration
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_STDIO_BUFSIZE
|
||||
*===========================================================================
|
||||
* Maximum I/O bufsize, e.g. for ipcom_prinf(), ipcom_fprintf() etc.
|
||||
*/
|
||||
#define IPCOM_STDIO_BUFSIZE 3000
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM SHELL
|
||||
*===========================================================================
|
||||
* IPCOM login shell config macro. Also see config/ipcom_config.c for additional
|
||||
* shell configuration constants.
|
||||
*/
|
||||
|
||||
/* Maximum length of current working directory */
|
||||
#define IPCOM_SHELL_MAX_PATH 256
|
||||
|
||||
|
||||
/* Define if you want alias expansion in the IPCOM Shell */
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
/* #define IPCOM_USE_ALIAS 1 */
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_BITARRAY
|
||||
*===========================================================================
|
||||
* Define for including bitarray.
|
||||
*/
|
||||
#define IPCOM_USE_BITARRAY
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_MUX_DRV
|
||||
*===========================================================================
|
||||
* Define for using the mux driver
|
||||
*/
|
||||
#define IPCOM_USE_MUX_DRV
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_NON_ETHERNET
|
||||
*===========================================================================
|
||||
* Define for support non-ethernet interface
|
||||
*/
|
||||
#if defined(IPCOM_USE_INET) || defined(IPCOM_USE_INET6)
|
||||
#define IPCOM_USE_NON_ETHERNET
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* IPCOM CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_telnets_config.c,v $ $Revision: 1.10.18.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/config/ipcom_telnets_config.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_err.h"
|
||||
#include "ipcom_sysvar.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err iptelnets_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* SYSTEM VARIABLES
|
||||
*===========================================================================
|
||||
*/
|
||||
IP_STATIC IP_CONST Ipcom_sysvar iptelnets_conf_sysvar[] =
|
||||
{
|
||||
/* Telnet port */
|
||||
#if defined(IPCOM_TELNET_PORT)
|
||||
{ "ipcom.telnet.port", IPCOM_TELNET_PORT },
|
||||
#else
|
||||
{ "ipcom.telnet.port", "2323" },
|
||||
#endif
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
/* Shell greeting. */
|
||||
{ "ipcom.shell.greeting", "Copyright (c) Interpeak AB 2000-2010. All rights reserved.\n\nWelcome to IPCOM SHELL. Type help for a list of commands.\n\n" },
|
||||
|
||||
/* Shell prompt. Supported special characters are:
|
||||
* \p - shell process name
|
||||
* \P - shell process id
|
||||
* \i - the IP address of the target
|
||||
* \w - the current working directory
|
||||
* \W - the basename of the current working directory
|
||||
* \V - ipcom_getenv("VR")
|
||||
*/
|
||||
/*{ "ipcom.shell.prompt", "\\i$\\w> " },*/
|
||||
{ "ipcom.shell.prompt", "\\i#\\V> " },
|
||||
#endif /* IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM */
|
||||
|
||||
#ifndef IP_PORT_VXWORKS
|
||||
#ifdef IPCOM_USE_AUTH
|
||||
/* Require telnet users to authenticate (1 = enabled, 0 = disabled) */
|
||||
{ "ipcom.telnet.authenticate", "0" },
|
||||
#endif
|
||||
#endif
|
||||
#ifdef IPCOM_TELNET_MAX_CLIENTS
|
||||
{ "ipcom.telnet.max_sessions", IPCOM_TELNET_MAX_CLIENTS },
|
||||
#endif
|
||||
#ifdef IPCOM_TELNET_IDLE_TIMEOUT
|
||||
{ "ipcom.telnet.idle_timeout", IPCOM_TELNET_IDLE_TIMEOUT },
|
||||
#endif
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
/*
|
||||
* Priority of ipcom_telnetd task, from 1 - 7,
|
||||
* 1 - IPCOM_PROC_PRIO_1
|
||||
* 2 - IPCOM_PROC_PRIO_2
|
||||
* 3 - IPCOM_PROC_PRIO_3
|
||||
* 4 - IPCOM_PROC_PRIO_4
|
||||
* 5 - IPCOM_PROC_PRIO_5
|
||||
* 6 - IPCOM_PROC_PRIO_6
|
||||
* 7 - IPCOM_PROC_PRIO_7
|
||||
*/
|
||||
{ "ipcom.telnet.task_priority", IPCOM_MAKE_STR(IPCOM_PRIORITY_DEFAULT) },
|
||||
#endif
|
||||
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* iptelnets_configure
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
iptelnets_configure(void)
|
||||
{
|
||||
/* Set IPTELNETS system variables. */
|
||||
(void)ipcom_sysvar_setv(iptelnets_conf_sysvar, 0);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
IPTARGETS := lib
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include ipcom.mk
|
||||
include ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
@@ -0,0 +1,189 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom.mk,v $ $Revision: 1.54.10.2 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/gmake/ipcom.mk,v $
|
||||
# $Author: svc-cmnet $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
ifeq ($(IPCOM),)
|
||||
IPCOM := yes
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ipcom
|
||||
-include $(IPCOM_ROOT)/arch/gmake/ipcom_arch.mk
|
||||
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
#############################################################################
|
||||
|
||||
IPINCLUDE += -I$(IPCOM_ROOT)/config
|
||||
IPINCLUDE += -I$(IPCOM_ROOT)/include
|
||||
IPINCLUDE += -I$(IPCOM_ROOT)/src
|
||||
IPINCLUDE += -I$(IPCOM_ROOT)/port/include
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
###########################################################################
|
||||
|
||||
# Configuration
|
||||
ifneq ($(IPPORT),lkm)
|
||||
ifneq ($(IPPORT),las)
|
||||
IPLIBOBJECTS_C += ipcom_config.o
|
||||
IPLIBOBJECTS_C += ipcom_ipd_config.o
|
||||
IPLIBOBJECTS_C += ipcom_telnets_config.o
|
||||
endif
|
||||
endif
|
||||
|
||||
# Main
|
||||
IPLIBOBJECTS += ipcom_bitarray.o
|
||||
IPLIBOBJECTS += ipcom_cache.o
|
||||
IPLIBOBJECTS += ipcom_err_string.o
|
||||
IPLIBOBJECTS += ipcom_flow_fingerprint.o
|
||||
IPLIBOBJECTS += ipcom_getinaddrprefixbyaddr.o
|
||||
IPLIBOBJECTS += ipcom_hash.o
|
||||
IPLIBOBJECTS += ipcom_heap_sort.o
|
||||
IPLIBOBJECTS += ipcom_inet.o
|
||||
IPLIBOBJECTS += ipcom_inet6.o
|
||||
IPLIBOBJECTS += ipcom_inet_ntop.o
|
||||
IPLIBOBJECTS += ipcom_inet_pton.o
|
||||
IPLIBOBJECTS += ipcom_init.o
|
||||
IPLIBOBJECTS += ipcom_list.o
|
||||
IPLIBOBJECTS += ipcom_mask.o
|
||||
IPLIBOBJECTS += ipcom_nae.o
|
||||
IPLIBOBJECTS += ipcom_observer.o
|
||||
IPLIBOBJECTS += ipcom_once.o
|
||||
IPLIBOBJECTS += ipcom_pkt_util.o
|
||||
IPLIBOBJECTS += ipcom_pqueue.o
|
||||
IPLIBOBJECTS += ipcom_route.o
|
||||
IPLIBOBJECTS += ipcom_set.o
|
||||
IPLIBOBJECTS += ipcom_sock2.o
|
||||
IPLIBOBJECTS += ipcom_sysvar.o
|
||||
IPLIBOBJECTS += ipcom_sysvar2.o
|
||||
IPLIBOBJECTS += ipcom_sysvar_conf.o
|
||||
IPLIBOBJECTS += ipcom_usr_init.o
|
||||
IPLIBOBJECTS += ipcom_netlink.o
|
||||
|
||||
ifneq ($(IPPORT),lkm)
|
||||
# Files that should be in LAS but not in LKM
|
||||
IPLIBOBJECTS += ipcom_syslog_data.o
|
||||
IPLIBOBJECTS += ipcom_strlib.o
|
||||
IPLIBOBJECTS += ipcom_buffer.o
|
||||
IPLIBOBJECTS += ipcom_dmalloc.o
|
||||
IPLIBOBJECTS += ipcom_getsockaddrbyaddr.o
|
||||
IPLIBOBJECTS += ipcom_file.o
|
||||
IPLIBOBJECTS += ipcom_func.o
|
||||
IPLIBOBJECTS += ipcom_getline.o
|
||||
IPLIBOBJECTS += ipcom_getopt.o
|
||||
IPLIBOBJECTS += ipcom_tmo.o
|
||||
IPLIBOBJECTS += ipcom_tmo2.o
|
||||
ifneq ($(IPPORT),las)
|
||||
IPLIBOBJECTS += ipcom_auth.o
|
||||
IPLIBOBJECTS += ipcom_auth_login.o
|
||||
IPLIBOBJECTS += ipcom_drv_eth_filter.o
|
||||
IPLIBOBJECTS += ipcom_ipd.o
|
||||
IPLIBOBJECTS += ipcom_prof.o
|
||||
IPLIBOBJECTS += ipcom_stdio_syslog.o
|
||||
IPLIBOBJECTS += ipcom_mshell.o
|
||||
IPLIBOBJECTS += ipcom_shell.o
|
||||
IPLIBOBJECTS += ipcom_shellalias.o
|
||||
IPLIBOBJECTS += ipcom_shellcmd.o
|
||||
IPLIBOBJECTS += ipcom_shellctx.o
|
||||
IPLIBOBJECTS += ipcom_shellfile.o
|
||||
IPLIBOBJECTS += ipcom_shellio.o
|
||||
IPLIBOBJECTS += ipcom_shell_start.o
|
||||
IPLIBOBJECTS += ipcom_syslogd.o
|
||||
IPLIBOBJECTS += ipcom_telnet.o
|
||||
IPLIBOBJECTS += ipcom_waitif.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(IPPORT),las)
|
||||
IPLIBOBJECTS += ipcom_pipe.o
|
||||
endif
|
||||
|
||||
# Shell commands
|
||||
IPLIBOBJECTS += ipcom_cmd.o
|
||||
ifneq ($(IPPORT),lkm)
|
||||
ifneq ($(IPPORT),las)
|
||||
IPLIBOBJECTS += ipcom_cmd_echo.o
|
||||
IPLIBOBJECTS += ipcom_cmd_ipd.o
|
||||
IPLIBOBJECTS += ipcom_cmd_shellcmds.o
|
||||
IPLIBOBJECTS += ipcom_cmd_sockperf.o
|
||||
IPLIBOBJECTS += ipcom_cmd_socktest.o
|
||||
IPLIBOBJECTS += ipcom_cmd_syslog.o
|
||||
IPLIBOBJECTS += ipcom_cmd_sysvar.o
|
||||
IPLIBOBJECTS += ipcom_cmd_tracert.o
|
||||
IPLIBOBJECTS += ipcom_cmd_ttcp.o
|
||||
IPLIBOBJECTS += ipcom_cmd_user.o
|
||||
IPLIBOBJECTS += ipcom_cmd_version.o
|
||||
IPLIBOBJECTS += ipcom_cmd_mib2.o
|
||||
IPLIBOBJECTS += ipcom_cmd_smptest.o
|
||||
IPLIBOBJECTS += ipcom_cmd_cpu.o
|
||||
#IPLIBOBJECTS += ipcom_cmd_wlan.o
|
||||
endif
|
||||
endif
|
||||
|
||||
###########################################################################
|
||||
# Market Specific Platform
|
||||
###########################################################################
|
||||
|
||||
ifneq ($(FEATURE_SET),)
|
||||
ifneq ($(FEATURE_SET),gpp)
|
||||
|
||||
IPLIBOBJECTS += ipcom_key_db.o
|
||||
|
||||
ifneq ($(IPPORT),las)
|
||||
IPLIBOBJECTS += ipcom_forwarder_common.o
|
||||
IPLIBOBJECTS += ipcom_forwarder_ctrl.o
|
||||
IPLIBOBJECTS += ipcom_forwarder_data.o
|
||||
IPLIBOBJECTS += ipcom_forwarder_ipsec.o
|
||||
IPLIBOBJECTS += ipcom_forwarder_svlan.o
|
||||
ifneq ($(IPPORT),lkm)
|
||||
IPLIBOBJECTS += ipcom_cmd_fwctrl.o
|
||||
IPLIBOBJECTS += ipcom_cmd_svlanfwd.o
|
||||
IPLIBOBJECTS += ipcom_cmd_keydb.o
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
###########################################################################
|
||||
|
||||
|
||||
# Compiles the xxx_config.o if the $SKIP_CONFIG macro is either not defined
|
||||
# or set to anything other than true.
|
||||
ifneq ($(SKIP_CONFIG),true)
|
||||
IPLIBOBJECTS += $(IPLIBOBJECTS_C)
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
###########################################################################
|
||||
|
||||
IPSRCDIRS += $(IPCOM_ROOT)/src
|
||||
IPSRCDIRS += $(IPCOM_ROOT)/config
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
###########################################################################
|
||||
|
||||
# Library
|
||||
IPLIBS += $(IPLIBROOT)/libipcom.a
|
||||
|
||||
|
||||
endif
|
||||
#############################################################################
|
||||
# END OF IPCOM.MK
|
||||
#############################################################################
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_defs.mk,v $ $Revision: 1.34.10.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/gmake/ipcom_defs.mk,v $
|
||||
# $Author: xxiong $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
include $(IPCOM_ROOT)/port/$(IPPORT)/gmake/ipcom_$(IPPORT)_config.mk
|
||||
|
||||
# Port
|
||||
IPPRODS += $(IPCOM_ROOT)
|
||||
IPPRODS += $(IPCOM_ROOT)/port/$(IPPORT)
|
||||
|
||||
# Stack
|
||||
IPPRODS += $(IPNET_ROOT)
|
||||
IPPRODS += $(IPLITE_ROOT)
|
||||
IPPRODS += $(IPTCP_ROOT)
|
||||
IPPRODS += $(IPSCTP_ROOT)
|
||||
IPPRODS += $(IPPPP_ROOT)
|
||||
IPPRODS += $(IPIPSEC_ROOT)
|
||||
IPPRODS += $(IPFIREWALL_ROOT)
|
||||
IPPRODS += $(IPCCI_ROOT)
|
||||
IPPRODS += $(IPMCRYPTO_ROOT)
|
||||
|
||||
# Applications
|
||||
IPPRODS += $(IPIFPROXY_ROOT)
|
||||
IPPRODS += $(IP8021X_ROOT)
|
||||
IPPRODS += $(IPANVL_ROOT)
|
||||
IPPRODS += $(IPAPPL_ROOT)
|
||||
IPPRODS += $(IPCCI_ROOT)
|
||||
IPPRODS += $(IPCRYPTO_ROOT)
|
||||
IPPRODS += $(IPDHCPC6_ROOT)
|
||||
IPPRODS += $(IPDHCPR_ROOT)
|
||||
IPPRODS += $(IPDHCPS6_ROOT)
|
||||
IPPRODS += $(IPDHCPS_ROOT)
|
||||
IPPRODS += $(IPDIAMETER_ROOT)
|
||||
IPPRODS += $(IPEAP_ROOT)
|
||||
IPPRODS += $(IPEMANATE_ROOT)
|
||||
IPPRODS += $(IPCAVIUM_ROOT)
|
||||
IPPRODS += $(IPFREESCALE_ROOT)
|
||||
IPPRODS += $(IPHWCRYPTO_ROOT)
|
||||
IPPRODS += $(IPIKE_ROOT)
|
||||
IPPRODS += $(IPL2TP_ROOT)
|
||||
IPPRODS += $(IPLDAPC_ROOT)
|
||||
IPPRODS += $(IPMCP_ROOT)
|
||||
IPPRODS += $(IPMIP4_ROOT)
|
||||
IPPRODS += $(IPMIP6CN_ROOT)
|
||||
IPPRODS += $(IPMIP6HA_ROOT)
|
||||
IPPRODS += $(IPMIP6MN_ROOT)
|
||||
IPPRODS += $(IPMIP6PM_ROOT)
|
||||
IPPRODS += $(IPMIP6_ROOT)
|
||||
IPPRODS += $(IPMIPFA_ROOT)
|
||||
IPPRODS += $(IPMIPHA_ROOT)
|
||||
IPPRODS += $(IPMIPMN_ROOT)
|
||||
IPPRODS += $(IPMLDS_ROOT)
|
||||
IPPRODS += $(IPMPLS_ROOT)
|
||||
IPPRODS += $(IPNETPERF_ROOT)
|
||||
IPPRODS += $(IPNETSNMP_ROOT)
|
||||
IPPRODS += $(IPNGC_ROOT)
|
||||
IPPRODS += $(IPPRISM_ROOT)
|
||||
IPPRODS += $(IPQUAGGA_ROOT)
|
||||
IPPRODS += $(IPRADIUS_ROOT)
|
||||
IPPRODS += $(IPRIPNG_ROOT)
|
||||
IPPRODS += $(IPRIP_ROOT)
|
||||
IPPRODS += $(IPSAFENET_ROOT)
|
||||
IPPRODS += $(IPSNMP_ROOT)
|
||||
IPPRODS += $(IPSNTP_ROOT)
|
||||
IPPRODS += $(IPSSH_ROOT)
|
||||
IPPRODS += $(IPSSLPROXY_ROOT)
|
||||
IPPRODS += $(IPSSL_ROOT)
|
||||
IPPRODS += $(IPWEBS_ROOT)
|
||||
IPPRODS += $(IPXINC_ROOT)
|
||||
IPPRODS += $(WRSNMP_ROOT)
|
||||
IPPRODS += $(IPRIPNG_ROOT)
|
||||
IPPRODS += $(IPDIAMETER_ROOT)
|
||||
IPPRODS += $(IPWLAN_ROOT)
|
||||
IPPRODS += $(IPROUTE2_ROOT)
|
||||
IPPRODS += $(IPMIPPM_ROOT)
|
||||
IPPRODS += $(IPMIP_ROOT)
|
||||
IPPRODS += $(VXCOMPAT_ROOT)
|
||||
IPPRODS += $(VXMUX_ROOT)
|
||||
IPPRODS += $(IPROHC_ROOT)
|
||||
IPPRODS += $(VXBRIDGE_ROOT)
|
||||
IPPRODS += $(VXCOREIP_ROOT)
|
||||
IPPRODS += $(IPWPS_ROOT)
|
||||
IPPRODS += $(VXDOT1X_ROOT)
|
||||
IPPRODS += $(IPMACSEC_ROOT)
|
||||
IPPRODS += $(IPPTP_ROOT)
|
||||
IPPRODS += $(TSN_ROOT)
|
||||
IPPRODS += $(IPNTP_ROOT)
|
||||
IPPRODS += $(WRNAD_ROOT)
|
||||
IPPRODS += $(IFPROXY_ROOT)
|
||||
|
||||
ifeq ($(IPTARGETS),)
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# END OF IPCOM_DEFS.MK
|
||||
#############################################################################
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user