Example #1
0
    def __init__(self,
                 ip='127.0.0.1',
                 port=13400,
                 activate_routing=True,
                 source_address=0xe80,
                 target_address=0,
                 activation_type=0):
        # type: (str, int, bool, int, int, int) -> None
        self.ip = ip
        self.port = port
        self.source_address = source_address
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.connect((self.ip, self.port))
        StreamSocket.__init__(self, s, DoIP)

        if activate_routing:
            resp = self.sr1(DoIP(payload_type=0x5,
                                 activation_type=activation_type,
                                 source_address=source_address),
                            verbose=False,
                            timeout=1)
            if resp and resp.payload_type == 0x6 and \
                    resp.routing_activation_response == 0x10:
                self.target_address = target_address or \
                    resp.logical_address_doip_entity
                print("Routing activation successful! "
                      "Target address set to: 0x%x" % self.target_address)
            else:
                print("Routing activation failed! Response: %s" % repr(resp))
Example #2
0
 def _init_socket(self, sock_family=socket.AF_INET):
     # type: (int) -> None
     s = socket.socket(sock_family, socket.SOCK_STREAM)
     s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
     s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     s.connect((self.ip, self.port))
     StreamSocket.__init__(self, s, DoIP)
Example #3
0
 def __init__(self, ip='127.0.0.1', port=6801):
     # type: (str, int) -> None
     self.ip = ip
     self.port = port
     s = socket.socket()
     s.connect((self.ip, self.port))
     StreamSocket.__init__(self, s, HSFZ)
Example #4
0
 def __init__(self, ip='127.0.0.1', port=6801):
     # type: (str, int) -> None
     self.ip = ip
     self.port = port
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
     s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     s.connect((self.ip, self.port))
     StreamSocket.__init__(self, s, HSFZ)
Example #5
0
    def __init__(self, sock, keep_alive=True):
        """
        Initializes the NI stream socket.

        @param sock: socket
        @type sock: C{socket}

        @param keep_alive: if true, the socket will automatically respond to
            keep-alive request messages. Otherwise, the keep-alive messages
            are passed to the caller in L{recv} and L{sr} calls.
        @type keep_alive: C{bool}
        """
        StreamSocket.__init__(self, sock, Raw)
        self.keep_alive = keep_alive
Example #6
0
    def __init__(self, sock, keep_alive=True, base_cls=None):
        """Initializes the NI stream socket.

        :param sock: socket to wrap
        :type sock: C{socket}

        :param keep_alive: if true, the socket will automatically respond to
            keep-alive request messages. Otherwise, the keep-alive messages
            are passed to the caller in :class:`recv` and :class:`sr` calls.
        :type keep_alive: ``bool``

        :param base_cls: the base class to use when receiving packets, it uses
            :class:`SAPNI` as default if no class specified
        :type base_cls: :class:`Packet` class
        """
        StreamSocket.__init__(self, sock, Raw)
        self.keep_alive = keep_alive
        self.basecls = base_cls
Example #7
0
    def __init__(self, sock, keep_alive=True, base_cls=None):
        """Initializes the NI stream socket.

        @param sock: socket to wrap
        @type sock: C{socket}

        @param keep_alive: if true, the socket will automatically respond to
            keep-alive request messages. Otherwise, the keep-alive messages
            are passed to the caller in L{recv} and L{sr} calls.
        @type keep_alive: C{bool}

        @param base_cls: the base class to use when receiving packets, it uses
            L{SAPNI} as default if no class specified
        @type base_cls: L{Packet} class
        """
        StreamSocket.__init__(self, sock, Raw)
        self.keep_alive = keep_alive
        self.basecls = base_cls
Example #8
0
    def __init__(self, sock, keep_alive=True, base_cls=None):
        """Initializes the NI stream socket.

        @param sock: socket to wrap
        @type sock: C{socket}

        @param keep_alive: if true, the socket will automatically respond to
            keep-alive request messages. Otherwise, the keep-alive messages
            are passed to the caller in L{recv} and L{sr} calls.
        @type keep_alive: C{bool}

        @param base_cls: the base class to use when receiving packets, it uses
            L{SAPNI} as default if no class specified
        @type base_cls: L{Packet} class
        """
        StreamSocket.__init__(self, sock, Raw)
        self.keep_alive = keep_alive
        self.basecls = base_cls
Example #9
0
    def __init__(self, sock, keep_alive=True, base_cls=None):
        """Initializes the NI stream socket.

        :param sock: socket to wrap
        :type sock: C{socket}

        :param keep_alive: if true, the socket will automatically respond to
            keep-alive request messages. Otherwise, the keep-alive messages
            are passed to the caller in :class:`recv` and :class:`sr` calls.
        :type keep_alive: ``bool``

        :param base_cls: the base class to use when receiving packets, it uses
            :class:`SAPNI` as default if no class specified
        :type base_cls: :class:`Packet` class
        """
        StreamSocket.__init__(self, sock, Raw)
        self.keep_alive = keep_alive
        self.basecls = base_cls
Example #10
0
 def __init__(self, ip='127.0.0.1', port=6801):
     s = socket.socket()
     s.connect((ip, port))
     StreamSocket.__init__(self, s, DoIP)
Example #11
0
 def __init__(self, ip='127.0.0.1', port=6801):
     self.ip = ip
     self.port = port
     s = socket.socket()
     s.connect((self.ip, self.port))
     StreamSocket.__init__(self, s, HSFZ)
Example #12
0
File: doip.py Project: netkey/scapy
 def __init__(self, ip='127.0.0.1', port=6801):
     s = socket.socket()
     s.connect((ip, port))
     StreamSocket.__init__(self, s, DoIP)