Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved ip4_config#nameservers and refactored whole ip4 stuff
- Loading branch information
Showing
11 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module NetworkManager::Ip4 | ||
# require all .rb files from lib/network_manager/ip4 | ||
Dir.glob(File.join(File.dirname(__FILE__), "ip4/*.rb")).each do |p| | ||
require p | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module NetworkManager::Ip4::Calculations | ||
def self.revert_octects(ipv4) | ||
IPAddress::IPv4.new(ipv4.octets.reverse.join('.')) | ||
end | ||
|
||
def self.ip4_from_u32(address_u32) | ||
revert_octects(IPAddress::IPv4.parse_u32(address_u32)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe "NetworkManager::Ip4::Calculations" do | ||
it 'should #ip4_from_u32' do | ||
network_manager_dbus_mock | ||
ip4 = NetworkManager::Ip4::Calculations.ip4_from_u32 118139072 | ||
ip4.to_s.should == '192.168.10.7' | ||
end | ||
|
||
it 'should #revert_octects' do | ||
network_manager_dbus_mock | ||
ip4 = NetworkManager::Ip4::Calculations.revert_octects IPAddress::IPv4.new('192.168.10.7') | ||
ip4.to_s.should == '7.10.168.192' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters