diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-03-21 13:46:34 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-04-04 17:14:26 +0000 |
commit | 55afe0072b435a0d9abc2db934ec9f17d4fb07dd (patch) | |
tree | 4024840f040ee162659d1ef404e7707cbbee1212 /src/target/trx_toolkit/ctrl_cmd.py | |
parent | 9d90d1907b9d1013a07ef7a9c187f16bc29129fb (diff) |
trx_toolkit: Add cmdline arg to set bind addr
Previous hardcoded default of 0.0.0.0 was inappropiate in some
scenarios, as it sets the SRC addr of the packets sent through the
socket based on the routing.
For instance, if iface IF1 has assigned two IP addresses A and B,
A being the first addr of the interface, and osmo-bts-trx is
configured with "osmotrx ip local A" and "osmotrx ip remote B",
the following happens:
CMD POWER OFF src=A:5801 dst=B:5701
RSP POWER OFF src=A:5701 dst=A:5701 <-- A is assigned as src addr.
But osmo-bts-trx is waiting for packets from B:5701, and the packet
is dropped with ICMP Unreachable. If addr binding is forced in
fake_trx to B, then everthing's fine.
Let's extend the UDPLink in order to allow manual, but optional
setting of bind address, and add a corresponding cmdline
argument to all executables.
Change-Id: I7be18fef40967fb7551f4115f22cbbd9cdb0840d
Diffstat (limited to 'src/target/trx_toolkit/ctrl_cmd.py')
-rwxr-xr-x | src/target/trx_toolkit/ctrl_cmd.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/target/trx_toolkit/ctrl_cmd.py b/src/target/trx_toolkit/ctrl_cmd.py index 0791f85c..e56105a8 100755 --- a/src/target/trx_toolkit/ctrl_cmd.py +++ b/src/target/trx_toolkit/ctrl_cmd.py @@ -36,6 +36,7 @@ from udp_link import UDPLink class Application: # Application variables remote_addr = "127.0.0.1" + bind_addr = "0.0.0.0" base_port = 5700 bind_port = 0 fuzzing = False @@ -48,8 +49,8 @@ class Application: signal.signal(signal.SIGINT, self.sig_handler) # Init UDP connection - self.ctrl_link = UDPLink(self.remote_addr, - self.base_port + 1, self.bind_port) + self.ctrl_link = UDPLink(self.remote_addr, self.base_port + 1, + self.bind_addr, self.bind_port) # Debug print print("[i] Init CTRL interface (%s)" \ @@ -64,9 +65,10 @@ class Application: " -r --remote-addr Set remote address (default %s)\n" \ " -p --base-port Set base port number (default %d)\n" \ " -P --bind-port Set local port number (default: random)\n" \ + " -b --bind-addr Set local address (default %s)\n" \ " -f --fuzzing Send raw payloads (without CMD)\n" \ - print(s % (self.remote_addr, self.base_port)) + print(s % (self.remote_addr, self.base_port, self.bind_addr)) if msg is not None: print(msg) @@ -74,12 +76,13 @@ class Application: def parse_argv(self): try: opts, args = getopt.getopt(sys.argv[1:], - "r:p:P:fh", + "r:p:P:b:fh", [ "help", "fuzzing", "base-port=", "bind-port=", + "bind-addr=", "remote-addr=", ]) except getopt.GetoptError as err: @@ -93,6 +96,8 @@ class Application: elif o in ("-r", "--remote-addr"): self.remote_addr = v + elif o in ("-b", "--bind-addr"): + self.bind_addr = v elif o in ("-p", "--base-port"): self.base_port = int(v) elif o in ("-P", "--bind-port"): |