Bridge : Network bridge
This module is a Bridge device operation module that supports layer two network switching.
User can use the following code to import the Bridge
module.
var Bridge = require('router/bridge');
Support
The following shows Bridge
module APIs available for each permissions.
User Mode | Privilege Mode | |
---|---|---|
Bridge | ● | |
Bridge.add | ● | |
bridge.index | ● | |
bridge.subif | ● | |
bridge.delete | ● | |
bridge.ifAdd | ● | |
bridge.ifDelete | ● |
Bridge Class
new Bridge(brname)
brname
{String} Bridge net device name.- Returns: {Object} Returns bridge object.
Create a bridge device with the specified name.
Example
var bridge = new Bridge('brdev0');
Bridge.add(brname)
brname
{String} Bridge net device name.- Returns: {Object} Returns bridge object.
Same as new Bridge(brname)
.
Bridge Object
bridge.index
- {Integer}
Bridge device network interface index number. A network interface index greater than 0 is considered valid.
bridge.subif
- {Array}
List of network interface contained within the bridge device.
Example
var bridge = new Bridge('brdev0');
bridge.ifAdd('en1');
bridge.ifAdd('wl3');
console.log(bridge.subif); // ['en1', 'wl3']
bridge.delete()
- Returns: {Boolean} Whether the operation was successful.
Remove the previously created bridge device, and the network interfaces in the bridge device will be re-added to the system. This object cannot be operated here after the bridge device is removed.
Example
var bridge = new Bridge('brdev0');
bridge.delete();
bridge = null;
bridge.ifAdd(ifname)
ifname
{String} Network interface name.- Returns: {Boolean} Whether the operation was successful.
Add a network interface to the bridge device, currently only supports Ethernet MAC standard.
bridge.ifDelete(ifname)
ifname
{String} Network interface name added before.- Returns: {Boolean} Whether the operation was successful.
Remove a previously added network interface from the bridge device. The removed network interface will be recognized by the operating system again and added to the working device.
Example
var bridge = new Bridge('brdev0');
bridge.ifAdd('en1');
bridge.ifDelete('en1');