dot1x_status_search.tcl
来自「smartbits二次开发示例代码」· TCL 代码 · 共 333 行 · 第 1/2 页
TCL
333 行
puts "\nStopping Supplicants ..."
LIBCMD HTSetStructure $::NS_DOT1X_SUPPLICANT_CONTROL 0 0 0 stopSupplicant 0 $H $S $P
unset stopSupplicant
}
#################################################################################
# - Fill Supplicant #
# - Increment Source MAC for Supplicants with index 1 to 19 #
# Source MAC for Supplicant 1 will be 3.3.3.3.3.3, Supplicant 2 will be #
# 4.4.4.4.4.4 and so on. #
#################################################################################
proc FillSupplicant {H S P } {
struct_new supplicantFill NSDOT1XSupplicantFill
set supplicantFill(ulBaseIndex) 0
set supplicantFill(ulDestinationIndex) 1
set supplicantFill(ulCount) 19
set supplicantFill(uiField) $::DOT1X_SUPPLICANT_SRC_MAC
for {set i 0} {$i < 6} {incr i} {
set supplicantFill(ucDelta.$i) 1
}
puts "\nChanging Source MAC with Fill command ..."
LIBCMD HTSetStructure $::NS_DOT1X_SUPPLICANT_FILL 0 0 0 supplicantFill 0 $H $S $P
unset supplicantFill
}
#################################################################################
# - Search for Supplicants which are in Authenticated State #
# #
#################################################################################
proc StatusSearch {H S P } {
struct_new search NSDOT1XSupplicantStatusSearchInfo
set search(ulIndex) 0
set search(ulCount) 20
set search(uiSearchField) $::DOT1X_SUPPLICANT_STATUS_SUPPICANT_STATE
set search(uiReturnField) $::DOT1X_SUPPLICANT_STATUS_INDEX
set search(u64SearchRangeLow.low) $::DOT1X_SUPPLICANT_AUTHENTICATED
set search(u64SearchRangeHigh.low) $::DOT1X_SUPPLICANT_AUTHENTICATED
puts "\nSearch for Supplicants which are Authenticated ..."
HTGetStructure $::NS_DOT1X_SUPPLICANT_STATUS_SEARCH_INFO 0 0 0 search 0 $H $S $P
puts "\nNumber of Supplicants Authenticated : $search(ulReturnCount)"
puts "\nSupplicants Authenticated ..."
for {set i 0} {$i < $search(ulReturnCount)} {incr i} {
puts "Supplicant with index : $search(u64Data.$i.low)"
}
unset search
}
#################################################################################
# - Check the state of Supplicants #
# Verify if both Supplicants have been Authenticated #
#################################################################################
proc CheckSupplicantState {H S P} {
struct_new supplicantStatus NSDOT1XSupplicantStatusInfo*10
puts "\nChecking for Successful Authentication ..."
LIBCMD HTGetStructure $::NS_DOT1X_SUPPLICANT_STATUS_INFO 0 10 0 supplicantStatus 0 $H $S $P
for {set i 0} {$i < 10} {incr i} {
while { ($supplicantStatus($i.ucSupplicantState) != $::DOT1X_SUPPLICANT_AUTHENTICATED) || \
($supplicantStatus($i.ucSessionState) != $::DOT1X_SUPPLICANT_SESSION_AUTHENTICATED) } {
after 3000
LIBCMD HTGetStructure $::NS_DOT1X_SUPPLICANT_STATUS_INFO 0 10 0 supplicantStatus 0 $H $S $P
}
}
}
set TxHub 0
set TxSlot 0
set TxPort 0
struct_new ulSubHandle ULong
# Reserve the cards
LIBCMD HTSlotReserve $TxHub $TxSlot
# Reset the cards to the default values
LIBCMD HTResetPort $RESET_FULL $TxHub $TxSlot $TxPort
#################################################################################
# - Start Subprocess for Supplicant #
# #
#################################################################################
set ulSubHandle(ul) [StartSubprocess $TxHub $TxSlot $TxPort]
#################################################################################
# - Delete all supplicants, and clear all the supplicants and session #
# statistics on the port. #
#################################################################################
LIBCMD HTSetCommand $::NS_DOT1X_SUPPLICANT_RESET 0 0 0 "" $TxHub $TxSlot $TxPort
#################################################################################
# - Configure port for Supplicant configuration. #
# #
#################################################################################
ConfigurePort $TxHub $TxSlot $TxPort
#################################################################################
# - Configure Supplicants. #
# #
#################################################################################
ConfigureSupplicant $TxHub $TxSlot $TxPort
#################################################################################
# - Fill Parameter Supplicant Configuration. #
# #
#################################################################################
FillSupplicant $TxHub $TxSlot $TxPort
#################################################################################
# - Start Supplicant, to begin Authentication #
# #
#################################################################################
StartSupplicant $TxHub $TxSlot $TxPort
#################################################################################
# - Check Supplicant State #
# #
#################################################################################
CheckSupplicantState $TxHub $TxSlot $TxPort
#################################################################################
# - Status Search #
# Search for Supplicants in Connecting, Acquired or Authenticating States #
#################################################################################
StatusSearch $TxHub $TxSlot $TxPort
#################################################################################
# - Stop Supplicants to end Authentication #
# #
#################################################################################
StopSupplicant $TxHub $TxSlot $TxPort
#Destroy Subporcess
LIBCMD HTSetStructure $::NS_DESTROY_SUBPROCESS 0 0 0 ulSubHandle 0 $TxHub $TxSlot $TxPort
# Unlink from Chassis
NSUnLink
puts "DONE!"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?