Ejemplo n.º 1
0
 @Override
 public Action deserialize(ByteBuf message) {
   ActionBuilder actionBuilder = deserializeHeader(message);
   ActionSetNshc1Builder builder = new ActionSetNshc1Builder();
   NxActionSetNshc1Builder nxActionSetNspBuilder = new NxActionSetNshc1Builder();
   message.skipBytes(padding);
   nxActionSetNspBuilder.setNshc(message.readUnsignedInt());
   builder.setNxActionSetNshc1(nxActionSetNspBuilder.build());
   actionBuilder.setActionChoice(builder.build());
   return actionBuilder.build();
 }
  /**
   * @param version openflow version
   * @param inputPacket input packet
   * @param datapathid datapath id
   * @param xid tx id
   * @return PacketOutInput required by OF Library
   */
  public static PacketOutInput toPacketOutInput(
      final TransmitPacketInput inputPacket,
      final short version,
      final Long xid,
      final BigInteger datapathid) {

    LOG.trace("toPacketOutInput for datapathId:{}, xid:{}", datapathid, xid);
    // Build Port ID from TransmitPacketInput.Ingress
    PortNumber inPortNr = null;
    Long bufferId = OFConstants.OFP_NO_BUFFER;
    Iterable<PathArgument> inArgs = null;
    PacketOutInputBuilder builder = new PacketOutInputBuilder();
    if (inputPacket.getIngress() != null) {
      inArgs = inputPacket.getIngress().getValue().getPathArguments();
    }
    if (inArgs != null && Iterables.size(inArgs) >= 3) {
      inPortNr = getPortNumber(Iterables.get(inArgs, 2), version);
    } else {
      // The packetOut originated from the controller
      inPortNr = new PortNumber(0xfffffffdL);
    }

    // Build Buffer ID to be NO_OFP_NO_BUFFER
    if (inputPacket.getBufferId() != null) {
      bufferId = inputPacket.getBufferId();
    }

    PortNumber outPort = null;
    NodeConnectorRef outRef = inputPacket.getEgress();
    Iterable<PathArgument> outArgs = outRef.getValue().getPathArguments();
    if (Iterables.size(outArgs) >= 3) {
      outPort = getPortNumber(Iterables.get(outArgs, 2), version);
    } else {
      // TODO : P4 search for some normal exception
      new Exception("PORT NR not exist in Egress");
    }

    List<Action> actions = null;
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
        inputActions = inputPacket.getAction();
    if (inputActions != null) {
      actions = ActionConvertor.getActions(inputActions, version, datapathid, null);

    } else {
      actions = new ArrayList<>();
      // TODO VD P! wait for way to move Actions (e.g. augmentation)
      ActionBuilder aBuild = new ActionBuilder();

      OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();

      OutputActionBuilder outputActionBuilder = new OutputActionBuilder();

      outputActionBuilder.setPort(outPort);
      outputActionBuilder.setMaxLength(OFConstants.OFPCML_NO_BUFFER);

      outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());

      aBuild.setActionChoice(outputActionCaseBuilder.build());

      actions.add(aBuild.build());
    }

    builder.setAction(actions);
    builder.setData(inputPacket.getPayload());
    builder.setVersion(version);
    builder.setXid(xid);
    builder.setInPort(inPortNr);
    builder.setBufferId(bufferId);
    // --------------------------------------------------------

    return builder.build();
  }