Skip to content

Commit

Permalink
Phy layer check does driver initialization to ensure proper detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Apr 25, 2014
1 parent 0cea678 commit eae539e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/include/network/routines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1037,16 +1037,27 @@ def SetAllLinksUp
ret
end

# Checks if given device is physically connected to a network
# Checks if given device has carrier
#
# @return [boolean] true if physical layer is connected
def phy_connected?(dev_name)
# @return [boolean] true if device has carrier
def has_carrier?(dev_name)
SCR.Read(
path(".target.string"),
"/sys/class/net/#{dev_name}/carrier"
).to_i != 0
end

# Checks if device is physically connected to a network
#
# It does neccessary steps which might be needed for proper initialization
# of devices driver.
#
# @return [boolean] true if physical layer is connected
def phy_connected?(dev_name)
# SetLinkUp ensures that driver is properly initialized
SetLinkUp(dev_name) && has_carrier?(dev_name)
end

def validPrefixOrNetmask(ip, mask)
valid_mask = false
if Builtins.substring(mask, 0, 1) == "/"
Expand Down

0 comments on commit eae539e

Please sign in to comment.