net: updates/cleanup/docs for net, netdev, and netlink

This commit is contained in:
Scott Feldman
2023-06-11 20:34:18 -07:00
committed by Ron Evans
parent 196d1dd58d
commit 3089bf8b1b
23 changed files with 232 additions and 869 deletions
-67
View File
@@ -1,67 +0,0 @@
package wifinina
type CommandType uint8
//go:generate stringer -type=CommandType -trimprefix=Cmd
const (
CmdStart CommandType = 0xE0
CmdEnd CommandType = 0xEE
CmdErr CommandType = 0xEF
CmdSetNet CommandType = 0x10
CmdSetPassphrase CommandType = 0x11
CmdSetKey CommandType = 0x12
CmdSetIPConfig CommandType = 0x14
CmdSetDNSConfig CommandType = 0x15
CmdSetHostname CommandType = 0x16
CmdSetPowerMode CommandType = 0x17
CmdSetAPNet CommandType = 0x18
CmdSetAPPassphrase CommandType = 0x19
CmdSetDebug CommandType = 0x1A
CmdGetTemperature CommandType = 0x1B
CmdGetReasonCode CommandType = 0x1F
// TEST_CMD = 0x13
CmdGetConnStatus CommandType = 0x20
CmdGetIPAddr CommandType = 0x21
CmdGetMACAddr CommandType = 0x22
CmdGetCurrSSID CommandType = 0x23
CmdGetCurrBSSID CommandType = 0x24
CmdGetCurrRSSI CommandType = 0x25
CmdGetCurrEncrType CommandType = 0x26
CmdScanNetworks CommandType = 0x27
CmdStartServerTCP CommandType = 0x28
CmdGetStateTCP CommandType = 0x29
CmdDataSentTCP CommandType = 0x2A
CmdAvailDataTCP CommandType = 0x2B
CmdGetDataTCP CommandType = 0x2C
CmdStartClientTCP CommandType = 0x2D
CmdStopClientTCP CommandType = 0x2E
CmdGetClientStateTCP CommandType = 0x2F
CmdDisconnect CommandType = 0x30
CmdGetIdxRSSI CommandType = 0x32
CmdGetIdxEncrType CommandType = 0x33
CmdReqHostByName CommandType = 0x34
CmdGetHostByName CommandType = 0x35
CmdStartScanNetworks CommandType = 0x36
CmdGetFwVersion CommandType = 0x37
CmdSendDataUDP CommandType = 0x39
CmdGetRemoteData CommandType = 0x3A
CmdGetTime CommandType = 0x3B
CmdGetIdxBSSID CommandType = 0x3C
CmdGetIdxChannel CommandType = 0x3D
CmdPing CommandType = 0x3E
CmdGetSocket CommandType = 0x3F
// GET_IDX_SSID_CMD = 0x31,
// GET_TEST_CMD = 0x38
// All command with DATA_FLAG 0x40 send a 16bit Len
CmdSendDataTCP CommandType = 0x44
CmdGetDatabufTCP CommandType = 0x45
CmdInsertDataBuf CommandType = 0x46
// regular format commands
CmdSetPinMode CommandType = 0x50
CmdSetDigitalWrite CommandType = 0x51
CmdSetAnalogWrite CommandType = 0x52
)
-120
View File
@@ -1,120 +0,0 @@
//go:build wifidebug
// Code generated by "stringer -type=CommandType -trimprefix=Cmd"; DO NOT EDIT.
package wifinina
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[CmdStart-224]
_ = x[CmdEnd-238]
_ = x[CmdErr-239]
_ = x[CmdSetNet-16]
_ = x[CmdSetPassphrase-17]
_ = x[CmdSetKey-18]
_ = x[CmdSetIPConfig-20]
_ = x[CmdSetDNSConfig-21]
_ = x[CmdSetHostname-22]
_ = x[CmdSetPowerMode-23]
_ = x[CmdSetAPNet-24]
_ = x[CmdSetAPPassphrase-25]
_ = x[CmdSetDebug-26]
_ = x[CmdGetTemperature-27]
_ = x[CmdGetReasonCode-31]
_ = x[CmdGetConnStatus-32]
_ = x[CmdGetIPAddr-33]
_ = x[CmdGetMACAddr-34]
_ = x[CmdGetCurrSSID-35]
_ = x[CmdGetCurrBSSID-36]
_ = x[CmdGetCurrRSSI-37]
_ = x[CmdGetCurrEncrType-38]
_ = x[CmdScanNetworks-39]
_ = x[CmdStartServerTCP-40]
_ = x[CmdGetStateTCP-41]
_ = x[CmdDataSentTCP-42]
_ = x[CmdAvailDataTCP-43]
_ = x[CmdGetDataTCP-44]
_ = x[CmdStartClientTCP-45]
_ = x[CmdStopClientTCP-46]
_ = x[CmdGetClientStateTCP-47]
_ = x[CmdDisconnect-48]
_ = x[CmdGetIdxRSSI-50]
_ = x[CmdGetIdxEncrType-51]
_ = x[CmdReqHostByName-52]
_ = x[CmdGetHostByName-53]
_ = x[CmdStartScanNetworks-54]
_ = x[CmdGetFwVersion-55]
_ = x[CmdSendDataUDP-57]
_ = x[CmdGetRemoteData-58]
_ = x[CmdGetTime-59]
_ = x[CmdGetIdxBSSID-60]
_ = x[CmdGetIdxChannel-61]
_ = x[CmdPing-62]
_ = x[CmdGetSocket-63]
_ = x[CmdSendDataTCP-68]
_ = x[CmdGetDatabufTCP-69]
_ = x[CmdInsertDataBuf-70]
_ = x[CmdSetPinMode-80]
_ = x[CmdSetDigitalWrite-81]
_ = x[CmdSetAnalogWrite-82]
}
const (
_CommandType_name_0 = "SetNetSetPassphraseSetKey"
_CommandType_name_1 = "SetIPConfigSetDNSConfigSetHostnameSetPowerModeSetAPNetSetAPPassphraseSetDebugGetTemperature"
_CommandType_name_2 = "GetReasonCodeGetConnStatusGetIPAddrGetMACAddrGetCurrSSIDGetCurrBSSIDGetCurrRSSIGetCurrEncrTypeScanNetworksStartServerTCPGetStateTCPDataSentTCPAvailDataTCPGetDataTCPStartClientTCPStopClientTCPGetClientStateTCPDisconnect"
_CommandType_name_3 = "GetIdxRSSIGetIdxEncrTypeReqHostByNameGetHostByNameStartScanNetworksGetFwVersion"
_CommandType_name_4 = "SendDataUDPGetRemoteDataGetTimeGetIdxBSSIDGetIdxChannelPingGetSocket"
_CommandType_name_5 = "SendDataTCPGetDatabufTCPInsertDataBuf"
_CommandType_name_6 = "SetPinModeSetDigitalWriteSetAnalogWrite"
_CommandType_name_7 = "Start"
_CommandType_name_8 = "EndErr"
)
var (
_CommandType_index_0 = [...]uint8{0, 6, 19, 25}
_CommandType_index_1 = [...]uint8{0, 11, 23, 34, 46, 54, 69, 77, 91}
_CommandType_index_2 = [...]uint8{0, 13, 26, 35, 45, 56, 68, 79, 94, 106, 120, 131, 142, 154, 164, 178, 191, 208, 218}
_CommandType_index_3 = [...]uint8{0, 10, 24, 37, 50, 67, 79}
_CommandType_index_4 = [...]uint8{0, 11, 24, 31, 42, 55, 59, 68}
_CommandType_index_5 = [...]uint8{0, 11, 24, 37}
_CommandType_index_6 = [...]uint8{0, 10, 25, 39}
_CommandType_index_8 = [...]uint8{0, 3, 6}
)
func (i CommandType) String() string {
switch {
case 16 <= i && i <= 18:
i -= 16
return _CommandType_name_0[_CommandType_index_0[i]:_CommandType_index_0[i+1]]
case 20 <= i && i <= 27:
i -= 20
return _CommandType_name_1[_CommandType_index_1[i]:_CommandType_index_1[i+1]]
case 31 <= i && i <= 48:
i -= 31
return _CommandType_name_2[_CommandType_index_2[i]:_CommandType_index_2[i+1]]
case 50 <= i && i <= 55:
i -= 50
return _CommandType_name_3[_CommandType_index_3[i]:_CommandType_index_3[i+1]]
case 57 <= i && i <= 63:
i -= 57
return _CommandType_name_4[_CommandType_index_4[i]:_CommandType_index_4[i+1]]
case 68 <= i && i <= 70:
i -= 68
return _CommandType_name_5[_CommandType_index_5[i]:_CommandType_index_5[i+1]]
case 80 <= i && i <= 82:
i -= 80
return _CommandType_name_6[_CommandType_index_6[i]:_CommandType_index_6[i+1]]
case i == 224:
return _CommandType_name_7
case 238 <= i && i <= 239:
i -= 238
return _CommandType_name_8[_CommandType_index_8[i]:_CommandType_index_8[i+1]]
default:
return "CommandType(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
-41
View File
@@ -1,41 +0,0 @@
//go:build wifidebug
// Code generated by "stringer -type=ConnectionStatus -trimprefix=Status"; DO NOT EDIT.
package wifinina
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[StatusNoShield-255]
_ = x[StatusIdle-0]
_ = x[StatusNoSSIDAvail-1]
_ = x[StatusScanCompleted-2]
_ = x[StatusConnected-3]
_ = x[StatusConnectFailed-4]
_ = x[StatusConnectionLost-5]
_ = x[StatusDisconnected-6]
}
const (
_ConnectionStatus_name_0 = "IdleNoSSIDAvailScanCompletedConnectedConnectFailedConnectionLostDisconnected"
_ConnectionStatus_name_1 = "NoShield"
)
var (
_ConnectionStatus_index_0 = [...]uint8{0, 4, 15, 28, 37, 50, 64, 76}
)
func (i ConnectionStatus) String() string {
switch {
case i <= 6:
return _ConnectionStatus_name_0[_ConnectionStatus_index_0[i]:_ConnectionStatus_index_0[i+1]]
case i == 255:
return _ConnectionStatus_name_1
default:
return "ConnectionStatus(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
-44
View File
@@ -1,44 +0,0 @@
//go:build wifidebug
// Code generated by "stringer -type=EncryptionType -trimprefix=EncType"; DO NOT EDIT.
package wifinina
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[EncTypeTKIP-2]
_ = x[EncTypeCCMP-4]
_ = x[EncTypeWEP-5]
_ = x[EncTypeNone-7]
_ = x[EncTypeAuto-8]
}
const (
_EncryptionType_name_0 = "TKIP"
_EncryptionType_name_1 = "CCMPWEP"
_EncryptionType_name_2 = "NoneAuto"
)
var (
_EncryptionType_index_1 = [...]uint8{0, 4, 7}
_EncryptionType_index_2 = [...]uint8{0, 4, 8}
)
func (i EncryptionType) String() string {
switch {
case i == 2:
return _EncryptionType_name_0
case 4 <= i && i <= 5:
i -= 4
return _EncryptionType_name_1[_EncryptionType_index_1[i]:_EncryptionType_index_1[i+1]]
case 7 <= i && i <= 8:
i -= 7
return _EncryptionType_name_2[_EncryptionType_index_2[i]:_EncryptionType_index_2[i+1]]
default:
return "EncryptionType(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
-59
View File
@@ -1,59 +0,0 @@
// Code generated by "stringer -type=Error -trimprefix=Err"; DO NOT EDIT.
package wifinina
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[ErrTimeoutChipReady-1]
_ = x[ErrTimeoutChipSelect-2]
_ = x[ErrCheckStartCmd-3]
_ = x[ErrWaitRsp-4]
_ = x[ErrUnexpectedLength-224]
_ = x[ErrNoParamsReturned-225]
_ = x[ErrIncorrectSentinel-226]
_ = x[ErrCmdErrorReceived-239]
_ = x[ErrNotImplemented-240]
_ = x[ErrUnknownHost-241]
_ = x[ErrSocketAlreadySet-242]
_ = x[ErrConnectionTimeout-243]
_ = x[ErrNoData-244]
_ = x[ErrDataNotWritten-245]
_ = x[ErrCheckDataError-246]
_ = x[ErrBufferTooSmall-247]
_ = x[ErrNoSocketAvail-255]
}
const (
_Error_name_0 = "TimeoutChipReadyTimeoutChipSelectCheckStartCmdWaitRsp"
_Error_name_1 = "UnexpectedLengthNoParamsReturnedIncorrectSentinel"
_Error_name_2 = "CmdErrorReceivedNotImplementedUnknownHostSocketAlreadySetConnectionTimeoutNoDataDataNotWrittenCheckDataErrorBufferTooSmall"
_Error_name_3 = "NoSocketAvail"
)
var (
_Error_index_0 = [...]uint8{0, 16, 33, 46, 53}
_Error_index_1 = [...]uint8{0, 16, 32, 49}
_Error_index_2 = [...]uint8{0, 16, 30, 41, 57, 74, 80, 94, 108, 122}
)
func (i Error) String() string {
switch {
case 1 <= i && i <= 4:
i -= 1
return _Error_name_0[_Error_index_0[i]:_Error_index_0[i+1]]
case 224 <= i && i <= 226:
i -= 224
return _Error_name_1[_Error_index_1[i]:_Error_index_1[i+1]]
case 239 <= i && i <= 247:
i -= 239
return _Error_name_2[_Error_index_2[i]:_Error_index_2[i+1]]
case i == 255:
return _Error_name_3
default:
return "Error(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
-5
View File
@@ -1,5 +0,0 @@
//go:build !wifidebug
package wifinina
var _debug = false
-75
View File
@@ -1,75 +0,0 @@
package wifinina
type ConnectionStatus uint8
//go:generate stringer -type=ConnectionStatus -trimprefix=Status
const (
StatusNoShield ConnectionStatus = 255
StatusIdle ConnectionStatus = 0
StatusNoSSIDAvail ConnectionStatus = 1
StatusScanCompleted ConnectionStatus = 2
StatusConnected ConnectionStatus = 3
StatusConnectFailed ConnectionStatus = 4
StatusConnectionLost ConnectionStatus = 5
StatusDisconnected ConnectionStatus = 6
)
// Default state value for Wifi state field
// #define NA_STATE -1
type EncryptionType uint8
//go:generate stringer -type=EncryptionType -trimprefix=EncType
const (
EncTypeTKIP EncryptionType = 2
EncTypeCCMP EncryptionType = 4
EncTypeWEP EncryptionType = 5
EncTypeNone EncryptionType = 7
EncTypeAuto EncryptionType = 8
)
type TCPState uint8
//go:generate stringer -type=TCPState -trimprefix=TCPState
const (
TCPStateClosed TCPState = 0
TCPStateListen TCPState = 1
TCPStateSynSent TCPState = 2
TCPStateSynRcvd TCPState = 3
TCPStateEstablished TCPState = 4
TCPStateFinWait1 TCPState = 5
TCPStateFinWait2 TCPState = 6
TCPStateCloseWait TCPState = 7
TCPStateClosing TCPState = 8
TCPStateLastACK TCPState = 9
TCPStateTimeWait TCPState = 10
)
type Error uint8
func (err Error) Error() string {
return "wifinina error: " + err.String()
}
//go:generate stringer -type=Error -trimprefix=Err
const (
ErrTimeoutChipReady Error = 0x01
ErrTimeoutChipSelect Error = 0x02
ErrCheckStartCmd Error = 0x03
ErrWaitRsp Error = 0x04
ErrUnexpectedLength Error = 0xE0
ErrNoParamsReturned Error = 0xE1
ErrIncorrectSentinel Error = 0xE2
ErrCmdErrorReceived Error = 0xEF
ErrNotImplemented Error = 0xF0
ErrUnknownHost Error = 0xF1
ErrSocketAlreadySet Error = 0xF2
ErrConnectionTimeout Error = 0xF3
ErrNoData Error = 0xF4
ErrDataNotWritten Error = 0xF5
ErrCheckDataError Error = 0xF6
ErrBufferTooSmall Error = 0xF7
ErrNoSocketAvail Error = 0xFF
NoSocketAvail uint8 = 0xFF
)
-35
View File
@@ -1,35 +0,0 @@
//go:build wifidebug
// Code generated by "stringer -type=TCPState -trimprefix=TCPState"; DO NOT EDIT.
package wifinina
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[TCPStateClosed-0]
_ = x[TCPStateListen-1]
_ = x[TCPStateSynSent-2]
_ = x[TCPStateSynRcvd-3]
_ = x[TCPStateEstablished-4]
_ = x[TCPStateFinWait1-5]
_ = x[TCPStateFinWait2-6]
_ = x[TCPStateCloseWait-7]
_ = x[TCPStateClosing-8]
_ = x[TCPStateLastACK-9]
_ = x[TCPStateTimeWait-10]
}
const _TCPState_name = "ClosedListenSynSentSynRcvdEstablishedFinWait1FinWait2CloseWaitClosingLastACKTimeWait"
var _TCPState_index = [...]uint8{0, 6, 12, 19, 26, 37, 45, 53, 62, 69, 76, 84}
func (i TCPState) String() string {
if i >= TCPState(len(_TCPState_index)-1) {
return "TCPState(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _TCPState_name[_TCPState_index[i]:_TCPState_index[i+1]]
}
-7
View File
@@ -498,13 +498,6 @@ func (w *wifinina) NetNotify(cb func(netlink.Event)) {
w.notifyCb = cb
}
func (w *wifinina) SendEth(pkt []byte) error {
return netlink.ErrNotSupported
}
func (w *wifinina) RecvEthFunc(cb func(pkt []byte) error) {
}
func (w *wifinina) GetHostByName(name string) (net.IP, error) {
if debugging(debugNetdev) {