' Gambas module file

Public device_assign_type As String
Public subsystem_device As String
Public subsystem_vendor As String
Public device_address As String
Public device_addr_len As String
Public device_broadcast As String
Public device_carrier As String
Public device_dev_id As String
Public device_dormant As String
Public device_duplex As String
Public device_flags As String
Public device_ifalias As String
Public device_ifindex As String
Public device_iflink As String
Public device_link_mode As String
Public device_mtu As String
Public device_netdev_group As String '
Public device_operstate As String
Public device_speed As String
Public device_tx_queue_len As String
Public device_type As String
Public lspci As String
Private set_interface As String

Public Sub inits()
  Dim sdx As String
  Dim Avail_Net As Integer 
  Dim Max_Net As Integer
  Dim cache As String
  Debug "Add Network Devices to ComboBox"
  Shell "ls /sys/class/net/ | wc -l" Wait To cache
  Max_Net = Replace(Replace(cache, " ", ""), "\n", "")
  For Avail_Net = 1 To Max_Net
   Shell "ls /sys/class/net/ | sed -n '" & Avail_Net & "p'" Wait To sdx
   sdx = Replace(sdx, "\n", "")
   Finfosys.ComboBox2.Add(sdx)
  Next
  Shell "ls /sys/class/net/ | sed -n '1p'" Wait To set_interface
  set_interface = Replace(set_interface, "\n", "")
  Finfosys.ComboBox2.Text = set_interface
End

Public Sub get_informations_about_net_interface()
 
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/addr_assign_type" Wait To device_assign_type
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/device/device" Wait To subsystem_device
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/device/vendor" Wait To subsystem_vendor
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/address" Wait To device_address
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/addr_len" Wait To device_addr_len
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/broadcast" Wait To device_broadcast
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/carrier" Wait To device_carrier
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/dev_id" Wait To device_dev_id
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/dormant" Wait To device_dormant
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/duplex" Wait To device_duplex
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/flags" Wait To device_flags
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/ifalias" Wait To device_ifalias
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/ifindex" Wait To device_ifindex
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/iflink" Wait To device_iflink
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/link_mode" Wait To device_link_mode
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/mtu" Wait To device_mtu
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/netdev_group" Wait To device_netdev_group
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/operstate" Wait To device_operstate
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/speed" Wait To device_speed
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/tx_queue_len" Wait To device_tx_queue_len
 Shell "cat /sys/class/net/" & Finfosys.ComboBox2.Text & "/type" Wait To device_type
 subsystem_device = Replace(subsystem_device, "\n", "")
 subsystem_vendor = Replace(subsystem_vendor, "\n", "")
  If subsystem_device Like "*0x*" Then
  Shell "lspci -d " & subsystem_vendor & ":" & subsystem_device & " | cut -d ':' -f 3 | cut -d '(' -f 1" Wait To lspci
     lspci = Replace(lspci, "\n", "")
  Else
     lspci = Null
  Endif
 
 _replace()
End

Public Sub _replace()
 
 device_address = Replace(device_address, "\n", "")
 device_addr_len = Replace(device_addr_len, "\n", "")
 device_assign_type = Replace(device_assign_type, "\n", "")
 device_broadcast = Replace(device_broadcast, "\n", "")
 device_carrier = Replace(device_carrier, "\n", "")
 device_dev_id = Replace(device_dev_id, "\n", "")
 device_dormant = Replace(device_dormant, "\n", "")
 device_duplex = Replace(device_duplex, "\n", "")
 device_flags = Replace(device_flags, "\n", "")
 device_ifalias = Replace(device_ifalias, "\n", "")
 device_ifindex = Replace(device_ifindex, "\n", "")
 device_iflink = Replace(device_iflink, "\n", "")
 device_link_mode = Replace(device_link_mode, "\n", "")
 device_mtu = Replace(device_mtu, "\n", "")
 device_netdev_group = Replace(device_netdev_group, "\n", "")
 device_operstate = Replace(device_operstate, "\n", "")
 device_speed = Replace(device_speed, "\n", "")
 device_tx_queue_len = Replace(device_tx_queue_len, "\n", "")
 device_type = Replace(device_type, "\n", "")
 
End

Public Sub net_dev()
 
End


