Switch¶
The Switch API allow you to control the settings of the Freebox integrated switch.
Switch Errors¶
When attempting to access the switch API, you may encounter the following errors:
error_code | Description |
---|---|
bad_port | invalid port number |
bad_speed | unable to set port speed |
bad_link | unable to set port link mode |
bad_mac_entry_type | invalid mac entry type |
Switch Port Status Object¶
SwitchPortStatus has the following attributes:
-
SwitchPortStatus
¶ -
id
int Read-only¶ switch port id
-
link
enum Read-only¶ link Description up port is up down port is down
-
duplex
enum¶ duplex Description half force in half duplex mode full force in full duplex mode
-
speed
enum¶ duplex Description 10 10Base-T 100 100Base-TX 1000 1000Base-T
-
mode
string Read-only¶ display form of speed and duplex mode
-
mac_list
[] array of object Read-only¶ list of { mac, name } of hosts connected to this port
-
Switch Port Configuration Object¶
SwitchPortConfig has the following attributes:
Switch Port Stats Object [UNSTABLE]¶
SwitchPortStats has the following attributes:
-
SwitchPortStats
¶ -
rx_bad_bytes
int Read-only¶
-
rx_broadcast_packets
int Read-only¶
-
rx_bytes_rate
int Read-only¶
-
rx_err_packets
int Read-only¶
-
rx_fcs_packets
int Read-only¶
-
rx_fragments_packets
int Read-only¶
-
rx_good_bytes
int Read-only¶
-
rx_good_packets
int Read-only¶
-
rx_jabber_packets
int Read-only¶
-
rx_multicast_packets
int Read-only¶
-
rx_oversize_packets
int Read-only¶
-
rx_packets_rate
int Read-only¶
-
rx_pause
int Read-only¶
-
rx_undersize_packets
int Read-only¶
-
rx_unicast_packets
int Read-only¶
-
tx_broadcast_packets
int Read-only¶
-
tx_bytes
int Read-only¶
-
tx_bytes_rate
int Read-only¶
-
tx_collisions
int Read-only¶
-
tx_deferred
int Read-only¶
-
tx_excessive
int Read-only¶
-
tx_fcs
int Read-only¶
-
tx_late
int Read-only¶
-
tx_multicast_packets
int Read-only¶
-
tx_multiple
int Read-only¶
-
tx_packets
int Read-only¶
-
tx_packets_rate
int Read-only¶
-
tx_pause
int Read-only¶
-
tx_single
int Read-only¶
-
tx_unicast_packets
int Read-only¶
-
Switch API¶
Get the current switch status¶
-
GET
/api/v4/switch/status/
¶ Return the list of swith port status
SwitchPortStatus
Example request:
GET /api/v4/switch/status/ HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": [ { "duplex": "half", "link": "down", "id": 3, "mode": "10BaseT-HD", "speed": "10" }, { "duplex": "full", "link": "up", "id": 1, "mode": "1000BaseT-FD", "speed": "1000" }, { "duplex": "half", "link": "down", "id": 2, "mode": "10BaseT-HD", "speed": "10" }, { "duplex": "full", "mac_list": [ { "mac": "00:24:D4:7E:00:4C", "hostname": "r0ro's player" } ], "link": "up", "id": 4, "mode": "1000BaseT-FD", "speed": "1000" } ] }
Get a port configuration¶
-
GET
/api/v4/switch/port/{id}
¶ Get the
SwitchPortConfig
for the given port idExample request:
GET /api/v4/switch/port/1 HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "id": 1, "speed": "auto", "duplex": "auto" } }
Update a port configuration¶
-
PUT
/api/v4/switch/port/{id}
¶ Update the
SwitchPortConfig
for the given port idExample request:
PUT /api/v4/switch/port/1 HTTP/1.1 Host: mafreebox.freebox.fr
{ "speed": "10" }
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "id": 4, "speed": "10", "duplex": "auto" } }
Get a port stats¶
-
GET
/api/v4/switch/port/{id}/stats
¶ Get the
SwitchPortStats
for the given port idExample request:
GET /api/v4/switch/port/4/stats HTTP/1.1 Host: mafreebox.freebox.fr
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8
{ "success": true, "result": { "rx_packets_rate": 4, "rx_good_bytes": 20018805, "rx_oversize_packets": 0, "rx_unicast_packets": 113034, "tx_bytes_rate": 736, "tx_unicast_packets": 112409, "rx_bytes_rate": 608, "tx_packets": 166266, "tx_collisions": 0, "tx_packets_rate": 6, "tx_fcs": 0, "tx_bytes": 25316860, "rx_jabber_packets": 0, "tx_single": 0, "tx_excessive": 0, "rx_pause": 0, "rx_multicast_packets": 1217, "tx_pause": 0, "rx_good_packets": 114296, "rx_broadcast_packets": 45, "tx_multiple": 0, "tx_deferred": 0, "tx_late": 0, "tx_multicast_packets": 27962, "rx_fcs_packets": 0, "tx_broadcast_packets": 25895, "rx_err_packets": 0, "rx_fragments_packets": 0, "rx_bad_bytes": 0, "rx_undersize_packets": 0 } }