Remove longs and fix octals
diff --git a/scapy/arch/unix.py b/scapy/arch/unix.py
index 725d17d..f85f4b6 100644
--- a/scapy/arch/unix.py
+++ b/scapy/arch/unix.py
@@ -82,8 +82,8 @@
if flg.find("Lc") >= 0:
continue
if dest == "default":
- dest = 0L
- netmask = 0L
+ dest = 0
+ netmask = 0
else:
if SOLARIS:
netmask = scapy.utils.atol(mask)
diff --git a/scapy/asn1/ber.py b/scapy/asn1/ber.py
index 9c55656..97fc4a0 100644
--- a/scapy/asn1/ber.py
+++ b/scapy/asn1/ber.py
@@ -62,7 +62,7 @@
s = ""
while l or size>0:
s = chr(l&0xff)+s
- l >>= 8L
+ l >>= 8
size -= 1
if len(s) > 127:
raise BER_Exception("BER_len_enc: Length too long (%i) to be encoded [%r]" % (len(s),s))
@@ -74,9 +74,9 @@
l &= 0x7f
if len(s) <= l:
raise BER_Decoding_Error("BER_len_dec: Got %i bytes while expecting %i" % (len(s)-1, l),remaining=s)
- ll = 0L
+ ll = 0
for c in s[1:l+1]:
- ll <<= 8L
+ ll <<= 8
ll |= ord(c)
return ll,s[l+1:]
@@ -290,10 +290,10 @@
@classmethod
def do_dec(cls, s, context=None, safe=False):
l,s,t = cls.check_type_check_len(s)
- x = 0L
+ x = 0
if s:
if ord(s[0])&0x80: # negative int
- x = -1L
+ x = -1
for c in s:
x <<= 8
x |= ord(c)
diff --git a/scapy/base_classes.py b/scapy/base_classes.py
index 8cd7e19..a97e582 100644
--- a/scapy/base_classes.py
+++ b/scapy/base_classes.py
@@ -60,9 +60,9 @@
x,y = map(int,a.split("-"))
if x > y:
y = x
- a = (x & (0xffL<<netmask) , max(y, (x | (0xffL>>(8-netmask))))+1)
+ a = (x & (0xff<<netmask) , max(y, (x | (0xff>>(8-netmask))))+1)
else:
- a = (int(a) & (0xffL<<netmask),(int(a) | (0xffL>>(8-netmask)))+1)
+ a = (int(a) & (0xff<<netmask),(int(a) | (0xff>>(8-netmask)))+1)
return a
@classmethod
diff --git a/scapy/fields.py b/scapy/fields.py
index 4f2fcc6..645f741 100644
--- a/scapy/fields.py
+++ b/scapy/fields.py
@@ -738,12 +738,12 @@
if self.rev:
val = self.reverse(val)
v <<= self.size
- v |= val & ((1L<<self.size) - 1)
+ v |= val & ((1<<self.size) - 1)
bitsdone += self.size
while bitsdone >= 8:
bitsdone -= 8
s = s+struct.pack("!B", v >> bitsdone)
- v &= (1L<<bitsdone)-1
+ v &= (1<<bitsdone)-1
if bitsdone:
return s,bitsdone,v
else:
@@ -760,12 +760,12 @@
# split the substring byte by byte
bytes = struct.unpack('!%dB' % nb_bytes , w)
- b = 0L
+ b = 0
for c in xrange(nb_bytes):
b |= long(bytes[c]) << (nb_bytes-c-1)*8
# get rid of high order bits
- b &= (1L << (nb_bytes*8-bn)) - 1
+ b &= (1 << (nb_bytes*8-bn)) - 1
# remove low order bits
b = b >> (nb_bytes*8 - self.size - bn)
@@ -1235,7 +1235,7 @@
def i2h(self, pkt, val):
int_part = val >> self.frac_bits
- frac_part = val & (1L << self.frac_bits) - 1
+ frac_part = val & (1 << self.frac_bits) - 1
frac_part /= 2.0**self.frac_bits
return int_part+frac_part
def i2repr(self, pkt, val):
diff --git a/scapy/layers/bluetooth.py b/scapy/layers/bluetooth.py
index f37394a..e17aac0 100644
--- a/scapy/layers/bluetooth.py
+++ b/scapy/layers/bluetooth.py
@@ -783,7 +783,7 @@
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)
s.setsockopt(socket.SOL_HCI, socket.HCI_DATA_DIR,1)
s.setsockopt(socket.SOL_HCI, socket.HCI_TIME_STAMP,1)
- s.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, struct.pack("IIIh2x", 0xffffffffL,0xffffffffL,0xffffffffL,0)) #type mask, event mask, event mask, opcode
+ s.setsockopt(socket.SOL_HCI, socket.HCI_FILTER, struct.pack("IIIh2x", 0xffffffff,0xffffffff,0xffffffff,0)) #type mask, event mask, event mask, opcode
s.bind((iface,))
self.ins = self.outs = s
# s.connect((peer,0))
diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py
index bba5d30..20afedf 100644
--- a/scapy/layers/inet6.py
+++ b/scapy/layers/inet6.py
@@ -170,7 +170,7 @@
def parse_digit(a, netmask):
netmask = min(8,max(netmask,0))
- a = (int(a) & (0xffL<<netmask),(int(a) | (0xffL>>(8-netmask)))+1)
+ a = (int(a) & (0xff<<netmask),(int(a) | (0xff>>(8-netmask)))+1)
return a
self.parsed = map(lambda x,y: parse_digit(x,y), tmp, map(lambda x,nm=self.plen: x-nm, tuple))
@@ -1671,8 +1671,8 @@
BitField("A",1,1),
BitField("R",0,1),
BitField("res1",0,5),
- XIntField("validlifetime",0xffffffffL),
- XIntField("preferredlifetime",0xffffffffL),
+ XIntField("validlifetime",0xffffffff),
+ XIntField("preferredlifetime",0xffffffff),
XIntField("res2",0x00000000),
IP6Field("prefix","::") ]
def mysummary(self):
diff --git a/scapy/layers/ir.py b/scapy/layers/ir.py
index fc738c5..90935aa 100644
--- a/scapy/layers/ir.py
+++ b/scapy/layers/ir.py
@@ -26,7 +26,7 @@
fields_desc = [ XByteField("Control", 0),
XByteField("Format identifier", 0),
XIntField("Source address", 0),
- XIntField("Destination address", 0xffffffffL),
+ XIntField("Destination address", 0xffffffff),
XByteField("Discovery flags", 0x1),
ByteEnumField("Slot number", 255, {"final":255}),
XByteField("Version", 0)]
diff --git a/scapy/layers/isakmp.py b/scapy/layers/isakmp.py
index 90c703c..74d9778 100644
--- a/scapy/layers/isakmp.py
+++ b/scapy/layers/isakmp.py
@@ -144,7 +144,7 @@
if value_len+4 > len(m):
warning("Bad length for ISAKMP tranform type=%#6x" % trans_type)
value = m[4:4+value_len]
- value = reduce(lambda x,y: (x<<8L)|y, struct.unpack("!%s" % ("B"*len(value),), value),0)
+ value = reduce(lambda x,y: (x<<8)|y, struct.unpack("!%s" % ("B"*len(value),), value),0)
else:
trans_type &= 0x7fff
value_len=0
diff --git a/scapy/layers/netbios.py b/scapy/layers/netbios.py
index 605e06f..156adb7 100644
--- a/scapy/layers/netbios.py
+++ b/scapy/layers/netbios.py
@@ -89,7 +89,7 @@
IntField("TTL", 0),
ShortField("RDLENGTH", 6),
BitEnumField("G",0,1,{0:"Unique name",1:"Group name"}),
- BitEnumField("OWNER_NODE_TYPE",00,2,{00:"B node",01:"P node",02:"M node",03:"H node"}),
+ BitEnumField("OWNER_NODE_TYPE",00,2,{0:"B node",1:"P node",2:"M node",3:"H node"}),
BitEnumField("UNUSED",0,13,{0:"Unused"}),
IPField("NB_ADDRESS", "127.0.0.1")]
@@ -131,7 +131,7 @@
IntField("TTL",0),
ShortField("RDLENGTH",6),
BitEnumField("G",0,1,{0:"Unique name",1:"Group name"}),
- BitEnumField("OWNER_NODE_TYPE",00,2,{00:"B node",01:"P node",02:"M node",03:"H node"}),
+ BitEnumField("OWNER_NODE_TYPE",00,2,{0:"B node",1:"P node",2:"M node",3:"H node"}),
BitEnumField("UNUSED",0,13,{0:"Unused"}),
IPField("NB_ADDRESS", "127.0.0.1")]
diff --git a/scapy/layers/smb.py b/scapy/layers/smb.py
index 271e500..c1b478c 100644
--- a/scapy/layers/smb.py
+++ b/scapy/layers/smb.py
@@ -168,7 +168,7 @@
BitField("CompBulk",0,2),
BitField("Reserved3",0,5),
# There have been 127490112000000000 tenths of micro-seconds between 1st january 1601 and 1st january 2005. 127490112000000000=0x1C4EF94D6228000, so ServerTimeHigh=0xD6228000 and ServerTimeLow=0x1C4EF94.
- LEIntField("ServerTimeHigh",0xD6228000L),
+ LEIntField("ServerTimeHigh",0xD6228000),
LEIntField("ServerTimeLow",0x1C4EF94),
LEShortField("ServerTimeZone",0x3c),
ByteField("EncryptionKeyLength",0),
@@ -209,7 +209,7 @@
FlagsField("CompBulk",0,2,"CB"),
BitField("Reserved3",0,5),
# There have been 127490112000000000 tenths of micro-seconds between 1st january 1601 and 1st january 2005. 127490112000000000=0x1C4EF94D6228000, so ServerTimeHigh=0xD6228000 and ServerTimeLow=0x1C4EF94.
- LEIntField("ServerTimeHigh",0xD6228000L),
+ LEIntField("ServerTimeHigh",0xD6228000),
LEIntField("ServerTimeLow",0x1C4EF94),
LEShortField("ServerTimeZone",0x3c),
ByteField("EncryptionKeyLength",8),
@@ -250,7 +250,7 @@
FlagsField("CompBulk",0,2,"CB"),
BitField("Reserved3",0,5),
# There have been 127490112000000000 tenths of micro-seconds between 1st january 1601 and 1st january 2005. 127490112000000000=0x1C4EF94D6228000, so ServerTimeHigh=0xD6228000 and ServerTimeLow=0x1C4EF94.
- LEIntField("ServerTimeHigh",0xD6228000L),
+ LEIntField("ServerTimeHigh",0xD6228000),
LEIntField("ServerTimeLow",0x1C4EF94),
LEShortField("ServerTimeZone",0x3c),
ByteField("EncryptionKeyLength",0),
diff --git a/scapy/modules/p0f.py b/scapy/modules/p0f.py
index ac7b684..499aea6 100644
--- a/scapy/modules/p0f.py
+++ b/scapy/modules/p0f.py
@@ -391,9 +391,9 @@
# MSS might have a maximum size because of window size
# specification
if pers[0][0] == 'S':
- maxmss = (2L**16-1) / int(pers[0][1:])
+ maxmss = (2**16-1) / int(pers[0][1:])
else:
- maxmss = (2L**16-1)
+ maxmss = (2**16-1)
# If we have to randomly pick up a value, we cannot use
# scapy RandXXX() functions, because the value has to be
# set in case we need it for the window size value. That's
@@ -411,7 +411,7 @@
elif opt[1] == '%':
coef = int(opt[2:])
options.append(('WScale', coef*RandNum(min=1,
- max=(2L**8-1)/coef)))
+ max=(2**8-1)/coef)))
else:
options.append(('WScale', int(opt[1:])))
elif opt == 'T0':
@@ -454,7 +454,7 @@
pkt.payload.window = int(pers[0])
elif pers[0][0] == '%':
coef = int(pers[0][1:])
- pkt.payload.window = coef * RandNum(min=1,max=(2L**16-1)/coef)
+ pkt.payload.window = coef * RandNum(min=1,max=(2**16-1)/coef)
elif pers[0][0] == 'T':
pkt.payload.window = mtu * int(pers[0][1:])
elif pers[0][0] == 'S':
diff --git a/scapy/route.py b/scapy/route.py
index b2e01d4..df15b12 100644
--- a/scapy/route.py
+++ b/scapy/route.py
@@ -152,7 +152,7 @@
continue
aa = atol(a)
if aa == dst:
- pathes.append((0xffffffffL,(LOOPBACK_INTERFACE,a,"0.0.0.0")))
+ pathes.append((0xffffffff,(LOOPBACK_INTERFACE,a,"0.0.0.0")))
if (dst & m) == (d & m):
pathes.append((m,(i,a,gw)))
if not pathes:
@@ -175,7 +175,7 @@
continue
elif iff != iface:
continue
- bcast = atol(addr)|(~msk&0xffffffffL); # FIXME: check error in atol()
+ bcast = atol(addr)|(~msk&0xffffffff); # FIXME: check error in atol()
return ltoa(bcast)
warning("No broadcast address found for iface %s\n" % iff);
diff --git a/scapy/tools/UTscapy.py b/scapy/tools/UTscapy.py
index 5cdf27b..63fe42a 100755
--- a/scapy/tools/UTscapy.py
+++ b/scapy/tools/UTscapy.py
@@ -298,7 +298,7 @@
#### COMPUTE CAMPAIGN DIGESTS ####
def crc32(x):
- return "%08X" % (0xffffffffL & zlib.crc32(x))
+ return "%08X" % (0xffffffff & zlib.crc32(x))
def sha1(x):
return sha.sha(x).hexdigest().upper()
diff --git a/scapy/utils.py b/scapy/utils.py
index 5f05cac..7dd8f9f 100644
--- a/scapy/utils.py
+++ b/scapy/utils.py
@@ -403,7 +403,7 @@
return inet_ntoa(struct.pack("!I", x&0xffffffff))
def itom(x):
- return (0xffffffff00000000L>>x)&0xffffffffL
+ return (0xffffffff00000000>>x)&0xffffffff
def do_graph(graph,prog=None,format=None,target=None,type=None,string=None,options=None):
"""do_graph(graph, prog=conf.prog.dot, format="svg",
@@ -1008,7 +1008,7 @@
if g.read(16):
return
- self.f.write(struct.pack(self.endian+"IHHIIII", 0xa1b23c4dL if self.nano else 0xa1b2c3d4L,
+ self.f.write(struct.pack(self.endian+"IHHIIII", 0xa1b23c4d if self.nano else 0xa1b2c3d4,
2, 4, 0, 0, MTU, self.linktype))
self.f.flush()
diff --git a/scapy/volatile.py b/scapy/volatile.py
index 0c2b5e8..230470b 100644
--- a/scapy/volatile.py
+++ b/scapy/volatile.py
@@ -133,67 +133,67 @@
class RandByte(RandNum):
def __init__(self):
- RandNum.__init__(self, 0, 2L**8-1)
+ RandNum.__init__(self, 0, 2**8-1)
class RandSByte(RandNum):
def __init__(self):
- RandNum.__init__(self, -2L**7, 2L**7-1)
+ RandNum.__init__(self, -2**7, 2**7-1)
class RandShort(RandNum):
def __init__(self):
- RandNum.__init__(self, 0, 2L**16-1)
+ RandNum.__init__(self, 0, 2**16-1)
class RandSShort(RandNum):
def __init__(self):
- RandNum.__init__(self, -2L**15, 2L**15-1)
+ RandNum.__init__(self, -2**15, 2**15-1)
class RandInt(RandNum):
def __init__(self):
- RandNum.__init__(self, 0, 2L**32-1)
+ RandNum.__init__(self, 0, 2**32-1)
class RandSInt(RandNum):
def __init__(self):
- RandNum.__init__(self, -2L**31, 2L**31-1)
+ RandNum.__init__(self, -2**31, 2**31-1)
class RandLong(RandNum):
def __init__(self):
- RandNum.__init__(self, 0, 2L**64-1)
+ RandNum.__init__(self, 0, 2**64-1)
class RandSLong(RandNum):
def __init__(self):
- RandNum.__init__(self, -2L**63, 2L**63-1)
+ RandNum.__init__(self, -2**63, 2**63-1)
class RandEnumByte(RandEnum):
def __init__(self):
- RandEnum.__init__(self, 0, 2L**8-1)
+ RandEnum.__init__(self, 0, 2**8-1)
class RandEnumSByte(RandEnum):
def __init__(self):
- RandEnum.__init__(self, -2L**7, 2L**7-1)
+ RandEnum.__init__(self, -2**7, 2**7-1)
class RandEnumShort(RandEnum):
def __init__(self):
- RandEnum.__init__(self, 0, 2L**16-1)
+ RandEnum.__init__(self, 0, 2**16-1)
class RandEnumSShort(RandEnum):
def __init__(self):
- RandEnum.__init__(self, -2L**15, 2L**15-1)
+ RandEnum.__init__(self, -2**15, 2**15-1)
class RandEnumInt(RandEnum):
def __init__(self):
- RandEnum.__init__(self, 0, 2L**32-1)
+ RandEnum.__init__(self, 0, 2**32-1)
class RandEnumSInt(RandEnum):
def __init__(self):
- RandEnum.__init__(self, -2L**31, 2L**31-1)
+ RandEnum.__init__(self, -2**31, 2**31-1)
class RandEnumLong(RandEnum):
def __init__(self):
- RandEnum.__init__(self, 0, 2L**64-1)
+ RandEnum.__init__(self, 0, 2**64-1)
class RandEnumSLong(RandEnum):
def __init__(self):
- RandEnum.__init__(self, -2L**63, 2L**63-1)
+ RandEnum.__init__(self, -2**63, 2**63-1)
class RandEnumKeys(RandEnum):
"""Picks a random value from dict keys list. """
@@ -533,35 +533,35 @@
class RandSingByte(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, 0, 2L**8-1)
+ RandSingNum.__init__(self, 0, 2**8-1)
class RandSingSByte(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, -2L**7, 2L**7-1)
+ RandSingNum.__init__(self, -2**7, 2**7-1)
class RandSingShort(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, 0, 2L**16-1)
+ RandSingNum.__init__(self, 0, 2**16-1)
class RandSingSShort(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, -2L**15, 2L**15-1)
+ RandSingNum.__init__(self, -2**15, 2**15-1)
class RandSingInt(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, 0, 2L**32-1)
+ RandSingNum.__init__(self, 0, 2**32-1)
class RandSingSInt(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, -2L**31, 2L**31-1)
+ RandSingNum.__init__(self, -2**31, 2**31-1)
class RandSingLong(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, 0, 2L**64-1)
+ RandSingNum.__init__(self, 0, 2**64-1)
class RandSingSLong(RandSingNum):
def __init__(self):
- RandSingNum.__init__(self, -2L**63, 2L**63-1)
+ RandSingNum.__init__(self, -2**63, 2**63-1)
class RandSingString(RandSingularity):
def __init__(self):
diff --git a/setup.py b/setup.py
index 8372967..fd5c124 100755
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@
os.system("zip -A '%s'" % fname)
of.close()
os.unlink(ofname)
- os.chmod(fname, 0755)
+ os.chmod(fname, 0o755)
return fname