This is a working specification for a new interface JSON interface for CoovaChilli. Please note that this is different from the existing XML based interface used for WISPr messages, and extended as a previous attempt for browser based clients.
To communicate with the CoovaChilli Controller, the application uses the methods exposed by the chilliController javascript object. This object sends commands as HTTP GET requests to CoovaChilli and receives JSON formatted replies from CoovaChilli. This chilliController object can issue three main commands to the Controller:
A Browser Based Smart Client Application downloads the ChilliLibrary.js javascript library and is then be able to use the global chilliController object with three methods:
When a client is authorized, the chilliController object will periodically update accounting data by issuing periodic status commands to refresh the data (autorefresh).
Only CHAP authentication supported method. The password will never leave the browser executing the BBSC application.
The security model of both Web browsers and the Flash player will not allow programmatic HTTP request to URLs residing on a different host/domain/port, after the containing page/movie is loaded. However, there are workarounds:
Using these two workarounds, any HTML page (Flash movie), from any domain, can include a single ChilliLibrary.js file (ChilliLibrary.swf) to create a Controller object that will allow communication from the client application to CoovaChilli.
BBSCs could also be implemented as FireFox extensions or IE add-ons.
<script src="http://my.host.com/ChilliLibrary.js"></script>
<script>
// The included script creates a global chilliController object
// If you use non standard configuration, define your configuration
chilliController.host = "10.0.0.1"; // Default is 192.168.182.1
chilliController.port = 4003 ; // Default is 3990
chilliController.interval = 60 ; // Default is 30 seconds
// then define event handler functions
chilliController.onError = handleErrors;
chilliController.onUpdate = updateUI ;
// when the reply is ready, this handler function is called
function updateUI( cmd ) {
alert ( ‘You called the method' + cmd + '\n Your current state is =’ + chilliController.clientState ) ;
}
// If an error occurs, this handler will be called instead
function handleErrors ( code ) {
alert ( 'The last contact with the Controller failed. Error code =' + code );
}
// finally, get current state
chilliController.refresh() ;
</script>
The chilliController is a global object created by the included script. By default, it is configured to contact the CoovaChilli gateway at 192.168.182.1:3990 every 30 seconds. If required, you must modify these values to match your specific configuration before calling a method.
After the chilliController object is configured, you must explicitly call the refresh method to determine the current state of the client.
- UNKNOWN (-1)
- NOT_AUTHORIZED (0)
- AUTHORIZED (1)
- AUTH_PENDING (2)
- User-Request (1)
- Lost-Carrier (2)
- Idle-Timeout (4)
- Session-Timeout (5)
- NAS-Reboot (11)
- UNKOWN (-1)
originalURL URL originally requested by the client (before the redirection) redirectionURL URL to redirecto to next, WISPr-Redirection-URL or otherwise macAddress Calling-Station-Id - mac address of the client device ipAddress Framed-IP-Address (not yet implemented)
name WISPr-Location-Name - name of the location (chilli.conf locationname or radiuslocationname)
userName User-Name (not yet implemented) startTime CoovaChilli time session start time. ECMAScript Date object. This one is not a radius attribute, but useful in the BBSC user interface. terminateTime WISPr-Session-Terminate-Time. ECMAScript Date object. (not yet implemented) sessionTimeout Session-Timeout idleTimeout Idle-Timeout maxInputOctets ChilliSpot-Max-Input-Octets (not yet) maxOutputOctets ChilliSpot-Max-Output-Octets (not yet) maxTotalOctets ChilliSpot-Max-Total-Octets (not yet) bandwidthMaxDown WISPr-Bandwidth-Max-Down (not yet) bandwidthMaxUp WISPr-Bandwidth-Max-Up (not yet)
sessionTime Acct-Session-Time - session duration idleTime Idle time calculated by CoovaChilli (traffic to/from CoovaChilli is ignored). This one is not a radius attribute, but the Controller object will use it to schedule the next refresh just after a likely IdleTimeout disconnection. It's also exposed in the API, to be comprehensive. inputOctets Acct-Input-Octets outputOctets Acct-Output-Octets inputGigawords Acct-Input-Gigawords outputGigawords Acct-Output-Gigawords
Commands are send to CoovaChilli with HTTP requests. The lang GET parameter is used on all URLs to pass the preferred language (only used in logon for the time being).
The version field is used to track different versions of the CoovaChilli JSON protocol.
If a callback parameter (callback=function) is present, then CoovaChilli will wrap the JSON output text in parentheses and prepend it with the callback function. The output will look like a function call with a JSON object passed as parameter. This will allow cross domain access to the JSON feed from JavaScript.
When the logon() method of the Controller object is called, the Controller object:
{
"version" : "1.0",
"clientState" : 1 ,
"sessionId" : "4662e92b0000000e" ,
"message" : "You’re now connected" ,
"location" : {
"name": "Coova labs"
},
"redir" : {
"macAddress" : "00-30-1B-B5-03-6B",
"originalURL" : "http://my.yahoo.com/",
"redirectionURL" : "http://www.coova.org/welcome.php",
"ipAddress" : "192.168.182.47"
},
"session" : {
"startTime" : 137550720,
"terminateTime" : 13756072,
"sessionTimeout" : 3600,
"idleTimeout" : 240,
"maxInputOctets" : 100000000,
"maxOutputOctets" : 100000000,
"maxTotalOctets" : 100000000,
"bandwidthMaxDown" : 1000000,
"bandwidthMaxUp" : 1000000
},
"accounting": {
"sessionTime" : 2,
"idleTime" : 0,
"inputOctets" : 0,
"outputOctets" : 0,
"inputGigawords" : 0,
"outputGigawords" : 0
}
}
If the authorization, does not succeed. The JSON reply will look like this
{
"version": "1.0",
"clientState": 0,
"message": "This username does not exist",
"location" : { "name":"My HotSpot" }
}
myfunc ( { "version": "1.0", "clientState": 0 } )
{
"version" : "1.0",
"clientState" : 1 ,
"sessionId" : "4662e92b0000000e" ,
"accounting": {
"sessionTime" : 1230,
"idleTime" : 240,
"inputOctets" : 2912981 ,
"outputOctets" : 51498511,
"inputGigawords" : 0,
"outputGigawords" : 0
}
}
It's not necessary to repeat the fixed session properties here. The sessionId is used to associate the newly received accounting values with the session values received with the initial logon command.
Problem: What if a someone uses the HTML form to connect and then uses a BBSC for status display?
If the client is not authorized:
{
"version" : "1.0",
"clientState" : 0
}