From a0821eb4751e9d96085c46e050b6fa5fd6318622 Mon Sep 17 00:00:00 2001
From: Pierre LALET <pierre.lalet@cea.fr>
Date: Wed, 21 Dec 2016 12:55:34 +0100
Subject: [PATCH] Clean-up & fix DHCP pools

---
 scapy/layers/dhcp.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scapy/layers/dhcp.py b/scapy/layers/dhcp.py
index 612d72f7..8572fe9c 100644
--- a/scapy/layers/dhcp.py
+++ b/scapy/layers/dhcp.py
@@ -7,6 +7,7 @@
 DHCP (Dynamic Host Configuration Protocol) d BOOTP
 """
 
+from collections import Iterable
 import struct
 
 from scapy.packet import *
@@ -301,8 +302,6 @@ class BOOTP_am(AnsweringMachine):
     send_function = staticmethod(sendp)
     def parse_options(self, pool=Net("192.168.1.128/25"), network="192.168.1.0/24",gw="192.168.1.1",
                       domain="localnet", renewal_time=60, lease_time=1800):
-        if type(pool) is str:
-            poom = Net(pool)
         self.domain = domain
         netw,msk = (network.split("/")+["32"])[:2]
         msk = itom(int(msk))
@@ -310,7 +309,9 @@ class BOOTP_am(AnsweringMachine):
         self.network = ltoa(atol(netw)&msk)
         self.broadcast = ltoa( atol(self.network) | (0xffffffff&~msk) )
         self.gw = gw
-        if isinstance(pool,Gen):
+        if isinstance(pool, basestring):
+            pool = Net(pool)
+        if isinstance(pool, Iterable):
             pool = [k for k in pool if k not in [gw, self.network, self.broadcast]]
             pool.reverse()
         if len(pool) == 1:
-- 
GitLab