diff options
author | jdolecek <jdolecek@pkgsrc.org> | 2020-07-27 14:11:16 +0000 |
---|---|---|
committer | jdolecek <jdolecek@pkgsrc.org> | 2020-07-27 14:11:16 +0000 |
commit | 88385c1ac3c4cf42ed0d3fc109553e526da51aae (patch) | |
tree | 1e3b8291770b06fbe1301319b16f345ea6bc1e2d /net | |
parent | 307e3a41ed73ef72b95eef2bda936f9edb8b5664 (diff) | |
download | pkgsrc-88385c1ac3c4cf42ed0d3fc109553e526da51aae.tar.gz |
Add package for the Python script needed to connect a Intel XMM7360 device
to network, from https://github.com/xmm7360/xmm7360-pci
There is no release for the master project, so base this on latest commit.
Diffstat (limited to 'net')
-rw-r--r-- | net/Makefile | 3 | ||||
-rw-r--r-- | net/py-xmm7360/DESCR | 6 | ||||
-rw-r--r-- | net/py-xmm7360/Makefile | 44 | ||||
-rw-r--r-- | net/py-xmm7360/PLIST | 5 | ||||
-rw-r--r-- | net/py-xmm7360/distinfo | 8 | ||||
-rw-r--r-- | net/py-xmm7360/patches/patch-rpc_open_xdatachannel.py | 80 | ||||
-rw-r--r-- | net/py-xmm7360/patches/patch-rpc_rpc.py | 42 |
7 files changed, 187 insertions, 1 deletions
diff --git a/net/Makefile b/net/Makefile index 175885b554c..e3036e8c20a 100644 --- a/net/Makefile +++ b/net/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1340 2020/06/18 18:30:41 bsiegert Exp $ +# $NetBSD: Makefile,v 1.1341 2020/07/27 14:11:16 jdolecek Exp $ # COMMENT= Networking tools @@ -751,6 +751,7 @@ SUBDIR+= py-twython SUBDIR+= py-txamqp SUBDIR+= py-txtorcon SUBDIR+= py-xandikos +SUBDIR+= py-xmm7360 SUBDIR+= py-zeep SUBDIR+= py-zeroconf SUBDIR+= py-zmq diff --git a/net/py-xmm7360/DESCR b/net/py-xmm7360/DESCR new file mode 100644 index 00000000000..bc24e58adc5 --- /dev/null +++ b/net/py-xmm7360/DESCR @@ -0,0 +1,6 @@ +This package contains tool to connect Intel XMM7360 modem to mobile network. + +It requires the wwanc(4) driver to be present, and device nodes already +created, for details see the manpage. + +open_xdatachannel.py must be run as root. diff --git a/net/py-xmm7360/Makefile b/net/py-xmm7360/Makefile new file mode 100644 index 00000000000..8e4a73c2f82 --- /dev/null +++ b/net/py-xmm7360/Makefile @@ -0,0 +1,44 @@ +# $NetBSD: Makefile,v 1.1 2020/07/27 14:11:16 jdolecek Exp $ + +DISTNAME= xmm7360-0.20200727 +PKGNAME= ${PYPKGPREFIX}-${DISTNAME} +CATEGORIES= net python +MASTER_SITES= ${MASTER_SITE_GITHUB:=xmm7360/} +GITHUB_PROJECT= xmm7360-pci +GITHUB_TAG= 0060149958d00b9cec87b73cd610c136f69e5275 + +MAINTAINER= pkgsrc-users@NetBSD.org +HOMEPAGE= https://github.com/xmm7360/xmm7360-pci +COMMENT= Network initialization for L850-GL / Intel XMM7360 driver +LICENSE= modified-bsd + +ONLY_FOR_PLATFORM= NetBSD-*-* OpenBSD-*-* + +USE_LANGUAGES= # none + +DEPENDS+= ${PYPKGPREFIX}-configargparse>=1.2.3:../../devel/py-configargparse + +NO_BUILD= yes +XMM_DIR= ${PYSITELIB}/xmm7360 + +PYTHON_VERSIONS_ACCEPTED= 37 38 +REPLACE_PYTHON= rpc/open_xdatachannel.py rpc/rpc.py +INSTALLATION_DIRS+= bin ${XMM_DIR} +PY_PATCHPLIST= yes + +do-configure: + # XXX: Blank, but we can't define NO_CONFIGURE and use REPLACE_PYTHON... + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/rpc/rpc.py \ + ${DESTDIR}${PREFIX}/${XMM_DIR}/ + ${INSTALL_SCRIPT} ${WRKSRC}/rpc/rpc_call_ids.py \ + ${DESTDIR}${PREFIX}/${XMM_DIR}/ + ${INSTALL_SCRIPT} ${WRKSRC}/rpc/rpc_unsol_table.py \ + ${DESTDIR}${PREFIX}/${XMM_DIR}/ + ${INSTALL_SCRIPT} ${WRKSRC}/rpc/open_xdatachannel.py \ + ${DESTDIR}${PREFIX}/bin/open_xdatachannel.py + +.include "../../lang/python/application.mk" +.include "../../lang/python/extension.mk" +.include "../../mk/bsd.pkg.mk" diff --git a/net/py-xmm7360/PLIST b/net/py-xmm7360/PLIST new file mode 100644 index 00000000000..cf950a92b17 --- /dev/null +++ b/net/py-xmm7360/PLIST @@ -0,0 +1,5 @@ +@comment $NetBSD: PLIST,v 1.1 2020/07/27 14:11:16 jdolecek Exp $ +bin/open_xdatachannel.py +${PYSITELIB}/xmm7360/rpc.py +${PYSITELIB}/xmm7360/rpc_call_ids.py +${PYSITELIB}/xmm7360/rpc_unsol_table.py diff --git a/net/py-xmm7360/distinfo b/net/py-xmm7360/distinfo new file mode 100644 index 00000000000..50c39fc1398 --- /dev/null +++ b/net/py-xmm7360/distinfo @@ -0,0 +1,8 @@ +$NetBSD: distinfo,v 1.1 2020/07/27 14:11:16 jdolecek Exp $ + +SHA1 (xmm7360-0.20200727-0060149958d00b9cec87b73cd610c136f69e5275.tar.gz) = 4ca33e127d447584a81c5b28b1d74bb27a0d96f2 +RMD160 (xmm7360-0.20200727-0060149958d00b9cec87b73cd610c136f69e5275.tar.gz) = 03ecd54b2f44be3613aecc609fa8cfa0ba77fa02 +SHA512 (xmm7360-0.20200727-0060149958d00b9cec87b73cd610c136f69e5275.tar.gz) = d732a536d02dc68e6768e5687db74ac544b62c5ab57d25b8a7fa1270c2f38a855aa707c69f82a64ad08c87badc50837364deb1563b70da9aa74ef9f56d3cf547 +Size (xmm7360-0.20200727-0060149958d00b9cec87b73cd610c136f69e5275.tar.gz) = 24345 bytes +SHA1 (patch-rpc_open_xdatachannel.py) = ba4c07aa4028716aea5d7b259c07afbda888dde0 +SHA1 (patch-rpc_rpc.py) = 17a614d4d9bc03d8d8f3b09f83d2eddfed7c5281 diff --git a/net/py-xmm7360/patches/patch-rpc_open_xdatachannel.py b/net/py-xmm7360/patches/patch-rpc_open_xdatachannel.py new file mode 100644 index 00000000000..db49b39fec6 --- /dev/null +++ b/net/py-xmm7360/patches/patch-rpc_open_xdatachannel.py @@ -0,0 +1,80 @@ +$NetBSD: patch-rpc_open_xdatachannel.py,v 1.1 2020/07/27 14:11:16 jdolecek Exp $ + +--- rpc/open_xdatachannel.py.orig 2020-01-15 00:30:10.000000000 +0000 ++++ rpc/open_xdatachannel.py +@@ -4,11 +4,18 @@ import logging + # must do this before importing pyroute2 + logging.basicConfig(level=logging.DEBUG) + +-import rpc ++from xmm7360 import rpc + import binascii + import time + import sys +-from pyroute2 import IPRoute ++import os ++try: ++ from pyroute2 import IPRoute ++ ipr = IPRoute() ++ if not callable(getattr(ipr, 'link_lookup')): ++ ipr = None ++except: ++ ipr = None + + import configargparse + +@@ -29,8 +36,6 @@ cfg = parser.parse_args() + + r = rpc.XMMRPC() + +-ipr = IPRoute() +- + r.execute('UtaMsSmsInit') + r.execute('UtaMsCbsInit') + r.execute('UtaMsNetOpen') +@@ -72,26 +77,30 @@ logging.info("DNS server(s): " + ', '.jo + + # For some reason, on IPv6 networks, the GetNegIpAddrReq call returns 8 bytes of the IPv6 address followed by our 4 byte IPv4 address. + # use the last nonzero IP ++ip_addr = None + for addr in ip_values[::-1]: + if addr.compressed != '0.0.0.0': + ip_addr = addr.compressed + break + +-idx = ipr.link_lookup(ifname='wwan0')[0] +- +-ipr.flush_addr(index=idx) +-ipr.link('set', +- index=idx, +- state='up') +-ipr.addr('add', +- index=idx, +- address=ip_addr) +- +-if not cfg.nodefaultroute: +- ipr.route('add', +- dst='default', +- priority=cfg.metric, +- oif=idx) ++if not ip_addr: ++ logging.info('No valid IP address, exiting') ++ sys.exit(1) ++ ++if ipr: ++ idx = ipr.link_lookup(ifname='wwan0')[0] ++ ++ ipr.flush_addr(index=idx) ++ ipr.link('set', index=idx, state='up') ++ ipr.addr('add', index=idx, address=ip_addr) ++ ++ if not cfg.nodefaultroute: ++ ipr.route('add', dst='default', ++ priority=cfg.metric, ++ oif=idx) ++else: ++ os.system('ifconfig wwan0 %s' % (ip_addr)) ++ os.system('route add default -iface %s' % (ip_addr)) + + # Add DNS values to /etc/resolv.conf + if not cfg.noresolv: diff --git a/net/py-xmm7360/patches/patch-rpc_rpc.py b/net/py-xmm7360/patches/patch-rpc_rpc.py new file mode 100644 index 00000000000..26b31f1856b --- /dev/null +++ b/net/py-xmm7360/patches/patch-rpc_rpc.py @@ -0,0 +1,42 @@ +$NetBSD: patch-rpc_rpc.py,v 1.1 2020/07/27 14:11:16 jdolecek Exp $ + +--- rpc/rpc.py.orig 2020-01-15 00:30:10.000000000 +0000 ++++ rpc/rpc.py +@@ -7,8 +7,8 @@ import struct + import itertools + import ipaddress + import hashlib +-import rpc_call_ids +-import rpc_unsol_table ++from .rpc_call_ids import call_ids ++from .rpc_unsol_table import xmm7360_unsol + + def asn_int4(val): + return b'\x02\x04' + struct.pack('>L', val) +@@ -29,7 +29,7 @@ class XMMRPC(object): + desc = resp['type'] + + if resp['type'] == 'unsolicited': +- name = rpc_unsol_table.xmm7360_unsol.get(resp['code'], '0x%02x' % resp['code']) ++ name = xmm7360_unsol.get(resp['code'], '0x%02x' % resp['code']) + desc = 'unsolicited: %s' % name + self.handle_unsolicited(resp) + +@@ -107,7 +107,7 @@ class XMMRPC(object): + return {'tid': txid, 'type': t, 'code': code, 'body': body, 'content': content} + + def handle_unsolicited(self, message): +- name = rpc_unsol_table.xmm7360_unsol.get(message['code'], None) ++ name = xmm7360_unsol.get(message['code'], None) + + if name == 'UtaMsNetIsAttachAllowedIndCb': + self.attach_allowed = message['content'][2] +@@ -322,7 +322,7 @@ def UtaModeSet(rpc, mode): + while True: + msg = rpc.pump() + # msg['txid'] will be mode_tid as well +- if rpc_unsol_table.xmm7360_unsol.get(msg['code'], None) == 'UtaModeSetRspCb': ++ if xmm7360_unsol.get(msg['code'], None) == 'UtaModeSetRspCb': + if msg['content'][0] != mode: + raise IOError("UtaModeSet was not able to set mode. FCC lock enabled?") + return |