Skip to content
Snippets Groups Projects
Commit 0a31dc9f authored by Pierre Lalet's avatar Pierre Lalet
Browse files

Merge pull request #102 from guedou/arch_common

Move get_if() to scapy/arch/common.py
parents 40d37f96 b9613b73
No related branches found
No related tags found
No related merge requests found
## This file is part of Scapy
## See http://www.secdev.org/projects/scapy for more informations
## Copyright (C) Philippe Biondi <phil@secdev.org>
## This program is published under a GPLv2 license
"""
Functions common to different architectures
"""
import socket
from fcntl import ioctl
import struct
def get_if(iff, cmd):
"""Ease SIOCGIF* ioctl calls"""
sck = socket.socket()
ifreq = ioctl(sck, cmd, struct.pack("16s16x", iff))
sck.close()
return ifreq
...@@ -19,6 +19,7 @@ from scapy.data import * ...@@ -19,6 +19,7 @@ from scapy.data import *
from scapy.supersocket import SuperSocket from scapy.supersocket import SuperSocket
import scapy.arch import scapy.arch
from scapy.error import warning, Scapy_Exception from scapy.error import warning, Scapy_Exception
from scapy.arch.common import get_if
...@@ -276,15 +277,6 @@ def read_routes6(): ...@@ -276,15 +277,6 @@ def read_routes6():
return routes return routes
def get_if(iff,cmd):
s=socket.socket()
ifreq = ioctl(s, cmd, struct.pack("16s16x",iff))
s.close()
return ifreq
def get_if_index(iff): def get_if_index(iff):
return int(struct.unpack("I",get_if(iff, SIOCGIFINDEX)[16:20])[0]) return int(struct.unpack("I",get_if(iff, SIOCGIFINDEX)[16:20])[0])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment