⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftfil.c

📁 netflow,抓包
💻 C
📖 第 1 页 / 共 5 页
字号:
  struct ftfil_lookup_tag_mask_rec *ftfltmr;  u_int32 *src_tag;  int match;  src_tag = ((u_int32*)(rec+fo->src_tag));  match = 0;  FT_STAILQ_FOREACH(ftfltmr, &lookup->list, chain) {    /* match? */    if ((*src_tag & ftfltmr->mask) == ftfltmr->tag) {      match = 1;      break;    }  } /* ftfltmr */  /* if there was a match, then return that mode */  if (match)    return ftfltmr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_src_tag_l *//* * function: eval_match_src_tag_h * * Evalute src_tag as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_src_tag_h(struct ftfil_lookup_tag *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftchash_rec_fil_c32 *ftch_recfc32p;  u_int32 *src_tag, hash;  int match;  src_tag = ((u_int32*)(rec+fo->src_tag));  match = 0;  hash = (*src_tag>>16) ^ (*src_tag & 0xFFFF);  hash = ((hash >>8) ^ (hash & 0x0FFF));  if ((ftch_recfc32p = ftchash_lookup(lookup->ftch, src_tag, hash)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftch_recfc32p->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_src_tag_h *//* * function: eval_match_dst_tag_h * * Evalute dst_tag as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_dst_tag_h(struct ftfil_lookup_tag *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftchash_rec_fil_c32 *ftch_recfc32p;  u_int32 *dst_tag, hash;  int match;  dst_tag = ((u_int32*)(rec+fo->dst_tag));  match = 0;  hash = (*dst_tag>>16) ^ (*dst_tag & 0xFFFF);  hash = ((hash >>8) ^ (hash & 0x0FFF));  if ((ftch_recfc32p = ftchash_lookup(lookup->ftch, dst_tag, hash)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftch_recfc32p->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_dst_tag_h *//* * function: eval_match_dst_tag_l * * Evalute dst_tag as list * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_dst_tag_l(struct ftfil_lookup_tag_mask *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_tag_mask_rec *ftfltmr;  u_int32 *dst_tag;  int match;  dst_tag = ((u_int32*)(rec+fo->dst_tag));  match = 0;  FT_STAILQ_FOREACH(ftfltmr, &lookup->list, chain) {    /* match? */    if ((*dst_tag & ftfltmr->mask) == ftfltmr->tag) {      match = 1;      break;    }  } /* ftfltmr */  /* if there was a match, then return that mode */  if (match)    return ftfltmr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_dst_tag_l *//* * function: eval_match_nexthop_l * * Evalute nexthop as list * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_nexthop_addr_l(struct ftfil_lookup_ip_mask *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_ip_mask_rec *ftflipmr;  u_int32 *nexthop;  int match;  nexthop = ((u_int32*)(rec+fo->nexthop));  match = 0;  FT_STAILQ_FOREACH(ftflipmr, &lookup->list, chain) {    /* match? */    if ((*nexthop & ftflipmr->mask) == ftflipmr->ip) {      match = 1;      break;    }  } /* ftflipmr */  /* if there was a match, then return that mode */  if (match)    return ftflipmr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_nexthop_addr_l *//* * function: eval_match_ip_nexthop_addr_h * * Evalute nexthop as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_nexthop_addr_h(struct ftfil_lookup_ip_address *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftchash_rec_fil_c32 *ftch_recfc32p;  u_int32 *nexthop, hash;  int match;  nexthop = ((u_int32*)(rec+fo->nexthop));  match = 0;  hash = (*nexthop>>16) ^ (*nexthop & 0xFFFF);  hash = ((hash >>8) ^ (hash & 0x0FFF));  if ((ftch_recfc32p = ftchash_lookup(lookup->ftch, nexthop, hash)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftch_recfc32p->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_nexthop_addr_h *//* * function: eval_match_ip_nexthop_addr_r * * Evalute nexthop as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_nexthop_addr_r(struct ftfil_lookup_ip_prefix *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_ip_prefix_rec *ftflipprr;  struct radix_node_head *rhead;  struct radix_sockaddr_in sock1;  int match;  sock1.sin_addr.s_addr = *((u_int32*)(rec+fo->nexthop));  sock1.sin_len = sizeof sock1;  sock1.sin_family = AF_INET;  match = 0;  rhead = lookup->rhead;  if ((ftflipprr = (struct ftfil_lookup_ip_prefix_rec*)rhead->rnh_matchaddr(    &sock1, rhead)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftflipprr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_nexthop_addr_r *//* * function: eval_match_ip_sc_addr_l * * Evalute sc as list * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_sc_addr_l(struct ftfil_lookup_ip_mask *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_ip_mask_rec *ftflipmr;  u_int32 *sc;  int match;  sc = ((u_int32*)(rec+fo->router_sc));  match = 0;  FT_STAILQ_FOREACH(ftflipmr, &lookup->list, chain) {    /* match? */    if ((*sc & ftflipmr->mask) == ftflipmr->ip) {      match = 1;      break;    }  } /* ftflipmr */  /* if there was a match, then return that mode */  if (match)    return ftflipmr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_sc_addr_l *//* * function: eval_match_ip_sc_addr_h * * Evalute sc as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_sc_addr_h(struct ftfil_lookup_ip_address *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftchash_rec_fil_c32 *ftch_recfc32p;  u_int32 *sc, hash;  int match;  sc = ((u_int32*)(rec+fo->router_sc));  match = 0;  hash = (*sc>>16) ^ (*sc & 0xFFFF);  hash = ((hash >>8) ^ (hash & 0x0FFF));  if ((ftch_recfc32p = ftchash_lookup(lookup->ftch, sc, hash)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftch_recfc32p->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_sc_addr_h *//* * function: eval_match_ip_sc_addr_r * * Evalute sc as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_sc_addr_r(struct ftfil_lookup_ip_prefix *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_ip_prefix_rec *ftflipprr;  struct radix_node_head *rhead;  struct radix_sockaddr_in sock1;  int match;  sock1.sin_addr.s_addr = *((u_int32*)(rec+fo->router_sc));  sock1.sin_len = sizeof sock1;  sock1.sin_family = AF_INET;  match = 0;  rhead = lookup->rhead;  if ((ftflipprr = (struct ftfil_lookup_ip_prefix_rec*)rhead->rnh_matchaddr(    &sock1, rhead)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftflipprr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_sc_addr_r *//* * function: eval_match_ip_src_addr_l * * Evalute ip_src_addr as list * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_src_addr_l(struct ftfil_lookup_ip_mask *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_ip_mask_rec *ftflipmr;  u_int32 *ip_src_addr;  int match;  ip_src_addr = ((u_int32*)(rec+fo->srcaddr));  match = 0;  FT_STAILQ_FOREACH(ftflipmr, &lookup->list, chain) {    /* match? */    if ((*ip_src_addr & ftflipmr->mask) == ftflipmr->ip) {      match = 1;      break;    }  } /* ftflipmr */  /* if there was a match, then return that mode */  if (match)    return ftflipmr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_src_addr_l *//* * function: eval_match_ip_src_addr_h * * Evalute ip_src_addr as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_src_addr_h(struct ftfil_lookup_ip_address *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftchash_rec_fil_c32 *ftch_recfc32p;  u_int32 *ip_src_addr, hash;  int match;  ip_src_addr = ((u_int32*)(rec+fo->srcaddr));  match = 0;  hash = (*ip_src_addr>>16) ^ (*ip_src_addr & 0xFFFF);  hash = ((hash >>8) ^ (hash & 0x0FFF));  if ((ftch_recfc32p = ftchash_lookup(lookup->ftch, ip_src_addr, hash)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftch_recfc32p->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_src_addr_h *//* * function: eval_match_ip_src_addr_r * * Evalute ip_src_addr as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_src_addr_r(struct ftfil_lookup_ip_prefix *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_ip_prefix_rec *ftflipprr;  struct radix_node_head *rhead;  struct radix_sockaddr_in sock1;  int match;  sock1.sin_addr.s_addr = *((u_int32*)(rec+fo->srcaddr));  sock1.sin_len = sizeof sock1;  sock1.sin_family = AF_INET;  match = 0;  rhead = lookup->rhead;  if ((ftflipprr = (struct ftfil_lookup_ip_prefix_rec*)rhead->rnh_matchaddr(    &sock1, rhead)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftflipprr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_src_addr_r *//* * function: eval_match_ip_dst_addr_l * * Evalute ip_dst_addr as list * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_dst_addr_l(struct ftfil_lookup_ip_mask *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftfil_lookup_ip_mask_rec *ftflipmr;  u_int32 *ip_dst_addr;  int match;  ip_dst_addr = ((u_int32*)(rec+fo->dstaddr));  match = 0;  FT_STAILQ_FOREACH(ftflipmr, &lookup->list, chain) {    /* match? */    if ((*ip_dst_addr & ftflipmr->mask) == ftflipmr->ip) {      match = 1;      break;    }  } /* ftflipmr */  /* if there was a match, then return that mode */  if (match)    return ftflipmr->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_dst_addr_l *//* * function: eval_match_ip_dst_addr_h * * Evalute ip_dst_addr as hash * * returns: FT_FIL_MODE_PERMIT *          FT_FIL_MODE_DENY */inline int eval_match_ip_dst_addr_h(struct ftfil_lookup_ip_address *lookup,  char *rec, struct fts3rec_offsets *fo){  struct ftchash_rec_fil_c32 *ftch_recfc32p;  u_int32 *ip_dst_addr, hash;  int match;  ip_dst_addr = ((u_int32*)(rec+fo->dstaddr));  match = 0;  hash = (*ip_dst_addr>>16) ^ (*ip_dst_addr & 0xFFFF);  hash = ((hash >>8) ^ (hash & 0x0FFF));  if ((ftch_recfc32p = ftchash_lookup(lookup->ftch, ip_dst_addr, hash)))    match = 1;  /* if there was a match, then return that mode */  if (match)    return ftch_recfc32p->mode;  /* else return the default */  return lookup->default_mode;} /* eval_match_ip_dst_addr_h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -