parameters: (self, route_db, dst_addr)
return_statement: return lpm_route
docstring: find the routes to the longest prefix matches of dst.
docstring_summary: find the routes to the longest prefix matches of dst.
docstring_tokens: find the routes to the longest prefix matches of dst .
function: def get_lpm_route(self, route_db, dst_addr):
          """find the routes to the longest prefix matches of dst."""
  
          max_prefix_len = -1
          lpm_route = None
          dst_addr = ipaddress.ip_address(dst_addr)
          for route in route_db.unicastRoutes:
              prefix = ipaddress.ip_network(ipnetwork.sprint_prefix(route.dest))
              if dst_addr in prefix:
                  next_hop_prefix_len = route.dest.prefixLength
                  if next_hop_prefix_len == max_prefix_len:
                      raise Exception(
                          "Duplicate prefix found in routing table {}".format(
                              ipnetwork.sprint_prefix(route.dest)
                          )
                      )
                  elif next_hop_prefix_len > max_prefix_len:
                      lpm_route = route
                      max_prefix_len = next_hop_prefix_len
  
          return lpm_route
function_tokens: def get_lpm_route ( self , route_db , dst_addr ) : max_prefix_len = - 1 lpm_route = None dst_addr = ipaddress . ip_address ( dst_addr ) for route in route_db . unicastRoutes : prefix = ipaddress . ip_network ( ipnetwork . sprint_prefix ( route . dest ) ) if dst_addr in prefix : next_hop_prefix_len = route . dest . prefixLength if next_hop_prefix_len == max_prefix_len : raise Exception ( "Duplicate prefix found in routing table {}" . format ( ipnetwork . sprint_prefix ( route . dest ) ) ) elif next_hop_prefix_len > max_prefix_len : lpm_route = route max_prefix_len = next_hop_prefix_len return lpm_route