12
12
import com .exalttech .trex .core .ConnectionManager ;
13
13
import com .exalttech .trex .core .RPCMethods ;
14
14
import com .exalttech .trex .ui .models .ConfigurationMode ;
15
+ import com .exalttech .trex .ui .models .PortLayerConfigurationModel ;
15
16
import com .exalttech .trex .ui .models .PortModel ;
16
17
import com .exalttech .trex .ui .views .logs .LogType ;
17
18
import com .exalttech .trex .ui .views .logs .LogsController ;
@@ -249,7 +250,7 @@ private void handleStartIPv6Scan(ActionEvent actionEvent) {
249
250
@ Override
250
251
public Optional <Map <String , Ipv6Node >> call () {
251
252
try {
252
- return Optional .of (iPv6NDService .scan (model .getIndex (), 10 , null ));
253
+ return Optional .of (iPv6NDService .scan (model .getIndex (), 10 , null , null ));
253
254
} catch (ServiceModeRequiredException e ) {
254
255
AsyncResponseManager .getInstance ().unmuteLogger ();
255
256
AsyncResponseManager .getInstance ().suppressIncomingEvents (false );
@@ -357,7 +358,7 @@ public Optional<String> call() {
357
358
try {
358
359
serverRPCMethods .setSetL2 (model .getIndex (), dstMac );
359
360
guiLogger .appendText (LogType .INFO , "L2 mode configured for " + model .getIndex ());
360
-
361
+ clearModelIPv6 ();
361
362
} catch (Exception e1 ) {
362
363
logger .error ("Failed to set L2 mode: " + e1 .getMessage ());
363
364
}
@@ -367,9 +368,14 @@ public Optional<String> call() {
367
368
String portSrcIP = l3Source .getText ();
368
369
String portDstIP = l3Destination .getText ();
369
370
final boolean dstIsIPv6 = InetAddresses .forString (portDstIP ).getAddress ().length > 4 ;
371
+ final boolean srcIsIPv6 = InetAddresses .forString (portSrcIP ).getAddress ().length > 4 ;
372
+
373
+ if (srcIsIPv6 != dstIsIPv6 ) {
374
+ throw new Exception ("src and dst addresses are different version" );
375
+ }
370
376
371
377
if (dstIsIPv6 ) {
372
- Map <String , Ipv6Node > result = getIPv6NDService ().scan (model .getIndex (), 5 , portDstIP );
378
+ Map <String , Ipv6Node > result = getIPv6NDService ().scan (model .getIndex (), 5 , portDstIP , portSrcIP );
373
379
AsyncResponseManager .getInstance ().unmuteLogger ();
374
380
375
381
String statusString ;
@@ -386,6 +392,9 @@ public Optional<String> call() {
386
392
serverRPCMethods .setSetL2 (model .getIndex (), mac );
387
393
guiLogger .appendText (LogType .INFO , "L2 mode configured for " + model .getIndex ());
388
394
395
+ final PortLayerConfigurationModel l3Conf = model .getL3LayerConfiguration ();
396
+ l3Conf .setSrc6 (portSrcIP );
397
+ l3Conf .setDst6 (portDstIP );
389
398
} catch (Exception e1 ) {
390
399
logger .error ("Failed to set L2 mode: " + e1 .getMessage ());
391
400
}
@@ -401,6 +410,7 @@ public Optional<String> call() {
401
410
} else {
402
411
trexClient .setL3Mode (model .getIndex (), null , portSrcIP , portDstIP );
403
412
413
+ clearModelIPv6 ();
404
414
String nextHopMac = trexClient .resolveArp (model .getIndex (), portSrcIP , portDstIP );
405
415
if (nextHopMac != null ) {
406
416
trexClient .setL3Mode (model .getIndex (), nextHopMac , portSrcIP , portDstIP );
@@ -419,7 +429,8 @@ public Optional<String> call() {
419
429
LogsController .getInstance ().appendText (LogType .ERROR , "Service mode is not enabled for port: " + model .getIndex () + ". Enable Service Mode in Control tab." );
420
430
});
421
431
} catch (Exception e ) {
422
- logger .error ("Failed to set L3IPv4 mode: " + e .getMessage ());
432
+ logger .error ("Failed to set L3 mode: " + e .getMessage ());
433
+ guiLogger .appendText (LogType .ERROR , "Failed to set L3 mode: " + e .getMessage ());
423
434
} finally {
424
435
trexClient .serviceMode (model .getIndex (), false );
425
436
AsyncResponseManager .getInstance ().suppressIncomingEvents (false );
@@ -433,8 +444,12 @@ public Optional<String> call() {
433
444
saveConfigurationTask .setOnSucceeded (e -> {
434
445
saveBtn .setText ("Apply" );
435
446
saveBtn .setDisable (false );
447
+
448
+ final boolean dstIsIPv6 = InetAddresses .forString (l3Source .getText ()).getAddress ().length > 4 ;
449
+ final boolean srcIsIPv6 = InetAddresses .forString (l3Destination .getText ()).getAddress ().length > 4 ;
450
+
436
451
Optional result = (Optional ) (saveConfigurationTask .getValue ());
437
- if (l3Mode .isSelected ()) {
452
+ if (l3Mode .isSelected () && ! dstIsIPv6 && ! srcIsIPv6 ) {
438
453
String status = "unresolved" ;
439
454
if (result .isPresent ()) {
440
455
status = "resolved" ;
@@ -583,8 +598,21 @@ public void bindModel(PortModel model) {
583
598
l2Destination .textProperty ().bindBidirectional (this .model .getL2LayerConfiguration ().dstProperty ());
584
599
l2Source .textProperty ().bindBidirectional (this .model .getL2LayerConfiguration ().srcProperty ());
585
600
586
- l3Destination .textProperty ().bindBidirectional (this .model .getL3LayerConfiguration ().dstProperty ());
587
- l3Source .textProperty ().bindBidirectional (this .model .getL3LayerConfiguration ().srcProperty ());
601
+ final PortLayerConfigurationModel l3Conf = this .model .getL3LayerConfiguration ();
602
+
603
+ l3Destination .textProperty ().bindBidirectional (l3Conf .dstProperty ());
604
+ l3Source .textProperty ().bindBidirectional (l3Conf .srcProperty ());
605
+
606
+ final String src6 = l3Conf .getSrc6 ();
607
+ final String dst6 = l3Conf .getDst6 ();
608
+
609
+ if (src6 != null && !src6 .equals ("" )) {
610
+ l3Source .textProperty ().setValue (src6 );
611
+ }
612
+
613
+ if (dst6 != null && !dst6 .equals ("" )) {
614
+ l3Destination .textProperty ().setValue (dst6 );
615
+ }
588
616
589
617
vlan .textProperty ().bindBidirectional (this .model .vlanProperty ());
590
618
@@ -608,4 +636,10 @@ private void unbindAll() {
608
636
arpStatus .textProperty ().unbindBidirectional (model .getL3LayerConfiguration ().stateProperty ());
609
637
model .layerConfigurationTypeProperty ().removeListener (configurationModeChangeListener );
610
638
}
639
+
640
+ private void clearModelIPv6 () {
641
+ final PortLayerConfigurationModel l3Conf = this .model .getL3LayerConfiguration ();
642
+ l3Conf .setSrc6 (null );
643
+ l3Conf .setDst6 (null );
644
+ }
611
645
}
0 commit comments