| Path: | lib/ohai/plugins/windows/network.rb |
| Last Update: | Mon Oct 26 19:44:02 +0000 2009 |
| Author: | James Gartrell (<jgartrel@gmail.com>) |
| Copyright: | Copyright (c) 2008 Opscode, Inc. |
| License: | Apache License, Version 2.0 |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
# File lib/ohai/plugins/windows/network.rb, line 26
26: def derive_bcast(ipaddr, ipmask, zero_bcast = false)
27: begin
28: ipaddr_int = ipaddr.split(".").collect{ |x| x.to_i}.pack("C4").unpack("N").first
29: ipmask_int = ipmask.split(".").collect{ |x| x.to_i}.pack("C4").unpack("N").first
30: if zero_bcast
31: bcast_int = ipaddr_int & ipmask_int
32: else
33: bcast_int = ipaddr_int | 2 ** 32 - ipmask_int - 1
34: end
35: bcast = [bcast_int].pack("N").unpack("C4").join(".")
36: return bcast
37: rescue
38: return nil
39: end
40: end