diff options
author | David Cantrell <dcantrell@redhat.com> | 2006-10-03 18:28:18 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2006-10-03 18:28:18 +0000 |
commit | 8d0364df93d72b9dc1497e7044a48c5d01de6009 (patch) | |
tree | b269771240b34e61e97c888743a9986bac5f1a6b /isys/isys.py | |
parent | bc01ad83ca869f7ef6cd2b4eb29e7cca5516e92e (diff) | |
download | anaconda-8d0364df93d72b9dc1497e7044a48c5d01de6009.tar.gz anaconda-8d0364df93d72b9dc1497e7044a48c5d01de6009.tar.xz anaconda-8d0364df93d72b9dc1497e7044a48c5d01de6009.zip |
* iw/network_gui.py (NetworkWindow): Use isys.netmask2prefix() and
isys.prefix2netmask() correctly.
* textw/network_text.py (NetworkDeviceWindow): Use isys.prefix2netmask()
correctly.
* isys/isys.c (doPrefixToNetmask): Renamed to a shorter function name
and it somewhat matches what the isys.py passthrough is called. We
also take an int as the argument now and return a string.
* isys/isys.py (netmask2prefix): Added this function to replace the
borken inet_convertNetmaskToPrefix() function.
Diffstat (limited to 'isys/isys.py')
-rw-r--r-- | isys/isys.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/isys/isys.py b/isys/isys.py index f62148e85..62d6026cb 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -436,19 +436,6 @@ def inet_calcNetBroad (ip, nm): return (nw, bc) -# Converts IPv4 netmasks in dotted-quad notation to the CIDR prefix -def inet_convertNetmaskToPrefix (netmask): - (nm,) = struct.unpack('I', socket.inet_pton(socket.AF_INET, netmask)) - prefix = 0 - - while prefix < 33: - if (nm >> prefix) == 0: - return prefix - - prefix += 1 - - return prefix - def getopt(*args): warnings.warn("isys.getopt is deprecated. Use optparse instead.", DeprecationWarning, stacklevel=2) @@ -882,6 +869,17 @@ def resetFileContext(fn, instroot = '/'): def prefix2netmask(prefix): return _isys.prefix2netmask(prefix) +def netmask2prefix (netmask): + prefix = 0 + + while prefix < 33: + if (prefix2netmask(prefix) == netmask): + return prefix + + prefix += 1 + + return prefix + auditDaemon = _isys.auditdaemon handleSegv = _isys.handleSegv |