diff --git a/pox/lib/pxpcap/__init__.py b/pox/lib/pxpcap/__init__.py old mode 100644 new mode 100755 index b34b2396f..aff520594 --- a/pox/lib/pxpcap/__init__.py +++ b/pox/lib/pxpcap/__init__.py @@ -14,11 +14,19 @@ enabled = False try: - import pxpcap as pcapc + import platform + import importlib + _module = 'pox.lib.pxpcap.%s.pxpcap' % (platform.system().lower(),) + pcapc = importlib.import_module(_module) enabled = True except: - # We can at least import the rest - pass + # Try generic... + try: + import pxpcap as pcapc + enabled = True + except: + # We can at least import the rest + pass from pox.lib.addresses import IPAddr, EthAddr import parser diff --git a/pox/lib/pxpcap/pxpcap_c/build_linux b/pox/lib/pxpcap/pxpcap_c/build_linux index 8192f6e6a..8c295ba6b 100755 --- a/pox/lib/pxpcap/pxpcap_c/build_linux +++ b/pox/lib/pxpcap/pxpcap_c/build_linux @@ -1,3 +1,7 @@ #!/bin/bash DEST=lib.linux* -python setup.py build && cp build/${DEST}/pxpcap.so .. +DEST=$(ls -d build/${DEST} | tail -1) +OUT=../linux +mkdir $OUT 2> /dev/null +touch $OUT/__init__.py +python setup.py build && cp ${DEST}/pxpcap.so .. && cp ${DEST}/pxpcap.so ${OUT}/pxpcap.so diff --git a/pox/lib/pxpcap/pxpcap_c/build_mac b/pox/lib/pxpcap/pxpcap_c/build_mac index 97bdc834a..45bf33262 100755 --- a/pox/lib/pxpcap/pxpcap_c/build_mac +++ b/pox/lib/pxpcap/pxpcap_c/build_mac @@ -1,3 +1,7 @@ #!/bin/bash DEST=lib.macosx* -python setup.py build && cp build/${DEST}/pxpcap.so .. +DEST=$(ls -d build/${DEST} | tail -1) +OUT=../darwin +mkdir $OUT 2> /dev/null +touch $OUT/__init__.py +python setup.py build && cp ${DEST}/pxpcap.so .. && cp ${DEST}/pxpcap.so ${OUT}/pxpcap.so diff --git a/pox/lib/pxpcap/pxpcap_c/build_win.bat b/pox/lib/pxpcap/pxpcap_c/build_win.bat index e962ec6fb..8a5fa9c4e 100644 --- a/pox/lib/pxpcap/pxpcap_c/build_win.bat +++ b/pox/lib/pxpcap/pxpcap_c/build_win.bat @@ -1,8 +1,12 @@ @echo off IF NOT EXIST WpdPack GOTO NODIR +mkdir ..\windows +echo. > ..\windows\__init__.py + python setup.py build xcopy /y build\lib.win32-2.7\pxpcap.pyd .. +xcopy /y build\lib.win32-2.7\pxpcap.pyd ..\windows GOTO DONE @@ -10,4 +14,4 @@ GOTO DONE echo Please put the WinPcap developer pack directory, WpdPack, in this directory. echo (You can download it from http://www.winpcap.org/devel.htm) -:DONE \ No newline at end of file +:DONE