From a1ef2def2bcf18c2c805f9931f3a65272cf0a122 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 20 Jan 2015 21:41:08 +0000 Subject: [PATCH] refactor: extract pdu statics into separate file --- router/consts.go | 23 ++--------------------- router/protocol.go | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 router/protocol.go diff --git a/router/consts.go b/router/consts.go index 84baddd0..b15e24a4 100644 --- a/router/consts.go +++ b/router/consts.go @@ -6,8 +6,6 @@ import ( ) const ( - Protocol = "weave" - ProtocolVersion = 10 EthernetOverhead = 14 UDPOverhead = 28 // 20 bytes for IPv4, 8 bytes for UDP Port = 6783 @@ -28,24 +26,7 @@ const ( MaxDuration = time.Duration(math.MaxInt64) ) -const ( - ProtocolConnectionEstablished = iota - ProtocolFragmentationReceived - ProtocolStartFragmentationTest - ProtocolNonce - ProtocolFetchAll - ProtocolUpdate - ProtocolPMTUVerified -) - var ( - FragTest = make([]byte, FragTestSize) - PMTUDiscovery = make([]byte, PMTUDiscoverySize) - ProtocolConnectionEstablishedByte = []byte{ProtocolConnectionEstablished} - ProtocolFragmentationReceivedByte = []byte{ProtocolFragmentationReceived} - ProtocolStartFragmentationTestByte = []byte{ProtocolStartFragmentationTest} - ProtocolNonceByte = []byte{ProtocolNonce} - ProtocolFetchAllByte = []byte{ProtocolFetchAll} - ProtocolUpdateByte = []byte{ProtocolUpdate} - ProtocolPMTUVerifiedByte = []byte{ProtocolPMTUVerified} + FragTest = make([]byte, FragTestSize) + PMTUDiscovery = make([]byte, PMTUDiscoverySize) ) diff --git a/router/protocol.go b/router/protocol.go new file mode 100644 index 00000000..05c36a45 --- /dev/null +++ b/router/protocol.go @@ -0,0 +1,26 @@ +package router + +const ( + Protocol = "weave" + ProtocolVersion = 10 +) + +const ( + ProtocolConnectionEstablished = iota + ProtocolFragmentationReceived + ProtocolStartFragmentationTest + ProtocolNonce + ProtocolFetchAll + ProtocolUpdate + ProtocolPMTUVerified +) + +var ( + ProtocolConnectionEstablishedByte = []byte{ProtocolConnectionEstablished} + ProtocolFragmentationReceivedByte = []byte{ProtocolFragmentationReceived} + ProtocolStartFragmentationTestByte = []byte{ProtocolStartFragmentationTest} + ProtocolNonceByte = []byte{ProtocolNonce} + ProtocolFetchAllByte = []byte{ProtocolFetchAll} + ProtocolUpdateByte = []byte{ProtocolUpdate} + ProtocolPMTUVerifiedByte = []byte{ProtocolPMTUVerified} +)