Skip to content

Commit

Permalink
pxpcap: Try to load platform-specific module
Browse files Browse the repository at this point in the history
We now store platform-specific C++ modules in pox.lib.pxpcap.arch.pxpcap.
And we now try to load one for the current arch based on that.

There may well be a better way to do this.
  • Loading branch information
MurphyMc committed Sep 17, 2013
1 parent 22dd49c commit 4e3aeab
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
14 changes: 11 additions & 3 deletions pox/lib/pxpcap/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion pox/lib/pxpcap/pxpcap_c/build_linux
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion pox/lib/pxpcap/pxpcap_c/build_mac
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion pox/lib/pxpcap/pxpcap_c/build_win.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
@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

:NODIR
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
:DONE

0 comments on commit 4e3aeab

Please sign in to comment.