-def is_icmp_reply(pkt, ipformat):
- """Return True if pkt is echo reply, else return False. If exception occurs
- return False.
-
- :param pkt: Packet.
- :param ipformat: Dictionary of names to distinguish IPv4 and IPv6.
- :type pkt: dict
- :type ipformat: dict
- :rtype: bool
- """
- # pylint: disable=bare-except
- try:
- if pkt[ipformat['IPType']][ipformat['ICMP_rep']].type == \
- ipformat['Type']:
- return True
- else:
- return False
- except: # pylint: disable=bare-except
- return False
-
-
-def address_check(request, reply, ipformat):
- """Compare request packet source address with reply destination address
- and vice versa. If exception occurs return False.
-
- :param request: Sent packet containing request.
- :param reply: Received packet containing reply.
- :param ipformat: Dictionary of names to distinguish IPv4 and IPv6.
- :type request: dict
- :type reply: dict
- :type ipformat: dict
- :rtype: bool
- """
- # pylint: disable=bare-except
- try:
- r_src = reply[ipformat['IPType']].src == request[ipformat['IPType']].dst
- r_dst = reply[ipformat['IPType']].dst == request[ipformat['IPType']].src
- return r_src and r_dst
- except: # pylint: disable=bare-except
- return False
-
-