Search in sources :

Example 6 with Argument

use of org.cybergarage.upnp.Argument in project i2p.i2p by i2p.

the class UPnP method getDownstreamMaxBitRate.

/**
 * @return the reported downstream bit rate in bits per second. -1 if it's not available. Blocking.
 */
private int getDownstreamMaxBitRate() {
    Service service;
    synchronized (lock) {
        if (!isNATPresent() || thinksWeAreDoubleNatted)
            return -1;
        service = _service;
    }
    Action getIP = service.getAction("GetLinkLayerMaxBitRates");
    if (getIP == null || !getIP.postControlAction())
        return -1;
    Argument a = getIP.getOutputArgumentList().getArgument("NewDownstreamMaxBitRate");
    if (a == null)
        return -1;
    try {
        return Integer.parseInt(a.getValue());
    } catch (NumberFormatException nfe) {
        return -1;
    }
}
Also used : Action(org.cybergarage.upnp.Action) Argument(org.cybergarage.upnp.Argument) Service(org.cybergarage.upnp.Service)

Example 7 with Argument

use of org.cybergarage.upnp.Argument in project i2p.i2p by i2p.

the class UPnP method toString.

private String toString(String action, String arg, Service serv) {
    synchronized (toStringLock) {
        if ((!action.equals(_lastAction)) || (!serv.equals(_lastService)) || _lastArgumentList == null) {
            Action getIP = serv.getAction(action);
            if (getIP == null || !getIP.postControlAction()) {
                _lastAction = null;
                return null;
            }
            _lastAction = action;
            _lastService = serv;
            _lastArgumentList = getIP.getOutputArgumentList();
        }
        Argument a = _lastArgumentList.getArgument(arg);
        if (a == null)
            return "";
        String rv = a.getValue();
        return DataHelper.escapeHTML(rv);
    }
}
Also used : Action(org.cybergarage.upnp.Action) Argument(org.cybergarage.upnp.Argument)

Example 8 with Argument

use of org.cybergarage.upnp.Argument in project i2p.i2p by i2p.

the class UPnP method getNATAddress.

/**
 * @return the external IPv4 address the NAT thinks we have.  Blocking.
 * null if we can't find it.
 */
private String getNATAddress() {
    Service service;
    synchronized (lock) {
        if (!isNATPresent())
            return null;
        service = _service;
    }
    Action getIP = service.getAction("GetExternalIPAddress");
    if (getIP == null || !getIP.postControlAction())
        return null;
    Argument a = getIP.getOutputArgumentList().getArgument("NewExternalIPAddress");
    if (a == null)
        return null;
    String rv = a.getValue();
    // I2P some devices return 0.0.0.0 when not connected
    if ("0.0.0.0".equals(rv) || rv == null || rv.length() <= 0)
        return null;
    return rv;
}
Also used : Action(org.cybergarage.upnp.Action) Argument(org.cybergarage.upnp.Argument) Service(org.cybergarage.upnp.Service)

Example 9 with Argument

use of org.cybergarage.upnp.Argument in project i2p.i2p by i2p.

the class UPnP method getUpstreamMaxBitRate.

/**
 * @return the reported upstream bit rate in bits per second. -1 if it's not available. Blocking.
 */
private int getUpstreamMaxBitRate() {
    Service service;
    synchronized (lock) {
        if (!isNATPresent() || thinksWeAreDoubleNatted)
            return -1;
        service = _service;
    }
    Action getIP = service.getAction("GetLinkLayerMaxBitRates");
    if (getIP == null || !getIP.postControlAction())
        return -1;
    Argument a = getIP.getOutputArgumentList().getArgument("NewUpstreamMaxBitRate");
    if (a == null)
        return -1;
    try {
        return Integer.parseInt(a.getValue());
    } catch (NumberFormatException nfe) {
        return -1;
    }
}
Also used : Action(org.cybergarage.upnp.Action) Argument(org.cybergarage.upnp.Argument) Service(org.cybergarage.upnp.Service)

Aggregations

Argument (org.cybergarage.upnp.Argument)9 Action (org.cybergarage.upnp.Action)5 ArgumentList (org.cybergarage.upnp.ArgumentList)4 Service (org.cybergarage.upnp.Service)4 Properties (java.util.Properties)2 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)2 UPnPAction (org.osgi.service.upnp.UPnPAction)2 UPnPException (org.osgi.service.upnp.UPnPException)2 UPnPService (org.osgi.service.upnp.UPnPService)2 UPnPStateVariable (org.osgi.service.upnp.UPnPStateVariable)2 Dictionary (java.util.Dictionary)1 AllowedValueList (org.cybergarage.upnp.AllowedValueList)1 AllowedValueRange (org.cybergarage.upnp.AllowedValueRange)1 ControlPoint (org.cybergarage.upnp.ControlPoint)1 StateVariable (org.cybergarage.upnp.StateVariable)1 UPnPStatus (org.cybergarage.upnp.UPnPStatus)1 UPnPDevice (org.osgi.service.upnp.UPnPDevice)1