Compare commits
33 Commits
15d0205f89
...
v0.0.0
Author | SHA1 | Date | |
---|---|---|---|
057a23d435 | |||
fb4a3a9d82 | |||
495eda6abe | |||
906dd79c64 | |||
241e18a832 | |||
5c6779b80b | |||
284d15e58d | |||
5da6c02b2d | |||
ee8d8c31d5 | |||
8ec8df566a | |||
809d6d1d2f | |||
12ad56ea95 | |||
e169ff8c70 | |||
ba126051c5 | |||
a05bbf5fd6 | |||
996446d115 | |||
a2e8e77468 | |||
35813e2cae | |||
80ddc96b9e | |||
dbbdce72fe | |||
2e3035f354 | |||
1f572a2ac0 | |||
b881698d8b | |||
c0038c2dd6 | |||
f12d9060f9 | |||
2915110a8a | |||
d582503c78 | |||
ac58b6cc72 | |||
724260b664 | |||
985ef22917 | |||
7dab041047 | |||
51416668c4 | |||
9106f5a0a3 |
10
INSTALL
10
INSTALL
@ -1,14 +1,16 @@
|
|||||||
pre-requisites to build actube
|
pre-requisites to build actube
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
On FreeBSD 10.2
|
On FreeBSD 10.2
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
pkg install gmake
|
|
||||||
pkg install gnutls
|
|
||||||
pkg install libconfuse
|
pkg install libconfuse
|
||||||
pkg install sqlite3
|
pkg install wget
|
||||||
pkg install p11-kit
|
pkg install libnettle
|
||||||
|
|
||||||
|
|
||||||
Ubuntu 14.04
|
Ubuntu 14.04
|
||||||
|
17
Makefile
17
Makefile
@ -1,28 +1,11 @@
|
|||||||
TARGETS=\
|
|
||||||
src/contrib/jsmn \
|
|
||||||
src/cw
|
|
||||||
|
|
||||||
|
|
||||||
#src/cw src/mod src/ac
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
#$(foreach i,$(TARGETS),$(call $(MAKE) -c, $i))
|
|
||||||
|
|
||||||
$(MAKE) -C src/contrib/jsmn
|
|
||||||
$(MAKE) -C src/cw
|
$(MAKE) -C src/cw
|
||||||
$(MAKE) -C src/mod
|
$(MAKE) -C src/mod
|
||||||
$(MAKE) -C src/ac
|
$(MAKE) -C src/ac
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
||||||
#$(foreach i,$(TARGETS),$(call $(MAKE) -c, $i))
|
|
||||||
|
|
||||||
$(MAKE) -C src/contrib/jsmn clean
|
|
||||||
$(MAKE) -C src/cw clean
|
$(MAKE) -C src/cw clean
|
||||||
$(MAKE) -C src/mod clean
|
$(MAKE) -C src/mod clean
|
||||||
$(MAKE) -C src/ac clean
|
$(MAKE) -C src/ac clean
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<CodeLite_Project Name="mod_capwap" InternalType="">
|
|
||||||
<VirtualDirectory Name="src">
|
|
||||||
<VirtualDirectory Name="mod">
|
|
||||||
<VirtualDirectory Name="capwap">
|
|
||||||
<File Name="src/mod/capwap/capwap_out_ac_ip_list.c"/>
|
|
||||||
<File Name="src/mod/capwap/mod_capwap_ac.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_wtp_board_data.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_actions_wtp.c"/>
|
|
||||||
<File Name="src/mod/capwap/mod_capwap_wtp.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_out_ac_descriptor.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_ac_ip_list.c"/>
|
|
||||||
<File Name="src/mod/capwap/mod_capwap.h"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_wtp_descriptor.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_session_id.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_out_get_session_id.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_out_get_idle_timeout.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_actions_ac.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_vendor_specific_payload.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_mtu_discovery_padding.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_out_wtp_board_data.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_out_wtp_descriptor.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_out_capwap_control_ip_address.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_capwap_control_ip_address.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_in_ac_descriptor.c"/>
|
|
||||||
<File Name="src/mod/capwap/capwap_out_capwap_local_ip_address.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<Description/>
|
|
||||||
<Dependencies/>
|
|
||||||
<Settings Type="Dynamic Library">
|
|
||||||
<GlobalSettings>
|
|
||||||
<Compiler Options="" C_Options="" Assembler="">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="">
|
|
||||||
<LibraryPath Value="."/>
|
|
||||||
</Linker>
|
|
||||||
<ResourceCompiler Options=""/>
|
|
||||||
</GlobalSettings>
|
|
||||||
<Configuration Name="Debug" CompilerType="clang( tags/RELEASE_380/final )" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="-g" C_Options="-g" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Debug" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand>make clean && make</RebuildCommand>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)/src/mod/capwap/</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration Name="Release" CompilerType="clang( tags/RELEASE_380/final )" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="-O2" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Release" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand/>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
</Settings>
|
|
||||||
<Dependencies Name="Debug"/>
|
|
||||||
<Dependencies Name="Release"/>
|
|
||||||
</CodeLite_Project>
|
|
@ -1,105 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<CodeLite_Project Name="mod_capwap80211" InternalType="">
|
|
||||||
<VirtualDirectory Name="src">
|
|
||||||
<VirtualDirectory Name="mod">
|
|
||||||
<VirtualDirectory Name="capwap80211">
|
|
||||||
<File Name="src/mod/capwap80211/mod_capwap80211.h"/>
|
|
||||||
<File Name="src/mod/capwap80211/capwap80211_out_wtp_radio_cfg.c"/>
|
|
||||||
<File Name="src/mod/capwap80211/mod_capwap80211.c"/>
|
|
||||||
<File Name="src/mod/capwap80211/capwap80211_messages.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<Description/>
|
|
||||||
<Dependencies/>
|
|
||||||
<Settings Type="Dynamic Library">
|
|
||||||
<GlobalSettings>
|
|
||||||
<Compiler Options="" C_Options="" Assembler="">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="">
|
|
||||||
<LibraryPath Value="."/>
|
|
||||||
</Linker>
|
|
||||||
<ResourceCompiler Options=""/>
|
|
||||||
</GlobalSettings>
|
|
||||||
<Configuration Name="Debug" CompilerType="GCC" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="-g" C_Options="-g" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Debug" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand>make clean && make
|
|
||||||
</RebuildCommand>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)/src/mod/capwap80211/</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration Name="Release" CompilerType="GCC" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="-O2" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Release" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand/>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
</Settings>
|
|
||||||
<Dependencies Name="Debug"/>
|
|
||||||
<Dependencies Name="Release"/>
|
|
||||||
</CodeLite_Project>
|
|
@ -1,105 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<CodeLite_Project Name="mod_cipwap" InternalType="">
|
|
||||||
<VirtualDirectory Name="src">
|
|
||||||
<VirtualDirectory Name="mod">
|
|
||||||
<VirtualDirectory Name="cipwap">
|
|
||||||
<File Name="src/mod/cipwap/cipwap_actions_ac.c"/>
|
|
||||||
<File Name="src/mod/cipwap/mod_cipwap_ac.c"/>
|
|
||||||
<File Name="src/mod/cipwap/mod_cipwap.h"/>
|
|
||||||
<File Name="src/mod/cipwap/mod_cipwap_wtp.c"/>
|
|
||||||
<File Name="src/mod/cipwap/cipwap_actions_wtp.c"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<Description/>
|
|
||||||
<Dependencies/>
|
|
||||||
<Settings Type="Dynamic Library">
|
|
||||||
<GlobalSettings>
|
|
||||||
<Compiler Options="" C_Options="" Assembler="">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="">
|
|
||||||
<LibraryPath Value="."/>
|
|
||||||
</Linker>
|
|
||||||
<ResourceCompiler Options=""/>
|
|
||||||
</GlobalSettings>
|
|
||||||
<Configuration Name="Debug" CompilerType="clang( tags/RELEASE_380/final )" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="-g" C_Options="-g" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Debug" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand>make clean && make</RebuildCommand>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)/src/mod/cipwap</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration Name="Release" CompilerType="clang( tags/RELEASE_380/final )" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="-O2" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Release" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand/>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
</Settings>
|
|
||||||
<Dependencies Name="Debug"/>
|
|
||||||
<Dependencies Name="Release"/>
|
|
||||||
</CodeLite_Project>
|
|
@ -1,104 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<CodeLite_Project Name="mod_fortinet" InternalType="">
|
|
||||||
<VirtualDirectory Name="src">
|
|
||||||
<VirtualDirectory Name="mod">
|
|
||||||
<VirtualDirectory Name="fortinet">
|
|
||||||
<File Name="src/mod/fortinet/mod_fortinet_ac.c"/>
|
|
||||||
<File Name="src/mod/fortinet/mod_fortinet_wtp.c"/>
|
|
||||||
<File Name="src/mod/fortinet/fortinet.h"/>
|
|
||||||
<File Name="src/mod/fortinet/fortinet_actions_ac.c"/>
|
|
||||||
<File Name="src/mod/fortinet/fortinet_actions_wtp.c"/>
|
|
||||||
<File Name="src/mod/fortinet/mod_fortinet.h"/>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
</VirtualDirectory>
|
|
||||||
<Description/>
|
|
||||||
<Dependencies/>
|
|
||||||
<Settings Type="Dynamic Library">
|
|
||||||
<GlobalSettings>
|
|
||||||
<Compiler Options="" C_Options="" Assembler="">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="">
|
|
||||||
<LibraryPath Value="."/>
|
|
||||||
</Linker>
|
|
||||||
<ResourceCompiler Options=""/>
|
|
||||||
</GlobalSettings>
|
|
||||||
<Configuration Name="Debug" CompilerType="GCC" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="-g" C_Options="-g" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Debug" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand>make clean && make</RebuildCommand>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)/src/mod/fortinet</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration Name="Release" CompilerType="GCC" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
|
|
||||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
|
|
||||||
<IncludePath Value="."/>
|
|
||||||
</Compiler>
|
|
||||||
<Linker Options="-O2" Required="yes"/>
|
|
||||||
<ResourceCompiler Options="" Required="no"/>
|
|
||||||
<General OutputFile="" IntermediateDirectory="./Release" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
|
||||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
|
||||||
<![CDATA[]]>
|
|
||||||
</Environment>
|
|
||||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
|
||||||
<DebuggerSearchPaths/>
|
|
||||||
<PostConnectCommands/>
|
|
||||||
<StartupCommands/>
|
|
||||||
</Debugger>
|
|
||||||
<PreBuild/>
|
|
||||||
<PostBuild/>
|
|
||||||
<CustomBuild Enabled="yes">
|
|
||||||
<RebuildCommand/>
|
|
||||||
<CleanCommand>make clean</CleanCommand>
|
|
||||||
<BuildCommand>make</BuildCommand>
|
|
||||||
<PreprocessFileCommand/>
|
|
||||||
<SingleFileCommand/>
|
|
||||||
<MakefileGenerationCommand/>
|
|
||||||
<ThirdPartyToolName>None</ThirdPartyToolName>
|
|
||||||
<WorkingDirectory>$(WorkspacePath)</WorkingDirectory>
|
|
||||||
</CustomBuild>
|
|
||||||
<AdditionalRules>
|
|
||||||
<CustomPostBuild/>
|
|
||||||
<CustomPreBuild/>
|
|
||||||
</AdditionalRules>
|
|
||||||
<Completion EnableCpp11="no" EnableCpp14="no">
|
|
||||||
<ClangCmpFlagsC/>
|
|
||||||
<ClangCmpFlags/>
|
|
||||||
<ClangPP/>
|
|
||||||
<SearchPaths/>
|
|
||||||
</Completion>
|
|
||||||
</Configuration>
|
|
||||||
</Settings>
|
|
||||||
</CodeLite_Project>
|
|
@ -1,5 +1,5 @@
|
|||||||
#include ../Config.default.mak
|
#include ../Config.default.mak
|
||||||
-include ../Config.mak
|
#-include ../Config.mak
|
||||||
include ../Defs.mak
|
include ../Defs.mak
|
||||||
|
|
||||||
OBJS = \
|
OBJS = \
|
||||||
@ -7,26 +7,23 @@ OBJS = \
|
|||||||
dataman.o \
|
dataman.o \
|
||||||
ac_interface.o \
|
ac_interface.o \
|
||||||
socklist.o \
|
socklist.o \
|
||||||
db.o \
|
|
||||||
ac_global.o \
|
|
||||||
discovery_cache.o\
|
discovery_cache.o\
|
||||||
shell.o\
|
shell.o\
|
||||||
|
|
||||||
PRG=actube
|
PRG=actube
|
||||||
LIBPATH=-L../../lib/Linux/$(ARCH)/ -L/usr/local/lib -L/usr/lib
|
LIBPATH=-L../../lib/$(KERNEL)/$(ARCH)/ -L/usr/local/lib -L/usr/lib
|
||||||
|
|
||||||
LIBS+=-lmavl
|
LIBS+=-lmavl
|
||||||
LIBS+=-lcw
|
LIBS+=-lcw
|
||||||
LIBS+=-lrt
|
LIBS+=-lrt
|
||||||
LIBS+=-lpthread
|
LIBS+=-lpthread
|
||||||
LIBS+=-lconfuse
|
LIBS+=-lconfuse
|
||||||
LIBS+=-lsqlite3
|
|
||||||
LIBS+=-lc
|
LIBS+=-lc
|
||||||
LIBS+=-lnettle
|
LIBS+=-lnettle
|
||||||
LIBS+=$(OPENSSL_LIBS)
|
LIBS+=-lssl
|
||||||
|
LIBS+=-lcrypto
|
||||||
|
|
||||||
|
INCL_DIRS=-I../ -I/usr/local/include -I./ -I../../include
|
||||||
INCL_DIRS=-I../ -I/usr/local/include -I./ -I/home/tube/v/rsrch/libmavl/
|
|
||||||
#FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH="$(ARCH)" -DSYS_ARCH="XXX"
|
#FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH="$(ARCH)" -DSYS_ARCH="XXX"
|
||||||
FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(ARCH)"'
|
FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(ARCH)"'
|
||||||
|
|
||||||
@ -37,7 +34,7 @@ FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(ARCH)"'
|
|||||||
|
|
||||||
$(PRG): $(OBJS)
|
$(PRG): $(OBJS)
|
||||||
# $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
# $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||||
$(CC) $(LIBS) $(OBJS) -o $(PRG) $(LIBPATH) $(LDFLAGS) $(LIBS)
|
$(CC) $(OBJS) -o $(PRG) $(LIBPATH) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -197,31 +197,31 @@ ssl_cert="../../ssl/certs/ac-xcisco.pem"
|
|||||||
# dbg
|
# dbg
|
||||||
# Set debug level
|
# Set debug level
|
||||||
#
|
#
|
||||||
dbg = info # Show all kind of infos
|
# dbg = info # Show all kind of infos
|
||||||
# dbg += all
|
# dbg += all
|
||||||
dbg += msg_in # Incomming CAPWAP messages
|
# dbg += msg_in # Incomming CAPWAP messages
|
||||||
dbg += msg_out # Outgoing CAPWAP messages
|
# dbg += msg_out # Outgoing CAPWAP messages
|
||||||
dbg += msg_err # Be verbose about capwap message errors like re-transmission
|
# dbg += msg_err # Be verbose about capwap message errors like re-transmission
|
||||||
dbg += msg_dmp
|
# dbg += msg_dmp
|
||||||
dbg += elem_in # CAPWAP message elements
|
# dbg += elem_in # CAPWAP message elements
|
||||||
dbg += elem_out
|
# dbg += elem_out
|
||||||
dbg += subelem #
|
# dbg += subelem #
|
||||||
dbg += elem_err # Errors in message elements
|
# dbg += elem_err # Errors in message elements
|
||||||
dbg += elem_dmp # Print hex dump for capwap messages elements
|
# dbg += elem_dmp # Print hex dump for capwap messages elements
|
||||||
dbg += rfc # Show warnings if CAPWAP messages don't conform to RFC
|
# dbg += rfc # Show warnings if CAPWAP messages don't conform to RFC
|
||||||
dbg += pkt_in # CAPWAP packets received
|
# dbg += pkt_in # CAPWAP packets received
|
||||||
dbg += pkt_out # CAPWAP packets sent
|
# dbg += pkt_out # CAPWAP packets sent
|
||||||
dbg += pkt # CAPWAP packets both sent and received
|
# dbg += pkt # CAPWAP packets both sent and received
|
||||||
dbg += pkt_dmp # Hex dump CAPWAP packets.
|
# dbg += pkt_dmp # Hex dump CAPWAP packets.
|
||||||
dbg += pkt_err # Show messages about malformed packets when detected
|
# dbg += pkt_err # Show messages about malformed packets when detected
|
||||||
dbg += dtls # Messages concerning DTLS
|
# dbg += dtls # Messages concerning DTLS
|
||||||
# dbg += dtls_detail # DTLS in more detail
|
# dbg += dtls_detail # DTLS in more detail
|
||||||
dbg += dtls_bio # DTLS BIO operations
|
# dbg += dtls_bio # DTLS BIO operations
|
||||||
# dbg += dtls_bio_dmp # HeXy dump data in BIO operations
|
# dbg += dtls_bio_dmp # HeXy dump data in BIO operations
|
||||||
dbg += warn # misc warnings
|
# dbg += warn # misc warnings
|
||||||
dbg += mod # Debugs specific to mod
|
# dbg = mod # Debugs specific to mod
|
||||||
dbg += cfg_dmp
|
# dbg += cfg_dmp
|
||||||
dbg += state
|
# dbg += state
|
||||||
#
|
#
|
||||||
# dbg += all # all of the above
|
# dbg += all # all of the above
|
||||||
# dbg += err # Same as dbg_err and pkt_err
|
# dbg += err # Same as dbg_err and pkt_err
|
||||||
@ -239,7 +239,7 @@ ssl_cert="../../ssl/certs/ac-xcisco.pem"
|
|||||||
#
|
#
|
||||||
|
|
||||||
#mods = { cisco, capwap }
|
#mods = { cisco, capwap }
|
||||||
mods = { cisco, capwap, capwap80211 }
|
mods = { cisco,capwap, capwap80211 }
|
||||||
#, capwap80211 }
|
#, capwap80211 }
|
||||||
|
|
||||||
mods_dir = ../../lib/Linux/x86_64/
|
mods_dir = ../../lib/Linux/x86_64/
|
||||||
|
@ -1,119 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "ac.h"
|
|
||||||
#include "conf.h"
|
|
||||||
#include "cw/capwap.h"
|
|
||||||
|
|
||||||
/*#include "cw/aciplist.h"*/
|
|
||||||
#include "socklist.h"
|
|
||||||
#include "cw/sock.h"
|
|
||||||
#include "cw/dbg.h"
|
|
||||||
|
|
||||||
#include "wtpman.h"
|
|
||||||
#include "discovery_cache.h"
|
|
||||||
|
|
||||||
#include "cw/mavltypes.h"
|
|
||||||
mavl_t actube_global_cfg;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
cw_aciplist_t get_aciplist()
|
|
||||||
{
|
|
||||||
int i=0;
|
|
||||||
|
|
||||||
cw_aciplist_t aciplist = cw_aciplist_create();
|
|
||||||
|
|
||||||
if(!aciplist)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
for (i=0; i<socklist_len;i++){
|
|
||||||
|
|
||||||
if (socklist[i].type != SOCKLIST_UNICAST_SOCKET)
|
|
||||||
break;
|
|
||||||
|
|
||||||
struct sockaddr_storage sa;
|
|
||||||
unsigned int salen=sizeof(sa);
|
|
||||||
if ( getsockname(socklist[i].sockfd,(struct sockaddr*)&sa,&salen)<0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cw_acip_t * acip;
|
|
||||||
acip = malloc(sizeof(cw_acip_t));
|
|
||||||
if (!acip)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sock_copyaddr(&acip->ip,(struct sockaddr*)&sa);
|
|
||||||
if (acip->ip.ss_family == AF_INET)
|
|
||||||
acip->index=11;
|
|
||||||
else
|
|
||||||
acip->index=3;
|
|
||||||
|
|
||||||
|
|
||||||
/ * // printf ("Adding IP %s\n",sock_addr2str(&acip->ip));
|
|
||||||
* /
|
|
||||||
cw_aciplist_add(aciplist,acip);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return aciplist;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void * get_iplist(void * arg)
|
|
||||||
{
|
|
||||||
return get_aciplist();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void release_iplist(void *arg,void *data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
int handle_echo_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
|
||||||
int len, struct sockaddr *from)
|
|
||||||
{
|
|
||||||
cw_dbg(DBG_X,"Handle Echo Request %p",conn->data);
|
|
||||||
// struct wtpman * wtpman = conn->data;
|
|
||||||
// wtpman_echo_req(wtpman);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*static void setup_actions (struct mod_ac *c, struct mod_ac *b, struct cw_actiondef *actions)
|
|
||||||
{
|
|
||||||
cw_dbg(DBG_X,"Setup Actions! Yea");
|
|
||||||
cw_set_msg_end_callback(actions,CW_STATE_RUN,CW_MSG_ECHO_REQUEST,handle_echo_req);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_DiscoveryCache * discovery_cache;
|
|
||||||
|
|
||||||
int ac_global_init()
|
|
||||||
{
|
|
||||||
/* initialize discovery cache */
|
|
||||||
discovery_cache = discovery_cache_create(100);
|
|
||||||
if (discovery_cache==NULL)
|
|
||||||
goto errX;
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
errX:
|
|
||||||
return 0;
|
|
||||||
}
|
|
211
src/ac/ac_main.c
211
src/ac/ac_main.c
@ -46,21 +46,11 @@
|
|||||||
|
|
||||||
#include "dataman.h"
|
#include "dataman.h"
|
||||||
|
|
||||||
|
#include "cw/cfg.h"
|
||||||
|
|
||||||
int ac_run();
|
int ac_run();
|
||||||
|
|
||||||
|
|
||||||
static void *alive_thread (void *data)
|
|
||||||
{
|
|
||||||
/* Ping the database every 5 seconds */
|
|
||||||
while (1) {
|
|
||||||
sleep (5);
|
|
||||||
db_ping();
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +64,7 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
|||||||
int c;
|
int c;
|
||||||
opterr = 1;
|
opterr = 1;
|
||||||
|
|
||||||
bootcfg->cfgfilename = "config.ktv";
|
bootcfg->cfgfilename = "config.atv";
|
||||||
|
|
||||||
while ( (c = getopt (argc, argv, "vc:d:p:")) != -1) {
|
while ( (c = getopt (argc, argv, "vc:d:p:")) != -1) {
|
||||||
|
|
||||||
@ -113,7 +103,21 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct cw_DiscoveryCache * discovery_cache;
|
||||||
|
mavl_t actube_global_cfg;
|
||||||
|
|
||||||
|
int ac_global_init()
|
||||||
|
{
|
||||||
|
/* initialize discovery cache */
|
||||||
|
discovery_cache = discovery_cache_create(100);
|
||||||
|
if (discovery_cache==NULL)
|
||||||
|
goto errX;
|
||||||
|
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
errX:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -133,73 +137,9 @@ extern struct cw_Mod * cw_get_mod_ac (const char *name);
|
|||||||
|
|
||||||
extern void test_sets();
|
extern void test_sets();
|
||||||
#include "cw/file.h"
|
#include "cw/file.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
|
|
||||||
|
|
||||||
struct mykv {
|
|
||||||
int key;
|
|
||||||
int value;
|
|
||||||
};
|
|
||||||
|
|
||||||
int mycmp (void *e1, void *e2)
|
|
||||||
{
|
|
||||||
struct mykv * k1 = e1;
|
|
||||||
struct mykv * k2 = e2;
|
|
||||||
|
|
||||||
/*//printf("My CMP: %d and %d\n", k1->key, k2->key);
|
|
||||||
*/
|
|
||||||
if (k1->key > k2->key)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (k1->key < k2->key)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void mavl_walk (struct mavlnode * node)
|
|
||||||
{
|
|
||||||
struct mykv * kv;
|
|
||||||
|
|
||||||
if (!node) {
|
|
||||||
printf ("\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
kv = mavlnode_dataptr (node);
|
|
||||||
printf ("KV %d\n", kv->key);
|
|
||||||
|
|
||||||
printf ("go left:");
|
|
||||||
mavl_walk (node->left);
|
|
||||||
printf ("go right:");
|
|
||||||
mavl_walk (node->right);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
int stcmp (const void * sa1, const void *sa2)
|
|
||||||
{
|
|
||||||
const char **s1 = sa1;
|
|
||||||
const char **s2 = sa2;
|
|
||||||
int rc;
|
|
||||||
rc = strcmp (*s1, *s2);
|
|
||||||
|
|
||||||
printf ("CMP %s, %s = %d\n", *s1, *s2, rc);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
static int ibcmp(const void *v1, const void *v2)
|
|
||||||
{
|
|
||||||
int *i1,*i2;
|
|
||||||
i1=v1;i2=v2;
|
|
||||||
|
|
||||||
return *i1-*i2;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "discovery_cache.h"
|
#include "discovery_cache.h"
|
||||||
void tester1()
|
void tester1()
|
||||||
{
|
{
|
||||||
@ -225,64 +165,124 @@ void tester1()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void show_cfg (FILE *out, mavl_t ktv)
|
||||||
|
{
|
||||||
|
char value[500];
|
||||||
|
struct cw_Val * data;
|
||||||
|
mavliter_t it;
|
||||||
|
const struct cw_Type * type;
|
||||||
|
|
||||||
|
|
||||||
|
mavliter_init(&it,ktv);
|
||||||
|
|
||||||
|
mavliter_foreach(&it){
|
||||||
|
|
||||||
|
data = mavliter_get(&it);
|
||||||
|
type = data->type;
|
||||||
|
type->to_str(data,value,0);
|
||||||
|
|
||||||
|
fprintf(out,"%s :%s: %s\n",data->key,type->get_type_name(data), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
cw_Cfg_t * cfg;
|
||||||
|
cfg=cw_cfg_create();
|
||||||
|
char *val;
|
||||||
|
|
||||||
|
cw_cfg_load("tube.akv",cfg);
|
||||||
|
|
||||||
|
// cw_cfg_set(cfg,"cisco/tube","99");
|
||||||
|
// cw_cfg_set(cfg,"Hello","30");
|
||||||
|
|
||||||
|
cw_cfg_dump(cfg);
|
||||||
|
|
||||||
|
val = cw_cfg_get(cfg,"birth");
|
||||||
|
if (val){
|
||||||
|
printf("Birts: %s\n",val);
|
||||||
|
}
|
||||||
|
|
||||||
|
mavl_destroy(cfg);
|
||||||
|
}
|
||||||
|
cw_Val_t x;
|
||||||
|
CW_TYPE_STR->from_str(&x,"hallo");
|
||||||
|
x.type->del(&x);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct bootcfg bootcfg;
|
struct bootcfg bootcfg;
|
||||||
FILE * file;
|
FILE * file;
|
||||||
mavl_t types_tree, global_cfg;
|
mavl_t types_tree, acglobal_cfg;
|
||||||
const cw_Type_t **ti;
|
const cw_Type_t **ti;
|
||||||
|
|
||||||
|
|
||||||
|
cw_Cfg_t * global_cfg = NULL;
|
||||||
|
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
parse_args (argc, argv, &bootcfg);
|
parse_args (argc, argv, &bootcfg);
|
||||||
|
|
||||||
|
global_cfg=cw_cfg_create();
|
||||||
|
if (!global_cfg){
|
||||||
|
fprintf(stderr,"Can't create global_cfg: %s\n",strerror(errno));
|
||||||
|
goto errX;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = cw_cfg_load(bootcfg.cfgfilename,global_cfg);
|
||||||
|
if (rc)
|
||||||
|
{
|
||||||
|
if (rc<0)
|
||||||
|
fprintf(stderr,"Can't load cfg '%s': %s\n",bootcfg.cfgfilename,strerror(errno));
|
||||||
|
goto errX;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* open config file */
|
/* open config file */
|
||||||
file = fopen(bootcfg.cfgfilename,"r");
|
file = fopen("config.ktv","r");
|
||||||
if (file == NULL){
|
if (file == NULL){
|
||||||
cw_log(LOG_ERR,"Cant open config file '%s': %s",
|
cw_log(LOG_ERR,"Cant open config file '%s': %s",
|
||||||
bootcfg.cfgfilename, strerror(errno));
|
bootcfg.cfgfilename, strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* create types tree with default types */
|
/* create types tree with default types */
|
||||||
types_tree = cw_ktv_create_types_tree();
|
types_tree = cw_ktv_create_types_tree();
|
||||||
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
|
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
|
||||||
mavl_insert_ptr(types_tree,*ti);
|
mavl_insert_ptr(types_tree,*ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
global_cfg = cw_ktv_create();
|
acglobal_cfg = cw_ktv_create();
|
||||||
if (global_cfg == NULL){
|
if (acglobal_cfg == NULL){
|
||||||
cw_log(LOG_ERR,"Can't create local_cfg: %s",strerror(errno));
|
cw_log(LOG_ERR,"Can't create local_cfg: %s",strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_ktv_read_file(file,global_cfg,types_tree);
|
cw_ktv_read_file(file,acglobal_cfg,types_tree);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
|
actube_global_cfg = acglobal_cfg;
|
||||||
actube_global_cfg = global_cfg;
|
|
||||||
|
|
||||||
/* cw_dbg_opt_level=0xffffffff;*/
|
|
||||||
cw_dbg(DBG_INFO,"Hello world");
|
|
||||||
|
|
||||||
|
|
||||||
cw_dbg_ktv_dump(global_cfg,DBG_INFO,NULL,"CFG:",NULL);
|
cw_dbg_ktv_dump(acglobal_cfg,DBG_INFO,NULL,"CFG:",NULL);
|
||||||
|
|
||||||
/* int idx;
|
|
||||||
idx = cw_ktv_idx_get(global_cfg,"capwap-control-ip-address/address",0,CW_TYPE_IPADDRESS);
|
|
||||||
printf("IDX: %d\n");
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
*/
|
|
||||||
cw_log_name = "AC-Tube";
|
cw_log_name = "AC-Tube";
|
||||||
|
|
||||||
if (!read_config ("ac.conf"))
|
if (!read_config ("ac.conf"))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
start_shell();
|
start_shell();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Show debug options if there are any set */
|
/* Show debug options if there are any set */
|
||||||
@ -290,7 +290,7 @@ start_shell();
|
|||||||
cw_log (LOG_INFO, "Debug Options: %08X", cw_dbg_opt_level);
|
cw_log (LOG_INFO, "Debug Options: %08X", cw_dbg_opt_level);
|
||||||
|
|
||||||
/* XXX Hard coded debug settigns, set it by config in the future */
|
/* XXX Hard coded debug settigns, set it by config in the future */
|
||||||
cw_dbg_opt_display = DBG_DISP_ASC_DMP | DBG_DISP_COLORS;
|
// cw_dbg_opt_display = DBG_DISP_ASC_DMP | DBG_DISP_COLORS;
|
||||||
|
|
||||||
/* Warn, if the "secret" debugging feature for
|
/* Warn, if the "secret" debugging feature for
|
||||||
developers is turned on ;) */
|
developers is turned on ;) */
|
||||||
@ -307,21 +307,6 @@ start_shell();
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the database */
|
|
||||||
if (!db_init())
|
|
||||||
goto errX;
|
|
||||||
|
|
||||||
/* Start the database */
|
|
||||||
if (!db_start())
|
|
||||||
goto errX;
|
|
||||||
|
|
||||||
db_ping();
|
|
||||||
|
|
||||||
|
|
||||||
/* Start a database "pinger thread", which inserts
|
|
||||||
every xx seconds a timestamp into the DB */
|
|
||||||
pthread_t alth;
|
|
||||||
pthread_create (&alth, NULL, alive_thread, NULL);
|
|
||||||
|
|
||||||
/* Init DTLS library */
|
/* Init DTLS library */
|
||||||
dtls_init();
|
dtls_init();
|
||||||
@ -341,6 +326,10 @@ start_shell();
|
|||||||
cw_log (LOG_INFO, "Starting AC-Tube, Name=%s, ID=%s", conf_acname, conf_acid);
|
cw_log (LOG_INFO, "Starting AC-Tube, Name=%s, ID=%s", conf_acname, conf_acid);
|
||||||
rc = ac_run();
|
rc = ac_run();
|
||||||
errX:
|
errX:
|
||||||
|
if (global_cfg)
|
||||||
|
mavl_destroy(global_cfg);
|
||||||
|
|
||||||
|
|
||||||
/* XXX There is more cleanup to do */
|
/* XXX There is more cleanup to do */
|
||||||
wtplist_destroy();
|
wtplist_destroy();
|
||||||
socklist_destroy();
|
socklist_destroy();
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
#!/usr/bin/php
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sqlfile="./ac.sqlite3";
|
|
||||||
if (!file_exists($sqlfile))
|
|
||||||
die ("Can't open $sqlfile\n");
|
|
||||||
|
|
||||||
|
|
||||||
class DB extends SQLite3
|
|
||||||
{
|
|
||||||
function __construct()
|
|
||||||
{
|
|
||||||
global $sqlfile;
|
|
||||||
$this->open($sqlfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = new DB();
|
|
||||||
|
|
||||||
|
|
||||||
function ls_acs()
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
echo "List of ACs\n";
|
|
||||||
echo "===========\n";
|
|
||||||
$results = $db->query("SELECT
|
|
||||||
acid as id,
|
|
||||||
acname as name,
|
|
||||||
lastseen>datetime('now','-10 second') as active
|
|
||||||
FROM acs ORDER by active,id,name;"
|
|
||||||
);
|
|
||||||
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
|
|
||||||
$o = $row['active'] ? "yes" : "no";
|
|
||||||
echo "ID: $row[id], Name: $row[name] - Online: $o\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ls_wtps()
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
echo "List of WTPs\n";
|
|
||||||
echo "============\n";
|
|
||||||
|
|
||||||
$result = $db->query("SELECT
|
|
||||||
wtpid as wtpid,
|
|
||||||
wtps.acid as acid,
|
|
||||||
acs.acname as acname
|
|
||||||
FROM wtps
|
|
||||||
LEFT join acs USING(acid)
|
|
||||||
");
|
|
||||||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
|
||||||
$j = $row['acid'] ? "Joined to $row[acid]" : "Not joined";
|
|
||||||
|
|
||||||
echo "ID: $row[wtpid], $j\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_help()
|
|
||||||
{
|
|
||||||
echo "acshell <cmd>\n";
|
|
||||||
echo "\n";
|
|
||||||
echo "acshell lsacs - list acs\n";
|
|
||||||
echo "acshell lswtp - list wtps\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//ls_wtps();
|
|
||||||
//
|
|
||||||
//var_dump($argv);
|
|
||||||
if (count($argv)==1){
|
|
||||||
print_help();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( $argv[1] == "lsacs" )
|
|
||||||
ls_acs();
|
|
||||||
if( $argv[1] == "lswtps" )
|
|
||||||
ls_wtps();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,7 +82,6 @@ int conf_ac_ips_len;
|
|||||||
char *conf_sslcertfilename = NULL;
|
char *conf_sslcertfilename = NULL;
|
||||||
char *conf_sslkeyfilename = NULL;
|
char *conf_sslkeyfilename = NULL;
|
||||||
char *conf_sslkeypass = NULL;
|
char *conf_sslkeypass = NULL;
|
||||||
char *conf_sslcipher = NULL;
|
|
||||||
char *conf_dtls_psk = NULL;
|
char *conf_dtls_psk = NULL;
|
||||||
|
|
||||||
int conf_security = 0;
|
int conf_security = 0;
|
||||||
@ -197,48 +196,6 @@ static int init_vendor_id()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
static int init_version()
|
|
||||||
{
|
|
||||||
|
|
||||||
// Init hardware version
|
|
||||||
if (!conf_hardware_version) {
|
|
||||||
struct utsname u;
|
|
||||||
int rc = uname(&u);
|
|
||||||
if (rc < 0)
|
|
||||||
conf_hardware_version =
|
|
||||||
(bstr_t) strdup(CONF_DEFAULT_HARDWARE_VERSION);
|
|
||||||
else {
|
|
||||||
char str[265];
|
|
||||||
sprintf(str, "%s / %s %s", u.machine, u.sysname, u.release);
|
|
||||||
conf_hardware_version = (bstr_t) strdup(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
bstr_replace(&conf_hardware_version,
|
|
||||||
bstr_create_from_cfgstr((char *) conf_hardware_version));
|
|
||||||
|
|
||||||
// software version
|
|
||||||
if (!conf_software_version)
|
|
||||||
conf_software_version = (bstr_t) strdup(CONF_DEFAULT_SOFTWARE_VERSION);
|
|
||||||
bstr_replace(&conf_software_version,
|
|
||||||
bstr_create_from_cfgstr((char *) conf_software_version));
|
|
||||||
|
|
||||||
|
|
||||||
// Cisco hardware version
|
|
||||||
if (!conf_cisco_hardware_version)
|
|
||||||
conf_cisco_hardware_version =
|
|
||||||
(bstr_t) strdup(CONF_DEFAULT_CISCO_HARDWARE_VERSION);
|
|
||||||
bstr_replace(&conf_cisco_hardware_version,
|
|
||||||
bstr_create_from_cfgstr((char *) conf_cisco_hardware_version));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int init_control_port()
|
static int init_control_port()
|
||||||
{
|
{
|
||||||
char str[30];
|
char str[30];
|
||||||
@ -281,10 +238,8 @@ static int init_listen_addrs()
|
|||||||
|
|
||||||
if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4)
|
if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4)
|
||||||
ctr++;
|
ctr++;
|
||||||
#ifdef WITH_IPV6
|
|
||||||
if (ifa->ifa_addr->sa_family == AF_INET6 && conf_ipv6)
|
if (ifa->ifa_addr->sa_family == AF_INET6 && conf_ipv6)
|
||||||
ctr++;
|
ctr++;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conf_listen_addrs = malloc(sizeof(char *) * ctr);
|
conf_listen_addrs = malloc(sizeof(char *) * ctr);
|
||||||
@ -537,14 +492,6 @@ static int conf_read_strings(cfg_t * cfg, char *name, char ***dst, int *len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
struct conf_dbg_level_names{
|
|
||||||
const char *name;
|
|
||||||
int level;
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static int conf_read_dbg_level(cfg_t * cfg)
|
static int conf_read_dbg_level(cfg_t * cfg)
|
||||||
{
|
{
|
||||||
@ -571,6 +518,7 @@ char *conf_mods_dir = NULL;
|
|||||||
* Read the module names from config file
|
* Read the module names from config file
|
||||||
*/
|
*/
|
||||||
static int conf_read_mods(cfg_t *cfg){
|
static int conf_read_mods(cfg_t *cfg){
|
||||||
|
|
||||||
int n, i;
|
int n, i;
|
||||||
n = cfg_size(cfg,CFG_ENTRY_MODS);
|
n = cfg_size(cfg,CFG_ENTRY_MODS);
|
||||||
|
|
||||||
@ -590,24 +538,6 @@ static int conf_read_mods(cfg_t *cfg){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void conf_init_capwap_mode()
|
|
||||||
{
|
|
||||||
if (conf_capwap_mode_str == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (0 == strcmp(conf_capwap_mode_str, "cipwap")) {
|
|
||||||
conf_capwap_mode = CW_MODE_CIPWAP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == strcmp(conf_capwap_mode_str, "capwap")) {
|
|
||||||
conf_capwap_mode = CW_MODE_CAPWAP;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
int conf_parse_listen_addr(const char *addrstr, char *saddr, char *port, int *proto)
|
int conf_parse_listen_addr(const char *addrstr, char *saddr, char *port, int *proto)
|
||||||
{
|
{
|
||||||
@ -745,7 +675,6 @@ int read_config(const char *filename)
|
|||||||
CFG_SIMPLE_STR("ssl_cert", &conf_sslcertfilename),
|
CFG_SIMPLE_STR("ssl_cert", &conf_sslcertfilename),
|
||||||
CFG_SIMPLE_STR("ssl_key", &conf_sslkeyfilename),
|
CFG_SIMPLE_STR("ssl_key", &conf_sslkeyfilename),
|
||||||
CFG_SIMPLE_STR("ssl_key_pass", &conf_sslkeypass),
|
CFG_SIMPLE_STR("ssl_key_pass", &conf_sslkeypass),
|
||||||
CFG_SIMPLE_STR("ssl_cipher", &conf_sslcipher),
|
|
||||||
CFG_SIMPLE_STR("dtls_psk", &conf_dtls_psk),
|
CFG_SIMPLE_STR("dtls_psk", &conf_dtls_psk),
|
||||||
|
|
||||||
CFG_SIMPLE_BOOL("dtls_verify_peer", &conf_dtls_verify_peer),
|
CFG_SIMPLE_BOOL("dtls_verify_peer", &conf_dtls_verify_peer),
|
||||||
@ -801,6 +730,7 @@ int read_config(const char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!conf_read_mods(cfg)){
|
if (!conf_read_mods(cfg)){
|
||||||
cfg_free(cfg);
|
cfg_free(cfg);
|
||||||
return 0;
|
return 0;
|
||||||
@ -825,10 +755,10 @@ int read_config(const char *filename)
|
|||||||
if (!init_dtls())
|
if (!init_dtls())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!conf_sslcipher)
|
/* if (!conf_sslcipher)
|
||||||
conf_sslcipher = CAPWAP_CIPHER;
|
conf_sslcipher = CAPWAP_CIPHER;
|
||||||
|
|
||||||
if (!conf_image_dir)
|
*/ if (!conf_image_dir)
|
||||||
conf_image_dir = CONF_DEFAULT_IMAGE_DIR;
|
conf_image_dir = CONF_DEFAULT_IMAGE_DIR;
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ extern char *conf_sslkeyfilename;
|
|||||||
extern char *conf_sslkeypass;
|
extern char *conf_sslkeypass;
|
||||||
extern char *conf_dtls_psk;
|
extern char *conf_dtls_psk;
|
||||||
extern int conf_dtls_verify_peer;
|
extern int conf_dtls_verify_peer;
|
||||||
char *conf_sslcipher;
|
extern char *conf_sslcipher;
|
||||||
|
|
||||||
extern char *conf_image_dir;
|
extern char *conf_image_dir;
|
||||||
|
|
||||||
|
@ -1,838 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of actube.
|
|
||||||
|
|
||||||
actube is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
libcapwap is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h> // sleep
|
|
||||||
|
|
||||||
|
|
||||||
#include "cw/capwap.h"
|
|
||||||
#include "cw/sock.h"
|
|
||||||
#include "cw/log.h"
|
|
||||||
#include "cw/timer.h"
|
|
||||||
#include "cw/cw.h"
|
|
||||||
|
|
||||||
#include "cw/dtls.h"
|
|
||||||
#include "cw/dbg.h"
|
|
||||||
#include "cw/conn.h"
|
|
||||||
#include "cw/format.h"
|
|
||||||
|
|
||||||
#include "ac.h"
|
|
||||||
#include "conf.h"
|
|
||||||
#include "db.h"
|
|
||||||
#include "socklist.h"
|
|
||||||
#include "wtpman.h"
|
|
||||||
#include "wtplist.h"
|
|
||||||
#include "cw/ktv.h"
|
|
||||||
|
|
||||||
static void reset_echointerval_timer(struct wtpman *wtpman)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
/* uint16_t ct = mbag_get_word(wtpman->conn->local, CW_ITEM_CAPWAP_TIMERS,
|
|
||||||
CW_MAX_DISCOVERY_INTERVAL << 8 |
|
|
||||||
CAPWAP_ECHO_INTERVAL);
|
|
||||||
*/
|
|
||||||
/* start echinterval timer and put 2 seconds for "safety" on it */
|
|
||||||
|
|
||||||
/*
|
|
||||||
// wtpman->echointerval_timer = cw_timer_start(2+ (ct & 0xff));
|
|
||||||
// db_ping_wtp(sock_addr2str_p(&wtpman->conn->addr,sock_buf), conf_acname);
|
|
||||||
// cw_dbg(DBG_X, "Starting capwap timer: %d", wtpman->echointerval_timer);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int msg_start_handler(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
|
||||||
int len, struct sockaddr *from)
|
|
||||||
{
|
|
||||||
struct wtpman *wtpman = conn->data;
|
|
||||||
reset_echointerval_timer(wtpman);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void wtpman_remove(struct wtpman *wtpman)
|
|
||||||
{
|
|
||||||
wtplist_lock();
|
|
||||||
wtplist_remove(wtpman);
|
|
||||||
wtplist_unlock();
|
|
||||||
wtpman_destroy(wtpman);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void wtpman_run_discovery(void *arg)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
|
||||||
|
|
||||||
time_t timer = cw_timer_start(10);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wtpman->conn->capwap_state = CAPWAP_STATE_DISCOVERY;
|
|
||||||
/*// wtpman->conn->actions = &capwap_actions;*/
|
|
||||||
|
|
||||||
/* wtpman->conn->outgoing = mbag_create();
|
|
||||||
wtpman->conn->incomming = mbag_create();
|
|
||||||
*/
|
|
||||||
wtpman->conn->remote_cfg = cw_ktv_create(); /*//mavl_cmp_kv,NULL,1312);*/
|
|
||||||
|
|
||||||
while (!cw_timer_timeout(timer)
|
|
||||||
&& wtpman->conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
|
|
||||||
cw_read_messages(wtpman->conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// struct mbag_item *wn = mbag_get(wtpman->conn->incomming, CW_ITEM_WTP_NAME);
|
|
||||||
|
|
||||||
// if (wn) {
|
|
||||||
// printf("WTP Name: %s\n", wn->data);
|
|
||||||
// exit(0);
|
|
||||||
// }
|
|
||||||
*/
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int xprocess_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
|
||||||
struct sockaddr *from)
|
|
||||||
{
|
|
||||||
uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);
|
|
||||||
uint32_t type = cw_get_msg_type(msgptr);
|
|
||||||
cw_log(LOG_ERR, "Hey: %d", type);
|
|
||||||
if (type == CAPWAP_MSG_DISCOVERY_REQUEST)
|
|
||||||
conn->capwap_state = CAPWAP_STATE_DISCOVERY;
|
|
||||||
|
|
||||||
|
|
||||||
return process_message(conn, rawmsg, rawlen, from);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int wtpman_establish_dtls(void *arg)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
|
||||||
|
|
||||||
/* setup cipher */
|
|
||||||
wtpman->conn->dtls_cipher = conf_sslcipher;
|
|
||||||
|
|
||||||
/* setup DTSL certificates */
|
|
||||||
int dtls_ok = 0;
|
|
||||||
if (conf_sslkeyfilename && conf_sslcertfilename) {
|
|
||||||
|
|
||||||
|
|
||||||
wtpman->conn->dtls_key_file = conf_sslkeyfilename;
|
|
||||||
wtpman->conn->dtls_cert_file = conf_sslcertfilename;
|
|
||||||
wtpman->conn->dtls_key_pass = conf_sslkeypass;
|
|
||||||
wtpman->conn->dtls_verify_peer = conf_dtls_verify_peer;
|
|
||||||
cw_dbg(DBG_DTLS, "Using key file %s", wtpman->conn->dtls_key_file);
|
|
||||||
cw_dbg(DBG_DTLS, "Using cert file %s", wtpman->conn->dtls_cert_file);
|
|
||||||
dtls_ok = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup DTLS psk */
|
|
||||||
if (conf_dtls_psk) {
|
|
||||||
wtpman->conn->dtls_psk = conf_dtls_psk;
|
|
||||||
wtpman->conn->dtls_psk_len = strlen(conf_dtls_psk);
|
|
||||||
dtls_ok = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dtls_ok) {
|
|
||||||
cw_log(LOG_ERR,
|
|
||||||
"Can't establish DTLS session, neither psk nor certs set in config file.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* try to accept the connection */
|
|
||||||
if (!dtls_accept(wtpman->conn)) {
|
|
||||||
cw_dbg(DBG_DTLS, "Error establishing DTLS session with %s",
|
|
||||||
sock_addr2str_p(&wtpman->conn->addr,sock_buf));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cw_dbg(DBG_DTLS, "DTLS session established with %s, cipher=%s",
|
|
||||||
sock_addr2str_p(&wtpman->conn->addr,sock_buf), dtls_get_cipher(wtpman->conn));
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int wtpman_join(void *arg, time_t timer)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
|
||||||
struct conn *conn = wtpman->conn;
|
|
||||||
|
|
||||||
/*
|
|
||||||
// wtpman->conn->outgoing = mbag_create();
|
|
||||||
// wtpman->conn->incomming = mbag_create();
|
|
||||||
// conn->config = conn->incomming;
|
|
||||||
// wtpman->conn->local = ac_config;
|
|
||||||
|
|
||||||
// mbag_set_str(conn->local, CW_ITEM_AC_NAME, conf_acname);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
wtpman->conn->capwap_state = CAPWAP_STATE_JOIN;
|
|
||||||
|
|
||||||
/*
|
|
||||||
// wtpman->conn->actions = &capwap_actions;
|
|
||||||
|
|
||||||
// wtpman->conn->itemstore = mbag_create();
|
|
||||||
*/
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO, "Join State - %s", sock_addr2str(&conn->addr,sock_buf));
|
|
||||||
|
|
||||||
int rc;
|
|
||||||
while (!cw_timer_timeout(timer) && wtpman->conn->capwap_state == CAPWAP_STATE_JOIN) {
|
|
||||||
rc = cw_read_messages(wtpman->conn);
|
|
||||||
if (rc < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc != 0) {
|
|
||||||
cw_log(LOG_ERR, "Error joining WTP %s", cw_strerror(rc));
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (wtpman->conn->capwap_state == CAPWAP_STATE_JOIN) {
|
|
||||||
cw_dbg(DBG_MSG_ERR, "No join request from %s after %d seconds, WTP died.",
|
|
||||||
sock_addr2str(&wtpman->conn->addr,sock_buf), wtpman->conn->wait_dtls);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wtpman_image_data(struct wtpman *wtpman)
|
|
||||||
{
|
|
||||||
/* char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
struct conn *conn = wtpman->conn;
|
|
||||||
|
|
||||||
// Image upload
|
|
||||||
const char *filename = mbag_get_str(conn->outgoing, CW_ITEM_IMAGE_FILENAME, NULL);
|
|
||||||
if (!filename) {
|
|
||||||
cw_log(LOG_ERR,
|
|
||||||
"Can't send image to %s. No Image Filename Item found.",
|
|
||||||
sock_addr2str(&conn->addr,sock_buf));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cw_dbg(DBG_INFO, "Sending image file '%s' to '%s'.", filename,
|
|
||||||
sock_addr2str(&conn->addr,sock_buf));
|
|
||||||
FILE *infile = fopen(filename, "rb");
|
|
||||||
if (infile == NULL) {
|
|
||||||
cw_log(LOG_ERR, "Can't open image %s: %s",
|
|
||||||
sock_addr2str(&conn->addr,sock_buf), strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CW_CLOCK_DEFINE(clk);
|
|
||||||
cw_clock_start(&clk);
|
|
||||||
|
|
||||||
mbag_item_t *eof = mbag_set_const_ptr(conn->outgoing, CW_ITEM_IMAGE_FILEHANDLE,
|
|
||||||
infile);
|
|
||||||
|
|
||||||
int rc = 0;
|
|
||||||
while (conn->capwap_state == CW_STATE_IMAGE_DATA && rc == 0 && eof != NULL) {
|
|
||||||
rc = cw_send_request(conn, CAPWAP_MSG_IMAGE_DATA_REQUEST);
|
|
||||||
eof = mbag_get(conn->outgoing, CW_ITEM_IMAGE_FILEHANDLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (rc) {
|
|
||||||
cw_log(LOG_ERR, "Error sending image to %s: %s",
|
|
||||||
sock_addr2str(&conn->addr,sock_buf), cw_strrc(rc));
|
|
||||||
} else {
|
|
||||||
cw_dbg(DBG_INFO, "Image '%s' sucessful sent to %s in %0.1f seconds.",
|
|
||||||
filename, sock_addr2str(&conn->addr,sock_buf), cw_clock_stop(&clk));
|
|
||||||
conn->capwap_state = CW_STATE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(infile);
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void config_to_sql(struct conn *conn)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
// XXX for the moment we use just the IP adress as ID
|
|
||||||
char *wtp_id = sock_addr2str(&conn->addr);
|
|
||||||
|
|
||||||
// cw_dbg(DBG_X, "WTPID: %s\n", wtp_id);
|
|
||||||
|
|
||||||
MAVLITER_DEFINE(it, conn->incomming);
|
|
||||||
mavliter_foreach(&it) {
|
|
||||||
mbag_item_t *i = mavliter_get(&it);
|
|
||||||
|
|
||||||
const struct cw_itemdef *cwi =
|
|
||||||
cw_itemdef_get(conn->actions->items, i->id, NULL);
|
|
||||||
|
|
||||||
cw_dbg(DBG_X,"ID GOT: %s",i->id);
|
|
||||||
|
|
||||||
if (cwi) {
|
|
||||||
DBGX("SQL ID %s,%s", i->id, cwi->id);
|
|
||||||
DBGX("SQL Type %s,Typecwd %s", i->type->name, cwi->type->name);
|
|
||||||
|
|
||||||
// printf("%s != %s ?\n",i->type->name,cwi->type->name);
|
|
||||||
char str[256];
|
|
||||||
if (i->type->to_str) {
|
|
||||||
i->type->to_str(i, str);
|
|
||||||
db_put_wtp_prop(wtp_id, cwi->id, cwi->sub_id, str);
|
|
||||||
} else {
|
|
||||||
cw_log(LOG_ERR, "Can't converto to str for %s", cwi->id,
|
|
||||||
cwi->sub_id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// DBGX("ID %d",i->id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void xradio_to_sql(struct conn *conn, char *wtp_id, int rid, int radio)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
MAVLITER_DEFINE(it, radio);
|
|
||||||
mavliter_foreach(&it) {
|
|
||||||
mbag_item_t *i = mavliter_get(&it);
|
|
||||||
|
|
||||||
const struct cw_itemdef *cwi =
|
|
||||||
cw_itemdef_get(conn->actions->radioitems, i->id, NULL);
|
|
||||||
if (cwi) {
|
|
||||||
char str[4096];
|
|
||||||
if (i->type->to_str) {
|
|
||||||
i->type->to_str(i, str);
|
|
||||||
// printf("I would put RID: %d, %s=>%s\n",rid,cwi->id,str);
|
|
||||||
|
|
||||||
char srid[6];
|
|
||||||
sprintf(srid,"%d",rid);
|
|
||||||
|
|
||||||
db_put_radio_prop(wtp_id,srid,cwi->id,cwi->sub_id,str);
|
|
||||||
|
|
||||||
// db_put_wtp_prop(wtp_id, cwi->id, cwi->sub_id, str);
|
|
||||||
} else {
|
|
||||||
cw_log(LOG_ERR, "Can't converto to str for %s", cwi->id,
|
|
||||||
cwi->sub_id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// DBGX("ID %d",i->id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// int rid = ((struct mbag_item*)mavliter_get(&it))->iid;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void radios_to_sql(struct conn *conn)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
char *wtp_id = sock_addr2str(&conn->addr,sock_buf);
|
|
||||||
MAVLITER_DEFINE(it, conn->radios);
|
|
||||||
mavliter_foreach(&it) {
|
|
||||||
struct mbag_item * i = mavliter_get(&it);
|
|
||||||
int rid = i->u1.iid;
|
|
||||||
|
|
||||||
radio_to_sql(conn,wtp_id,rid,i->u2.data);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wtpman_run_data(void *wtpman_arg)
|
|
||||||
{
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
struct wtpman *wtpman = (struct wtpman *) wtpman_arg;
|
|
||||||
struct conn *conn = wtpman->conn;
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t data[1001];
|
|
||||||
memset(data, 0, 1000);
|
|
||||||
|
|
||||||
cw_log(LOG_ERR, "I am the data thread**********************************************************************\n");
|
|
||||||
while (1) {
|
|
||||||
sleep(5);
|
|
||||||
/*// conn->write_data(conn, data, 100);*/
|
|
||||||
cw_log(LOG_ERR, "O was the data thread***********************************************************\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int msg_end_handler(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
|
||||||
int len, struct sockaddr *from)
|
|
||||||
{
|
|
||||||
/* if (a->msg_id ==CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST) {
|
|
||||||
props_to_sql(conn,conn->incomming,0);
|
|
||||||
radios_to_sql(conn);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void wtpman_run(void *arg)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
|
|
||||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
|
||||||
|
|
||||||
wtpman->conn->seqnum = 0;
|
|
||||||
struct conn *conn = wtpman->conn;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* reject connections to our multi- or broadcast sockets */
|
|
||||||
/* if (socklist[wtpman->socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
|
|
||||||
cw_dbg(DBG_DTLS, "Dropping connection from %s to non-unicast socket.",
|
|
||||||
CLIENT_IP);
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
time_t timer = cw_timer_start(wtpman->conn->wait_dtls);
|
|
||||||
|
|
||||||
/* establish dtls session */
|
|
||||||
/* if (!wtpman_establish_dtls(wtpman)) {
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* dtls is established, goto join state */
|
|
||||||
if (!wtpman_join(wtpman, timer)) {
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
conn->msg_start = msg_start_handler;
|
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO, "WTP from %s has joined with session id: %s",
|
|
||||||
sock_addr2str_p(&conn->addr,sock_buf),
|
|
||||||
format_bin2hex(conn->session_id,16));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// cw_dbg(DBG_INFO, "Creating data thread");
|
|
||||||
// pthread_t thread;
|
|
||||||
// pthread_create(&thread, NULL, (void *) wtpman_run_data, (void *) wtpman);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* here the WTP has joined, now we assume an image data request
|
|
||||||
or an configuration status request. Nothing else.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int rc = 0;
|
|
||||||
while (!cw_timer_timeout(timer)
|
|
||||||
&& wtpman->conn->capwap_state == CW_STATE_CONFIGURE) {
|
|
||||||
rc = cw_read_messages(wtpman->conn);
|
|
||||||
if (rc < 0) {
|
|
||||||
if (errno != EAGAIN)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cw_result_is_ok(rc)) {
|
|
||||||
cw_dbg(DBG_INFO, "WTP Problem: %s", cw_strrc(rc));
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (conn->capwap_state == CW_STATE_IMAGE_DATA) {
|
|
||||||
wtpman_image_data(wtpman);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
conn->capwap_state = CW_STATE_RUN;
|
|
||||||
/*
|
|
||||||
// XXX testing ...
|
|
||||||
// DBGX("Cofig to sql", "");
|
|
||||||
// props_to_sql(conn,conn->incomming,0);
|
|
||||||
// radios_to_sql(conn);
|
|
||||||
*/
|
|
||||||
|
|
||||||
conn->msg_end=msg_end_handler;
|
|
||||||
/* The main run loop */
|
|
||||||
reset_echointerval_timer(wtpman);
|
|
||||||
|
|
||||||
rc = 0;
|
|
||||||
while (wtpman->conn->capwap_state == CW_STATE_RUN) {
|
|
||||||
rc = cw_read_messages(wtpman->conn);
|
|
||||||
if (rc < 0) {
|
|
||||||
if (errno != EAGAIN)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*// cw_dbg(DBG_X, "Time left: %d",
|
|
||||||
//*/
|
|
||||||
cw_timer_timeleft(wtpman->echointerval_timer);
|
|
||||||
if (cw_timer_timeout(wtpman->echointerval_timer)) {
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO, "Lost connection to WTP:%s",
|
|
||||||
sock_addr2str_p(&conn->addr,sock_buf));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// mavl_del_all(conn->outgoing);
|
|
||||||
// conn_clear_upd(conn,1);
|
|
||||||
|
|
||||||
// props_to_sql(conn,conn->incomming,0);
|
|
||||||
// radios_to_sql(conn);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
mavl_t r;
|
|
||||||
r = db_get_update_tasks(conn, sock_addr2str(&conn->addr,sock_buf));
|
|
||||||
if (r) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
// if (!conn->outgoing->count)
|
|
||||||
// continue;
|
|
||||||
*/
|
|
||||||
cw_dbg(DBG_INFO, "Updating WTP %s",sock_addr2str(&conn->addr,sock_buf));
|
|
||||||
|
|
||||||
rc = cw_send_request(conn, CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// mavl_merge(conn->config, conn->outgoing);
|
|
||||||
// mavl_destroy(conn->outgoing);
|
|
||||||
// conn->outgoing = mbag_create();
|
|
||||||
// props_to_sql(conn,conn->incomming,0);
|
|
||||||
// radios_to_sql(conn);
|
|
||||||
// mavl_destroy(r);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
r = db_get_radio_tasks(conn, sock_addr2str(&conn->addr,sock_buf));
|
|
||||||
if (r) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
// if (!conn->radios_upd->count)
|
|
||||||
// continue;
|
|
||||||
*/
|
|
||||||
cw_dbg(DBG_INFO, "Updating Radios for %s",sock_addr2str(&conn->addr,sock_buf));
|
|
||||||
rc = cw_send_request(conn, CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// conn_clear_upd(conn,1);
|
|
||||||
|
|
||||||
// mavl_destroy(conn->radios_upd);
|
|
||||||
// conn->radios_upd=mbag_i_create();
|
|
||||||
|
|
||||||
|
|
||||||
// radios_to_sql(conn);
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
rc = cw_send_request(conn, CW_MSG_CONFIGURATION_UPDATE_REQUEST);
|
|
||||||
mavl_merge(conn->config, conn->outgoing);
|
|
||||||
mavl_destroy(conn->outgoing);
|
|
||||||
conn->outgoing = mbag_create();
|
|
||||||
config_to_sql(conn);
|
|
||||||
radios_to_sql(conn);
|
|
||||||
mavl_destroy(r);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
db_ping_wtp(sock_addr2str_p(&conn->addr,sock_buf), "");
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void wtpman_run_dtls(void *arg)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* reject connections to our multi- or broadcast sockets */
|
|
||||||
if (socklist[wtpman->socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
|
|
||||||
cw_dbg(DBG_DTLS, "Dropping connection from %s to non-unicast socket.",
|
|
||||||
sock_addr2str_p(&wtpman->conn->addr,sock_buf));
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*// time_t timer = cw_timer_start(wtpman->conn->wait_dtls);*/
|
|
||||||
|
|
||||||
/* establish dtls session */
|
|
||||||
if (!wtpman_establish_dtls(wtpman)) {
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wtpman_run(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wtpman_destroy(struct wtpman *wtpman)
|
|
||||||
{
|
|
||||||
if (wtpman->conn)
|
|
||||||
conn_destroy(wtpman->conn);
|
|
||||||
free(wtpman);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr)
|
|
||||||
{
|
|
||||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
|
||||||
struct wtpman *wtpman;
|
|
||||||
wtpman = malloc(sizeof(struct wtpman));
|
|
||||||
if (!wtpman)
|
|
||||||
return 0;
|
|
||||||
memset(wtpman, 0, sizeof(struct wtpman));
|
|
||||||
|
|
||||||
|
|
||||||
int replyfd;
|
|
||||||
if (socklist[socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
|
|
||||||
|
|
||||||
int port = sock_getport(&socklist[socklistindex].addr);
|
|
||||||
replyfd = socklist_find_reply_socket(srcaddr, port);
|
|
||||||
|
|
||||||
if (replyfd == -1) {
|
|
||||||
cw_log(LOG_ERR, "Can't find reply socket for request from %s",
|
|
||||||
sock_addr2str(srcaddr,sock_buf));
|
|
||||||
free(wtpman);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
replyfd = socklist[socklistindex].sockfd;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sockfd = replyfd; /*//socklist[socklistindex].reply_sockfd;
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct sockaddr dbgaddr;
|
|
||||||
socklen_t dbgaddrl = sizeof(dbgaddr);
|
|
||||||
getsockname(sockfd, &dbgaddr, &dbgaddrl);
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO, "Creating wtpman on socket %d, %s:%d", sockfd,
|
|
||||||
sock_addr2str(&dbgaddr,sock_buf), sock_getport(&dbgaddr));
|
|
||||||
|
|
||||||
/*
|
|
||||||
//extern int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
|
||||||
// struct sockaddr *from);
|
|
||||||
*/
|
|
||||||
wtpman->conn = conn_create(sockfd, srcaddr, 100);
|
|
||||||
wtpman->conn->role = CW_ROLE_AC;
|
|
||||||
|
|
||||||
wtpman->conn->data_sock = socklist[socklistindex].data_sockfd;
|
|
||||||
sock_copyaddr(&wtpman->conn->data_addr, (struct sockaddr *) &wtpman->conn->addr);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// wtpman->conn->process_packet = conn_process_packet2;
|
|
||||||
*/
|
|
||||||
if (!wtpman->conn) {
|
|
||||||
wtpman_destroy(wtpman);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wtpman->conn->mods = conf_mods;
|
|
||||||
|
|
||||||
wtpman->conn->strict_capwap = conf_strict_capwap;
|
|
||||||
wtpman->conn->strict_hdr = conf_strict_headers;
|
|
||||||
/*
|
|
||||||
// wtpman->conn->radios = mbag_i_create();
|
|
||||||
// wtpman->conn->radios_upd = mbag_i_create();
|
|
||||||
// wtpman->conn->local = ac_config;
|
|
||||||
//wtpman->conn->capwap_mode=0; //CW_MODE_STD; //CISCO;
|
|
||||||
// wtpman->conn->capwap_mode = CW_MODE_CISCO;
|
|
||||||
//wtpman->conn->strict_capwap_hdr=0;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wtpman->conn->local_cfg = cw_ktv_create();
|
|
||||||
wtpman->conn->global_cfg = actube_global_cfg;
|
|
||||||
wtpman->conn->local_cfg = actube_global_cfg;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return wtpman;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
|
|
||||||
{
|
|
||||||
conn_q_add_packet(wtpman->conn, packet, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int nodtls = 0;
|
|
||||||
|
|
||||||
|
|
||||||
void wtpman_start(struct wtpman *wtpman, int dtlsmode)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (dtlsmode) {
|
|
||||||
cw_dbg(DBG_INFO, "Starting wtpman in DTLS mode");
|
|
||||||
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_dtls,
|
|
||||||
(void *) wtpman);
|
|
||||||
} else {
|
|
||||||
cw_dbg(DBG_INFO, "Starting wtpman in non-dtls mode");
|
|
||||||
|
|
||||||
if (nodtls) {
|
|
||||||
wtpman->conn->process_message = xprocess_message;
|
|
||||||
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run,
|
|
||||||
(void *) wtpman);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_discovery,
|
|
||||||
(void *) wtpman);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wtpman_lw_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
// uint8_t * m = packet+12;
|
|
||||||
// int l = LWTH_GET_LENGTH(packet+6);
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t *msg = packet + 12;
|
|
||||||
|
|
||||||
|
|
||||||
int msgtype = LWMSG_GET_TYPE(msg);
|
|
||||||
int msglen = LWMSG_GET_LEN(msg);
|
|
||||||
printf("Type is %d, Len is %d\n", msgtype, msglen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// uint8_t *msgdata = LWMSG_GET_DATA(msg);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
int c=0;
|
|
||||||
while (c < msglen){
|
|
||||||
int eltype = LWMSGELEM_GET_TYPE(data);
|
|
||||||
int ellen = LWMSGELEM_GET_LEN(data);
|
|
||||||
printf ("ELEM TYPE: %d, LEN: %d\n",eltype,ellen);
|
|
||||||
c+=ellen+3;
|
|
||||||
data=data+ellen+3;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*//uint8_t *data;*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
lw_foreach_msgelem(data,msgdata,msglen){
|
|
||||||
int eltype = LWMSGELEM_GET_TYPE(data);
|
|
||||||
int ellen = LWMSGELEM_GET_LEN(data);
|
|
||||||
uint8_t * eldata = LWMSGELEM_GET_DATA(data);
|
|
||||||
|
|
||||||
wtpinfo_lwreadelem_wtp_descriptor(&wtpman->wtpinfo,eltype,eldata,ellen);
|
|
||||||
|
|
||||||
printf ("ELEM TYPE: %d, LEN: %d\n",eltype,ellen);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
// char wi[4096];
|
|
||||||
// wtpinfo_print(wi, &wtpman->wtpinfo);
|
|
||||||
// printf("WTPINFO: \n%s\n", wi);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// char buffer[2048];
|
|
||||||
// struct lwmsg lwmsg;
|
|
||||||
// lwmsg_init(&lwmsg, buffer,conf_macaddress,LWMSG_DISCOVERY_RESPONSE,conn_get_next_seqnum(wtpman->conn));
|
|
||||||
|
|
||||||
// conn_send_packet(wtpman->conn,buffer,60);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void wtpman_lw_start(struct wtpman *wtpman)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
@ -1,65 +0,0 @@
|
|||||||
#ifndef __WTPMAN_H
|
|
||||||
#define __WTPMAN_H
|
|
||||||
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <semaphore.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "cw/capwap.h"
|
|
||||||
#include "cw/fragman.h"
|
|
||||||
#include "cw/timer.h"
|
|
||||||
|
|
||||||
#define WTPMAN_QSIZE 1024
|
|
||||||
|
|
||||||
struct wtpman{
|
|
||||||
pthread_t thread;
|
|
||||||
|
|
||||||
/* packet queue */
|
|
||||||
/* uint8_t * q[WTPMAN_QSIZE];
|
|
||||||
int qrpos;
|
|
||||||
int qwpos;
|
|
||||||
sem_t q_sem;
|
|
||||||
*/
|
|
||||||
struct conn * conn;
|
|
||||||
|
|
||||||
|
|
||||||
/* wtp data */
|
|
||||||
uint8_t * wtp_name;
|
|
||||||
uint8_t * wtp_location;
|
|
||||||
uint8_t * session_id;
|
|
||||||
uint8_t wtp_mactype;
|
|
||||||
|
|
||||||
/* //struct wtpinfo wtpinfo;*/
|
|
||||||
|
|
||||||
|
|
||||||
int socklistindex;
|
|
||||||
int connected;
|
|
||||||
|
|
||||||
|
|
||||||
cw_timer_t echointerval_timer;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
struct wtp{
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//extern void wtpman_run(void *arg);
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern struct wtpman * wtpman_create();
|
|
||||||
|
|
||||||
extern struct wtpman * wtpman_create(int socklistindex,struct sockaddr * srcaddr);
|
|
||||||
|
|
||||||
extern void wtpman_addpacket(struct wtpman * wtpman,uint8_t *packet,int len);
|
|
||||||
extern void wtpman_destroy(struct wtpman * wtpman);
|
|
||||||
extern void wtpman_start(struct wtpman * wtpman,int dtlsmode);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -32,6 +32,7 @@ void ucfg_cmd(struct shelldata *sd, const char * cmd);
|
|||||||
void set_cmd(struct shelldata *sd, const char * cmd);
|
void set_cmd(struct shelldata *sd, const char * cmd);
|
||||||
void del_cmd(struct shelldata *sd, const char * cmd);
|
void del_cmd(struct shelldata *sd, const char * cmd);
|
||||||
void send_cmd(struct shelldata *sd, const char * cmd);
|
void send_cmd(struct shelldata *sd, const char * cmd);
|
||||||
|
void wlan0_cmd(struct shelldata *sd, const char * cmd);
|
||||||
void show_cfg (FILE *out, mavl_t ktv);
|
void show_cfg (FILE *out, mavl_t ktv);
|
||||||
void show_aps (FILE *out);
|
void show_aps (FILE *out);
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ static struct command cmdlist[]={
|
|||||||
{"select", select_cmd },
|
{"select", select_cmd },
|
||||||
{"send", send_cmd},
|
{"send", send_cmd},
|
||||||
{"set", set_cmd },
|
{"set", set_cmd },
|
||||||
|
{"wlan0",wlan0_cmd},
|
||||||
|
|
||||||
|
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
@ -106,10 +108,29 @@ send_cmd(struct shelldata * sd, const char *cmd)
|
|||||||
wtplist_unlock();
|
wtplist_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wlan0_cmd(struct shelldata * sd, const char *cmd)
|
||||||
|
{
|
||||||
|
struct conn * conn;
|
||||||
|
wtplist_lock();
|
||||||
|
conn = find_ap(sd->prompt);
|
||||||
|
if (conn==NULL){
|
||||||
|
fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
FILE *f=fopen("wlan0.ktv","r");
|
||||||
|
cw_ktv_read_file(f,sd->update_cfg,conn->msgset->types_tree);
|
||||||
|
//conn->update_cfg=sd->update_cfg;
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
wtplist_unlock();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void set_cmd(struct shelldata *sd, const char *str)
|
void set_cmd(struct shelldata *sd, const char *str)
|
||||||
{
|
{
|
||||||
struct conn * conn;
|
struct conn * conn;
|
||||||
struct cw_KTV_Reader r;
|
struct cw_Val_Reader r;
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
char type[CW_KTV_MAX_KEY_LEN];
|
char type[CW_KTV_MAX_KEY_LEN];
|
||||||
char val[2048];
|
char val[2048];
|
||||||
@ -134,7 +155,7 @@ void del_cmd(struct shelldata *sd, const char *str)
|
|||||||
void show_cfg (FILE *out, mavl_t ktv)
|
void show_cfg (FILE *out, mavl_t ktv)
|
||||||
{
|
{
|
||||||
char value[500];
|
char value[500];
|
||||||
struct cw_KTV * data;
|
struct cw_Val * data;
|
||||||
mavliter_t it;
|
mavliter_t it;
|
||||||
const struct cw_Type * type;
|
const struct cw_Type * type;
|
||||||
|
|
||||||
@ -165,7 +186,7 @@ void show_aps (FILE *out)
|
|||||||
mavliter_init (&it, cl->by_addr);
|
mavliter_init (&it, cl->by_addr);
|
||||||
fprintf (out, "IP\t\t\twtp-name\n");
|
fprintf (out, "IP\t\t\twtp-name\n");
|
||||||
mavliter_foreach (&it) {
|
mavliter_foreach (&it) {
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
char addr[SOCK_ADDR_BUFSIZE];
|
char addr[SOCK_ADDR_BUFSIZE];
|
||||||
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
||||||
struct conn * conn;
|
struct conn * conn;
|
||||||
@ -201,7 +222,7 @@ struct conn * find_ap(const char *name)
|
|||||||
|
|
||||||
mavliter_init (&it, cl->by_addr);
|
mavliter_init (&it, cl->by_addr);
|
||||||
mavliter_foreach (&it) {
|
mavliter_foreach (&it) {
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
||||||
struct conn * conn;
|
struct conn * conn;
|
||||||
conn = mavliter_get_ptr (&it);
|
conn = mavliter_get_ptr (&it);
|
||||||
@ -242,7 +263,7 @@ void con (FILE *out)
|
|||||||
mavliter_init (&it, cl->by_addr);
|
mavliter_init (&it, cl->by_addr);
|
||||||
fprintf (out, "IP\t\t\twtp-name\n");
|
fprintf (out, "IP\t\t\twtp-name\n");
|
||||||
mavliter_foreach (&it) {
|
mavliter_foreach (&it) {
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
char addr[SOCK_ADDR_BUFSIZE];
|
char addr[SOCK_ADDR_BUFSIZE];
|
||||||
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
|
||||||
struct conn * conn;
|
struct conn * conn;
|
||||||
@ -297,7 +318,7 @@ void execute_cmd (struct shelldata * sd, const char *str)
|
|||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
char args[1024];
|
char args[1024];
|
||||||
int n;
|
int n;
|
||||||
struct cw_KTV_Reader reader;
|
struct cw_Val_Reader reader;
|
||||||
struct command * searchcmd;
|
struct command * searchcmd;
|
||||||
|
|
||||||
args[0]=0;
|
args[0]=0;
|
||||||
@ -370,6 +391,7 @@ void shell_loop (FILE *file)
|
|||||||
{
|
{
|
||||||
struct shelldata sd;
|
struct shelldata sd;
|
||||||
int c;
|
int c;
|
||||||
|
c=0;
|
||||||
/* setvbuf(file,NULL,_IONBF,0);
|
/* setvbuf(file,NULL,_IONBF,0);
|
||||||
fflush(file);
|
fflush(file);
|
||||||
*/
|
*/
|
||||||
@ -404,7 +426,9 @@ void * run_shell (void * arg)
|
|||||||
const char * addr = "127.0.0.1:5000";
|
const char * addr = "127.0.0.1:5000";
|
||||||
int sockfd, clientsock;
|
int sockfd, clientsock;
|
||||||
int yes;
|
int yes;
|
||||||
while(1){
|
|
||||||
|
|
||||||
|
cw_dbg(DBG_INFO,"Staring shelli listening at: %s",addr);
|
||||||
|
|
||||||
|
|
||||||
rc = sock_strtoaddr (addr, (struct sockaddr*) &server);
|
rc = sock_strtoaddr (addr, (struct sockaddr*) &server);
|
||||||
@ -435,16 +459,17 @@ while(1){
|
|||||||
|
|
||||||
|
|
||||||
client_size = sizeof (client);
|
client_size = sizeof (client);
|
||||||
|
while(1){
|
||||||
|
|
||||||
clientsock = accept (sockfd, (struct sockaddr*) &client, &client_size);
|
clientsock = accept (sockfd, (struct sockaddr*) &client, &client_size);
|
||||||
|
|
||||||
if (clientsock > 0) {
|
if (clientsock > 0) {
|
||||||
sock_addr2str_p (&client, sockstr);
|
sock_addr2str_p (&client, sockstr);
|
||||||
cw_dbg (DBG_INFO, "Acceptiong session from %s", sockstr);
|
cw_dbg (DBG_INFO, "Acceptiong session from %s", sockstr);
|
||||||
printf("New shell lopp\n");
|
cw_dbg (DBG_INFO, "Start shell");
|
||||||
shell_loop (fdopen (clientsock, "a+"));
|
shell_loop (fdopen (clientsock, "a+"));
|
||||||
printf("end shell lopp\n");
|
cw_dbg (DBG_INFO, "Stop shell");
|
||||||
close (clientsock);
|
close (clientsock);
|
||||||
printf("close clsock\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "socklist.h"
|
#include "socklist.h"
|
||||||
#include "wtpman.h"
|
#include "wtpman.h"
|
||||||
#include "wtplist.h"
|
#include "wtplist.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
|
|
||||||
#include "actube.h"
|
#include "actube.h"
|
||||||
|
|
||||||
@ -114,23 +114,6 @@ static void wtpman_run_discovery(void *arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
int xprocess_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
|
||||||
struct sockaddr *from)
|
|
||||||
{
|
|
||||||
uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);
|
|
||||||
uint32_t type = cw_get_msg_type(msgptr);
|
|
||||||
cw_log(LOG_ERR, "Hey: %d", type);
|
|
||||||
if (type == CAPWAP_MSG_DISCOVERY_REQUEST)
|
|
||||||
conn->capwap_state = CAPWAP_STATE_DISCOVERY;
|
|
||||||
|
|
||||||
|
|
||||||
return process_message(conn, rawmsg, rawlen, from);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static int wtpman_dtls_setup(void *arg)
|
static int wtpman_dtls_setup(void *arg)
|
||||||
{
|
{
|
||||||
char cipherstr[512];
|
char cipherstr[512];
|
||||||
@ -387,62 +370,6 @@ static void * wtpman_main(void *arg)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
switch (conn->capwap_transition){
|
|
||||||
case CW_TRANSITION(CAPWAP_STATE_DTLS_SETUP, CAPWAP_STATE_JOIN):
|
|
||||||
{
|
|
||||||
|
|
||||||
wait_join = cw_ktv_get_word(conn->global_cfg,"wait-join",CAPWAP_WAIT_JOIN);
|
|
||||||
timer = cw_timer_start(wait_join);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CW_TRANSITION(CAPWAP_STATE_JOIN, CAPWAP_STATE_JOIN):
|
|
||||||
{
|
|
||||||
char wtpname[CAPWAP_MAX_WTP_NAME_LEN];
|
|
||||||
cw_KTV_t * result;
|
|
||||||
result = cw_ktv_get(conn->remote_cfg,"wtp-name",NULL);
|
|
||||||
result->type->to_str(result,wtpname,CAPWAP_MAX_WTP_NAME_LEN);
|
|
||||||
cw_dbg(DBG_INFO, "WTP joined: '%s', IP %s.",
|
|
||||||
wtpname,
|
|
||||||
sock_addr2str(&conn->addr,sock_buf)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CW_TRANSITION(CAPWAP_STATE_JOIN,CAPWAP_STATE_TIMEOUT):
|
|
||||||
{
|
|
||||||
cw_dbg(DBG_MSG_ERR, "No join request from %s after %d seconds, WTP died.",
|
|
||||||
sock_addr2str(&wtpman->conn->addr,sock_buf), wait_join);
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CW_TRANSITION(CAPWAP_STATE_JOIN, CAPWAP_STATE_CONFIGURE):
|
|
||||||
{
|
|
||||||
|
|
||||||
wait_change_state = cw_ktv_get_word(conn->global_cfg,
|
|
||||||
"capwap-timers/change-state-pending-timer",
|
|
||||||
CAPWAP_TIMER_CHANGE_STATE_PENDING_TIMER);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CW_TRANSITION(CAPWAP_STATE_CONFIGURE,CAPWAP_STATE_TIMEOUT):
|
|
||||||
{
|
|
||||||
cw_dbg(DBG_MSG_ERR, "No Change State Event Request %s after %d seconds, WTP died.",
|
|
||||||
sock_addr2str(&wtpman->conn->addr,sock_buf), wait_change_state);
|
|
||||||
wtpman_remove(wtpman);
|
|
||||||
return NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (!cw_timer_timeout(timer)) {
|
while (!cw_timer_timeout(timer)) {
|
||||||
if (conn->update_cfg != NULL){
|
if (conn->update_cfg != NULL){
|
||||||
mavl_t tmp;
|
mavl_t tmp;
|
||||||
@ -451,7 +378,7 @@ static void * wtpman_main(void *arg)
|
|||||||
tmp = conn->local_cfg;
|
tmp = conn->local_cfg;
|
||||||
|
|
||||||
mavl_merge(conn->default_cfg, conn->local_cfg);
|
mavl_merge(conn->default_cfg, conn->local_cfg);
|
||||||
mavl_merge(conn->default_cfg, conn->remote_cfg);
|
/* mavl_merge(conn->default_cfg, conn->remote_cfg);*/
|
||||||
|
|
||||||
conn->local_cfg=conn->update_cfg;
|
conn->local_cfg=conn->update_cfg;
|
||||||
|
|
||||||
@ -462,6 +389,8 @@ static void * wtpman_main(void *arg)
|
|||||||
cw_dbg(DBG_INFO, "Updating WTP %s",sock_addr2str(&conn->addr,sock_buf));
|
cw_dbg(DBG_INFO, "Updating WTP %s",sock_addr2str(&conn->addr,sock_buf));
|
||||||
|
|
||||||
rc = cw_send_request(conn, CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST);
|
rc = cw_send_request(conn, CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST);
|
||||||
|
mavl_merge(conn->remote_cfg,conn->update_cfg);
|
||||||
|
|
||||||
conn->update_cfg=NULL;
|
conn->update_cfg=NULL;
|
||||||
conn->local_cfg=tmp;
|
conn->local_cfg=tmp;
|
||||||
}
|
}
|
||||||
@ -578,7 +507,7 @@ cw_dbg_ktv_dump(conn->remote_cfg,DBG_INFO,"-------------dump------------","DMP",
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*// cw_dbg(DBG_X, "Time left: %d",
|
/*// cw_dbg(DBG_X, "Time left: %d",
|
||||||
//*/
|
// */
|
||||||
/*cw_timer_timeleft(wtpman->echointerval_timer);*/
|
/*cw_timer_timeleft(wtpman->echointerval_timer);*/
|
||||||
|
|
||||||
if (cw_timer_timeout(wtpman->echointerval_timer)) {
|
if (cw_timer_timeout(wtpman->echointerval_timer)) {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
include ../Defs.mak
|
include ../Defs.mak
|
||||||
MFDEPS=../Defs.mak ../LocalDefs.mak
|
MFDEPS=../Defs.mak
|
||||||
|
|
||||||
|
|
||||||
CWSRC=\
|
CWSRC=\
|
||||||
cw_write_header.c\
|
|
||||||
cw_check_missing_mand.c\
|
cw_check_missing_mand.c\
|
||||||
cw_clock_lap.c\
|
cw_clock_lap.c\
|
||||||
cw_dbg_elem.c\
|
cw_dbg_elem.c\
|
||||||
@ -93,7 +92,6 @@ KTVSRC=\
|
|||||||
cw_ktv_get_dword.c\
|
cw_ktv_get_dword.c\
|
||||||
cw_ktv_get_sysptr.c\
|
cw_ktv_get_sysptr.c\
|
||||||
cw_ktv_get_str.c\
|
cw_ktv_get_str.c\
|
||||||
cw_ktv_parser.c\
|
|
||||||
cw_ktv_idx_get.c\
|
cw_ktv_idx_get.c\
|
||||||
cw_ktv_mavlcmp.c\
|
cw_ktv_mavlcmp.c\
|
||||||
cw_ktv_mavlcmp_type_by_name.c\
|
cw_ktv_mavlcmp_type_by_name.c\
|
||||||
@ -106,6 +104,8 @@ KTVSRC=\
|
|||||||
cw_ktv_base_exists.c\
|
cw_ktv_base_exists.c\
|
||||||
cw_ktv_save.c\
|
cw_ktv_save.c\
|
||||||
cw_ktv_del_sub.c\
|
cw_ktv_del_sub.c\
|
||||||
|
cw_ktv_parser.c\
|
||||||
|
cfg.c\
|
||||||
|
|
||||||
|
|
||||||
LWSRC=\
|
LWSRC=\
|
||||||
@ -231,7 +231,7 @@ DTLSSRC += dtls_openssl.c \
|
|||||||
dtls_openssl_connect.c \
|
dtls_openssl_connect.c \
|
||||||
dtls_openssl_get_cipher.c \
|
dtls_openssl_get_cipher.c \
|
||||||
dtls_openssl_bio.c
|
dtls_openssl_bio.c
|
||||||
LIBS+=-lssl
|
LIBS=
|
||||||
|
|
||||||
#DTLSSRC+= dtls_gnutls.c \
|
#DTLSSRC+= dtls_gnutls.c \
|
||||||
# dtls_gnutls_accept.c \
|
# dtls_gnutls_accept.c \
|
||||||
@ -256,13 +256,12 @@ OBJDIR := ../../obj/cw/$(KERNEL)/$(ARCH)
|
|||||||
SNAME := $(LIBARCHDIR)/libcw.a
|
SNAME := $(LIBARCHDIR)/libcw.a
|
||||||
DNAME := $(LIBARCHDIR)/libcw.so
|
DNAME := $(LIBARCHDIR)/libcw.so
|
||||||
|
|
||||||
CFLAGS+=-fPIC -DUSE_OPENSSL -O0 -I../../include
|
CFLAGS+=-fPIC -DUSE_OPENSSL -O0 -I../../include -I/usr/local/include
|
||||||
CFLAGS+=-g
|
CFLAGS+=-g
|
||||||
|
|
||||||
all: $(SNAME) $(DNAME)
|
all: $(SNAME) $(DNAME)
|
||||||
static: $(SNAME)
|
static: $(SNAME)
|
||||||
dynamic: $(DNAME)
|
dynamic: $(DNAME)
|
||||||
|
|
||||||
|
|
||||||
include ../lib.mk
|
include ../lib.mk
|
||||||
|
|
||||||
|
372
src/cw/cfg.c
Normal file
372
src/cw/cfg.c
Normal file
@ -0,0 +1,372 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <mavl.h>
|
||||||
|
|
||||||
|
#include "cw.h"
|
||||||
|
#include "cfg.h"
|
||||||
|
#include "val.h"
|
||||||
|
|
||||||
|
static int cmp(const void *k1,const void*k2){
|
||||||
|
struct cw_Cfg_entry * e1,*e2;
|
||||||
|
e1=(struct cw_Cfg_entry *)k1;
|
||||||
|
e2=(struct cw_Cfg_entry *)k2;
|
||||||
|
return strcmp(e1->key,e2->key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void del(void *ptr)
|
||||||
|
{
|
||||||
|
struct cw_Cfg_entry * e;
|
||||||
|
e=(struct cw_Cfg_entry *)ptr;
|
||||||
|
free(e->key);
|
||||||
|
free(e->val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cw_Cfg_t * cw_cfg_create()
|
||||||
|
{
|
||||||
|
return mavl_create(cmp, del, sizeof(struct cw_Cfg_entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
int cw_cfg_set(cw_Cfg_t * cfg,const char *key, const char *val)
|
||||||
|
{
|
||||||
|
struct cw_Cfg_entry e;
|
||||||
|
int replaced;
|
||||||
|
|
||||||
|
e.key = cw_strdup(key);
|
||||||
|
if (!e.key)
|
||||||
|
return 0;
|
||||||
|
e.val = cw_strdup(val);
|
||||||
|
if (!e.val){
|
||||||
|
free(e.key);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void * rc = mavl_replace(cfg,&e,&replaced);
|
||||||
|
if (!rc){
|
||||||
|
del(&e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!replaced)
|
||||||
|
return 1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * cw_cfg_get(cw_Cfg_t * cfg, char *key)
|
||||||
|
{
|
||||||
|
struct cw_Cfg_entry e,*r;
|
||||||
|
e.key = key;
|
||||||
|
r = mavl_get(cfg,&e);
|
||||||
|
if (!r)
|
||||||
|
return NULL;
|
||||||
|
return r->val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, char *key)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void cw_cfg_dump(cw_Cfg_t *cfg)
|
||||||
|
{
|
||||||
|
mavliter_t it;
|
||||||
|
struct cw_Cfg_entry *e;
|
||||||
|
mavliter_init(&it,cfg);
|
||||||
|
mavliter_foreach(&it){
|
||||||
|
|
||||||
|
e = mavliter_get(&it);
|
||||||
|
printf("%s: '%s'\n",e->key,e->val);
|
||||||
|
//cw_dbg(dbglevel,"%s%s :%s: %s",prefix,data->key,type->get_type_name(data), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct parser {
|
||||||
|
int line;
|
||||||
|
int pos;
|
||||||
|
int prevpos;
|
||||||
|
char error[256];
|
||||||
|
int quote;
|
||||||
|
FILE *f;
|
||||||
|
int (*getc)(struct parser *);
|
||||||
|
void (*ungetc)(struct parser *);
|
||||||
|
};
|
||||||
|
|
||||||
|
static int get_char(struct parser *p)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
c = fgetc (p->f);
|
||||||
|
p->pos++;
|
||||||
|
if (c=='\n'){
|
||||||
|
p->prevpos=p->pos;
|
||||||
|
p->line ++;
|
||||||
|
p->pos=0;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unget_char(struct parser *p,int c){
|
||||||
|
ungetc(c,p->f);
|
||||||
|
if (c=='\n'){
|
||||||
|
p->line--;
|
||||||
|
p->pos=p->prevpos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
p->pos--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int get_char_q(struct parser *p)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
c = get_char(p);
|
||||||
|
if (c==EOF || c=='\n')
|
||||||
|
return c;
|
||||||
|
|
||||||
|
if(c=='"' && !p->quote){
|
||||||
|
p->quote=1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(c=='"' && p->quote){
|
||||||
|
p->quote=0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!p->quote)
|
||||||
|
return c;
|
||||||
|
|
||||||
|
if (c!='\\')
|
||||||
|
return c;
|
||||||
|
|
||||||
|
c = get_char(p);
|
||||||
|
switch(c){
|
||||||
|
case EOF:
|
||||||
|
return c;
|
||||||
|
case 'n':
|
||||||
|
return '\n';
|
||||||
|
|
||||||
|
case '\\':
|
||||||
|
return '\\';
|
||||||
|
case '"':
|
||||||
|
return '"';
|
||||||
|
default:
|
||||||
|
unget_char(p,c);
|
||||||
|
return '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We will never reach here */
|
||||||
|
/* return c;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
static int skip_chars (struct parser *p, const char * chars)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
while ( (c = get_char (p)) != EOF) {
|
||||||
|
if (strchr (chars, c))
|
||||||
|
continue;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int skip_to_chars (struct parser *p, const char *chars)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
while ( (c = get_char (p)) != EOF) {
|
||||||
|
if (strchr (chars, c))
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int read_key (struct parser *p, char *key, int max_len)
|
||||||
|
{
|
||||||
|
int c,n;
|
||||||
|
|
||||||
|
do {
|
||||||
|
c = skip_chars (p, " \t\n\a\v");
|
||||||
|
if (c == '#') {
|
||||||
|
c = skip_to_chars (p, "\n\a");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (c != EOF);
|
||||||
|
|
||||||
|
unget_char(p,c);
|
||||||
|
c=get_char_q(p);
|
||||||
|
|
||||||
|
n=0;
|
||||||
|
while(c!=EOF && n<max_len){
|
||||||
|
if (!p->quote && !isalnum(c) && !strchr("._/-()@#|{}[]\\",c)/*strchr(": \t\n\a",c)*/){
|
||||||
|
unget_char(p,c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
key[n]=c;
|
||||||
|
|
||||||
|
c=get_char_q(p);
|
||||||
|
n++;
|
||||||
|
|
||||||
|
}
|
||||||
|
key[n]=0;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int skip_to_colon(FILE *f,struct parser * p)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
c = skip_chars (p, " \t");
|
||||||
|
if (c!=':'){
|
||||||
|
if (c=='\n'){
|
||||||
|
unget_char(p,c);
|
||||||
|
sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL, collon expected.", p->line, p->pos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
sprintf(p->error,"Error at line %d, pos %d: Collon expected.", p->line, p->pos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int read_val(struct parser *p, char *val, int max_len){
|
||||||
|
int c,n,quote;
|
||||||
|
if (!skip_to_colon(p->f,p))
|
||||||
|
return -1;
|
||||||
|
c = skip_chars (p, " \t");
|
||||||
|
if (c=='"'){
|
||||||
|
quote=1;
|
||||||
|
c=get_char(p);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
quote=0;
|
||||||
|
}
|
||||||
|
n=0;
|
||||||
|
while(c!=EOF && n<max_len){
|
||||||
|
if (quote && c=='"'){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (c=='\n'){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (quote){
|
||||||
|
if (c=='\\'){
|
||||||
|
c = get_char(p);
|
||||||
|
switch(c){
|
||||||
|
case 'n':
|
||||||
|
c='\n';
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
unget_char(p,c);
|
||||||
|
c='\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val[n++]=c;
|
||||||
|
c=get_char(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!quote && n>0){
|
||||||
|
while(n>0){
|
||||||
|
if (isspace(val[n-1]))
|
||||||
|
n--;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val[n]=0;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cw_cfg_read_line (FILE *f, struct parser *p, char * key, char *val)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
|
||||||
|
n = read_key (p,key,CW_CFG_MAX_KEY_LEN);
|
||||||
|
if (n==0)
|
||||||
|
return 1;
|
||||||
|
if (n==-1){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = read_val (p,val,CW_CFG_MAX_KEY_LEN);
|
||||||
|
if (n==-1){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cw_cfg_read_from_file(FILE * f, cw_Cfg_t * cfg)
|
||||||
|
{
|
||||||
|
char key[CW_CFG_MAX_KEY_LEN];
|
||||||
|
char val[2048];
|
||||||
|
struct parser p;
|
||||||
|
|
||||||
|
p.line=1;
|
||||||
|
p.pos=0;
|
||||||
|
p.prevpos=0;
|
||||||
|
p.quote=0;
|
||||||
|
p.f=f;
|
||||||
|
|
||||||
|
int rc;
|
||||||
|
int errs=0;
|
||||||
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
rc = cw_cfg_read_line(f,&p,key,val);
|
||||||
|
if (rc==-1){
|
||||||
|
fprintf(stderr,"Error: %s\n",p.error);
|
||||||
|
errs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (rc != 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
cw_cfg_set(cfg,key,val);
|
||||||
|
|
||||||
|
|
||||||
|
}while(rc==0);
|
||||||
|
|
||||||
|
return errs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int cw_cfg_load(const char *filename,cw_Cfg_t * cfg)
|
||||||
|
{
|
||||||
|
int errs;
|
||||||
|
FILE *f = fopen(filename,"rb");
|
||||||
|
if (!f)
|
||||||
|
return errno;
|
||||||
|
errs = cw_cfg_read_from_file(f,cfg);
|
||||||
|
fclose(f);
|
||||||
|
return errs;
|
||||||
|
}
|
25
src/cw/cfg.h
Normal file
25
src/cw/cfg.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef _CFG_H
|
||||||
|
#define _CFG_H
|
||||||
|
|
||||||
|
#include <mavl.h>
|
||||||
|
|
||||||
|
#define CW_CFG_MAX_KEY_LEN 1024
|
||||||
|
|
||||||
|
typedef struct mavl cw_Cfg_t;
|
||||||
|
|
||||||
|
cw_Cfg_t * cw_cfg_create();
|
||||||
|
int cw_cfg_set(cw_Cfg_t *cfg,const char *key, const char *val);
|
||||||
|
void cw_cfg_dump(cw_Cfg_t *cfg);
|
||||||
|
int cw_cfg_read_from_file(FILE * file, cw_Cfg_t * cfg);
|
||||||
|
int cw_cfg_load(const char *filename,cw_Cfg_t * cfg);
|
||||||
|
|
||||||
|
struct cw_Cfg_entry{
|
||||||
|
char *key;
|
||||||
|
char *val;
|
||||||
|
};
|
||||||
|
|
||||||
|
char * cw_cfg_get(cw_Cfg_t * cfg, char *key);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -90,7 +90,7 @@ struct conn * conn_create(int sock, struct sockaddr * addr, int qsize)
|
|||||||
/* conn->send_data_packet = conn_send_data_packet;*/
|
/* conn->send_data_packet = conn_send_data_packet;*/
|
||||||
|
|
||||||
conn->last_seqnum_received=-1;
|
conn->last_seqnum_received=-1;
|
||||||
conn->mtu=500;
|
conn->mtu=600;
|
||||||
|
|
||||||
|
|
||||||
conn->cur_packet=0;
|
conn->cur_packet=0;
|
||||||
@ -102,7 +102,7 @@ struct conn * conn_create(int sock, struct sockaddr * addr, int qsize)
|
|||||||
|
|
||||||
/* conn->write_data = conn->send_data_packet; */
|
/* conn->write_data = conn->send_data_packet; */
|
||||||
|
|
||||||
conn->dtls_mtu = 500;
|
conn->dtls_mtu = 600;
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "mod.h"
|
#include "mod.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -515,6 +515,7 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
|
|||||||
if ((sd > 0 && sd < 128) || (sd < 0 && sd < -128) || s1 < 0) {
|
if ((sd > 0 && sd < 128) || (sd < 0 && sd < -128) || s1 < 0) {
|
||||||
/* seqnum is ok, normal message processing */
|
/* seqnum is ok, normal message processing */
|
||||||
conn->last_seqnum_received = seqnum;
|
conn->last_seqnum_received = seqnum;
|
||||||
|
|
||||||
return process_elements(conn, rawmsg, rawlen, from);
|
return process_elements(conn, rawmsg, rawlen, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
|
|||||||
handler->name);
|
handler->name);
|
||||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf ("USING HANDLERi TO DECODE: %d %s\n",handler->id,handler->name);
|
||||||
rc = handler->get(handler, params, data, len);
|
rc = handler->get(handler, params, data, len);
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
int cw_detect_nat(struct conn *conn)
|
int cw_detect_nat(struct conn *conn)
|
||||||
{
|
{
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
|
|
||||||
char local_str[128];
|
char local_str[128];
|
||||||
char remote_str[128];
|
char remote_str[128];
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||||
uint8_t * elem_data, int elem_len)
|
uint8_t * elem_data, int elem_len)
|
||||||
{
|
{
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
|
|
||||||
if (!handler->type){
|
if (!handler->type){
|
||||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
|
|
||||||
static const cw_KTVEnum_t * get_enum(const cw_KTVEnum_t * e, int val){
|
static const cw_ValEnum_t * get_enum(const cw_ValEnum_t * e, int val){
|
||||||
int i;
|
int i;
|
||||||
for (i=0; e[i].type != NULL; i++ ){
|
for (i=0; e[i].type != NULL; i++ ){
|
||||||
if (e[i].value==val){
|
if (e[i].value==val){
|
||||||
@ -16,7 +16,7 @@ int cw_in_generic_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerPar
|
|||||||
uint8_t * elem_data, int elem_len)
|
uint8_t * elem_data, int elem_len)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
const cw_KTVEnum_t * e;
|
const cw_ValEnum_t * e;
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
struct cw_ElemHandler thandler;
|
struct cw_ElemHandler thandler;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
|
|
||||||
static const cw_KTVEnum_t * get_enum(const cw_KTVEnum_t * e, int val){
|
static const cw_ValEnum_t * get_enum(const cw_ValEnum_t * e, int val){
|
||||||
int i;
|
int i;
|
||||||
for (i=0; e[i].type != NULL; i++ ){
|
for (i=0; e[i].type != NULL; i++ ){
|
||||||
if (e[i].value==val){
|
if (e[i].value==val){
|
||||||
@ -18,8 +18,8 @@ int cw_in_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHa
|
|||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
int l,f;
|
int l,f;
|
||||||
const cw_KTVEnum_t * e;
|
const cw_ValEnum_t * e;
|
||||||
const cw_KTVIndexed_t * ie;
|
const cw_ValIndexed_t * ie;
|
||||||
|
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
struct cw_ElemHandler thandler;
|
struct cw_ElemHandler thandler;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||||
@ -18,6 +18,8 @@ int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
|
|||||||
key = handler->key;
|
key = handler->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("CW_IN_GENERIC STRUCT: %s\n",key);
|
||||||
|
|
||||||
/* int (*mkkey)(struct cw_ElemHandler * handler, char *dst, struct cw_ElemHandlerParams * params,
|
/* int (*mkkey)(struct cw_ElemHandler * handler, char *dst, struct cw_ElemHandlerParams * params,
|
||||||
uint8_t*data, int len);
|
uint8_t*data, int len);
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@ int cw_in_idx_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerPara
|
|||||||
uint8_t * elem_data, int elem_len)
|
uint8_t * elem_data, int elem_len)
|
||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (!handler->type){
|
if (!handler->type){
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
|
|
||||||
cw_KTV_t * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
cw_Val_t * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||||
const void * valguard,
|
const void * valguard,
|
||||||
const uint8_t * data, int len)
|
const uint8_t * data, int len)
|
||||||
{
|
{
|
||||||
cw_KTV_t mdata, *mresult;
|
cw_Val_t mdata, *mresult;
|
||||||
int exists;
|
int exists;
|
||||||
|
|
||||||
mdata.key=cw_strdup(key);
|
mdata.key=cw_strdup(key);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@ -9,7 +9,7 @@ const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key,
|
|||||||
const void * valguard,
|
const void * valguard,
|
||||||
const char * str)
|
const char * str)
|
||||||
{
|
{
|
||||||
cw_KTV_t mdata, *mresult;
|
cw_Val_t mdata, *mresult;
|
||||||
int exists;
|
int exists;
|
||||||
|
|
||||||
/* cw_dbg(DBG_ELEM,"KVStore (%p,%d) add elem (%s): %s", kvstore, kvstore->count,
|
/* cw_dbg(DBG_ELEM,"KVStore (%p,%d) add elem (%s): %s", kvstore, kvstore->count,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* @description Implementation of cw_ktv_base_exisits
|
* @description Implementation of cw_ktv_base_exisits
|
||||||
@ -14,9 +14,9 @@
|
|||||||
* otherwise NULL if no element was found.
|
* otherwise NULL if no element was found.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
cw_KTV_t * cw_ktv_base_exists(mavl_t ktvstore, const char *basekey)
|
cw_Val_t * cw_ktv_base_exists(mavl_t ktvstore, const char *basekey)
|
||||||
{
|
{
|
||||||
cw_KTV_t * result, search;
|
cw_Val_t * result, search;
|
||||||
search.key=(char*)basekey;
|
search.key=(char*)basekey;
|
||||||
result = mavl_get_first(ktvstore,&search);
|
result = mavl_get_first(ktvstore,&search);
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
cw_KTV_t * cw_ktv_cast(cw_KTV_t *v,const cw_Type_t * type)
|
cw_Val_t * cw_ktv_cast(cw_Val_t *v,const cw_Type_t * type)
|
||||||
{
|
{
|
||||||
if (strcmp(v->type->name,type->name)==0)
|
if (strcmp(v->type->name,type->name)==0)
|
||||||
return v;
|
return v;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
void cw_ktv_del_sub(mavl_t ktvstore, const char *basekey)
|
void cw_ktv_del_sub(mavl_t ktvstore, const char *basekey)
|
||||||
{
|
{
|
||||||
cw_KTV_t * result, search;
|
cw_Val_t * result, search;
|
||||||
|
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "mavl.h"
|
#include "mavl.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7,12 +7,12 @@
|
|||||||
* @param ktv ktv store
|
* @param ktv ktv store
|
||||||
* @param key key to search for
|
* @param key key to search for
|
||||||
* @param type type to match
|
* @param type type to match
|
||||||
* @return A pointer to a #cw_KTV_t element, found in the ktv store or
|
* @return A pointer to a #cw_Val_t element, found in the ktv store or
|
||||||
* NULL if no element with matching key/type is found.
|
* NULL if no element with matching key/type is found.
|
||||||
*/
|
*/
|
||||||
cw_KTV_t * cw_ktv_get(mavl_t ktv, const char *key, const cw_Type_t * type)
|
cw_Val_t * cw_ktv_get(mavl_t ktv, const char *key, const cw_Type_t * type)
|
||||||
{
|
{
|
||||||
cw_KTV_t search, *result;
|
cw_Val_t search, *result;
|
||||||
/* we can safely cast from const char * to char *, because
|
/* we can safely cast from const char * to char *, because
|
||||||
* we never will use the search varaiable to store ktv values */
|
* we never will use the search varaiable to store ktv values */
|
||||||
search.key=(char*)key;
|
search.key=(char*)key;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
uint8_t cw_ktv_get_bool(mavl_t ktv,const char *key, uint8_t def)
|
uint8_t cw_ktv_get_bool(mavl_t ktv,const char *key, uint8_t def)
|
||||||
{
|
{
|
||||||
cw_KTV_t * k;
|
cw_Val_t * k;
|
||||||
k = cw_ktv_get(ktv,key,CW_TYPE_BOOL);
|
k = cw_ktv_get(ktv,key,CW_TYPE_BOOL);
|
||||||
if (k != NULL){
|
if (k != NULL){
|
||||||
return k->val.boolean;
|
return k->val.boolean;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "bstr.h"
|
#include "bstr.h"
|
||||||
|
|
||||||
bstr16_t cw_ktv_get_bstr16(mavl_t ktv,const char *key, bstr16_t def)
|
bstr16_t cw_ktv_get_bstr16(mavl_t ktv,const char *key, bstr16_t def)
|
||||||
{
|
{
|
||||||
cw_KTV_t * k;
|
cw_Val_t * k;
|
||||||
k = cw_ktv_get(ktv,key,CW_TYPE_BSTR16);
|
k = cw_ktv_get(ktv,key,CW_TYPE_BSTR16);
|
||||||
if (k != NULL){
|
if (k != NULL){
|
||||||
return bstr16_create(k->type->data(k),k->type->len(k));
|
return bstr16_create(k->type->data(k),k->type->len(k));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
uint8_t cw_ktv_get_byte(mavl_t ktv,const char *key, uint8_t def)
|
uint8_t cw_ktv_get_byte(mavl_t ktv,const char *key, uint8_t def)
|
||||||
{
|
{
|
||||||
cw_KTV_t * k;
|
cw_Val_t * k;
|
||||||
k = cw_ktv_get(ktv,key,CW_TYPE_BYTE);
|
k = cw_ktv_get(ktv,key,CW_TYPE_BYTE);
|
||||||
if (k != NULL){
|
if (k != NULL){
|
||||||
return k->val.byte;
|
return k->val.byte;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
uint32_t cw_ktv_get_dword(mavl_t ktv,const char *key, uint32_t def)
|
uint32_t cw_ktv_get_dword(mavl_t ktv,const char *key, uint32_t def)
|
||||||
{
|
{
|
||||||
cw_KTV_t * k;
|
cw_Val_t * k;
|
||||||
k = cw_ktv_get(ktv,key,CW_TYPE_DWORD);
|
k = cw_ktv_get(ktv,key,CW_TYPE_DWORD);
|
||||||
if (k != NULL){
|
if (k != NULL){
|
||||||
return k->val.dword;
|
return k->val.dword;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
char * cw_ktv_get_str(mavl_t ktv,const char *key, char * def)
|
char * cw_ktv_get_str(mavl_t ktv,const char *key, char * def)
|
||||||
{
|
{
|
||||||
cw_KTV_t * k;
|
cw_Val_t * k;
|
||||||
k = cw_ktv_get(ktv,key,CW_TYPE_STR);
|
k = cw_ktv_get(ktv,key,CW_TYPE_STR);
|
||||||
if (k != NULL){
|
if (k != NULL){
|
||||||
return k->val.ptr;
|
return k->val.ptr;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
void * cw_ktv_get_sysptr(mavl_t ktv,const char *key, void * def)
|
void * cw_ktv_get_sysptr(mavl_t ktv,const char *key, void * def)
|
||||||
{
|
{
|
||||||
cw_KTV_t * k;
|
cw_Val_t * k;
|
||||||
k = cw_ktv_get(ktv,key,CW_TYPE_SYSPTR);
|
k = cw_ktv_get(ktv,key,CW_TYPE_SYSPTR);
|
||||||
if (k != NULL){
|
if (k != NULL){
|
||||||
return k->val.ptr;
|
return k->val.ptr;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
uint16_t cw_ktv_get_word(mavl_t ktv,const char *key, uint16_t def)
|
uint16_t cw_ktv_get_word(mavl_t ktv,const char *key, uint16_t def)
|
||||||
{
|
{
|
||||||
cw_KTV_t * k;
|
cw_Val_t * k;
|
||||||
k = cw_ktv_get(ktv,key,CW_TYPE_WORD);
|
k = cw_ktv_get(ktv,key,CW_TYPE_WORD);
|
||||||
if (k != NULL){
|
if (k != NULL){
|
||||||
return k->val.word;
|
return k->val.word;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
void * ktvn(struct mavl *t ,const void *search)
|
void * ktvn(struct mavl *t ,const void *search)
|
||||||
{
|
{
|
||||||
@ -8,7 +8,7 @@ void * ktvn(struct mavl *t ,const void *search)
|
|||||||
n = t->root;
|
n = t->root;
|
||||||
while(n){
|
while(n){
|
||||||
int rc;
|
int rc;
|
||||||
/* const cw_KTV_t;*//* *c1,*c2;*/
|
/* const cw_Val_t;*//* *c1,*c2;*/
|
||||||
/*c1=search;
|
/*c1=search;
|
||||||
c2=mavlnode_dataptr(n);
|
c2=mavlnode_dataptr(n);
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@ void * ktvn(struct mavl *t ,const void *search)
|
|||||||
int cw_ktv_idx_get(mavl_t ktv, const char *key)
|
int cw_ktv_idx_get(mavl_t ktv, const char *key)
|
||||||
{
|
{
|
||||||
char ikey[CW_KTV_MAX_KEY_LEN];
|
char ikey[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t search, * result;
|
cw_Val_t search, * result;
|
||||||
char *d;
|
char *d;
|
||||||
|
|
||||||
sprintf(ikey,"%s.%d",key,65536);
|
sprintf(ikey,"%s.%d",key,65536);
|
||||||
@ -76,7 +76,7 @@ int cw_ktv_idx_get(mavl_t ktv, const char *key)
|
|||||||
int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
|
int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
|
||||||
{
|
{
|
||||||
char ikey[CW_KTV_MAX_KEY_LEN];
|
char ikey[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t search, * result;
|
cw_Val_t search, * result;
|
||||||
char *d;
|
char *d;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
/**
|
/**
|
||||||
* @brief Default function to compare two values of type #cw_KTV_t.
|
* @brief Default function to compare two values of type #cw_Val_t.
|
||||||
*
|
*
|
||||||
* @param v1
|
* @param v1
|
||||||
* @param v2
|
* @param v2
|
||||||
@ -14,8 +14,8 @@ int cw_ktv_mavlcmp (const void *v1, const void *v2)
|
|||||||
char *d1, *d2, *k1, *k2;
|
char *d1, *d2, *k1, *k2;
|
||||||
int l1, l2, rc, i1, i2;
|
int l1, l2, rc, i1, i2;
|
||||||
|
|
||||||
k1 = ( (cw_KTV_t *) v1)->key;
|
k1 = ( (cw_Val_t *) v1)->key;
|
||||||
k2 = ( (cw_KTV_t *) v2)->key;
|
k2 = ( (cw_Val_t *) v2)->key;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Find dots in both keys */
|
/* Find dots in both keys */
|
||||||
@ -28,16 +28,16 @@ int cw_ktv_mavlcmp (const void *v1, const void *v2)
|
|||||||
|
|
||||||
|
|
||||||
/* calculate the length of the key till dots */
|
/* calculate the length of the key till dots */
|
||||||
l1 = d1 - k1; /*((cw_KTV_t *) v1)->key;*/
|
l1 = d1 - k1; /*((cw_Val_t *) v1)->key;*/
|
||||||
l2 = d2 - k2; /*((cw_KTV_t *) v2)->key;*/
|
l2 = d2 - k2; /*((cw_Val_t *) v2)->key;*/
|
||||||
|
|
||||||
/* if length differs do a normal compare */
|
/* if length differs do a normal compare */
|
||||||
if (l1 != l2) {
|
if (l1 != l2) {
|
||||||
return strcmp (k1, k2); /*((cw_KTV_t *) v1)->key, ((cw_KTV_t *) v2)->key);*/
|
return strcmp (k1, k2); /*((cw_Val_t *) v1)->key, ((cw_Val_t *) v2)->key);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rc = strncmp (k1, k2, l1); /*((cw_KTV_t *) v1)->key,((cw_KTV_t *) v2)->key,l1);*/
|
rc = strncmp (k1, k2, l1); /*((cw_Val_t *) v1)->key,((cw_Val_t *) v2)->key,l1);*/
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
int cw_ktv_mavlcmp_type_by_name (const void *v1, const void *v2)
|
int cw_ktv_mavlcmp_type_by_name (const void *v1, const void *v2)
|
||||||
{
|
{
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
void cw_ktv_mavldel(void *data)
|
void cw_ktv_mavldel(void *data)
|
||||||
{
|
{
|
||||||
struct cw_KTV *ktv = data;
|
struct cw_Val *ktv = data;
|
||||||
if (ktv->type->del) {
|
if (ktv->type->del) {
|
||||||
ktv->type->del(data);
|
ktv->type->del(data);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
static int str_getc(struct cw_KTV_Reader * r)
|
static int str_getc(struct cw_Val_Reader * r)
|
||||||
{
|
{
|
||||||
if (r->next==r->maxlen)
|
if (r->next==r->maxlen)
|
||||||
return EOF;
|
return EOF;
|
||||||
@ -11,15 +11,15 @@ static int str_getc(struct cw_KTV_Reader * r)
|
|||||||
return *((uint8_t*)(r->data)+r->next++);
|
return *((uint8_t*)(r->data)+r->next++);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void str_ungetc(struct cw_KTV_Reader * r, int c)
|
static void str_ungetc(struct cw_Val_Reader * r, int c)
|
||||||
{
|
{
|
||||||
if (r->next>0)
|
if (r->next>0)
|
||||||
r->next--;
|
r->next--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cw_ktv_init_str_reader(struct cw_KTV_Reader *r, const char * str, int len)
|
void cw_ktv_init_str_reader(struct cw_Val_Reader *r, const char * str, int len)
|
||||||
{
|
{
|
||||||
memset(r,0,sizeof(struct cw_KTV_Reader));
|
memset(r,0,sizeof(struct cw_Val_Reader));
|
||||||
r->data = str;
|
r->data = str;
|
||||||
r->xgetchar=str_getc;
|
r->xgetchar=str_getc;
|
||||||
r->ungetchar=str_ungetc;
|
r->ungetchar=str_ungetc;
|
||||||
@ -28,7 +28,7 @@ void cw_ktv_init_str_reader(struct cw_KTV_Reader *r, const char * str, int len)
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
/*
|
/*
|
||||||
struct parser {
|
struct parser {
|
||||||
int line;
|
int line;
|
||||||
@ -44,7 +44,7 @@ struct parser {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int get_char(struct cw_KTV_Reader *r)
|
static int get_char(struct cw_Val_Reader *r)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
c = r->xgetchar (r);
|
c = r->xgetchar (r);
|
||||||
@ -58,7 +58,7 @@ static int get_char(struct cw_KTV_Reader *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void unget_char(struct cw_KTV_Reader * r,int c){
|
static void unget_char(struct cw_Val_Reader * r,int c){
|
||||||
r->ungetchar(r,c);
|
r->ungetchar(r,c);
|
||||||
if (c=='\n'){
|
if (c=='\n'){
|
||||||
r->line--;
|
r->line--;
|
||||||
@ -70,7 +70,7 @@ static void unget_char(struct cw_KTV_Reader * r,int c){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int get_char_q(struct cw_KTV_Reader *p)
|
static int get_char_q(struct cw_Val_Reader *p)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ static int get_char_q(struct cw_KTV_Reader *p)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int skip_chars (struct cw_KTV_Reader *r, const char * chars)
|
static int skip_chars (struct cw_Val_Reader *r, const char * chars)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ static int skip_chars (struct cw_KTV_Reader *r, const char * chars)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int skip_to_chars (struct cw_KTV_Reader *r, const char *chars)
|
static int skip_to_chars (struct cw_Val_Reader *r, const char *chars)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ static int skip_to_chars (struct cw_KTV_Reader *r, const char *chars)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int read_key (struct cw_KTV_Reader *r, char *key, int max_len)
|
static int read_key (struct cw_Val_Reader *r, char *key, int max_len)
|
||||||
{
|
{
|
||||||
int c,n;
|
int c,n;
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ static int read_key (struct cw_KTV_Reader *r, char *key, int max_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int skip_to_colon(struct cw_KTV_Reader * r)
|
static int skip_to_colon(struct cw_Val_Reader * r)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
c = skip_chars (r, " \t");
|
c = skip_chars (r, " \t");
|
||||||
@ -203,7 +203,7 @@ static int skip_to_colon(struct cw_KTV_Reader * r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int read_type(struct cw_KTV_Reader * r, char *type, int max_len)
|
static int read_type(struct cw_Val_Reader * r, char *type, int max_len)
|
||||||
{
|
{
|
||||||
int c,n;
|
int c,n;
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ static int read_type(struct cw_KTV_Reader * r, char *type, int max_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int read_val(struct cw_KTV_Reader *r, char *val, int max_len){
|
static int read_val(struct cw_Val_Reader *r, char *val, int max_len){
|
||||||
int c,n,quote;
|
int c,n,quote;
|
||||||
c = skip_to_colon(r);
|
c = skip_to_colon(r);
|
||||||
if (c==-1)
|
if (c==-1)
|
||||||
@ -337,12 +337,12 @@ int cw_ktv_parse_line (FILE *f, char * key, char * type, char *val)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int cw_ktv_parse_line(struct cw_KTV_Reader * r)
|
int cw_ktv_parse_line(struct cw_Val_Reader * r)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cw_ktv_parse_string(struct cw_KTV_Reader *r, char *key, char *type, char *val)
|
int cw_ktv_parse_string(struct cw_Val_Reader *r, char *key, char *type, char *val)
|
||||||
{
|
{
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
|
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
|
|
||||||
int cw_ktv_read_struct(mavl_t ktv,const cw_KTVStruct_t * stru, const char *pkey,
|
int cw_ktv_read_struct(mavl_t ktv,const cw_ValStruct_t * stru, const char *pkey,
|
||||||
uint8_t * data, int len)
|
uint8_t * data, int len)
|
||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
int pos, i,l;
|
int pos, i,l;
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
|
|
||||||
if (strcmp(pkey,"radio.0/cisco/wtp-radio-config")==0)
|
|
||||||
i = 99;
|
|
||||||
|
|
||||||
|
|
||||||
pos=0; i=0;
|
pos=0; i=0;
|
||||||
@ -47,6 +44,7 @@ int cw_ktv_read_struct(mavl_t ktv,const cw_KTVStruct_t * stru, const char *pkey,
|
|||||||
|
|
||||||
stru[i].type->to_str(result,dbstr,100);
|
stru[i].type->to_str(result,dbstr,100);
|
||||||
cw_dbg(DBG_ELEM_DETAIL, "Read (%d): %s: %s",pos,key,dbstr);
|
cw_dbg(DBG_ELEM_DETAIL, "Read (%d): %s: %s",pos,key,dbstr);
|
||||||
|
printf("READ STRUCT (%d): %s: %s\n",pos,key,dbstr);
|
||||||
|
|
||||||
if (stru[i].len==-1)
|
if (stru[i].len==-1)
|
||||||
l = result->type->len(result);
|
l = result->type->len(result);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
struct parser {
|
struct parser {
|
||||||
int line;
|
int line;
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
|
|
||||||
cw_KTV_t * cw_ktv_replace(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
cw_Val_t * cw_ktv_replace(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||||
const void * valguard,
|
const void * valguard,
|
||||||
const uint8_t * data, int len)
|
const uint8_t * data, int len)
|
||||||
{
|
{
|
||||||
cw_KTV_t mdata, *mresult;
|
cw_Val_t mdata, *mresult;
|
||||||
int exists;
|
int exists;
|
||||||
|
|
||||||
mdata.key=cw_strdup(key);
|
mdata.key=cw_strdup(key);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
static int write_str(FILE *outfile,const char *str)
|
static int write_str(FILE *outfile,const char *str)
|
||||||
@ -43,7 +43,7 @@ int cw_ktv_save(mavl_t ktvstore, const char * filename){
|
|||||||
|
|
||||||
mavliter_init(&it,ktvstore);
|
mavliter_init(&it,ktvstore);
|
||||||
mavliter_foreach(&it){
|
mavliter_foreach(&it){
|
||||||
cw_KTV_t * val;
|
cw_Val_t * val;
|
||||||
char buf[4000];
|
char buf[4000];
|
||||||
val = mavliter_get(&it);
|
val = mavliter_get(&it);
|
||||||
val->type->to_str(val,buf,4000);
|
val->type->to_str(val,buf,4000);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
cw_KTV_t * cw_ktv_set_byte(mavl_t ktv,const char * key, uint8_t byte)
|
cw_Val_t * cw_ktv_set_byte(mavl_t ktv,const char * key, uint8_t byte)
|
||||||
{
|
{
|
||||||
return cw_ktv_replace(ktv,key,CW_TYPE_BYTE,NULL,&byte,1);
|
return cw_ktv_replace(ktv,key,CW_TYPE_BYTE,NULL,&byte,1);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
cw_KTV_t * cw_ktv_set_dword(mavl_t ktv,const char * key, uint32_t dword)
|
cw_Val_t * cw_ktv_set_dword(mavl_t ktv,const char * key, uint32_t dword)
|
||||||
{
|
{
|
||||||
return cw_ktv_replace(ktv,key,CW_TYPE_DWORD,NULL,(void*)&dword,4);
|
return cw_ktv_replace(ktv,key,CW_TYPE_DWORD,NULL,(void*)&dword,4);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
cw_KTV_t * cw_ktv_set_word(mavl_t ktv,const char * key, uint16_t word)
|
cw_Val_t * cw_ktv_set_word(mavl_t ktv,const char * key, uint16_t word)
|
||||||
{
|
{
|
||||||
return cw_ktv_replace(ktv,key,CW_TYPE_WORD,NULL,(void*)&word,2);
|
return cw_ktv_replace(ktv,key,CW_TYPE_WORD,NULL,(void*)&word,2);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
const cw_Type_t * cw_ktv_std_types[] = {
|
const cw_Type_t * cw_ktv_std_types[] = {
|
||||||
CW_TYPE_BYTE,
|
CW_TYPE_BYTE,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
int cw_ktv_write_struct(mavl_t ktv, mavl_t def, const cw_KTVStruct_t * stru, const char *pkey,
|
int cw_ktv_write_struct(mavl_t ktv, mavl_t def, const cw_ValStruct_t * stru, const char *pkey,
|
||||||
uint8_t * dst)
|
uint8_t * dst)
|
||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
int pos, i;
|
int pos, i;
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
|
|
||||||
pos=0; i=0;
|
pos=0; i=0;
|
||||||
for(i=0; stru[i].type != NULL;i++){
|
for(i=0; stru[i].type != NULL;i++){
|
||||||
@ -24,9 +24,15 @@ int cw_ktv_write_struct(mavl_t ktv, mavl_t def, const cw_KTVStruct_t * stru, con
|
|||||||
else
|
else
|
||||||
sprintf(key,"%s",pkey);
|
sprintf(key,"%s",pkey);
|
||||||
|
|
||||||
|
printf("Get Key: %s\n",key);
|
||||||
result = cw_ktv_get(ktv,key,NULL);
|
result = cw_ktv_get(ktv,key,NULL);
|
||||||
|
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
char s[129];
|
||||||
|
result->type->to_str(result,s,128);
|
||||||
|
printf("Content: '%s'\n",s);
|
||||||
|
}
|
||||||
|
|
||||||
if (result == NULL && def != NULL){
|
if (result == NULL && def != NULL){
|
||||||
result = cw_ktv_get(def,key,NULL);
|
result = cw_ktv_get(def,key,NULL);
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||||
, uint8_t * dst)
|
, uint8_t * dst)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct cw_KTV * elem, search;
|
struct cw_Val * elem;
|
||||||
int start, len, l;
|
int start, len, l;
|
||||||
|
|
||||||
/* Get the element */
|
/* Get the element */
|
||||||
@ -49,7 +49,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
|
|||||||
/* Size for msg elem header depends on
|
/* Size for msg elem header depends on
|
||||||
vendor specific payload */
|
vendor specific payload */
|
||||||
/* start = handler->vendor ? 10 : 4; */
|
/* start = handler->vendor ? 10 : 4; */
|
||||||
start = cw_header_len(handler);
|
start = params->msgset->header_len(handler);
|
||||||
|
|
||||||
if (cw_ktv_cast(elem,handler->type)==NULL){
|
if (cw_ktv_cast(elem,handler->type)==NULL){
|
||||||
cw_log(LOG_ERR,"Can't put element '%s'- can't cast from %s to %s for key: %s", handler->name,
|
cw_log(LOG_ERR,"Can't put element '%s'- can't cast from %s to %s for key: %s", handler->name,
|
||||||
@ -67,7 +67,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
|
|||||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
||||||
|
|
||||||
l = len + cw_put_elem_hdr(dst, handler->id, len); */
|
l = len + cw_put_elem_hdr(dst, handler->id, len); */
|
||||||
l = cw_write_header(handler,dst,len);
|
l = params->msgset->write_header(handler,dst,len);
|
||||||
|
|
||||||
cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,handler,dst,l);
|
cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,handler,dst,l);
|
||||||
/* cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);*/
|
/* cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);*/
|
||||||
|
@ -5,12 +5,11 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
|
|||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
int i;
|
int i;
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
int len,start;
|
int len,start;
|
||||||
uint8_t * ob;
|
uint8_t * ob;
|
||||||
const cw_KTVIndexed_t *ie;
|
const cw_ValIndexed_t *ie;
|
||||||
cw_KTVEnum_t * e;
|
cw_ValEnum_t * e;
|
||||||
struct cw_ElemHandler thandler;
|
|
||||||
|
|
||||||
ie = handler->type;
|
ie = handler->type;
|
||||||
|
|
||||||
@ -22,10 +21,13 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
|
|||||||
|
|
||||||
for(i=0; e[i].name!=NULL; i++) {
|
for(i=0; e[i].name!=NULL; i++) {
|
||||||
sprintf(key,"%s/%s",handler->key,e[i].name);
|
sprintf(key,"%s/%s",handler->key,e[i].name);
|
||||||
|
|
||||||
|
//printf("Her is the Key: %s - %s\n",key, );
|
||||||
|
|
||||||
result = cw_ktv_base_exists(params->local_cfg,key);
|
result = cw_ktv_base_exists(params->local_cfg,key);
|
||||||
if (result==NULL)
|
if (result==NULL)
|
||||||
continue;
|
continue;
|
||||||
start = cw_header_len(handler);
|
start = params->msgset->header_len(handler);
|
||||||
len = 0;
|
len = 0;
|
||||||
if (ie->idxpos==0)
|
if (ie->idxpos==0)
|
||||||
len = 1;
|
len = 1;
|
||||||
@ -36,17 +38,11 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
|
|||||||
len += cw_ktv_write_struct(params->local_cfg,
|
len += cw_ktv_write_struct(params->local_cfg,
|
||||||
NULL,e[i].type,key,ob+start+len);
|
NULL,e[i].type,key,ob+start+len);
|
||||||
|
|
||||||
/* thandler.type=e[i].type;
|
|
||||||
thandler.key=key;
|
|
||||||
len += e->fun_out(&thandler,params,ob+start+len);
|
|
||||||
*/
|
|
||||||
cw_set_byte(ob+start+ie->idxpos,e[i].value);
|
cw_set_byte(ob+start+ie->idxpos,e[i].value);
|
||||||
if (ie->idxpos==len)
|
if (ie->idxpos==len)
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
ob += cw_write_header(handler,ob,len);
|
ob += params->msgset->write_header(handler,ob,len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandler
|
|||||||
{
|
{
|
||||||
int start;
|
int start;
|
||||||
int len;
|
int len;
|
||||||
cw_KTV_t search, *result;
|
cw_Val_t search, *result;
|
||||||
|
|
||||||
if (!handler->type){
|
if (!handler->type){
|
||||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
||||||
@ -30,12 +30,12 @@ int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
start = cw_header_len(handler);
|
start = params->msgset->header_len(handler);
|
||||||
|
|
||||||
len = cw_ktv_write_struct(params->local_cfg,
|
len = cw_ktv_write_struct(params->local_cfg,
|
||||||
params->default_cfg,
|
params->default_cfg,
|
||||||
handler->type,handler->key,dst+start);
|
handler->type,handler->key,dst+start);
|
||||||
|
|
||||||
return cw_write_header(handler,dst,len);
|
return params->msgset->write_header(handler,dst,len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ int cw_out_generic_with_index(struct cw_ElemHandler * eh,
|
|||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
int idx;
|
int idx;
|
||||||
cw_KTV_t * result, search;
|
cw_Val_t * result, search;
|
||||||
int len,start;
|
int len,start;
|
||||||
uint8_t * ob;
|
uint8_t * ob;
|
||||||
|
|
||||||
@ -24,12 +24,12 @@ int cw_out_generic_with_index(struct cw_ElemHandler * eh,
|
|||||||
if (strncmp(result->key,key,strlen(key))!=0)
|
if (strncmp(result->key,key,strlen(key))!=0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
start = cw_header_len(eh);
|
start = params->msgset->header_len(eh);
|
||||||
len = cw_put_byte(ob+start,idx);
|
len = cw_put_byte(ob+start,idx);
|
||||||
|
|
||||||
len += result->type->put(result,ob+start+len);
|
len += result->type->put(result,ob+start+len);
|
||||||
|
|
||||||
ob += cw_write_header(eh,ob,len);
|
ob += params->msgset->write_header(eh,ob,len);
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
|
|||||||
, uint8_t * dst)
|
, uint8_t * dst)
|
||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
struct cw_KTV * elem, search;
|
struct cw_Val * elem, search;
|
||||||
int i;
|
int i;
|
||||||
int idx, sr;
|
int idx, sr;
|
||||||
int len;
|
int len;
|
||||||
@ -37,15 +37,13 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
|
|||||||
|
|
||||||
sprintf(key,handler->key,idx);
|
sprintf(key,handler->key,idx);
|
||||||
|
|
||||||
printf("Here we are '%s'! --> %d\n",key,idx);
|
|
||||||
|
|
||||||
len =0;
|
len =0;
|
||||||
start = mdst + cw_header_len(handler);
|
start = mdst + params->msgset->header_len(handler);
|
||||||
|
|
||||||
len += cw_put_byte(start+len,idx);
|
len += cw_put_byte(start+len,idx);
|
||||||
len += cw_ktv_write_struct(params->local_cfg,NULL, handler->type,key,start+len);
|
len += cw_ktv_write_struct(params->local_cfg,NULL, handler->type,key,start+len);
|
||||||
|
|
||||||
mdst += cw_write_header(handler,mdst,len);
|
mdst += params->msgset->write_header(handler,mdst,len);
|
||||||
|
|
||||||
|
|
||||||
i=idx+1;
|
i=idx+1;
|
||||||
|
@ -14,12 +14,12 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
|
|||||||
cdst = dst;
|
cdst = dst;
|
||||||
|
|
||||||
|
|
||||||
offset = cw_header_len(handler);
|
offset = params->msgset->header_len(handler);
|
||||||
|
|
||||||
i=-1;
|
i=-1;
|
||||||
while(1){
|
while(1){
|
||||||
char basekey[CW_KTV_MAX_KEY_LEN];
|
char basekey[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
|
|
||||||
i = cw_ktv_idx_get_next(params->local_cfg,"radio",i+1);
|
i = cw_ktv_idx_get_next(params->local_cfg,"radio",i+1);
|
||||||
if (i==-1)
|
if (i==-1)
|
||||||
@ -37,7 +37,7 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
|
|||||||
l+= cw_ktv_write_struct(params->local_cfg,NULL, handler->type,basekey,cdst+offset+l);
|
l+= cw_ktv_write_struct(params->local_cfg,NULL, handler->type,basekey,cdst+offset+l);
|
||||||
|
|
||||||
|
|
||||||
cdst+=cw_write_header(handler,cdst,l);
|
cdst+=params->msgset->write_header(handler,cdst,l);
|
||||||
}
|
}
|
||||||
return cdst-dst;
|
return cdst-dst;
|
||||||
}
|
}
|
||||||
@ -53,15 +53,17 @@ int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParam
|
|||||||
int len;
|
int len;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
|
printf("Next: %s\n", next);
|
||||||
|
|
||||||
sl = strchr(next,'/');
|
sl = strchr(next,'/');
|
||||||
if (sl==NULL){
|
if (sl==NULL){
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
sprintf(key,"%s/%s",current,next);
|
sprintf(key,"%s/%s",current,next);
|
||||||
result = cw_ktv_base_exists(params->local_cfg,key);
|
result = cw_ktv_base_exists(params->local_cfg,key);
|
||||||
if (result != NULL){
|
if (result != NULL){
|
||||||
int offset;
|
int offset;
|
||||||
int i,l;
|
int i,l;
|
||||||
offset = cw_header_len(handler);
|
offset = params->msgset->header_len(handler);
|
||||||
printf("Yea! We can do it: %s\n",result->key);
|
printf("Yea! We can do it: %s\n",result->key);
|
||||||
for (i=0;i<stack[0];i++){
|
for (i=0;i<stack[0];i++){
|
||||||
printf("I=%i\n",stack[i+1]);
|
printf("I=%i\n",stack[i+1]);
|
||||||
@ -71,7 +73,7 @@ int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParam
|
|||||||
|
|
||||||
printf("Write struct len %i\n",l);
|
printf("Write struct len %i\n",l);
|
||||||
|
|
||||||
l=cw_write_header(handler,dst,l);
|
l=params->msgset->write_header(handler,dst,l);
|
||||||
printf("header wr len %d\n",l);
|
printf("header wr len %d\n",l);
|
||||||
if (handler->patch){
|
if (handler->patch){
|
||||||
handler->patch(dst+offset,stack);
|
handler->patch(dst+offset,stack);
|
||||||
@ -84,6 +86,9 @@ int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParam
|
|||||||
}
|
}
|
||||||
|
|
||||||
strcpy(key,current);
|
strcpy(key,current);
|
||||||
|
|
||||||
|
printf("current is %s\n", current);
|
||||||
|
|
||||||
if (key[0!=0])
|
if (key[0!=0])
|
||||||
strcat(key,"/");
|
strcat(key,"/");
|
||||||
l = sl - next;
|
l = sl - next;
|
||||||
@ -95,9 +100,10 @@ int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParam
|
|||||||
i=-1;
|
i=-1;
|
||||||
while(1){
|
while(1){
|
||||||
char basekey[CW_KTV_MAX_KEY_LEN];
|
char basekey[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
|
|
||||||
i = cw_ktv_idx_get_next(params->local_cfg,key,i+1);
|
i = cw_ktv_idx_get_next(params->local_cfg,key,i+1);
|
||||||
|
|
||||||
if (i==-1)
|
if (i==-1)
|
||||||
break;
|
break;
|
||||||
sprintf(basekey,"%s.%d",key,i);
|
sprintf(basekey,"%s.%d",key,i);
|
||||||
@ -128,6 +134,8 @@ int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
|
|||||||
|
|
||||||
current[0]=0;
|
current[0]=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack);
|
return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name
|
|||||||
|
|
||||||
cw_decode_elements( ¶ms, elems_ptr,elems_len);
|
cw_decode_elements( ¶ms, elems_ptr,elems_len);
|
||||||
|
|
||||||
|
printf ("----------------------------------- end redecode -----------------------------\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
static struct cw_DescriptorSubelemDef allowed_default[] = {
|
static struct cw_DescriptorSubelemDef allowed_default[] = {
|
||||||
{0,CAPWAP_SUBELEM_AC_HARDWARE_VERSION, "hardware", 1024,1},
|
{0,CAPWAP_SUBELEM_AC_HARDWARE_VERSION, "hardware", 1024,1},
|
||||||
@ -9,7 +9,7 @@ static struct cw_DescriptorSubelemDef allowed_default[] = {
|
|||||||
{0,0, NULL,0, 0}
|
{0,0, NULL,0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
cw_KTVStruct_t acstatus [] = {
|
cw_ValStruct_t acstatus [] = {
|
||||||
/* type key len, pos */
|
/* type key len, pos */
|
||||||
{CW_TYPE_WORD, "stations", 2, -1},
|
{CW_TYPE_WORD, "stations", 2, -1},
|
||||||
{CW_TYPE_WORD, "station-limit", 2, -1},
|
{CW_TYPE_WORD, "station-limit", 2, -1},
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
@ -10,7 +10,7 @@ int cw_in_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerPa
|
|||||||
uint8_t * elem_data, int elem_len)
|
uint8_t * elem_data, int elem_len)
|
||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
int radio;
|
int radio;
|
||||||
|
|
||||||
if (!handler->type){
|
if (!handler->type){
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
|
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
static int get_psk(struct conn * conn,const char * username, uint8_t **psk, unsigned int *len)
|
static int get_psk(struct conn * conn,const char * username, uint8_t **psk, unsigned int *len)
|
||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
sprintf(key,"%s/%s","psk",username);
|
sprintf(key,"%s/%s","psk",username);
|
||||||
result = cw_ktv_get(conn->local_cfg,key,CW_TYPE_BSTR16);
|
result = cw_ktv_get(conn->local_cfg,key,CW_TYPE_BSTR16);
|
||||||
if (result == NULL){
|
if (result == NULL){
|
||||||
|
@ -19,21 +19,21 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
static cw_KTV_t *get(cw_KTV_t * data, const uint8_t * src, int len)
|
static cw_Val_t *get(cw_Val_t * data, const uint8_t * src, int len)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_bool;
|
data->type = &cw_type_bool;
|
||||||
data->val.boolean = cw_get_byte(src);
|
data->val.boolean = cw_get_byte(src);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put(const cw_KTV_t *data, uint8_t * dst)
|
static int put(const cw_Val_t *data, uint8_t * dst)
|
||||||
{
|
{
|
||||||
return cw_put_byte(dst, data->val.boolean);
|
return cw_put_byte(dst, data->val.boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str(const cw_KTV_t *data, char *dst, int max_len)
|
static int to_str(const cw_Val_t *data, char *dst, int max_len)
|
||||||
{
|
{
|
||||||
/*if (max_len<3){
|
/*if (max_len<3){
|
||||||
return 0;
|
return 0;
|
||||||
@ -44,7 +44,7 @@ static int to_str(const cw_KTV_t *data, char *dst, int max_len)
|
|||||||
return sprintf(dst, "%s", "false");
|
return sprintf(dst, "%s", "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
static cw_Val_t *from_str(cw_Val_t * data, const char *src)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_bool;
|
data->type = &cw_type_bool;
|
||||||
if (cw_stricmp(src,"true") == 0){
|
if (cw_stricmp(src,"true") == 0){
|
||||||
@ -69,17 +69,17 @@ static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int len (cw_KTV_t * data)
|
static int len (cw_Val_t * data)
|
||||||
{
|
{
|
||||||
return sizeof(int);
|
return sizeof(int);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * data( cw_KTV_t * data)
|
static void * data( cw_Val_t * data)
|
||||||
{
|
{
|
||||||
return & data->val.boolean;
|
return & data->val.boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_BOOL->name;
|
return CW_TYPE_BOOL->name;
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,15 @@
|
|||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
static void del ( struct cw_KTV * data )
|
static void del ( struct cw_Val * data )
|
||||||
{
|
{
|
||||||
free ( data->val.ptr );
|
free ( data->val.ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
static struct cw_Val *get ( struct cw_Val * data, const uint8_t * src, int len )
|
||||||
{
|
{
|
||||||
uint8_t * s;
|
uint8_t * s;
|
||||||
s = bstr16_create ( src, len );
|
s = bstr16_create ( src, len );
|
||||||
@ -41,12 +41,12 @@ static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put ( const struct cw_KTV *data, uint8_t * dst )
|
static int put ( const struct cw_Val *data, uint8_t * dst )
|
||||||
{
|
{
|
||||||
return cw_put_bstr16 ( dst, data->val.ptr );
|
return cw_put_bstr16 ( dst, data->val.ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
static int to_str ( const struct cw_Val *data, char *dst, int max_len )
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
d = dst;
|
d = dst;
|
||||||
@ -63,7 +63,7 @@ static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
|||||||
return d - dst;
|
return d - dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
static struct cw_Val *from_str ( struct cw_Val * data, const char *src )
|
||||||
{
|
{
|
||||||
uint8_t * s;
|
uint8_t * s;
|
||||||
s = bstr16_create_from_str(src);
|
s = bstr16_create_from_str(src);
|
||||||
@ -77,21 +77,21 @@ static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int len (cw_KTV_t * data ){
|
static int len (cw_Val_t * data ){
|
||||||
return bstr16_len(data->val.ptr);
|
return bstr16_len(data->val.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * data(cw_KTV_t * data)
|
static void * data(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
return bstr16_data(data->val.ptr);
|
return bstr16_data(data->val.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_BSTR16->name;
|
return CW_TYPE_BSTR16->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cast(cw_KTV_t * data)
|
static int cast(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
if (strcmp(data->type->name,CW_TYPE_BSTR16->name)==0)
|
if (strcmp(data->type->name,CW_TYPE_BSTR16->name)==0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
/*typedef uint16_t* bwstr_type;*/
|
/*typedef uint16_t* bwstr_type;*/
|
||||||
@ -38,12 +38,12 @@ static uint16_t * bwstr_create(const uint8_t *data, uint16_t len)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void del ( struct cw_KTV * data )
|
static void del ( struct cw_Val * data )
|
||||||
{
|
{
|
||||||
free ( data->val.ptr );
|
free ( data->val.ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
static struct cw_Val *get ( struct cw_Val * data, const uint8_t * src, int len )
|
||||||
{
|
{
|
||||||
uint16_t * s;
|
uint16_t * s;
|
||||||
s = bwstr_create ( src, len );
|
s = bwstr_create ( src, len );
|
||||||
@ -56,7 +56,7 @@ static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put ( const struct cw_KTV *data, uint8_t * dst )
|
static int put ( const struct cw_Val *data, uint8_t * dst )
|
||||||
{
|
{
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
len = bstr16_len(data->val.ptr);
|
len = bstr16_len(data->val.ptr);
|
||||||
@ -64,7 +64,7 @@ static int put ( const struct cw_KTV *data, uint8_t * dst )
|
|||||||
return lw_put_data ( dst, data->val.ptr+2,len*2 );
|
return lw_put_data ( dst, data->val.ptr+2,len*2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
static int to_str ( const struct cw_Val *data, char *dst, int max_len )
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
uint16_t *s;
|
uint16_t *s;
|
||||||
@ -82,7 +82,7 @@ static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
|||||||
return d - dst;
|
return d - dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
static struct cw_Val *from_str ( struct cw_Val * data, const char *src )
|
||||||
{
|
{
|
||||||
uint8_t * s;
|
uint8_t * s;
|
||||||
s = bstr16_create_from_str(src);
|
s = bstr16_create_from_str(src);
|
||||||
@ -96,21 +96,21 @@ static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int len (cw_KTV_t * data ){
|
static int len (cw_Val_t * data ){
|
||||||
return bstr16_len(data->val.ptr);
|
return bstr16_len(data->val.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * data(cw_KTV_t * data)
|
static void * data(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
return bstr16_data(data->val.ptr);
|
return bstr16_data(data->val.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_BSTR16->name;
|
return CW_TYPE_BSTR16->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cast(cw_KTV_t * data)
|
static int cast(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
if (strcmp(data->type->name,CW_TYPE_BSTR16->name)==0)
|
if (strcmp(data->type->name,CW_TYPE_BSTR16->name)==0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -19,21 +19,21 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
static cw_KTV_t *get(cw_KTV_t * data, const uint8_t * src, int len)
|
static cw_Val_t *get(cw_Val_t * data, const uint8_t * src, int len)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_byte;
|
data->type = &cw_type_byte;
|
||||||
data->val.byte = cw_get_byte(src);
|
data->val.byte = cw_get_byte(src);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put(const cw_KTV_t *data, uint8_t * dst)
|
static int put(const cw_Val_t *data, uint8_t * dst)
|
||||||
{
|
{
|
||||||
return cw_put_byte(dst, data->val.byte);
|
return cw_put_byte(dst, data->val.byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_guardstr(int val, const cw_KTVValRange_t * valrange)
|
static const char * get_guardstr(int val, const cw_ValValRange_t * valrange)
|
||||||
{
|
{
|
||||||
while(valrange->name!=NULL){
|
while(valrange->name!=NULL){
|
||||||
if(val>=valrange->min && val<=valrange->max)
|
if(val>=valrange->min && val<=valrange->max)
|
||||||
@ -44,7 +44,7 @@ static const char * get_guardstr(int val, const cw_KTVValRange_t * valrange)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int to_str(const cw_KTV_t *data, char *dst, int max_len)
|
static int to_str(const cw_Val_t *data, char *dst, int max_len)
|
||||||
{
|
{
|
||||||
if (data->valguard!=NULL){
|
if (data->valguard!=NULL){
|
||||||
const char * name;
|
const char * name;
|
||||||
@ -61,7 +61,7 @@ static int to_str(const cw_KTV_t *data, char *dst, int max_len)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_guardval(const char *str, const cw_KTVValRange_t * valrange)
|
static int get_guardval(const char *str, const cw_ValValRange_t * valrange)
|
||||||
{
|
{
|
||||||
while(valrange->name!=NULL){
|
while(valrange->name!=NULL){
|
||||||
if(strcmp(str,valrange->name)==0)
|
if(strcmp(str,valrange->name)==0)
|
||||||
@ -72,7 +72,7 @@ static int get_guardval(const char *str, const cw_KTVValRange_t * valrange)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
static cw_Val_t *from_str(cw_Val_t * data, const char *src)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_byte;
|
data->type = &cw_type_byte;
|
||||||
if (data->valguard != NULL){
|
if (data->valguard != NULL){
|
||||||
@ -90,17 +90,17 @@ static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int len (cw_KTV_t * data)
|
static int len (cw_Val_t * data)
|
||||||
{
|
{
|
||||||
return sizeof(data->val.byte);
|
return sizeof(data->val.byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * data(cw_KTV_t * data)
|
static void * data(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
return &data->val.byte;
|
return &data->val.byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
if (data->valguard != NULL){
|
if (data->valguard != NULL){
|
||||||
return CW_TYPE_STR->name;
|
return CW_TYPE_STR->name;
|
||||||
@ -108,7 +108,7 @@ static const char * get_type_name(cw_KTV_t *data)
|
|||||||
return CW_TYPE_BYTE->name;
|
return CW_TYPE_BYTE->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cast(cw_KTV_t * data)
|
static int cast(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
if (strcmp(data->type->name,CW_TYPE_BYTE->name)==0)
|
if (strcmp(data->type->name,CW_TYPE_BYTE->name)==0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -19,40 +19,40 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
static struct cw_KTV *get(struct cw_KTV * data, const uint8_t * src, int len)
|
static struct cw_Val *get(struct cw_Val * data, const uint8_t * src, int len)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_dword;
|
data->type = &cw_type_dword;
|
||||||
data->val.dword = cw_get_dword(src);
|
data->val.dword = cw_get_dword(src);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put(const struct cw_KTV *data, uint8_t * dst)
|
static int put(const struct cw_Val *data, uint8_t * dst)
|
||||||
{
|
{
|
||||||
return cw_put_dword(dst, data->val.dword);
|
return cw_put_dword(dst, data->val.dword);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str(const struct cw_KTV *data, char *dst, int max_len)
|
static int to_str(const struct cw_Val *data, char *dst, int max_len)
|
||||||
{
|
{
|
||||||
return sprintf(dst, "%d", data->val.dword);
|
return sprintf(dst, "%d", data->val.dword);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *from_str(struct cw_KTV * data, const char *src)
|
static struct cw_Val *from_str(struct cw_Val * data, const char *src)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_dword;
|
data->type = &cw_type_dword;
|
||||||
data->val.dword = atoi(src);
|
data->val.dword = atoi(src);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_DWORD->name;
|
return CW_TYPE_DWORD->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int cast(cw_KTV_t * data)
|
static int cast(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
if (strcmp(data->type->name,CW_TYPE_BYTE->name)==0)
|
if (strcmp(data->type->name,CW_TYPE_BYTE->name)==0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -8,17 +8,17 @@
|
|||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
|
|
||||||
static void del ( struct cw_KTV * data )
|
static void del ( struct cw_Val * data )
|
||||||
{
|
{
|
||||||
free ( data->val.ptr );
|
free ( data->val.ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
static struct cw_Val *get ( struct cw_Val * data, const uint8_t * src, int len )
|
||||||
{
|
{
|
||||||
uint8_t * s;
|
uint8_t * s;
|
||||||
s = bstr_create ( src, len );
|
s = bstr_create ( src, len );
|
||||||
@ -33,12 +33,12 @@ static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put ( const struct cw_KTV *data, uint8_t * dst )
|
static int put ( const struct cw_Val *data, uint8_t * dst )
|
||||||
{
|
{
|
||||||
return cw_put_bstr ( dst, data->val.ptr );
|
return cw_put_bstr ( dst, data->val.ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
static int to_str ( const struct cw_Val *data, char *dst, int max_len )
|
||||||
{
|
{
|
||||||
|
|
||||||
int l;
|
int l;
|
||||||
@ -63,7 +63,7 @@ static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
static struct cw_Val *from_str ( struct cw_Val * data, const char *src )
|
||||||
{
|
{
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
uint8_t * s, * addrptr;
|
uint8_t * s, * addrptr;
|
||||||
@ -98,15 +98,15 @@ static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int len ( struct cw_KTV * data ){
|
static int len ( struct cw_Val * data ){
|
||||||
return bstr_len(data->val.ptr);
|
return bstr_len(data->val.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * data(cw_KTV_t * data)
|
static void * data(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
return bstr_data(data->val.ptr);
|
return bstr_data(data->val.ptr);
|
||||||
}
|
}
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_IPADDRESS->name;
|
return CW_TYPE_IPADDRESS->name;
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,15 @@
|
|||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
static void del ( struct cw_KTV * data )
|
static void del ( struct cw_Val * data )
|
||||||
{
|
{
|
||||||
free ( data->val.str );
|
free ( data->val.str );
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
static struct cw_Val *get ( struct cw_Val * data, const uint8_t * src, int len )
|
||||||
{
|
{
|
||||||
uint8_t * s;
|
uint8_t * s;
|
||||||
s = malloc (len+1);
|
s = malloc (len+1);
|
||||||
@ -43,12 +43,12 @@ static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put ( const struct cw_KTV *data, uint8_t * dst )
|
static int put ( const struct cw_Val *data, uint8_t * dst )
|
||||||
{
|
{
|
||||||
return cw_put_str ( dst, (uint8_t*)data->val.str );
|
return cw_put_str ( dst, (uint8_t*)data->val.str );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
static int to_str ( const struct cw_Val *data, char *dst, int max_len )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
|||||||
return max_len;
|
return max_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
static struct cw_Val *from_str ( struct cw_Val * data, const char *src )
|
||||||
{
|
{
|
||||||
char * s;
|
char * s;
|
||||||
s = cw_strdup(src);
|
s = cw_strdup(src);
|
||||||
@ -81,11 +81,11 @@ static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int len ( struct cw_KTV * data ){
|
static int len ( struct cw_Val * data ){
|
||||||
return strlen (data->val.str);
|
return strlen (data->val.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_STR->name;
|
return CW_TYPE_STR->name;
|
||||||
}
|
}
|
||||||
|
@ -20,33 +20,33 @@
|
|||||||
|
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
|
|
||||||
static void del ( struct cw_KTV * data )
|
static void del ( struct cw_Val * data )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
|
static struct cw_Val *get ( struct cw_Val * data, const uint8_t * src, int len )
|
||||||
{
|
{
|
||||||
data->type = &cw_type_sysptr;
|
data->type = &cw_type_sysptr;
|
||||||
data->val.ptr = ((void**)(src))[0];
|
data->val.ptr = ((void**)(src))[0];
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put ( const struct cw_KTV *data, uint8_t * dst )
|
static int put ( const struct cw_Val *data, uint8_t * dst )
|
||||||
{
|
{
|
||||||
((void**)dst)[0] = data->val.ptr ;
|
((void**)dst)[0] = data->val.ptr ;
|
||||||
return sizeof(void*);
|
return sizeof(void*);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
|
static int to_str ( const struct cw_Val *data, char *dst, int max_len )
|
||||||
{
|
{
|
||||||
return sprintf(dst,"%p",data->val.ptr);
|
return sprintf(dst,"%p",data->val.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
static struct cw_Val *from_str ( struct cw_Val * data, const char *src )
|
||||||
{
|
{
|
||||||
uint8_t * s;
|
uint8_t * s;
|
||||||
s = bstr16_create_from_str(src);
|
s = bstr16_create_from_str(src);
|
||||||
@ -60,11 +60,11 @@ static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int len ( struct cw_KTV * data ){
|
static int len ( struct cw_Val * data ){
|
||||||
return sizeof(void*);
|
return sizeof(void*);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_SYSPTR->name;
|
return CW_TYPE_SYSPTR->name;
|
||||||
}
|
}
|
||||||
|
@ -18,39 +18,39 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
|
|
||||||
static struct cw_KTV *get(struct cw_KTV * data, const uint8_t * src, int len)
|
static struct cw_Val *get(struct cw_Val * data, const uint8_t * src, int len)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_word;
|
data->type = &cw_type_word;
|
||||||
data->val.word = cw_get_word(src);
|
data->val.word = cw_get_word(src);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put(const cw_KTV_t *data, uint8_t * dst)
|
static int put(const cw_Val_t *data, uint8_t * dst)
|
||||||
{
|
{
|
||||||
return cw_put_word(dst, data->val.word);
|
return cw_put_word(dst, data->val.word);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_str(const cw_KTV_t *data, char *dst, int max_len)
|
static int to_str(const cw_Val_t *data, char *dst, int max_len)
|
||||||
{
|
{
|
||||||
return sprintf(dst, "%d", data->val.word);
|
return sprintf(dst, "%d", data->val.word);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
|
static cw_Val_t *from_str(cw_Val_t * data, const char *src)
|
||||||
{
|
{
|
||||||
data->type = &cw_type_word;
|
data->type = &cw_type_word;
|
||||||
data->val.word = atoi(src);
|
data->val.word = atoi(src);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * get_type_name(cw_KTV_t *data)
|
static const char * get_type_name(cw_Val_t *data)
|
||||||
{
|
{
|
||||||
return CW_TYPE_WORD->name;
|
return CW_TYPE_WORD->name;
|
||||||
}
|
}
|
||||||
static int cast(cw_KTV_t * data)
|
static int cast(cw_Val_t * data)
|
||||||
{
|
{
|
||||||
if (strcmp(data->type->name,CW_TYPE_WORD->name)==0)
|
if (strcmp(data->type->name,CW_TYPE_WORD->name)==0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
@ -8,7 +8,7 @@ int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore,
|
|||||||
int subelem_id, const char * parent_key )
|
int subelem_id, const char * parent_key )
|
||||||
{
|
{
|
||||||
char key[256];
|
char key[256];
|
||||||
cw_KTV_t * vendor, *version ;
|
cw_Val_t * vendor, *version ;
|
||||||
uint8_t *d;
|
uint8_t *d;
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
|
|||||||
return len + cw_put_elem_hdr(dst, handler->id, len);
|
return len + cw_put_elem_hdr(dst, handler->id, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cw_header_len(struct cw_ElemHandler * handler)
|
int cw_header_len(struct cw_ElemHandler * handler)
|
||||||
{
|
{
|
||||||
return handler->vendor ? 10 : 4;
|
return handler->vendor ? 10 : 4;
|
||||||
|
@ -5,7 +5,7 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
|
|||||||
, uint8_t * dst)
|
, uint8_t * dst)
|
||||||
{
|
{
|
||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
cw_KTV_t *elem, search;
|
cw_Val_t *elem, search;
|
||||||
int len;
|
int len;
|
||||||
uint8_t * d;
|
uint8_t * d;
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
|||||||
const char *header, const char *prefix, const char *footer )
|
const char *header, const char *prefix, const char *footer )
|
||||||
{
|
{
|
||||||
char value[500];
|
char value[500];
|
||||||
struct cw_KTV * data;
|
struct cw_Val * data;
|
||||||
mavliter_t it;
|
mavliter_t it;
|
||||||
const struct cw_Type * type;
|
const struct cw_Type * type;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ struct mlistelem * mlist_get(mlist_t list, const void *data){
|
|||||||
mlist_foreach(elem,list){
|
mlist_foreach(elem,list){
|
||||||
void *tdata = mlistelem_dataptr(elem);
|
void *tdata = mlistelem_dataptr(elem);
|
||||||
if (list->cmp(tdata,data)==0){
|
if (list->cmp(tdata,data)==0){
|
||||||
return tdata;
|
return elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -105,7 +105,7 @@ struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn,
|
|||||||
struct cw_MsgSet *set;
|
struct cw_MsgSet *set;
|
||||||
|
|
||||||
if (!msgset_cache) {
|
if (!msgset_cache) {
|
||||||
msgset_cache = mavl_create(cmp, NULL, 1312);
|
msgset_cache = mavl_create(cmp, NULL, sizeof(struct cache_item*));
|
||||||
if (!msgset_cache) {
|
if (!msgset_cache) {
|
||||||
cw_log(LOG_ERR, "Can't initialize msgset cache: %s",
|
cw_log(LOG_ERR, "Can't initialize msgset cache: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@ -213,7 +213,7 @@ struct cw_Mod *cw_mod_load(const char *mod_name, mavl_t global_cfg, int role)
|
|||||||
|
|
||||||
/* if modlist is not initialized, initialize ... */
|
/* if modlist is not initialized, initialize ... */
|
||||||
if (mods_loaded == NULL) {
|
if (mods_loaded == NULL) {
|
||||||
mods_loaded = mavl_create(mod_cmp_mavl, NULL, 1312);
|
mods_loaded = mavl_create(mod_cmp_mavl, NULL, sizeof(struct cw_Mod*));
|
||||||
if (mods_loaded == NULL) {
|
if (mods_loaded == NULL) {
|
||||||
cw_log(LOG_ERROR, "Can't init modlist, no memory");
|
cw_log(LOG_ERROR, "Can't init modlist, no memory");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -272,8 +272,10 @@ struct cw_Mod *cw_mod_load(const char *mod_name, mavl_t global_cfg, int role)
|
|||||||
cw_log(LOG_ERR, "Can' add module %s", mod_name);
|
cw_log(LOG_ERR, "Can' add module %s", mod_name);
|
||||||
goto errX;
|
goto errX;
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_dbg(DBG_MOD, "MOD: %s sucessfull loaded, calling init now.", filename);
|
cw_dbg(DBG_MOD, "MOD: %s sucessfull loaded, calling init now.", filename);
|
||||||
mod->init(mod, global_cfg, role);
|
mod->init(mod, global_cfg, role);
|
||||||
|
|
||||||
errX:
|
errX:
|
||||||
free(filename);
|
free(filename);
|
||||||
return mod;
|
return mod;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include "msgset.h"
|
#include "msgset.h"
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
#include "mavltypes.h"
|
#include "mavltypes.h"
|
||||||
|
|
||||||
static int cmp_cw_elemhandler_by_id(const void *elem1, const void *elem2)
|
static int cmp_cw_elemhandler_by_id(const void *elem1, const void *elem2)
|
||||||
@ -114,6 +114,7 @@ void cw_msgset_destroy(struct cw_MsgSet *set)
|
|||||||
*/
|
*/
|
||||||
struct cw_MsgSet *cw_msgset_create()
|
struct cw_MsgSet *cw_msgset_create()
|
||||||
{
|
{
|
||||||
|
const cw_Type_t **ti;
|
||||||
|
|
||||||
/* allocate memory for a message_set */
|
/* allocate memory for a message_set */
|
||||||
struct cw_MsgSet *set = malloc(sizeof(struct cw_MsgSet));
|
struct cw_MsgSet *set = malloc(sizeof(struct cw_MsgSet));
|
||||||
@ -149,13 +150,15 @@ struct cw_MsgSet *cw_msgset_create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
set->types_tree = cw_ktv_create_types_tree();
|
set->types_tree = cw_ktv_create_types_tree();
|
||||||
|
|
||||||
printf("TYPES TREE %p\n",set->types_tree);
|
|
||||||
|
|
||||||
if (set->types_tree == NULL){
|
if (set->types_tree == NULL){
|
||||||
cw_msgset_destroy(set);
|
cw_msgset_destroy(set);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
/* insert default types */
|
||||||
|
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
|
||||||
|
mavl_insert_ptr(set->types_tree,*ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
set->state_machine = mavl_create(cmp_machinestate,NULL,sizeof(cw_StateMachineState_t));
|
set->state_machine = mavl_create(cmp_machinestate,NULL,sizeof(cw_StateMachineState_t));
|
||||||
if (set->state_machine == NULL)
|
if (set->state_machine == NULL)
|
||||||
@ -336,10 +339,6 @@ int cw_msgset_add(struct cw_MsgSet *set,
|
|||||||
{
|
{
|
||||||
mavliter_t it;
|
mavliter_t it;
|
||||||
cw_dbg(DBG_MOD," Known types:");
|
cw_dbg(DBG_MOD," Known types:");
|
||||||
|
|
||||||
printf("TYPES TREE ITER %p\n",set->types_tree);
|
|
||||||
|
|
||||||
|
|
||||||
mavliter_init(&it,set->types_tree);
|
mavliter_init(&it,set->types_tree);
|
||||||
mavliter_foreach(&it){
|
mavliter_foreach(&it){
|
||||||
struct cw_Type * t = mavliter_get_ptr(&it);
|
struct cw_Type * t = mavliter_get_ptr(&it);
|
||||||
|
@ -5,15 +5,8 @@
|
|||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "mavl.h"
|
#include "mavl.h"
|
||||||
|
|
||||||
#include "ktv.h"
|
#include "val.h"
|
||||||
|
|
||||||
struct cw_MsgSet {
|
|
||||||
mavl_t msgdata;
|
|
||||||
mavl_t handlers_by_id;
|
|
||||||
mavl_t handlers_by_key;
|
|
||||||
mavl_t types_tree;
|
|
||||||
mavl_t state_machine;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct cw_ElemDef{
|
struct cw_ElemDef{
|
||||||
int proto;
|
int proto;
|
||||||
@ -36,7 +29,7 @@ struct cw_ElemHandlerParams {
|
|||||||
struct cw_ElemData * elemdata;
|
struct cw_ElemData * elemdata;
|
||||||
struct sockaddr *from;
|
struct sockaddr *from;
|
||||||
mavl_t mand_found;
|
mavl_t mand_found;
|
||||||
cw_KTV_t * elem;
|
cw_Val_t * elem;
|
||||||
char * debug_details;
|
char * debug_details;
|
||||||
mavl_t remote_cfg;
|
mavl_t remote_cfg;
|
||||||
mavl_t local_cfg;
|
mavl_t local_cfg;
|
||||||
@ -68,6 +61,19 @@ struct cw_ElemHandler {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct cw_MsgSet {
|
||||||
|
mavl_t msgdata;
|
||||||
|
mavl_t handlers_by_id;
|
||||||
|
mavl_t handlers_by_key;
|
||||||
|
mavl_t types_tree;
|
||||||
|
mavl_t state_machine;
|
||||||
|
int (*write_header)(struct cw_ElemHandler * handler, uint8_t * dst, int len);
|
||||||
|
int (*header_len)(struct cw_ElemHandler *handler);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_State{
|
struct cw_State{
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
uint8_t next;
|
uint8_t next;
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
#define CW_KTV_MAX_KEY_LEN 1024
|
#define CW_KTV_MAX_KEY_LEN 1024
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct cw_KTV
|
* @struct cw_Val
|
||||||
* @file ktv.h
|
* @file ktv.h
|
||||||
* @brief Structure to store a key-type-value element.
|
* @brief Structure to store a key-type-value element.
|
||||||
*/
|
*/
|
||||||
struct cw_KTV {
|
struct cw_Val {
|
||||||
/** The key for this element. A string. */
|
/** The key for this element. A string. */
|
||||||
char *key;
|
char *key;
|
||||||
/** Teh type of this element. */
|
/** Teh type of this element. */
|
||||||
@ -45,7 +45,7 @@ struct cw_KTV {
|
|||||||
} val;
|
} val;
|
||||||
const void * valguard;
|
const void * valguard;
|
||||||
};
|
};
|
||||||
typedef struct cw_KTV cw_KTV_t;
|
typedef struct cw_Val cw_Val_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -61,13 +61,13 @@ struct cw_Type {
|
|||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
/** A pointer to a function to delete elements of this type */
|
/** A pointer to a function to delete elements of this type */
|
||||||
void (*del) (struct cw_KTV * data);
|
void (*del) (struct cw_Val * data);
|
||||||
|
|
||||||
/** A method to put this object to a buffer */
|
/** A method to put this object to a buffer */
|
||||||
int (*put) (const struct cw_KTV * data, uint8_t * dst);
|
int (*put) (const struct cw_Val * data, uint8_t * dst);
|
||||||
|
|
||||||
/** The get method */
|
/** The get method */
|
||||||
struct cw_KTV *(*get) (struct cw_KTV * data, const uint8_t * src, int len);
|
struct cw_Val *(*get) (struct cw_Val * data, const uint8_t * src, int len);
|
||||||
|
|
||||||
/** A pointer to a function to convert elements of this type to a string.
|
/** A pointer to a function to convert elements of this type to a string.
|
||||||
* This function is mainly used to store elements to an SQL database
|
* This function is mainly used to store elements to an SQL database
|
||||||
@ -77,39 +77,39 @@ struct cw_Type {
|
|||||||
* @param max_len maximum length of buffer
|
* @param max_len maximum length of buffer
|
||||||
* @return The number of bytes written to dst
|
* @return The number of bytes written to dst
|
||||||
*/
|
*/
|
||||||
int (*to_str) (const struct cw_KTV * data, char *dst, int max_len);
|
int (*to_str) (const struct cw_Val * data, char *dst, int max_len);
|
||||||
|
|
||||||
/** Cereate an item of this type from a string, which was previously
|
/** Cereate an item of this type from a string, which was previously
|
||||||
created by the #del function. */
|
created by the #del function. */
|
||||||
struct cw_KTV *(*from_str) (struct cw_KTV * data, const char *src);
|
struct cw_Val *(*from_str) (struct cw_Val * data, const char *src);
|
||||||
|
|
||||||
|
|
||||||
int (*len)(cw_KTV_t *);
|
int (*len)(cw_Val_t *);
|
||||||
|
|
||||||
void *(*data)(cw_KTV_t *);
|
void *(*data)(cw_Val_t *);
|
||||||
const char * (*get_type_name)(cw_KTV_t*);
|
const char * (*get_type_name)(cw_Val_t*);
|
||||||
|
|
||||||
int (*cast)(cw_KTV_t *);
|
int (*cast)(cw_Val_t *);
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef struct cw_Type cw_Type_t;
|
typedef struct cw_Type cw_Type_t;
|
||||||
|
|
||||||
|
|
||||||
struct cw_KTVValRange {
|
struct cw_ValValRange {
|
||||||
int min,max;
|
int min,max;
|
||||||
const char * name;
|
const char * name;
|
||||||
};
|
};
|
||||||
typedef struct cw_KTVValRange cw_KTVValRange_t;
|
typedef struct cw_ValValRange cw_ValValRange_t;
|
||||||
|
|
||||||
|
|
||||||
struct cw_KTVStruct {
|
struct cw_ValStruct {
|
||||||
const struct cw_Type * type;
|
const struct cw_Type * type;
|
||||||
const char * key;
|
const char * key;
|
||||||
int len;
|
int len;
|
||||||
int position;
|
int position;
|
||||||
const void * valguard;
|
const void * valguard;
|
||||||
};
|
};
|
||||||
typedef struct cw_KTVStruct cw_KTVStruct_t;
|
typedef struct cw_ValStruct cw_ValStruct_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -120,25 +120,25 @@ typedef struct cw_KTVStruct cw_KTVStruct_t;
|
|||||||
#define CW_KTVSTRUCT_L16 -2
|
#define CW_KTVSTRUCT_L16 -2
|
||||||
#define CW_KTVSTRUCT_L8 -3
|
#define CW_KTVSTRUCT_L8 -3
|
||||||
|
|
||||||
struct cw_KTVEnum{
|
struct cw_ValEnum{
|
||||||
int value;
|
int value;
|
||||||
const char * name;
|
const char * name;
|
||||||
const void * type;
|
const void * type;
|
||||||
int (*fun_in)();
|
int (*fun_in)();
|
||||||
int (*fun_out)();
|
int (*fun_out)();
|
||||||
};
|
};
|
||||||
typedef struct cw_KTVEnum cw_KTVEnum_t;
|
typedef struct cw_ValEnum cw_ValEnum_t;
|
||||||
|
|
||||||
|
|
||||||
struct cw_KTVIndexed{
|
struct cw_ValIndexed{
|
||||||
int idxpos;
|
int idxpos;
|
||||||
void *type;
|
void *type;
|
||||||
};
|
};
|
||||||
typedef struct cw_KTVIndexed cw_KTVIndexed_t;
|
typedef struct cw_ValIndexed cw_ValIndexed_t;
|
||||||
|
|
||||||
int cw_ktv_read_struct(mavl_t ktv,const cw_KTVStruct_t * stru, const char *pkey,
|
int cw_ktv_read_struct(mavl_t ktv,const cw_ValStruct_t * stru, const char *pkey,
|
||||||
uint8_t * data, int len);
|
uint8_t * data, int len);
|
||||||
int cw_ktv_write_struct(mavl_t ktv, mavl_t def, const cw_KTVStruct_t * stru, const char *pkey,
|
int cw_ktv_write_struct(mavl_t ktv, mavl_t def, const cw_ValStruct_t * stru, const char *pkey,
|
||||||
uint8_t * dst);
|
uint8_t * dst);
|
||||||
|
|
||||||
|
|
||||||
@ -165,13 +165,13 @@ extern const struct cw_Type cw_type_bool;
|
|||||||
/*
|
/*
|
||||||
void cw_kvstore_mavl_delete(const void *data);
|
void cw_kvstore_mavl_delete(const void *data);
|
||||||
*/
|
*/
|
||||||
cw_KTV_t *cw_ktv_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
|
cw_Val_t *cw_ktv_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
|
||||||
const void * valguard,
|
const void * valguard,
|
||||||
const uint8_t * data, int len);
|
const uint8_t * data, int len);
|
||||||
|
|
||||||
void cw_ktv_del_sub(mavl_t ktvstore, const char *basekey);
|
void cw_ktv_del_sub(mavl_t ktvstore, const char *basekey);
|
||||||
|
|
||||||
cw_KTV_t * cw_ktv_replace(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
cw_Val_t * cw_ktv_replace(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||||
const void * valguard,
|
const void * valguard,
|
||||||
const uint8_t * data, int len);
|
const uint8_t * data, int len);
|
||||||
|
|
||||||
@ -189,19 +189,19 @@ void cw_ktv_mavldel(void *data);
|
|||||||
* @return a #mavl_t object representing the KTV store
|
* @return a #mavl_t object representing the KTV store
|
||||||
*/
|
*/
|
||||||
#define cw_ktv_create()\
|
#define cw_ktv_create()\
|
||||||
mavl_create(cw_ktv_mavlcmp, cw_ktv_mavldel, sizeof(cw_KTV_t))
|
mavl_create(cw_ktv_mavlcmp, cw_ktv_mavldel, sizeof(cw_Val_t))
|
||||||
|
|
||||||
#define cw_ktv_create_types_tree()\
|
#define cw_ktv_create_types_tree()\
|
||||||
mavl_create(cw_ktv_mavlcmp_type_by_name,NULL,sizeof(struct cw_Type *))
|
mavl_create(cw_ktv_mavlcmp_type_by_name,NULL,sizeof(struct cw_Type *))
|
||||||
|
|
||||||
int cw_ktv_read_line (FILE *f, char * key, char * type, char *val);
|
int cw_ktv_read_line (FILE *f, char * key, char * type, char *val);
|
||||||
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types);
|
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types);
|
||||||
cw_KTV_t * cw_ktv_get(mavl_t ktv, const char *key, const cw_Type_t * type);
|
cw_Val_t * cw_ktv_get(mavl_t ktv, const char *key, const cw_Type_t * type);
|
||||||
uint8_t cw_ktv_get_byte(mavl_t ktv,const char *key, uint8_t def);
|
uint8_t cw_ktv_get_byte(mavl_t ktv,const char *key, uint8_t def);
|
||||||
uint8_t cw_ktv_get_bool(mavl_t ktv,const char *key, uint8_t def);
|
uint8_t cw_ktv_get_bool(mavl_t ktv,const char *key, uint8_t def);
|
||||||
cw_KTV_t * cw_ktv_set_byte(mavl_t ktv,const char * key, uint8_t byte);
|
cw_Val_t * cw_ktv_set_byte(mavl_t ktv,const char * key, uint8_t byte);
|
||||||
cw_KTV_t * cw_ktv_set_dword(mavl_t ktv,const char * key, uint32_t dword);
|
cw_Val_t * cw_ktv_set_dword(mavl_t ktv,const char * key, uint32_t dword);
|
||||||
cw_KTV_t * cw_ktv_set_word(mavl_t ktv,const char * key, uint16_t word);
|
cw_Val_t * cw_ktv_set_word(mavl_t ktv,const char * key, uint16_t word);
|
||||||
|
|
||||||
bstr16_t cw_ktv_get_bstr16(mavl_t ktv,const char *key, bstr16_t def);
|
bstr16_t cw_ktv_get_bstr16(mavl_t ktv,const char *key, bstr16_t def);
|
||||||
|
|
||||||
@ -211,19 +211,19 @@ void * cw_ktv_get_sysptr(mavl_t ktv,const char *key, void * def);
|
|||||||
char * cw_ktv_get_str(mavl_t ktv,const char *key, char * def);
|
char * cw_ktv_get_str(mavl_t ktv,const char *key, char * def);
|
||||||
|
|
||||||
int cw_ktv_idx_get(mavl_t ktv, const char *key);
|
int cw_ktv_idx_get(mavl_t ktv, const char *key);
|
||||||
cw_KTV_t * cw_ktv_base_exists(mavl_t ktvstore, const char *basekey);
|
cw_Val_t * cw_ktv_base_exists(mavl_t ktvstore, const char *basekey);
|
||||||
int cw_ktv_save(mavl_t ktvstore, const char * filename);
|
int cw_ktv_save(mavl_t ktvstore, const char * filename);
|
||||||
cw_KTV_t * cw_ktv_cast(cw_KTV_t *v,const cw_Type_t * type);
|
cw_Val_t * cw_ktv_cast(cw_Val_t *v,const cw_Type_t * type);
|
||||||
|
|
||||||
extern const cw_Type_t * cw_ktv_std_types[];
|
extern const cw_Type_t * cw_ktv_std_types[];
|
||||||
#define CW_KTV_STD_TYPES cw_ktv_std_types
|
#define CW_KTV_STD_TYPES cw_ktv_std_types
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_KTV_Reader {
|
struct cw_Val_Reader {
|
||||||
const void * data;
|
const void * data;
|
||||||
int (*xgetchar)(struct cw_KTV_Reader *);
|
int (*xgetchar)(struct cw_Val_Reader *);
|
||||||
void (*ungetchar)(struct cw_KTV_Reader *, int c);
|
void (*ungetchar)(struct cw_Val_Reader *, int c);
|
||||||
int quote;
|
int quote;
|
||||||
int line;
|
int line;
|
||||||
int pos;
|
int pos;
|
||||||
@ -233,8 +233,8 @@ struct cw_KTV_Reader {
|
|||||||
char error[256];
|
char error[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
void cw_ktv_init_str_reader(struct cw_KTV_Reader *r, const char * str, int len);
|
void cw_ktv_init_str_reader(struct cw_Val_Reader *r, const char * str, int len);
|
||||||
int cw_ktv_parse_string(struct cw_KTV_Reader *r, char *key, char *type, char *val);
|
int cw_ktv_parse_string(struct cw_Val_Reader *r, char *key, char *type, char *val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @} KTV
|
* @} KTV
|
@ -31,7 +31,7 @@ $(MF): Makefile $(MFDEPS)
|
|||||||
@echo "" >> $(MF)
|
@echo "" >> $(MF)
|
||||||
@echo "$(DNAME) : \$$(OBJS)" >> $(MF)
|
@echo "$(DNAME) : \$$(OBJS)" >> $(MF)
|
||||||
@echo " @echo Creating dynamic library: $(DNAME)" >> $(MF)
|
@echo " @echo Creating dynamic library: $(DNAME)" >> $(MF)
|
||||||
@echo " $(V)\$$(LD) \$$(LDFLAGS) -shared -o $(DNAME) \$$(OBJS) $(LIBS)" >> $(MF)
|
@echo " $(V)\$$(LD) \$$(LDFLAGS) -shared -o $(DNAME) \$$(OBJS)" >> $(MF)
|
||||||
@echo "" >> $(MF)
|
@echo "" >> $(MF)
|
||||||
# @echo " \$$(CC) -o $(PROGTARGET) \$$(LDFLAGS) \$$(OBJS) $(LIBS)" >> $(MF)
|
# @echo " \$$(CC) -o $(PROGTARGET) \$$(LDFLAGS) \$$(OBJS) $(LIBS)" >> $(MF)
|
||||||
@for f in $(SOURCES) ; do \
|
@for f in $(SOURCES) ; do \
|
||||||
|
@ -30,6 +30,8 @@ DNAME := $(LIBARCHDIR)/mod_capwap.so
|
|||||||
|
|
||||||
CFLAGS+=-fPIC
|
CFLAGS+=-fPIC
|
||||||
CFLAGS+= -I ../../ -I../ -I../../include -I../../../include
|
CFLAGS+= -I ../../ -I../ -I../../include -I../../../include
|
||||||
|
CFLAGS+= -DUSE_OPENSSL
|
||||||
|
|
||||||
CFLAGS+=$(INC2)
|
CFLAGS+=$(INC2)
|
||||||
|
|
||||||
all: $(SNAME) $(DNAME)
|
all: $(SNAME) $(DNAME)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "cw/cw.h"
|
#include "cw/cw.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
#include "cw/log.h"
|
#include "cw/log.h"
|
||||||
#include "cw/dbg.h"
|
#include "cw/dbg.h"
|
||||||
|
|
||||||
@ -32,7 +32,7 @@
|
|||||||
static int postprocess_join_request(struct conn *conn);
|
static int postprocess_join_request(struct conn *conn);
|
||||||
|
|
||||||
|
|
||||||
static cw_KTVStruct_t wtp_reboot_statistics[] = {
|
static cw_ValStruct_t wtp_reboot_statistics[] = {
|
||||||
{CW_TYPE_WORD, "reboot-count", 2,-1},
|
{CW_TYPE_WORD, "reboot-count", 2,-1},
|
||||||
{CW_TYPE_WORD, "ac-initiated-count", 2,-1},
|
{CW_TYPE_WORD, "ac-initiated-count", 2,-1},
|
||||||
{CW_TYPE_WORD, "link-failure-count", 2,-1},
|
{CW_TYPE_WORD, "link-failure-count", 2,-1},
|
||||||
@ -44,27 +44,27 @@ static cw_KTVStruct_t wtp_reboot_statistics[] = {
|
|||||||
{NULL,NULL,0,0}
|
{NULL,NULL,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static cw_KTVStruct_t capwap_timers[] = {
|
static cw_ValStruct_t capwap_timers[] = {
|
||||||
{CW_TYPE_BYTE, "max-discovery-interval", 1,-1},
|
{CW_TYPE_BYTE, "max-discovery-interval", 1,-1},
|
||||||
{CW_TYPE_BYTE, "echo-interval", 1,-1},
|
{CW_TYPE_BYTE, "echo-interval", 1,-1},
|
||||||
{NULL,NULL,0,0}
|
{NULL,NULL,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static cw_KTVStruct_t radio_operational_state[] = {
|
static cw_ValStruct_t radio_operational_state[] = {
|
||||||
{CW_TYPE_BYTE, "state", 1,-1},
|
{CW_TYPE_BYTE, "state", 1,-1},
|
||||||
{CW_TYPE_BYTE, "cause", 1,-1},
|
{CW_TYPE_BYTE, "cause", 1,-1},
|
||||||
{NULL,NULL,0,0}
|
{NULL,NULL,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static cw_KTVValRange_t radio_admin_state_valguard[]={
|
static cw_ValValRange_t radio_admin_state_valguard[]={
|
||||||
{0,0,"reserved"},
|
{0,0,"reserved"},
|
||||||
{1,1,"enabled"},
|
{1,1,"enabled"},
|
||||||
{2,2,"disabled"},
|
{2,2,"disabled"},
|
||||||
{0,0,NULL}
|
{0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static cw_KTVStruct_t radio_admin_state[] = {
|
static cw_ValStruct_t radio_admin_state[] = {
|
||||||
{CW_TYPE_BYTE, NULL, 1,-1, radio_admin_state_valguard},
|
{CW_TYPE_BYTE, NULL, 1,-1, radio_admin_state_valguard},
|
||||||
{NULL,NULL,0,0}
|
{NULL,NULL,0,0}
|
||||||
};
|
};
|
||||||
@ -748,7 +748,7 @@ static struct cw_MsgDef messages[] = {
|
|||||||
|
|
||||||
static int postprocess_join_request(struct conn *conn)
|
static int postprocess_join_request(struct conn *conn)
|
||||||
{
|
{
|
||||||
cw_KTV_t * result;
|
cw_Val_t * result;
|
||||||
|
|
||||||
result = cw_ktv_get(conn->remote_cfg,"session-id",CW_TYPE_BSTR16);
|
result = cw_ktv_get(conn->remote_cfg,"session-id",CW_TYPE_BSTR16);
|
||||||
if (result != NULL){
|
if (result != NULL){
|
||||||
@ -826,6 +826,19 @@ static cw_StateMachineState_t statemachine_states[]={
|
|||||||
{0,0,0}
|
{0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
|
||||||
|
{
|
||||||
|
if (handler->vendor)
|
||||||
|
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
||||||
|
|
||||||
|
return len + cw_put_elem_hdr(dst, handler->id, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int header_len(struct cw_ElemHandler * handler)
|
||||||
|
{
|
||||||
|
return handler->vendor ? 10 : 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode){
|
struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode){
|
||||||
@ -838,10 +851,8 @@ struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode){
|
|||||||
|
|
||||||
cw_msgset_add_states(set,statemachine_states);
|
cw_msgset_add_states(set,statemachine_states);
|
||||||
|
|
||||||
mavl_insert_ptr(set->types_tree,CW_TYPE_BSTR16);
|
set->write_header = write_header;
|
||||||
mavl_insert_ptr(set->types_tree,CW_TYPE_BYTE);
|
set->header_len = header_len;
|
||||||
mavl_insert_ptr(set->types_tree,CW_TYPE_DWORD);
|
|
||||||
mavl_insert_ptr(set->types_tree,CW_TYPE_WORD);
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO,"CAPWAP: Done register messages");
|
cw_dbg(DBG_INFO,"CAPWAP: Done register messages");
|
||||||
return set;
|
return set;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "cw/dbg.h"
|
#include "cw/dbg.h"
|
||||||
#include "cw/cw.h"
|
#include "cw/cw.h"
|
||||||
|
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
|
|
||||||
#include "cw/keys.h"
|
#include "cw/keys.h"
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "cw/capwap.h"
|
#include "cw/capwap.h"
|
||||||
#include "cw/cw.h"
|
#include "cw/cw.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
#include "cw/keys.h"
|
#include "cw/keys.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ int capwap_out_capwap_control_ip_address(struct cw_ElemHandler * eh,
|
|||||||
char key[CW_KTV_MAX_KEY_LEN];
|
char key[CW_KTV_MAX_KEY_LEN];
|
||||||
int i;
|
int i;
|
||||||
int wtps;
|
int wtps;
|
||||||
cw_KTV_t * address;
|
cw_Val_t * address;
|
||||||
uint8_t *d;
|
uint8_t *d;
|
||||||
|
|
||||||
d = dst;
|
d = dst;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
int capwap_out_capwap_local_ip_address(struct cw_ElemHandler * eh,
|
int capwap_out_capwap_local_ip_address(struct cw_ElemHandler * eh,
|
||||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||||
{
|
{
|
||||||
cw_KTV_t * ip;
|
cw_Val_t * ip;
|
||||||
ip = cw_ktv_get(params->local_cfg,eh->key,CW_TYPE_IPADDRESS);
|
ip = cw_ktv_get(params->local_cfg,eh->key,CW_TYPE_IPADDRESS);
|
||||||
if (ip==NULL){
|
if (ip==NULL){
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "cw/conn.h"
|
#include "cw/conn.h"
|
||||||
#include "cw/log.h"
|
#include "cw/log.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
#include "cw/msgset.h"
|
#include "cw/msgset.h"
|
||||||
#include "cw/keys.h"
|
#include "cw/keys.h"
|
||||||
#include "cw/cw.h"
|
#include "cw/cw.h"
|
||||||
@ -11,7 +11,7 @@ static int write_boarddata_subelem(uint8_t * dst, mavl_t ktv, const char * paren
|
|||||||
const char *skey, int type){
|
const char *skey, int type){
|
||||||
|
|
||||||
char key[256];
|
char key[256];
|
||||||
cw_KTV_t * val;
|
cw_Val_t * val;
|
||||||
uint8_t *d;
|
uint8_t *d;
|
||||||
|
|
||||||
d=dst;
|
d=dst;
|
||||||
@ -40,7 +40,7 @@ static int write_boarddata_subelem(uint8_t * dst, mavl_t ktv, const char * paren
|
|||||||
int capwap_out_wtp_board_data(struct cw_ElemHandler * eh,
|
int capwap_out_wtp_board_data(struct cw_ElemHandler * eh,
|
||||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||||
{
|
{
|
||||||
cw_KTV_t * val;
|
cw_Val_t * val;
|
||||||
mavl_t cfg;
|
mavl_t cfg;
|
||||||
uint8_t * d;
|
uint8_t * d;
|
||||||
char key[256];
|
char key[256];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "cw/log.h"
|
#include "cw/log.h"
|
||||||
#include "cw/cw.h"
|
#include "cw/cw.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
#include "cw/keys.h"
|
#include "cw/keys.h"
|
||||||
#include "cw/dbg.h"
|
#include "cw/dbg.h"
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
|||||||
int len,l;
|
int len,l;
|
||||||
/* // XXX Dummy WTP Descriptor Header */
|
/* // XXX Dummy WTP Descriptor Header */
|
||||||
uint8_t *d;
|
uint8_t *d;
|
||||||
cw_KTV_t * val;
|
cw_Val_t * val;
|
||||||
|
|
||||||
d = dst+4;
|
d = dst+4;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "cw/mod.h"
|
#include "cw/mod.h"
|
||||||
#include "cw/log.h"
|
#include "cw/log.h"
|
||||||
#include "cw/dbg.h"
|
#include "cw/dbg.h"
|
||||||
#include "cw/ktv.h"
|
#include "cw/val.h"
|
||||||
#include "cw/keys.h"
|
#include "cw/keys.h"
|
||||||
#include "cw/dtls.h"
|
#include "cw/dtls.h"
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user