summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-02-27 04:40:28 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-02-27 04:40:28 +0700
commite5480d2c2bc703ed1b387df753220506db2aceec (patch)
treee42cb34ca650c5321b83e755ef2f884cbff1a4cf /src
parent05ea7248f8e6c1aed7665efa82eeb92264027f86 (diff)
fake_trx/udp_link.py: close socket in destructor
Previously it was required to call the UDPLink.shutdown() method manually in order to close a socket. Let's do this automatically using the destructor of UDPLink. Change-Id: I59c3dc61ec58cd9effeb789947d28fd602ca91f4
Diffstat (limited to 'src')
-rwxr-xr-xsrc/target/fake_trx/burst_gen.py6
-rwxr-xr-xsrc/target/fake_trx/burst_send.py7
-rwxr-xr-xsrc/target/fake_trx/clck_gen.py1
-rwxr-xr-xsrc/target/fake_trx/ctrl_cmd.py1
-rw-r--r--src/target/fake_trx/ctrl_if_bb.py4
-rw-r--r--src/target/fake_trx/ctrl_if_bts.py4
-rwxr-xr-xsrc/target/fake_trx/fake_trx.py12
-rw-r--r--src/target/fake_trx/udp_link.py6
8 files changed, 3 insertions, 38 deletions
diff --git a/src/target/fake_trx/burst_gen.py b/src/target/fake_trx/burst_gen.py
index 9f366874..c2e1ad2d 100755
--- a/src/target/fake_trx/burst_gen.py
+++ b/src/target/fake_trx/burst_gen.py
@@ -143,8 +143,6 @@ class Application:
if self.output_file is not None:
self.ddf.append_msg(msg)
- self.shutdown()
-
def print_copyright(self):
print(COPYRIGHT)
@@ -237,13 +235,9 @@ class Application:
self.print_help("[!] Unknown burst type")
sys.exit(2)
- def shutdown(self):
- self.data_if.shutdown()
-
def sig_handler(self, signum, frame):
print("Signal %d received" % signum)
if signum is signal.SIGINT:
- self.shutdown()
sys.exit(0)
if __name__ == '__main__':
diff --git a/src/target/fake_trx/burst_send.py b/src/target/fake_trx/burst_send.py
index 87f9228b..61a526f6 100755
--- a/src/target/fake_trx/burst_send.py
+++ b/src/target/fake_trx/burst_send.py
@@ -100,9 +100,6 @@ class Application:
# Send message
self.data_if.send_msg(msg)
- # Finish
- self.shutdown()
-
def msg_pass_filter(self, l12trx, msg):
# Direction filter
if isinstance(msg, DATAMSG_L12TRX) and not l12trx:
@@ -216,13 +213,9 @@ class Application:
self.print_help("[!] Please specify a capture file")
sys.exit(2)
- def shutdown(self):
- self.data_if.shutdown()
-
def sig_handler(self, signum, frame):
print("Signal %d received" % signum)
if signum is signal.SIGINT:
- self.shutdown()
sys.exit(0)
if __name__ == '__main__':
diff --git a/src/target/fake_trx/clck_gen.py b/src/target/fake_trx/clck_gen.py
index 484ecde5..e7e58a3b 100755
--- a/src/target/fake_trx/clck_gen.py
+++ b/src/target/fake_trx/clck_gen.py
@@ -114,7 +114,6 @@ class Application:
print("Signal %d received" % signum)
if signum is signal.SIGINT:
self.clck.stop()
- self.link.shutdown()
if __name__ == '__main__':
app = Application()
diff --git a/src/target/fake_trx/ctrl_cmd.py b/src/target/fake_trx/ctrl_cmd.py
index 377a1f26..3faf8127 100755
--- a/src/target/fake_trx/ctrl_cmd.py
+++ b/src/target/fake_trx/ctrl_cmd.py
@@ -129,7 +129,6 @@ class Application:
def sig_handler(self, signum, frame):
print("\n\nSignal %d received" % signum)
if signum is signal.SIGINT:
- self.ctrl_link.shutdown()
sys.exit(0)
if __name__ == '__main__':
diff --git a/src/target/fake_trx/ctrl_if_bb.py b/src/target/fake_trx/ctrl_if_bb.py
index 440094a0..47c70484 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -36,10 +36,6 @@ class CTRLInterfaceBB(CTRLInterface):
print("[i] Init CTRL interface for BB")
CTRLInterface.__init__(self, remote_addr, remote_port, bind_port)
- def shutdown(self):
- print("[i] Shutdown CTRL interface for BB")
- CTRLInterface.shutdown(self)
-
def parse_cmd(self, request):
# Power control
if self.verify_cmd(request, "POWERON", 0):
diff --git a/src/target/fake_trx/ctrl_if_bts.py b/src/target/fake_trx/ctrl_if_bts.py
index d0a7db3c..92a4abb2 100644
--- a/src/target/fake_trx/ctrl_if_bts.py
+++ b/src/target/fake_trx/ctrl_if_bts.py
@@ -37,10 +37,6 @@ class CTRLInterfaceBTS(CTRLInterface):
print("[i] Init CTRL interface for BTS")
CTRLInterface.__init__(self, remote_addr, remote_port, bind_port)
- def shutdown(self):
- print("[i] Shutdown CTRL interface for BTS")
- CTRLInterface.shutdown(self)
-
def parse_cmd(self, request):
# Power control
if self.verify_cmd(request, "POWERON", 0):
diff --git a/src/target/fake_trx/fake_trx.py b/src/target/fake_trx/fake_trx.py
index 4f6d8c6b..bdc4c614 100755
--- a/src/target/fake_trx/fake_trx.py
+++ b/src/target/fake_trx/fake_trx.py
@@ -125,18 +125,6 @@ class Application:
# Stop clock generator
self.clck_gen.stop()
- # Close CLCK interfaces
- self.bts_clck.shutdown()
-
- # Close CTRL interfaces
- self.bts_ctrl.shutdown()
- self.bb_ctrl.shutdown()
-
- # Close DATA interfaces
- self.bts_data.shutdown()
- self.bb_data.shutdown()
-
-
def print_copyright(self):
print(COPYRIGHT)
diff --git a/src/target/fake_trx/udp_link.py b/src/target/fake_trx/udp_link.py
index 0afd1504..c0c41ff6 100644
--- a/src/target/fake_trx/udp_link.py
+++ b/src/target/fake_trx/udp_link.py
@@ -35,6 +35,9 @@ class UDPLink:
self.remote_addr = remote_addr
self.remote_port = remote_port
+ def __del__(self):
+ self.sock.close()
+
def loop(self):
r_event, w_event, x_event = select.select([self.sock], [], [])
@@ -43,9 +46,6 @@ class UDPLink:
data, addr = self.sock.recvfrom(128)
self.handle_rx(data.decode())
- def shutdown(self):
- self.sock.close();
-
def send(self, data):
if type(data) not in [bytearray, bytes]:
data = data.encode()