Changes

no edit summary
Line 2: Line 2:  
==Summary==
 
==Summary==
   −
'''JSON-RPC''' is a remote procedure call protocol encoded in JSON. It is a very simple protocol (and very similar to XML-RPC), defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered out of order. This is guide on how to use JSON-RPC on RUT230, RUT240, RUT850, RUT950 and RUT955 routers.
+
'''JSON-RPC''' is a remote procedure call protocol encoded in JSON. It is a very simple protocol (and very similar to XML-RPC), defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered out of order. This is a guide on how to use JSON-RPC on RUT230, RUT240, RUT850, RUT950 and RUT955 routers.
    
==Enabling JSON-RPC==
 
==Enabling JSON-RPC==
Line 31: Line 31:  
==Using JSON-RPC with Windows OS==
 
==Using JSON-RPC with Windows OS==
   −
This section is a guide on how to use JSON-RPC with a Windows operating system. If you're using a Linux OS, you can find the guide [[Monitoring_via_JSON-RPC#Using_JSON-RPC_with_Linux_OS|here]]
+
This section describes how to use JSON-RPC with a Windows operating system. If you're using a Linux OS, you can find the guide '''[[Monitoring_via_JSON-RPC#Using_JSON-RPC_with_Linux_OS|here]]'''
    
===Obtaining a session ID===
 
===Obtaining a session ID===
Line 37: Line 37:  
To login to the router via JSON-RPC you will need software capable of sending requests to the router. The simplest solution is to install an add-on similar to Firefox’s '''“Poster”''': '''https://addons.mozilla.org/en-US/firefox/addon/poster/'''.  
 
To login to the router via JSON-RPC you will need software capable of sending requests to the router. The simplest solution is to install an add-on similar to Firefox’s '''“Poster”''': '''https://addons.mozilla.org/en-US/firefox/addon/poster/'''.  
   −
Once you've installed this add-on, you can launch by opening the Mozilla Firefox browser and pressing '''Ctrl+Alt+p'''.  
+
Once you've installed this add-on, you can launch it by opening the Mozilla Firefox browser and pressing '''Ctrl+Alt+p'''.  
      Line 53: Line 53:       −
In order to obtain a Session ID, type in the router's LAN IP address in the '''URL''' field, type in the login username and password in the '''User Auth.''' field. Then paste this command into the '''Content to send''' field and click '''Post''':
+
In order to obtain a Session ID, enter the router's '''[[LAN]]''' IP address (default: '''http://192.168.1.1/ubus''') into the '''URL''' field if you're logging into the router locally or if you wish to login remotely, enter the '''[[WAN]]''' IP address instead. Next, enter the login username and password in the '''User Auth.''' field. Then paste this command into the '''Content to send''' field and click '''Post''':
      Line 80: Line 80:  
Copy the ID since you'll be needing it when issuing other commands to the router.
 
Copy the ID since you'll be needing it when issuing other commands to the router.
   −
'''NOTE:''' if your commands stop working and you get a Response like this: '''{"jsonrpc":"2.0","id":1,"error":{"code":-32002,"message":"Access denied"}}''', it probably means your Session ID has expired and you need a new one. A Session ID expires after 300 seconds (5 minutes).
+
'''NOTE:''' if your commands stop working and you get a Response like this: '''{"jsonrpc":"2.0","id":1,"error":{"code":-32002,"message":"<span style=color:red>Access denied</span>"}}''', it probably means that your Session ID has expired and that you need a new one. A Session ID expires after 300 seconds (5 minutes).
    
===Getting router parameters===
 
===Getting router parameters===
Line 123: Line 123:  
     ]
 
     ]
 
  }
 
  }
The command and the parameter are highlighted in orange. In this case the Linux '''cat'''(short for “concatenate“) is used to view the contents of the  '''/etc/config/network''' file. The Response is:
+
The command and the parameter are highlighted in orange. In this case the Linux '''cat'''(short for “concatenate“) command is used to view the contents of the  '''/etc/config/network''' file. The Response is:
      Line 130: Line 130:  
===Setting router parameters===
 
===Setting router parameters===
   −
The '''UCI set''' command is used to set router parameters. As an example, lets try to change the router's WiFi SSID. The command to do so looks like this:
+
The '''uci set''' command is used to set router parameters. As an example, lets try to change the router's WiFi SSID. The command to do so looks like this:
   −
====UCI set====
+
====uci set====
    
  {
 
  {
Line 152: Line 152:  
     ]
 
     ]
 
  }
 
  }
The sections highlighted in orange describes the config files name and section (in this case, '''wireless''' config and '''wifi-iface''' section). Highlighted in red is the exact part of the config file that you wish to change (in this case, the router's '''SSID'''). Finally, highlighted in green is the value that is to replace the old value (in this case, change the router's SSID to '''9999'''). If the issued command was a success, you should see a Response like this:
+
The sections highlighted in orange describes the config file's name and section (in this case, '''wireless''' config and '''wifi-iface''' section). Highlighted in red is the exact part of the config file that you wish to change (in this case, the router's '''SSID'''). Finally, highlighted in green is the value that will replace the old value (in this case, change the router's SSID to '''9999'''). If the issued command was a success, you should see a Response like this:
      Line 159: Line 159:  
====UCI commit====
 
====UCI commit====
   −
In order to commit the changes from RAM to flash memory, you must first send a UCI commit command. Continuing from the example above, lets commit the Wireless SSID changes. The command to do so looks like this:
+
When you set changes using '''uci commit''', you're only changing a copy of the file that is located in the router's RAM memory. In order for the changes to take place you'll need to issue a '''uci commit''' command that will commit the changes from RAM to flash memory. Continuing from the example above, lets commit the Wireless SSID changes. The command to do so looks like this:
    
  {
 
  {
Line 217: Line 217:  
==Using JSON-RPC with Linux OS==
 
==Using JSON-RPC with Linux OS==
   −
This section will describe how to use JSON-RPC commands with a Linux OS system. The guide for Windows users can be found [[Monitoring_via_JSON-RPC#Using_JSON-RPC_with_Windows_OS|here]]
+
This section will describe how to use JSON-RPC commands with a Linux OS system. The guide for Windows users can be found '''[[Monitoring_via_JSON-RPC#Using_JSON-RPC_with_Windows_OS|here]]'''
    
===Obtaining a session ID===
 
===Obtaining a session ID===
Line 225: Line 225:  
   curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"00000000000000000000000000000000\", \"session\", \"login\", { \"username\": \"root\", \"password\": \"<span style=color:orange>admin01</span>\"  } ] }" http://<span style=color:green>192.168.1.1</span>/ubus   
 
   curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"00000000000000000000000000000000\", \"session\", \"login\", { \"username\": \"root\", \"password\": \"<span style=color:orange>admin01</span>\"  } ] }" http://<span style=color:green>192.168.1.1</span>/ubus   
   −
The section highlighted in orange is the router's admin password. admin01 is the default value, replace it with your router's password. The address highlighted in green is the router's IP address. Replace this value with your router's IP. If you're trying to reach the router from [[LAN]], use the local IP address (default: '''192.168.1.1'''), if you're trying to reach the router from [[WAN]], use the router's WAN IP address.
+
The section highlighted in orange is the router's admin password. admin01 is the default value, replace it with your router's password. The address highlighted in green is the router's IP address. Replace this value with your router's IP. If you're trying to reach the router from '''[[LAN]]''', use the local IP address (default: '''192.168.1.1'''), if you're trying to reach the router from '''[[WAN]]''', use the router's WAN IP address.
     

Navigation menu