Compare commits

..

No commits in common. "20d582ae93862133f0857719b29b424632fbfe52" and "3f83a169c8ca1470d433bd5c995ab66080eb9e3d" have entirely different histories.

4 changed files with 3 additions and 201 deletions

View File

@ -1,47 +0,0 @@
From b6c4203f85dba18074971208c0602c5bada90e8b Mon Sep 17 00:00:00 2001
From: amitmi704 <36094800+amitmi704@users.noreply.github.com>
Date: Sun, 7 Feb 2021 18:54:27 -0600
Subject: [PATCH] Add hash capabilities to OUI (#225)
Closes #224
---
netaddr/eui/__init__.py | 3 +++
netaddr/tests/eui/test_eui.py | 8 ++++++++
2 files changed, 11 insertions(+)
diff --git a/netaddr/eui/__init__.py b/netaddr/eui/__init__.py
index 5639676..07bbdc3 100644
--- a/netaddr/eui/__init__.py
+++ b/netaddr/eui/__init__.py
@@ -100,6 +100,9 @@ class OUI(BaseIdentifier):
else:
raise NotRegisteredError('OUI %r not registered!' % (oui,))
+ def __hash__(self):
+ return hash(self._value)
+
def __eq__(self, other):
if not isinstance(other, OUI):
try:
diff --git a/netaddr/tests/eui/test_eui.py b/netaddr/tests/eui/test_eui.py
index 645a518..c17d0ce 100644
--- a/netaddr/tests/eui/test_eui.py
+++ b/netaddr/tests/eui/test_eui.py
@@ -186,6 +186,14 @@ def test_oui_constructor():
assert oui.reg_count == 3
+def test_oui_hash():
+ oui0 = OUI(0)
+ oui1 = OUI(1)
+ oui_dict = {oui0: None, oui1: None}
+
+ assert list(oui_dict.keys()) == [OUI(0), OUI(1)]
+
+
def test_eui_iab():
mac = EUI('00-50-C2-00-0F-01')
assert mac.is_iab()
--
2.42.0.windows.2

View File

@ -1,68 +0,0 @@
From 606a44b62ea7032f63e359aaaaabc0057e168890 Mon Sep 17 00:00:00 2001
From: niels <nkeulen@gmail.com>
Date: Wed, 27 Jan 2021 20:44:12 +0100
Subject: [PATCH] Fix for is_loopback behaviour (issue: #222) (#223)
---
netaddr/ip/__init__.py | 4 +--
.../tests/ip/test_ip_network_categories.py | 26 +++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 netaddr/tests/ip/test_ip_network_categories.py
diff --git a/netaddr/ip/__init__.py b/netaddr/ip/__init__.py
index d1232eb..9e13b29 100644
--- a/netaddr/ip/__init__.py
+++ b/netaddr/ip/__init__.py
@@ -151,7 +151,7 @@ class BaseIP(object):
if self._module.version == 4:
return self in IPV4_LOOPBACK
elif self._module.version == 6:
- return self == IPV6_LOOPBACK
+ return self in IPV6_LOOPBACK
def is_private(self):
"""
@@ -1949,7 +1949,7 @@ IPV4_RESERVED = (
#-----------------------------------------------------------------------------
# Cached IPv6 address range lookups.
#-----------------------------------------------------------------------------
-IPV6_LOOPBACK = IPAddress('::1')
+IPV6_LOOPBACK = IPNetwork('::1/128')
IPV6_PRIVATE = (
IPNetwork('fc00::/7'), # Unique Local Addresses (ULA)
diff --git a/netaddr/tests/ip/test_ip_network_categories.py b/netaddr/tests/ip/test_ip_network_categories.py
new file mode 100644
index 0000000..9f9961e
--- /dev/null
+++ b/netaddr/tests/ip/test_ip_network_categories.py
@@ -0,0 +1,26 @@
+from netaddr import IPNetwork
+
+
+def test_is_unicast():
+ assert IPNetwork('192.0.2.0/24').is_unicast()
+ assert IPNetwork('fe80::1/48').is_unicast()
+
+
+def test_is_multicast():
+ assert IPNetwork('239.192.0.1/24').is_multicast()
+ assert IPNetwork('ff00::/8').is_multicast()
+
+
+def test_is_private():
+ assert IPNetwork('10.0.0.0/24').is_private()
+ assert IPNetwork('fc00::/7').is_private()
+
+
+def test_is_reserved():
+ assert IPNetwork('240.0.0.0/24').is_reserved()
+ assert IPNetwork('0::/48').is_reserved()
+
+
+def test_is_loopback():
+ assert IPNetwork('127.0.0.0/8').is_loopback()
+ assert IPNetwork('::1/128').is_loopback()
--
2.33.0

View File

@ -1,64 +0,0 @@
From 76fe3af427a1316a91c96e01de1f0407893121a9 Mon Sep 17 00:00:00 2001
From: hanhui <hanhui15@h-partners.com>
Date: Sat, 26 Mar 2022 16:23:45 +0800
Subject: [PATCH] disable-test-oui-information
reason:elimate-ROC-in-python-netaddr.patch lead to
oui.registration.org and oui.registration.address
changed,cause the failure of test cases.
Therefore, disable the test code
---
netaddr/tests/eui/test_eui.py | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/netaddr/tests/eui/test_eui.py b/netaddr/tests/eui/test_eui.py
index 645a518..b8dcedd 100644
--- a/netaddr/tests/eui/test_eui.py
+++ b/netaddr/tests/eui/test_eui.py
@@ -146,42 +146,15 @@ def test_eui_oui_information():
oui = mac.oui
assert str(oui) == '00-1B-77'
- assert oui.registration().address == [
- 'Lot 8, Jalan Hi-Tech 2/3',
- 'Kulim Kedah 09000',
- 'MY'
- ]
-
- assert oui.registration().org == 'Intel Corporate'
-
-
def test_oui_constructor():
oui = OUI(524336)
assert str(oui) == '08-00-30'
assert oui == OUI('08-00-30')
- assert oui.registration(0).address == [
- '2380 N. ROSE AVENUE',
- 'OXNARD CA 93010',
- 'US'
- ]
- assert oui.registration(0).org == 'NETWORK RESEARCH CORPORATION'
assert oui.registration(0).oui == '08-00-30'
- assert oui.registration(1).address == [
- 'GPO BOX 2476V',
- 'MELBOURNE VIC 3001',
- 'AU',
- ]
- assert oui.registration(1).org == 'ROYAL MELBOURNE INST OF TECH'
assert oui.registration(1).oui == '08-00-30'
- assert oui.registration(2).address == [
- 'CH-1211',
- 'GENEVE SUISSE/SWITZ 023',
- 'CH'
- ]
- assert oui.registration(2).org == 'CERN'
assert oui.registration(2).oui == '08-00-30'
assert oui.reg_count == 3
--
2.33.0

View File

@ -1,16 +1,13 @@
Name: python-netaddr
Version: 0.8.0
Release: 7
Release: 2
Summary: A pure Python network address representation and manipulation library
License: BSD-3-Clause
License: BSD
URL: http://github.com/drkjam/netaddr
Source0: https://pypi.python.org/packages/source/n/netaddr/netaddr-%{version}.tar.gz
Patch9000: elimate-ROC-in-python-netaddr.patch
Patch9001: disable-test-oui-information.patch
Patch9002: 0001-Fix-for-is_loopback-behaviour-issue-222-223.patch
Patch9003: 0001-Add-hash-capabilities-to-OUI-225.patch
BuildArch: noarch
BuildRequires: python3-devel python3-setuptools python3-sphinx python3-pytest
@ -49,31 +46,15 @@ PYTHONPATH='../' sphinx-build-%{python3_version} -b html -d build/doctrees sourc
%py3_install
%check
py.test-%{python3_version}
%{__python3} setup.py test
%files -n python3-netaddr
%exclude %{python3_sitelib}/netaddr/eui/oui.txt
%license COPYRIGHT
%doc AUTHORS CHANGELOG README.rst docs/python3/html
%{python3_sitelib}/*
%{_bindir}/netaddr
%changelog
* Tue Nov 14 2023 liubo <liubo1@xfusion.com> - 0.8.0-7
- Add hash capabilities to OUI
* Tue Jun 13 2023 zhangpan <zhangpan103@h-partners.com> - 0.8.0-6
- delete taboo words
* Tue Jan 17 2023 caofei <caofei@xfusion.com> - 0.8.0-5
- Fix for is_loopback behaviour (issue: #222)
* Wed May 11 2022 wulei <wulei80@h-partners.com> - 0.8.0-4
- License compliance rectification
* Sat Mar 26 2022 hanhui <hanhui15@h-partners.com> - 0.8.0-3
- enable testcase
* Mon Jan 17 2022 xingxing <xingxing9@huawei.com> - 0.8.0-2
- delete more sensitive keyword