-
Notifications
You must be signed in to change notification settings - Fork 11
/
servP4lang.java
4572 lines (4312 loc) · 161 KB
/
servP4lang.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package net.freertr.serv;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import net.freertr.addr.addrIP;
import net.freertr.addr.addrIPv4;
import net.freertr.addr.addrIPv6;
import net.freertr.addr.addrMac;
import net.freertr.addr.addrPrefix;
import net.freertr.addr.addrType;
import net.freertr.cfg.cfgAceslst;
import net.freertr.cfg.cfgAll;
import net.freertr.cfg.cfgBndl;
import net.freertr.cfg.cfgBrdg;
import net.freertr.cfg.cfgIfc;
import net.freertr.cfg.cfgVrf;
import net.freertr.clnt.clntMplsPwe;
import net.freertr.clnt.clntPckOudp;
import net.freertr.clnt.clntVxlan;
import net.freertr.ifc.ifcBridge;
import net.freertr.ifc.ifcBridgeAdr;
import net.freertr.ifc.ifcBridgeIfc;
import net.freertr.ifc.ifcDn;
import net.freertr.ifc.ifcEthTyp;
import net.freertr.ifc.ifcEther;
import net.freertr.ifc.ifcNull;
import net.freertr.ifc.ifcP2pOEservSess;
import net.freertr.ifc.ifcPolka;
import net.freertr.ifc.ifcUp;
import net.freertr.ip.ipFwd;
import net.freertr.ip.ipFwdBier;
import net.freertr.ip.ipFwdIface;
import net.freertr.ip.ipFwdMcast;
import net.freertr.ip.ipFwdMpNe;
import net.freertr.ip.ipFwdMpmp;
import net.freertr.ip.ipIfc;
import net.freertr.ip.ipMpls;
import net.freertr.pack.packEsp;
import net.freertr.pack.packHolder;
import net.freertr.pipe.pipeLine;
import net.freertr.pipe.pipeSide;
import net.freertr.prt.prtDccp;
import net.freertr.prt.prtGen;
import net.freertr.prt.prtGenConn;
import net.freertr.prt.prtGenServ;
import net.freertr.prt.prtLudp;
import net.freertr.prt.prtSctp;
import net.freertr.prt.prtServS;
import net.freertr.prt.prtTcp;
import net.freertr.prt.prtUdp;
import net.freertr.rtr.rtrBgpEvpnPeer;
import net.freertr.sec.secTransform;
import net.freertr.tab.tabAceslstN;
import net.freertr.tab.tabConnect;
import net.freertr.tab.tabConnectEntry;
import net.freertr.tab.tabGen;
import net.freertr.tab.tabIndex;
import net.freertr.tab.tabIntMatcher;
import net.freertr.tab.tabLabel;
import net.freertr.tab.tabLabelBier;
import net.freertr.tab.tabLabelBierN;
import net.freertr.tab.tabLabelDup;
import net.freertr.tab.tabLabelEntry;
import net.freertr.tab.tabListing;
import net.freertr.tab.tabListingEntry;
import net.freertr.tab.tabNatCfgN;
import net.freertr.tab.tabNatTraN;
import net.freertr.tab.tabNshEntry;
import net.freertr.tab.tabPbrN;
import net.freertr.tab.tabQosN;
import net.freertr.tab.tabRoute;
import net.freertr.tab.tabRouteEntry;
import net.freertr.tab.tabRouteIface;
import net.freertr.user.userFilter;
import net.freertr.user.userHelping;
import net.freertr.util.bits;
import net.freertr.util.cmds;
import net.freertr.util.counter;
import net.freertr.util.debugger;
import net.freertr.util.history;
import net.freertr.util.logger;
import net.freertr.util.notifier;
import net.freertr.util.state;
/**
* p4lang
*
* @author matecsaba
*/
public class servP4lang extends servGeneric implements ifcUp, prtServS {
/**
* create instance
*/
public servP4lang() {
}
/**
* port
*/
public final static int port = 9080;
/**
* exported vrfs
*/
public tabGen<servP4langVrf> expVrf = new tabGen<servP4langVrf>();
/**
* exported interfaces
*/
public tabGen<servP4langIfc> expIfc = new tabGen<servP4langIfc>();
/**
* exported srv6
*/
public cfgIfc expSrv6 = null;
/**
* exported bridges
*/
public tabGen<servP4langBr> expBr = new tabGen<servP4langBr>();
/**
* exported copp
*/
public tabListing<tabAceslstN<addrIP>, addrIP> expCopp4 = null;
/**
* exported copp
*/
public tabListing<tabAceslstN<addrIP>, addrIP> expCopp6 = null;
/**
* exported dynamic interface first
*/
public int expDynBr1st = 0;
/**
* exported dynamic range size
*/
public int expDynBrSiz = 0;
/**
* exported dynamic interfaces
*/
public ifcBridgeIfc[] expDynBrIfc;
/**
* exported dynamic interfaces
*/
public String[] expDynBrTun;
/**
* exported dynamic next
*/
public int expDynBrNxt = 0;
/**
* exported dynamic interface first
*/
public int expDynAcc1st = 0;
/**
* exported dynamic range size
*/
public int expDynAccSiz = 0;
/**
* exported dynamic interfaces
*/
public servP4langIfc[] expDynAccIfc;
/**
* exported dynamic next
*/
public int expDynAccNxt = 0;
/**
* export interval
*/
public int expDelay = 1000;
/**
* last connection
*/
protected servP4langConn conn = null;
/**
* interconnection interface
*/
protected ifcEthTyp interconn = null;
/**
* downlink interfaces
*/
protected tabGen<servP4langDlnk> downLinks = new tabGen<servP4langDlnk>();
/**
* counter
*/
protected counter cntr = new counter();
/**
* counter
*/
protected notifier notif = new notifier();
private ifcDn intercon;
/**
* defaults text
*/
public final static String[] defaultL = {
"server p4lang .*! port " + port,
"server p4lang .*! protocol " + proto2string(protoAllStrm),
"server p4lang .*! no export-srv6",
"server p4lang .*! no export-copp4",
"server p4lang .*! no export-copp6",
"server p4lang .*! no export-dynbr",
"server p4lang .*! no export-dynacc",
"server p4lang .*! no interconnect",
"server p4lang .*! export-interval 1000",};
/**
* defaults filter
*/
public static tabGen<userFilter> defaultF;
public tabGen<userFilter> srvDefFlt() {
return defaultF;
}
public void srvShRun(String beg, List<String> l, int filter) {
for (int i = 0; i < expVrf.size(); i++) {
servP4langVrf ntry = expVrf.get(i);
l.add(beg + "export-vrf " + ntry.vrf.name + " " + ntry.id);
}
for (int i = 0; i < expBr.size(); i++) {
servP4langBr ntry = expBr.get(i);
l.add(beg + "export-bridge " + ntry.br.num);
}
for (int i = 0; i < expIfc.size(); i++) {
servP4langIfc ntry = expIfc.get(i);
l.add(beg + "export-port " + ntry.ifc.name + " " + ntry.id + " " + ntry.speed + " " + ntry.errCorr + " " + ntry.autoNeg + " " + ntry.flowCtrl);
}
if (expSrv6 == null) {
l.add(beg + "no export-srv6");
} else {
l.add(beg + "export-srv6 " + expSrv6.name);
}
if (expCopp4 == null) {
l.add(beg + "no export-copp4");
} else {
l.add(beg + "export-copp4 " + expCopp4.listName);
}
if (expCopp6 == null) {
l.add(beg + "no export-copp6");
} else {
l.add(beg + "export-copp6 " + expCopp6.listName);
}
cmds.cfgLine(l, expDynBrSiz < 1, beg, "export-dynbr", expDynBr1st + " " + expDynBrSiz);
cmds.cfgLine(l, expDynAccSiz < 1, beg, "export-dynacc", expDynAcc1st + " " + expDynAccSiz);
l.add(beg + "export-interval " + expDelay);
cmds.cfgLine(l, interconn == null, beg, "interconnect", "" + interconn);
for (int i = 0; i < downLinks.size(); i++) {
servP4langDlnk ntry = downLinks.get(i);
l.add(beg + "downlink " + ntry.id + " " + ntry.ifc);
}
}
public boolean srvCfgStr(cmds cmd) {
String s = cmd.word();
if (s.equals("export-vrf")) {
cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false);
if (vrf == null) {
cmd.error("no such vrf");
return false;
}
servP4langVrf ntry = new servP4langVrf(bits.str2num(cmd.word()));
ntry.doClear();
ntry.vrf = vrf;
expVrf.put(ntry);
vrf.fwd4.tableChanged = notif;
vrf.fwd6.tableChanged = notif;
return false;
}
if (s.equals("export-bridge")) {
cfgBrdg br = cfgAll.brdgFind(cmd.word(), false);
if (br == null) {
cmd.error("no such bridge");
return false;
}
servP4langBr ntry = new servP4langBr(br.num);
ntry.doClear();
ntry.br = br;
expBr.put(ntry);
return false;
}
if (s.equals("downlink")) {
servP4langDlnk ntry = new servP4langDlnk(this, bits.str2num(cmd.word()));
cfgIfc ifc = cfgAll.ifcFind(cmd.word(), false);
if (ifc == null) {
cmd.error("no such interface");
return false;
}
ntry.ifc = ifc.ethtyp;
ntry.ifc.addET(-1, "p4lang", ntry);
ntry.ifc.updateET(-1, ntry);
downLinks.add(ntry);
return false;
}
if (s.equals("interconnect")) {
cfgIfc ifc = cfgAll.ifcFind(cmd.word(), false);
if (ifc == null) {
cmd.error("no such interface");
return false;
}
interconn = ifc.ethtyp;
interconn.addET(-1, "p4lang", this);
interconn.updateET(-1, this);
return false;
}
if (s.equals("export-copp4")) {
cfgAceslst acl = cfgAll.aclsFind(cmd.word(), false);
if (acl == null) {
cmd.error("no such access list");
return false;
}
expCopp4 = acl.aceslst;
return false;
}
if (s.equals("export-copp6")) {
cfgAceslst acl = cfgAll.aclsFind(cmd.word(), false);
if (acl == null) {
cmd.error("no such access list");
return false;
}
expCopp6 = acl.aceslst;
return false;
}
if (s.equals("export-dynacc")) {
expDynAcc1st = bits.str2num(cmd.word());
expDynAccSiz = bits.str2num(cmd.word());
expDynAccNxt = 0;
expDynAccIfc = new servP4langIfc[expDynAccSiz];
return false;
}
if (s.equals("export-dynbr")) {
expDynBr1st = bits.str2num(cmd.word());
expDynBrSiz = bits.str2num(cmd.word());
expDynBrNxt = 0;
expDynBrIfc = new ifcBridgeIfc[expDynBrSiz];
expDynBrTun = new String[expDynBrSiz];
return false;
}
if (s.equals("export-interval")) {
expDelay = bits.str2num(cmd.word());
return false;
}
if (s.equals("export-srv6")) {
expSrv6 = cfgAll.ifcFind(cmd.word(), false);
if (expSrv6 == null) {
cmd.error("no such interface");
return false;
}
return false;
}
if (s.equals("export-port")) {
cfgIfc ifc = cfgAll.ifcFind(cmd.word(), false);
if (ifc == null) {
cmd.error("no such interface");
return false;
}
if ((ifc.type != cfgIfc.ifaceType.sdn) && (ifc.type != cfgIfc.ifaceType.bundle) && (ifc.type != cfgIfc.ifaceType.bridge) && (ifc.type != cfgIfc.ifaceType.dialer) && (ifc.type != cfgIfc.ifaceType.hairpin) && (ifc.type != cfgIfc.ifaceType.tunnel) && (ifc.type != cfgIfc.ifaceType.virtppp) && (ifc.type != cfgIfc.ifaceType.template)) {
cmd.error("not p4lang interface");
return false;
}
servP4langIfc ntry = new servP4langIfc(bits.str2num(cmd.word()));
ntry.lower = this;
ntry.ifc = ifc;
ntry.doClear();
servP4langIfc old = expIfc.find(ntry);
servP4langIfc orig = old;
if (old != null) {
if (ntry.ifc != old.ifc) {
cmd.error("port number already exported as " + old.ifc.name);
return false;
}
ntry = old;
}
for (int i = 0; i < expIfc.size(); i++) {
old = expIfc.get(i);
if ((ifc == old.ifc) && (old.id != ntry.id)) {
cmd.error("interface already exported as port " + old.id);
return false;
}
}
ntry.speed = bits.str2num(cmd.word());
ntry.errCorr = bits.str2num(cmd.word());
ntry.autoNeg = bits.str2num(cmd.word());
ntry.flowCtrl = bits.str2num(cmd.word());
boolean need = ifc.type == cfgIfc.ifaceType.sdn;
if (ifc.vlanNum != 0) {
need = false;
for (int i = 0; i < expIfc.size(); i++) {
old = expIfc.get(i);
if (old.master != null) {
continue;
}
if (old.ifc == ifc.parent) {
ntry.master = old;
break;
}
}
if (ntry.master == null) {
cmd.error("carrier not exported");
return false;
}
}
if (need) {
ntry.setUpper(ifc.ethtyp);
}
if (orig == null) {
ifc.ethtyp.hwHstry = new history();
ifc.ethtyp.hwCntr = new counter();
expIfc.put(ntry);
return false;
}
sendLine("state " + old.id + " 0 " + orig.getStateEnding());
sendLine("state " + ntry.id + " 1 " + ntry.getStateEnding());
return false;
}
if (!s.equals("no")) {
return true;
}
s = cmd.word();
if (s.equals("export-vrf")) {
cmd.word();
servP4langVrf ntry = new servP4langVrf(bits.str2num(cmd.word()));
ntry = expVrf.del(ntry);
if (ntry == null) {
cmd.error("no such export");
return false;
}
ntry.vrf.fwd4.tableChanged = null;
ntry.vrf.fwd6.tableChanged = null;
return false;
}
if (s.equals("export-copp4")) {
expCopp4 = null;
return false;
}
if (s.equals("export-copp6")) {
expCopp6 = null;
return false;
}
if (s.equals("export-bridge")) {
servP4langBr ntry = new servP4langBr(bits.str2num(cmd.word()));
ntry = expBr.del(ntry);
if (ntry == null) {
cmd.error("no such export");
return false;
}
return false;
}
if (s.equals("downlink")) {
servP4langDlnk ntry = new servP4langDlnk(this, bits.str2num(cmd.word()));
ntry = downLinks.del(ntry);
if (ntry == null) {
cmd.error("no such downlink");
return false;
}
return false;
}
if (s.equals("interconnect")) {
if (interconn == null) {
return false;
}
interconn.delET(-1);
interconn = null;
return false;
}
if (s.equals("export-dynacc")) {
expDynAcc1st = 0;
expDynAccSiz = 0;
expDynAccNxt = 0;
expDynAccIfc = null;
return false;
}
if (s.equals("export-dynbr")) {
expDynBr1st = 0;
expDynBrSiz = 0;
expDynBrNxt = 0;
expDynBrIfc = null;
expDynBrTun = null;
return false;
}
if (s.equals("export-srv6")) {
expSrv6 = null;
return false;
}
if (s.equals("export-port")) {
cmd.word();
servP4langIfc ntry = new servP4langIfc(bits.str2num(cmd.word()));
ntry = expIfc.del(ntry);
if (ntry == null) {
cmd.error("no such export");
return false;
}
sendLine("state " + ntry.id + " 0 " + ntry.getStateEnding());
if ((ntry.ifc.type == cfgIfc.ifaceType.sdn) && (ntry.ifc.vlanNum == 0)) {
ifcNull nul = new ifcNull();
nul.setUpper(ntry.ifc.ethtyp);
}
return false;
}
return true;
}
public void srvHelp(userHelping l) {
l.add(null, "1 2 export-vrf specify vrf to export");
l.add(null, "2 3 <name:vrf> vrf name");
l.add(null, "3 . <num> p4lang vrf number");
l.add(null, "1 2 export-dynbr specify dynamic bridge port range");
l.add(null, "2 3 <num> first id");
l.add(null, "3 . <num> number of ids");
l.add(null, "1 2 export-dynacc specify dynamic access port range");
l.add(null, "2 3 <num> first id");
l.add(null, "3 . <num> number of ids");
l.add(null, "1 2 export-bridge specify bridge to export");
l.add(null, "2 . <num> bridge number");
l.add(null, "1 2 export-port specify port to export");
l.add(null, "2 3 <name:ifc> interface name");
l.add(null, "3 4,. <num> port number");
l.add(null, "4 5,. <num> speed in gbps");
l.add(null, "5 6,. <num> fec, see hw vendor manual");
l.add(null, "6 7,. <num> autoneg, see hw vendor manual");
l.add(null, "7 . <num> flowctrl, see hw vendor manual");
l.add(null, "1 2 export-srv6 specify srv6 to export");
l.add(null, "2 . <name:ifc> interface name");
l.add(null, "1 2 export-copp4 specify copp acl to export");
l.add(null, "2 . <name:acl> acl name");
l.add(null, "1 2 export-copp6 specify copp acl to export");
l.add(null, "2 . <name:acl> acl name");
l.add(null, "1 2 export-interval specify export interval");
l.add(null, "2 . <num> time in ms");
l.add(null, "1 2 downlink specify downlink for packetin");
l.add(null, "2 3 <num> port number");
l.add(null, "3 . <name:ifc> interface name");
l.add(null, "1 2 interconnect specify port to for packetin");
l.add(null, "2 . <name:ifc> interface name");
}
public String srvName() {
return "p4lang";
}
public int srvPort() {
return port;
}
public int srvProto() {
return protoAllStrm;
}
public boolean srvInit() {
return genStrmStart(this, new pipeLine(32768, false), 0);
}
public boolean srvDeinit() {
return genericStop(0);
}
public boolean srvAccept(pipeSide pipe, prtGenConn id) {
if (conn != null) {
conn.pipe.setClose();
notif.wakeup();
}
id.timeout = 120000;
pipe.lineRx = pipeSide.modTyp.modeCRorLF;
pipe.lineTx = pipeSide.modTyp.modeLF;
for (int i = 0; i < expIfc.size(); i++) {
expIfc.get(i).doClear();
}
for (int i = 0; i < expVrf.size(); i++) {
expVrf.get(i).doClear();
}
for (int i = 0; i < expBr.size(); i++) {
expBr.get(i).doClear();
}
if (expDynBrIfc != null) {
for (int i = 0; i < expDynBrIfc.length; i++) {
expDynBrIfc[i] = null;
expDynBrTun[i] = null;
}
}
expDynBrNxt = 0;
if (expDynAccIfc != null) {
for (int i = 0; i < expDynAccIfc.length; i++) {
expDynAccIfc[i] = null;
}
}
expDynAccNxt = 0;
conn = new servP4langConn(pipe, this);
logger.warn("neighbor " + id.peerAddr + " up");
return false;
}
/**
* send line
*
* @param a line
*/
protected synchronized void sendLine(String a) {
if (conn == null) {
return;
}
if (debugger.servP4langTx) {
logger.debug("tx: " + a);
}
conn.pipe.linePut(a + " ");
}
/**
* send packet
*
* @param id id
* @param pckB binary
*/
protected void sendPack(int id, packHolder pckB) {
cntr.tx(pckB);
ifcEther.createETHheader(pckB, false);
if (intercon == null) {
return;
}
pckB.msbPutW(0, id);
pckB.putSkip(2);
pckB.merge2beg();
ifcEther.parseETHheader(pckB, false);
intercon.sendPack(pckB);
}
/**
* received packet
*
* @param pck packet
*/
public void recvPack(packHolder pck) {
cntr.rx(pck);
ifcEther.createETHheader(pck, false);
int id = pck.msbGetW(0);
pck.getSkip(2);
ifcEther.parseETHheader(pck, false);
if ((expDynAccIfc != null) && (id >= expDynAcc1st) && (id < (expDynAcc1st + expDynAccSiz))) {
servP4langIfc ifc = expDynAccIfc[id - expDynAcc1st];
if (ifc == null) {
if (debugger.servP4langErr) {
logger.debug("got unneeded target: " + id);
}
cntr.drop(pck, counter.reasons.noIface);
return;
}
ifc.ifc.ethtyp.gotFromDataplane(pck);
return;
}
if ((expDynBrIfc != null) && (id >= expDynBr1st) && (id < (expDynBr1st + expDynBrSiz))) {
if (pck.msbGetW(0) == ifcBridge.serialType) {
pck.getSkip(2);
} else {
pck.getSkip(-addrMac.sizeX2);
}
ifcBridgeIfc ifc = expDynBrIfc[id - expDynBr1st];
if (ifc == null) {
if (debugger.servP4langErr) {
logger.debug("got unneeded target: " + id);
}
cntr.drop(pck, counter.reasons.noIface);
return;
}
ifc.recvPack(pck);
return;
}
servP4langDlnk dlnk = new servP4langDlnk(this, id);
dlnk = downLinks.find(dlnk);
if (dlnk != null) {
ifcEther.createETHheader(pck, false);
pck.getSkip(-2);
ifcEther.parseETHheader(pck, false);
dlnk.parent.sendPack(pck);
return;
}
servP4langIfc ntry = new servP4langIfc(id);
ntry = expIfc.find(ntry);
if (ntry == null) {
if (debugger.servP4langErr) {
logger.debug("got unneeded target: " + id);
}
cntr.drop(pck, counter.reasons.noIface);
return;
}
ntry.ifc.ethtyp.gotFromDataplane(pck);
}
/**
* set parent
*
* @param parent parent
*/
public void setParent(ifcDn parent) {
intercon = parent;
}
/**
* set state
*
* @param stat state
*/
public void setState(state.states stat) {
}
/**
* close interface
*/
public void closeUp() {
}
/**
* get counter
*
* @return counter
*/
public counter getCounter() {
return cntr;
}
}
class servP4langStr<T extends Comparator<T>> implements Comparator<servP4langStr<T>> {
public final T data;
public int store;
public servP4langStr(T dat) {
data = dat;
}
public int compare(servP4langStr<T> o1, servP4langStr<T> o2) {
return o1.data.compare(o1.data, o2.data);
}
public boolean differs(tabGen<servP4langStr<T>> l) {
servP4langStr<T> o = l.find(this);
if (o == null) {
return true;
}
return store != o.store;
}
}
class servP4langDlnk implements Comparator<servP4langDlnk>, ifcUp {
public final int id;
public final servP4lang lower;
public counter cntr = new counter();
public ifcDn parent;
public ifcEthTyp ifc;
public servP4langDlnk(servP4lang prnt, int num) {
id = num;
lower = prnt;
}
public int compare(servP4langDlnk o1, servP4langDlnk o2) {
if (o1.id < o2.id) {
return -1;
}
if (o1.id > o2.id) {
return +1;
}
return 0;
}
public void recvPack(packHolder pck) {
cntr.rx(pck);
ifcEther.createETHheader(pck, false);
int id = pck.msbGetW(0);
pck.getSkip(2);
ifcEther.parseETHheader(pck, false);
lower.sendPack(id, pck);
}
public void setParent(ifcDn prnt) {
parent = prnt;
}
public void setState(state.states stat) {
}
public void closeUp() {
}
public counter getCounter() {
return cntr;
}
}
class servP4langNei implements Comparator<servP4langNei> {
public final addrIP adr;
public addrMac mac = null;
public final servP4langIfc iface;
public servP4langVrf vrf;
public String sentIpsec = "";
public servP4langNei viaH;
public servP4langIfc viaI;
public int sentIgNhop = -1;
public int sentIfc;
public int sentTun;
public int id;
public int need;
public servP4langNei(servP4langIfc ifc, addrIP per) {
adr = per;
iface = ifc;
}
public int compare(servP4langNei o1, servP4langNei o2) {
int i = o1.iface.compare(o1.iface, o2.iface);
if (i != 0) {
return i;
}
if (o1.iface.cloned != null) {
return 0;
}
if ((o1.iface.ifc.type == cfgIfc.ifaceType.dialer) || (o1.iface.ifc.type == cfgIfc.ifaceType.tunnel) || (o1.iface.ifc.type == cfgIfc.ifaceType.virtppp) || (o1.iface.ifc.type == cfgIfc.ifaceType.template)) {
return 0;
}
return o1.adr.compare(o1.adr, o2.adr);
}
public servP4langIfc getVia() {
servP4langNei via = this;
for (int i = 0; i < 8; i++) {
if (via.viaH == null) {
break;
}
via = via.viaH;
}
if (via.viaI == null) {
return via.iface;
} else {
return via.viaI;
}
}
}
class servP4langBr implements Comparator<servP4langBr> {
public final int id;
public cfgBrdg br;
public boolean routed;
public tabGen<ifcBridgeAdr> macs = new tabGen<ifcBridgeAdr>();
public tabGen<ifcBridgeIfc> ifcs = new tabGen<ifcBridgeIfc>();
public servP4langBr(int i) {
id = i;
}
public int compare(servP4langBr o1, servP4langBr o2) {
if (o1.id < o2.id) {
return -1;
}
if (o1.id > o2.id) {
return +1;
}
return 0;
}
public boolean findIfc(int lab) {
for (int i = 0; i < ifcs.size(); i++) {
try {
rtrBgpEvpnPeer ifc = (rtrBgpEvpnPeer) ifcs.get(i).lowerIf;
if (ifc.getLabelLoc() == lab) {
return true;
}
} catch (Exception e) {
}
}
return false;
}
public void doClear() {
ifcs = new tabGen<ifcBridgeIfc>();
macs = new tabGen<ifcBridgeAdr>();
}
}
class servP4langVrf implements Comparator<servP4langVrf> {
public final int id;
public cfgVrf vrf;
public boolean sentMcast;
public tabGen<servP4langStr<tabRouteEntry<addrIP>>> routed4 = new tabGen<servP4langStr<tabRouteEntry<addrIP>>>();
public tabGen<servP4langStr<tabRouteEntry<addrIP>>> routed6 = new tabGen<servP4langStr<tabRouteEntry<addrIP>>>();
public tabRoute<addrIP> routes4 = new tabRoute<addrIP>("sent");
public tabRoute<addrIP> routes6 = new tabRoute<addrIP>("sent");
public tabConnect<addrIP, prtGenServ> udp4 = new tabConnect<addrIP, prtGenServ>(new addrIP(), "sent");
public tabConnect<addrIP, prtGenServ> udp6 = new tabConnect<addrIP, prtGenServ>(new addrIP(), "sent");
public tabConnect<addrIP, prtGenServ> tcp4 = new tabConnect<addrIP, prtGenServ>(new addrIP(), "sent");
public tabConnect<addrIP, prtGenServ> tcp6 = new tabConnect<addrIP, prtGenServ>(new addrIP(), "sent");
public tabGen<ipFwdMcast> mroutes4 = new tabGen<ipFwdMcast>();
public tabGen<ipFwdMcast> mroutes6 = new tabGen<ipFwdMcast>();
public tabListing<tabAceslstN<addrIP>, addrIP> natCfg4;
public tabListing<tabAceslstN<addrIP>, addrIP> natCfg6;
public tabListing<tabAceslstN<addrIP>, addrIP> natCfg4f;
public tabListing<tabAceslstN<addrIP>, addrIP> natCfg6f;
public tabListing<tabPbrN, addrIP> pbrCfg4;
public tabListing<tabPbrN, addrIP> pbrCfg6;
public tabListing<tabAceslstN<addrIP>, addrIP> flwSpc4;
public tabListing<tabAceslstN<addrIP>, addrIP> flwSpc6;
public tabGen<tabNatTraN> natTrns4 = new tabGen<tabNatTraN>();
public tabGen<tabNatTraN> natTrns6 = new tabGen<tabNatTraN>();
public tabGen<servP4langStr<tabIndex<addrIP>>> indexed4 = new tabGen<servP4langStr<tabIndex<addrIP>>>();
public tabGen<servP4langStr<tabIndex<addrIP>>> indexed6 = new tabGen<servP4langStr<tabIndex<addrIP>>>();
public tabGen<tabIndex<addrIP>> indexes4 = new tabGen<tabIndex<addrIP>>();
public tabGen<tabIndex<addrIP>> indexes6 = new tabGen<tabIndex<addrIP>>();
public servP4langVrf(int i) {
id = i;
}
public int compare(servP4langVrf o1, servP4langVrf o2) {
if (o1.id < o2.id) {
return -1;
}
if (o1.id > o2.id) {
return +1;
}
return 0;
}
public void doClear() {
routed4 = new tabGen<servP4langStr<tabRouteEntry<addrIP>>>();
routed6 = new tabGen<servP4langStr<tabRouteEntry<addrIP>>>();
routes4 = new tabRoute<addrIP>("sent");
routes6 = new tabRoute<addrIP>("sent");
mroutes4 = new tabGen<ipFwdMcast>();
mroutes6 = new tabGen<ipFwdMcast>();
sentMcast = false;
natCfg4 = null;