コード例 #1
0
struct ospf_interface *
ospf_if_lookup_by_prefix (struct ospf *ospf, struct prefix_ipv4 *p)
{
  struct listnode *node;
  struct ospf_interface *oi;
  struct prefix ptmp;
  
  /* Check each Interface. */
  for (node = listhead (ospf->oiflist); node; nextnode (node))
    {
      if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
	{
	  if ((oi->type == OSPF_IFTYPE_POINTOPOINT) &&
	      CONNECTED_DEST_HOST(oi->connected))
	    {
	      prefix_copy (&ptmp, oi->connected->destination);
	      ptmp.prefixlen = IPV4_MAX_BITLEN;
	    }
	  else
	    prefix_copy (&ptmp, oi->address);
	
	  apply_mask (&ptmp);
	  if (prefix_same (&ptmp, (struct prefix *) p))
	    return oi;
	}
    }
  return NULL;
}
コード例 #2
0
ファイル: mailinfo.c プロジェクト: 9b/git
int cmd_mailinfo(int argc, const char **argv, const char *prefix)
{
	const char *def_charset;
	struct mailinfo mi;
	int status;
	char *msgfile, *patchfile;

	setup_mailinfo(&mi);

	def_charset = get_commit_output_encoding();
	mi.metainfo_charset = def_charset;

	while (1 < argc && argv[1][0] == '-') {
		if (!strcmp(argv[1], "-k"))
			mi.keep_subject = 1;
		else if (!strcmp(argv[1], "-b"))
			mi.keep_non_patch_brackets_in_subject = 1;
		else if (!strcmp(argv[1], "-m") || !strcmp(argv[1], "--message-id"))
			mi.add_message_id = 1;
		else if (!strcmp(argv[1], "-u"))
			mi.metainfo_charset = def_charset;
		else if (!strcmp(argv[1], "-n"))
			mi.metainfo_charset = NULL;
		else if (starts_with(argv[1], "--encoding="))
			mi.metainfo_charset = argv[1] + 11;
		else if (!strcmp(argv[1], "--scissors"))
			mi.use_scissors = 1;
		else if (!strcmp(argv[1], "--no-scissors"))
			mi.use_scissors = 0;
		else if (!strcmp(argv[1], "--no-inbody-headers"))
			mi.use_inbody_headers = 0;
		else
			usage(mailinfo_usage);
		argc--; argv++;
	}

	if (argc != 3)
		usage(mailinfo_usage);

	mi.input = stdin;
	mi.output = stdout;

	msgfile = prefix_copy(prefix, argv[1]);
	patchfile = prefix_copy(prefix, argv[2]);

	status = !!mailinfo(&mi, msgfile, patchfile);
	clear_mailinfo(&mi);

	free(msgfile);
	free(patchfile);
	return status;
}
コード例 #3
0
static struct ospf6_damp_info *
ospf6_damp_create (u_short type, struct prefix *name)
{
    struct route_node *node;
    struct ospf6_damp_info *di;
    char namebuf[64];

    di = ospf6_damp_lookup (type, name);
    if (di)
        return di;

    if (IS_OSPF6_DEBUG_DAMP)
    {
        prefix2str (name, namebuf, sizeof (namebuf));
        zlog_info ("DAMP: create: type: %d, name: %s", type, namebuf);
    }

    di = (struct ospf6_damp_info *)
         malloc (sizeof (struct ospf6_damp_info));
    memset (di, 0, sizeof (struct ospf6_damp_info));
    di->type = type;
    prefix_copy (&di->name, name);

    node = route_node_get (damp_info_table[type], name);
    node->info = di;

    return di;
}
コード例 #4
0
ファイル: bgp_table.c プロジェクト: Addision/LVS
/* Allocate new route node with prefix set. */
static struct bgp_node *
bgp_node_set (struct bgp_table *table, struct prefix *prefix)
{
  struct bgp_node *node;
  
  node = bgp_node_create ();

  prefix_copy (&node->p, prefix);
  node->table = table;

  return node;
}
コード例 #5
0
ファイル: table.c プロジェクト: millken/zhuxianB30
/* Allocate new route node with prefix set. */
static struct route_node *
route_node_set (struct route_table *table, struct prefix *prefix)
{
  struct route_node *node;
  
  node = route_node_new ();

  prefix_copy (&node->p, prefix);
  node->table = table;

  return node;
}
コード例 #6
0
ファイル: sharp_nht.c プロジェクト: ton31337/frr
struct sharp_nh_tracker *sharp_nh_tracker_get(struct prefix *p)
{
	struct listnode *node;
	struct sharp_nh_tracker *nht;

	for (ALL_LIST_ELEMENTS_RO(sg.nhs, node, nht)) {
		if (prefix_same(&nht->p, p))
			break;
	}

	if (nht)
		return nht;

	nht = XCALLOC(MTYPE_NH_TRACKER, sizeof(*nht));
	prefix_copy(&nht->p, p);

	listnode_add(sg.nhs, nht);
	return nht;
}
コード例 #7
0
ファイル: ospf_interface.c プロジェクト: yubo/quagga
struct ospf_interface *ospf_if_lookup_by_prefix(struct ospf *ospf,
						struct prefix_ipv4 *p)
{
	struct listnode *node;
	struct ospf_interface *oi;

	/* Check each Interface. */
	for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) {
		if (oi->type != OSPF_IFTYPE_VIRTUALLINK) {
			struct prefix ptmp;

			prefix_copy(&ptmp, CONNECTED_PREFIX(oi->connected));
			apply_mask(&ptmp);
			if (prefix_same(&ptmp, (struct prefix *)p))
				return oi;
		}
	}
	return NULL;
}
コード例 #8
0
ファイル: ospf_interface.c プロジェクト: xi-yang/DRAGON
struct ospf_interface *
ospf_if_lookup_by_prefix (struct ospf *ospf, struct prefix_ipv4 *p)
{
  listnode node;
  struct ospf_interface *oi;
  struct prefix ptmp;
  
  /* Check each Interface. */
  for (node = listhead (ospf->oiflist); node; nextnode (node))
    {
      if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK)
	{
	  prefix_copy (&ptmp, oi->address);

	  if (oi->type == OSPF_IFTYPE_POINTOPOINT)
  	      ptmp.prefixlen = IPV4_ALLOWABLE_BITLEN_P2P;
	
	  apply_mask (&ptmp);
	  if (prefix_same (&ptmp, (struct prefix *) p))
	    return oi;
	}
    }
  return NULL;
}