public void append(BatfishLoggerHistory history, String prefix) { for (HistoryItem item : history) { int level = item.getLevel(); String msg = prefix + item.getMessage(); write(level, msg); } }
public BatfishLogger(String logLevel, boolean timestamp) { _timestamp = timestamp; setLogLevel(logLevel); _history = new BatfishLoggerHistory(); }
private static void forbidHeaderSpaceField(String fieldName, IpSpace fieldValue) { if (fieldValue != null && fieldValue != EmptyIpSpace.INSTANCE) { throw new BatfishException("unsupported HeaderSpace field " + fieldName); } }
public static WorkItem getWorkItemGenerateDataPlane(String containerName, String testrigName) { WorkItem wItem = new WorkItem(containerName, testrigName); wItem.addRequestParam(BfConsts.COMMAND_DUMP_DP, ""); return wItem; }
@Override protected T1 featureValueOf(Pair<T1, T2> actual) { return actual.getFirst(); } }
public BatfishLogger(String logLevel, boolean timestamp, PrintStream stream) { _history = null; _timestamp = timestamp; String levelStr = logLevel; setLogLevel(levelStr); _ps = stream; }
public void pedantic(String msg) { if (!_pedanticRecord) { return; } pedantic(msg, TAG_PEDANTIC); }
@Override public void exitEveryRule(ParserRuleContext ctx) { _indent--; _ptSentences.appendToLastSentence(")"); }
public RoutingProtocol toRoutingProtocol() { switch (this) { case E1: return RoutingProtocol.OSPF_E1; case E2: return RoutingProtocol.OSPF_E2; default: throw new BatfishException("invalid ospf metric type"); } } }
public String toInterfaceName() { if (_inverted) { // _warnings.redFlag("Inversion of interface matching is not supported."); throw new BatfishException("Unknown matchdata type"); } return (String) _matchData; } }
public SetOspfMetricType(OspfMetricType metricType) { _metricType = metricType; if (_metricType == null) { throw new BatfishException("Cannot set null ospf metric type"); } }
private static EncryptionAlgorithm toEncryptionAlgorithm(String encryptionProtocol) { switch (encryptionProtocol) { case "aes-128-cbc": return EncryptionAlgorithm.AES_128_CBC; default: throw new BatfishException( "No conversion to encryption algorithm for string: \"" + encryptionProtocol + "\""); } }
private static IkeHashingAlgorithm toIkeAuthenticationAlgorithm(String ikeAuthProtocol) { switch (ikeAuthProtocol) { case "sha1": return IkeHashingAlgorithm.SHA1; default: throw new BatfishException( "No conversion to ike authentication algorithm for string: \"" + ikeAuthProtocol + "\""); } }
private static String ipFieldName(IpField ipField) { switch (ipField) { case DESTINATION: return PROP_DST_IP; case SOURCE: return PROP_SRC_IP; default: throw new BatfishException("Unknown IpField: " + ipField); } }
private static DiffieHellmanGroup toDiffieHellmanGroup(String perfectForwardSecrecy) { switch (perfectForwardSecrecy) { case "group2": return DiffieHellmanGroup.GROUP2; default: throw new BatfishException( "No conversion to Diffie-Hellman group for string: \"" + perfectForwardSecrecy + "\""); } }
private static IpsecProtocol toIpsecProtocol(String ipsecProtocol) { switch (ipsecProtocol) { case "esp": return IpsecProtocol.ESP; default: throw new BatfishException( "No conversion to ipsec protocol for string: \"" + ipsecProtocol + "\""); } }
public static OspfMetricType fromInteger(int i) { switch (i) { case 1: return E1; case 2: return E2; default: throw new BatfishException("invalid ospf metric type"); } }
public IpProtocol toIpProtocol() { if (_inverted) { // _warnings.redFlag("Inversion of protocol matching is not supported. // Current analysis will match everything."); // return IpWildcard.ANY; throw new BatfishException("Unknown matchdata type"); } return (IpProtocol) _matchData; }