| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import QtQuick 2.6
- import QtQuick.Window 2.2
- import gfa.plugins.qml.net 1.0
- Window {
- visible: true
- width: 640
- height: 480
- title: qsTr("Hello World")
- Text {
- id: idIpAddr
- x: 5
- y: 40
- color: "blue"
- font.pixelSize: 14
- text: idItf.interfaces[2].inet.stat.ipAddress.address
- }
- NetInterfaces {
- id: idItf
- // itfFilterName: "eth0"
- itfFilterAF: Interface.AF_Inet
- itfFilterMethod: Interface.IM_Static | Interface.IM_Manual
- onError:
- {
- console.error(msg);
- }
- onFilteredInterfacesChanged:
- {
- console.warn("Filtered Interfaces may have changed!");
- }
- }
- MouseArea {
- anchors.fill: parent
- onClicked:
- {
- if(idItf.filteredInterfaces.length > 0)
- {
- idItf.filteredInterfaces[0].inet.stat.ipAddress.address = "155.18.2.156";
- idItf.filteredInterfaces[0].inet.stat.ipAddress.b2 = 255;
- console.log(idItf.filteredInterfaces[0].inet.stat.ipAddress.address);
- }
- else
- {
- console.warn("No interface found!");
- }
- idItf.itfFilterMethod |= Interface.IM_Dhcp;
- idItf.itfFilterMethod &= ~Interface.IM_Manual;
- var itfn = idItf.newInterface("test1", Interface.AF_Inet6, Interface.IM_Dhcp);
- itfn.af = Interface.AF_Inet;
- itfn.inet.stat.ipAddress.address = "192.168.3.24";
- itfn.inet.stat.netMask.address = "255.255.254.0";
- itfn.inet.stat.netPrefix = 22;
- itfn.method = Interface.IM_Static;
- itfn.inet.stat.gateway.b0 = 192;
- itfn.inet.stat.gateway.b1 = 168;
- itfn.inet.stat.gateway.b2 = 0;
- itfn.inet.stat.gateway.b3 = 1;
- itfn.inet.stat.dnsServer[0].address = "8.8.8.8";
- itfn.inet.stat.dnsServer[1].address = "8.8.4.4";
- // idItf.removeInterface(itfn);
- idItf.saveAs("/home/wrk/share/gfanet/libgfanet/res/testitf");
- }
- }
- }
|