#!/bin/env python3 import socket; import sys; def init_socket(): # Creates a TCP/IP socket # socket type .AF_INET is the Internet address family for IPv4. # .SOCK_STREAM is the socket type for TCP. debug_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket to the port 8000 debug_server_address = ('localhost', 8000) debug_socket.bind(debug_server_address) # Listen for incoming connections debug_socket.listen(1) while True: # Wait for a connection print >>sys.stderr, 'Waiting for a Connection' connection, client_address = debug_socket.accept() def check_bridge_socket(): evt = None return evt def handle_bridge_evt(evt): """ TODO: Whatever bridge events to handle """ def check_debug_socket(): dbg_evt = None return dbg_evt def handle_debug_evt(dbg_evt): """ TODO: Do something with the events here.""" def run_loop(): """ """ while True: # 1. Check the BridgeSocket evt = check_bridge_socket() if evt != None: handle_bridge_evt(evt) dbg_evt = check_debug_socket() if dbg_evt != None: handle_debug_evt(dbg_evt) def main(): init_socket() """ 1. TODO: Open Server port that the device connects to. 2. TODO: Open Server port that an admin connects to, i.e., to test sending packets to 3. TODO (Optional): We might be able to start a Scapy [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) and then add these functions. That way the person in debugging the phone can do live testing. """ if __name__ == '__main__': main()