Search in sources :

Example 1 with Tcp_flags_atomContext

use of org.batfish.grammar.flatjuniper.FlatJuniperParser.Tcp_flags_atomContext in project batfish by batfish.

the class ConfigurationBuilder method toTcpFlags.

private static TcpFlags toTcpFlags(Tcp_flags_alternativeContext ctx) {
    TcpFlags tcpFlags = new TcpFlags();
    for (Tcp_flags_literalContext literalCtx : ctx.literals) {
        boolean value = literalCtx.BANG() == null;
        Tcp_flags_atomContext atom = literalCtx.tcp_flags_atom();
        if (atom.ACK() != null) {
            tcpFlags.setUseAck(true);
            tcpFlags.setAck(value);
        } else if (atom.CWR() != null) {
            tcpFlags.setUseCwr(true);
            tcpFlags.setCwr(value);
        } else if (atom.ECE() != null) {
            tcpFlags.setUseEce(true);
            tcpFlags.setEce(value);
        } else if (atom.FIN() != null) {
            tcpFlags.setUseFin(true);
            tcpFlags.setFin(value);
        } else if (atom.PSH() != null) {
            tcpFlags.setUsePsh(true);
            tcpFlags.setPsh(value);
        } else if (atom.RST() != null) {
            tcpFlags.setUseRst(true);
            tcpFlags.setRst(value);
        } else if (atom.SYN() != null) {
            tcpFlags.setUseSyn(true);
            tcpFlags.setSyn(value);
        } else if (atom.URG() != null) {
            tcpFlags.setUseUrg(true);
            tcpFlags.setUrg(value);
        } else {
            throw new BatfishException("Invalid tcp-flags atom: " + atom.getText());
        }
    }
    return tcpFlags;
}
Also used : TcpFlags(org.batfish.datamodel.TcpFlags) FwFromTcpFlags(org.batfish.representation.juniper.FwFromTcpFlags) BatfishException(org.batfish.common.BatfishException) Tcp_flags_atomContext(org.batfish.grammar.flatjuniper.FlatJuniperParser.Tcp_flags_atomContext) Tcp_flags_literalContext(org.batfish.grammar.flatjuniper.FlatJuniperParser.Tcp_flags_literalContext)

Aggregations

BatfishException (org.batfish.common.BatfishException)1 TcpFlags (org.batfish.datamodel.TcpFlags)1 Tcp_flags_atomContext (org.batfish.grammar.flatjuniper.FlatJuniperParser.Tcp_flags_atomContext)1 Tcp_flags_literalContext (org.batfish.grammar.flatjuniper.FlatJuniperParser.Tcp_flags_literalContext)1 FwFromTcpFlags (org.batfish.representation.juniper.FwFromTcpFlags)1