@@ -128,3 +128,65 @@ func TestExpandedSFlowDecode(t *testing.T) {
128128 var packet Packet
129129 assert .NoError (t , DecodeMessageVersion (buf , & packet ))
130130}
131+
132+ func TestSFlowDecodeDropEgressQueue (t * testing.T ) {
133+ data := []byte {
134+ 0x00 , 0x00 , 0x00 , 0x05 , 0x00 , 0x00 , 0x00 , 0x01 , 0xc0 , 0xa8 , 0x77 , 0xb8 , 0x00 , 0x01 , 0x86 , 0xa0 ,
135+ 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x30 , 0x7e , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x05 ,
136+ 0x00 , 0x00 , 0x00 , 0x2C , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 ,
137+ 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
138+ 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x04 , 0x0c , 0x00 , 0x00 , 0x00 , 0x04 , 0x00 , 0x00 , 0x00 , 0x2a ,
139+ }
140+
141+ buf := bytes .NewBuffer (data )
142+ var packet Packet
143+ assert .NoError (t , DecodeMessageVersion (buf , & packet ))
144+ assert .Len (t , packet .Samples , 1 )
145+ assert .NotNil (t , packet .Samples [0 ])
146+ sample , ok := packet .Samples [0 ].(DropSample )
147+ assert .True (t , ok )
148+ assert .Len (t , sample .Records , 1 )
149+ assert .Equal (t , EgressQueue {Queue : 42 }, sample .Records [0 ].Data )
150+ }
151+
152+ func TestSFlowDecodeDropExtendedACL (t * testing.T ) {
153+ data := []byte {
154+ 0x00 , 0x00 , 0x00 , 0x05 , 0x00 , 0x00 , 0x00 , 0x01 , 0xc0 , 0xa8 , 0x77 , 0xb8 , 0x00 , 0x01 , 0x86 , 0xa0 ,
155+ 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x30 , 0x7e , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x05 ,
156+ 0x00 , 0x00 , 0x00 , 0x38 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 ,
157+ 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
158+ 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x04 , 0x0d , 0x00 , 0x00 , 0x00 , 0x10 , 0x00 , 0x00 , 0x00 , 0x2a ,
159+ 0x00 , 0x00 , 0x00 , 0x04 , 0x66 , 0x6f , 0x6f , 0x21 , 0x00 , 0x00 , 0x00 , 0x02 ,
160+ }
161+
162+ buf := bytes .NewBuffer (data )
163+ var packet Packet
164+ assert .NoError (t , DecodeMessageVersion (buf , & packet ))
165+ assert .Len (t , packet .Samples , 1 )
166+ assert .NotNil (t , packet .Samples [0 ])
167+ sample , ok := packet .Samples [0 ].(DropSample )
168+ assert .True (t , ok )
169+ assert .Len (t , sample .Records , 1 )
170+ assert .Equal (t , ExtendedACL {Number : 42 , Name : "foo!" , Direction : 2 }, sample .Records [0 ].Data )
171+ }
172+
173+ func TestSFlowDecodeDropExtendedFunction (t * testing.T ) {
174+ data := []byte {
175+ 0x00 , 0x00 , 0x00 , 0x05 , 0x00 , 0x00 , 0x00 , 0x01 , 0xc0 , 0xa8 , 0x77 , 0xb8 , 0x00 , 0x01 , 0x86 , 0xa0 ,
176+ 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x30 , 0x7e , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x05 ,
177+ 0x00 , 0x00 , 0x00 , 0x32 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 ,
178+ 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x01 ,
179+ 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x04 , 0x0e , 0x00 , 0x00 , 0x00 , 0x0a , 0x00 , 0x00 , 0x00 , 0x06 ,
180+ 0x66 , 0x6f , 0x6f , 0x62 , 0x61 , 0x72 ,
181+ }
182+
183+ buf := bytes .NewBuffer (data )
184+ var packet Packet
185+ assert .NoError (t , DecodeMessageVersion (buf , & packet ))
186+ assert .Len (t , packet .Samples , 1 )
187+ assert .NotNil (t , packet .Samples [0 ])
188+ sample , ok := packet .Samples [0 ].(DropSample )
189+ assert .True (t , ok )
190+ assert .Len (t , sample .Records , 1 )
191+ assert .Equal (t , ExtendedFunction {Symbol : "foobar" }, sample .Records [0 ].Data )
192+ }
0 commit comments