@@ -1367,10 +1367,17 @@ public static String getNextIp6InRange(String currentIp, String ipRange) {
13671367 return resultIp ;
13681368 }
13691369
1370+ static final String VLAN_PREFIX = "vlan://" ;
1371+ static final int VLAN_PREFIX_LENGTH = VLAN_PREFIX .length ();
1372+
13701373 public static boolean isValidVlan (String vlan ) {
1374+ if (null == vlan || "" .equals (vlan ))
1375+ return false ;
1376+ if (vlan .startsWith (VLAN_PREFIX ))
1377+ vlan = vlan .substring (VLAN_PREFIX_LENGTH );
13711378 try {
13721379 int vnet = Integer .parseInt (vlan );
1373- if (vnet < 0 || vnet > 4096 ) {
1380+ if (vnet <= 0 || vnet >= 4095 ) { // the valid range is 1- 4094
13741381 return false ;
13751382 }
13761383 return true ;
@@ -1379,6 +1386,41 @@ public static boolean isValidVlan(String vlan) {
13791386 }
13801387 }
13811388
1389+ static final String VLAN_UNTAGGED = "untagged" ;
1390+
1391+ public static boolean sameIsolationId (String one , String other )
1392+ {
1393+ // check nulls
1394+ // check empty strings
1395+ if ((one == null || one .equals ("" ))
1396+ &&
1397+ (other == null || other .equals ("" )))
1398+ {
1399+ return true ;
1400+ }
1401+ // check 'untagged'
1402+ if (VLAN_UNTAGGED .equalsIgnoreCase (one ) && VLAN_UNTAGGED .equalsIgnoreCase (other ))
1403+ {
1404+ return true ;
1405+ }
1406+ // if one is a number check the other as number and as 'vlan://' + number
1407+ if (one .startsWith (VLAN_PREFIX ))
1408+ {
1409+ one = one .substring (VLAN_PREFIX_LENGTH );
1410+ }
1411+ if (other .startsWith (VLAN_PREFIX ))
1412+ {
1413+ other = other .substring (VLAN_PREFIX_LENGTH );
1414+ }
1415+ // check valid uris or numbers
1416+ if (one .equals (other ))
1417+ {
1418+ return true ;
1419+ }
1420+
1421+ return false ;
1422+ }
1423+
13821424 // Attention maintainers: these pvlan functions should take into account code
13831425 // in Networks.BroadcastDomainType, where URI construction is done for other
13841426 // types of BroadcastDomainTypes
0 commit comments