Beispiel #1
0
int garden_patricia_check(patricia_tree_t *ptree,
			  pass_through *ptlist, uint32_t *ptcnt,
			  struct pkt_ipphdr_t *ipph, int dst) {
  int found = 0;
  prefix_t *prefix;
  patricia_node_t *pfx;
  struct in_addr sin;

  sin.s_addr = dst ? ipph->daddr : ipph->saddr;
  prefix = patricia_prefix_new (AF_INET, &sin, 32);

  pfx = patricia_search_best(ptree, prefix);
  if (pfx) {
    struct node_pass_through_list *
        nd = PATRICIA_DATA_GET(pfx, struct node_pass_through_list);

    if (nd) {
      pass_through *pt=0;
      switch (garden_check(nd->ptlist, &nd->ptcnt,
			   &pt, ipph, dst, ptree)) {
        case 1:
          found = 1;
          break;
        case -1:
          if (pt)
            pass_through_rem(ptlist, ptcnt, pt, ptree);
          break;
      }
    }
  }

  patricia_prefix_deref (prefix);
  return found;
}
Beispiel #2
0
patricia_node_t* ptree_match(patricia_tree_t *tree, int family, void *addr, int bits) {
  prefix_t prefix;

  if(family == AF_INET)
    fill_prefix_v4(&prefix, (struct in_addr*)addr, bits, tree->maxbits);
  else
    fill_prefix_v6(&prefix, (struct in6_addr*)addr, bits, tree->maxbits);

  return(patricia_search_best(tree, &prefix));
}
Beispiel #3
0
struct route_entry_v4 
*ipv4_lookup(const struct route_table *rt, uint32_t ip)
{
    ip = htonl(ip);
    prefix_t *pref = New_Prefix(AF_INET, &ip, 32);
    patricia_node_t *node = patricia_search_best(rt->ipv4_table, pref);
    Deref_Prefix (pref);
    if (node != NULL){
        return (struct route_entry_v4*) node->data;
    }
    return NULL;
}
Beispiel #4
0
static inline void *
find_patricia_entry (patricia_tree_t * tree, void * addr, u_int16_t len)
{
	prefix_t prefix;
	patricia_node_t * pn;

	dst2prefix (addr, len, &prefix);

	pn = patricia_search_best (tree, &prefix);

	if (pn)
		return pn->data;

	return NULL;
}
Beispiel #5
0
Datei: db.c Projekt: derez/moloch
MolochIpInfo_t *moloch_db_get_local_ip(MolochSession_t *session, uint32_t ip) 
{
    prefix_t prefix;
    patricia_node_t *node;

    prefix.family = AF_INET;
    prefix.bitlen = 32;
    prefix.add.sin.s_addr = ip;

    if ((node = patricia_search_best (ipTree, &prefix)) == NULL)
        return 0;

    MolochIpInfo_t *ii = node->data;
    int t;

    for (t = 0; t < ii->numtags; t++) {
        moloch_field_int_add(MOLOCH_FIELD_TAGS, session, ii->tags[t]);
    }

    return ii;
}