Exemple #1
0
 DeletePortMappingActionInvocation(Service service) {
   super(service.getAction("DeletePortMapping"));
   try {
     // This might throw an ActionException if the value is of wrong type
     getInput().addValue(null); // NewRemoteHost
     getInput().addValue(new UnsignedIntegerTwoBytes(1234)); // NewExternalPort
     getInput().addValue("TCP"); // NewProtocol
   } catch (ActionException ex) {
     System.err.println(ex.getMessage());
   }
 }
Exemple #2
0
    AddPortMappingActionInvocation(Service service) {
      super(service.getAction("AddPortMapping"));
      try {
        // This might throw an ActionException if the value is of wrong type
        getInput().addValue(null); // NewRemoteHost
        getInput().addValue(new UnsignedIntegerTwoBytes(1234)); // NewExternalPort
        getInput().addValue("TCP"); // NewProtocol
        getInput().addValue(new UnsignedIntegerTwoBytes(1234)); // NewInternalPort

        // TODO: This may return null
        String localhost = NetUtilities.getNonLoopbackAddress().getHostAddress();
        System.out.println("Adding port to : " + localhost);

        getInput().addValue(localhost); // NewInternalClient
        getInput().addValue(true); // NewEnabled
        getInput().addValue("Description"); // NewPortMappingDescription
        getInput().addValue(new UnsignedIntegerFourBytes(0)); // NewLeaseDuration
      } catch (ActionException ex) {
        System.err.println(ex.getMessage());
      }
    }