Firewall

The Firewall service (com.palm.firewall) has one method -- control.


control

Opens a port on the firewall. If subscribe=true, then the port remains open until the service or app stops running.

Syntax

{
    "subscribe" : boolean,
    "rules"     : [ {
        "protocol"           : string,
        "destinationPort"    : number,
        "sourcePort"         : number,      
        "operation"          : string,
        "source"             : string,  
        "destination"        : string,  
        "interfaceName"      : string,
        "interfaceDirection" : string       
    }]
}

Parameters

Parameter Required Type Description
subscribe Yes boolean Flag to keep port open while calling app or service is still running
rules Yes object array Object array, see fields below
protocol Yes string TCP|UDP|ICMP|ANY
destinationPort Yes number Port number, must be higher than 1023
sourcePort No number Source port number
operation No string append|delete|insert|replace
source No string address/mask
destination No string address/mask
interfaceName No string Interface name, i.e., "eth0"
interfaceDirection No string in|out

Returns

{
   "returnValue"  : boolean,
   "errorCode"    : number,
   "errorText"    : string
}
Attribute Required Type Description
returnValue Yes boolean true (success) or false (failure)
errorCode No number Error code returned on failure
errorText No string Error message returned on failure

Examples

luna-send

 luna-send -P -i palm://com.palm.firewall/control '{"subscribe":true,"rules":[{"protocol":"TCP","destinationPort":7070}]}'
{"returnValue":true}

Enyo

enyo.kind({
   name : "enyo.Canon.Firewall",
   kind : enyo.VFlexBox,
   components : [ 
     { flex : 1,
      kind : "Pane",
      components : [{
         flex : 1,
         kind : "Scroller",
         components : [{
            name : "openPort",
            kind : "PalmService",
            service : "palm://com.palm.firewall",
            method : "control",
            onSuccess : "openPortSuccess",
            onFailure : "openPortFailure",
            subscribe : true
         },
         {kind : "Button", name : "openPortButton", caption : "Open Port", onclick : "openPortClick"}
        ]
      }]
    }],
    openPortClick: function() {     
         this.$.openPort.call({"subscribe":true,"rules":[{"protocol":"TCP","destinationPort":7070}]});
    },
    openPortSuccess: function(inSender, inResponse) {
        this.log("Open port success, results=" + enyo.json.stringify(inResponse));
    },          
    // Log errors to the console for debugging
    openPortFailure: function(inSender, inError, inRequest) {
        this.log(enyo.json.stringify(inError));
    }
});