mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-09 19:29:29 +08:00

* Switch CoAP lib Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Revert removed adapter code Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * WIP CoAP refactor Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Add auth key Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix observers map Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix reading message body Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix subtopic parsing Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix error handling Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix multi-protocol communication Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Separate client from observer Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Remove unused config Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Remove TCP option Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Inline error check Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Add logging client errors Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Replace RWMutex since we're not using RLock Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Inline error handling Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Inline error handling Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package dtls
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// Parse received handshakes and return next flightVal
|
|
type flightParser func(context.Context, flightConn, *State, *handshakeCache, *handshakeConfig) (flightVal, *alert, error)
|
|
|
|
// Generate flights
|
|
type flightGenerator func(flightConn, *State, *handshakeCache, *handshakeConfig) ([]*packet, *alert, error)
|
|
|
|
func (f flightVal) getFlightParser() (flightParser, error) {
|
|
switch f {
|
|
case flight0:
|
|
return flight0Parse, nil
|
|
case flight1:
|
|
return flight1Parse, nil
|
|
case flight2:
|
|
return flight2Parse, nil
|
|
case flight3:
|
|
return flight3Parse, nil
|
|
case flight4:
|
|
return flight4Parse, nil
|
|
case flight5:
|
|
return flight5Parse, nil
|
|
case flight6:
|
|
return flight6Parse, nil
|
|
default:
|
|
return nil, errInvalidFlight
|
|
}
|
|
}
|
|
|
|
func (f flightVal) getFlightGenerator() (flightGenerator, error) {
|
|
switch f {
|
|
case flight0:
|
|
return flight0Generate, nil
|
|
case flight1:
|
|
return flight1Generate, nil
|
|
case flight2:
|
|
return flight2Generate, nil
|
|
case flight3:
|
|
return flight3Generate, nil
|
|
case flight4:
|
|
return flight4Generate, nil
|
|
case flight5:
|
|
return flight5Generate, nil
|
|
case flight6:
|
|
return flight6Generate, nil
|
|
default:
|
|
return nil, errInvalidFlight
|
|
}
|
|
}
|