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

📄 plist.c

📁 linux 路由软件 可支持RIP OSPF BGP等
💻 C
📖 第 1 页 / 共 5 页
字号:
{  struct prefix_list *plist;  struct prefix_master *master;  int seqnum = 0;  master = prefix_master_get (afi);  if (master == NULL)    return CMD_WARNING;  if (seq)    seqnum = atoi (seq);  if (name)    {      plist = prefix_list_lookup (afi, name);      if (! plist)	{	  vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);	  return CMD_WARNING;	}      vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum);    }  else    {      if (dtype == detail_display || dtype == summary_display)	{	  if (master->recent)	    vty_out (vty, "Prefix-list with the last deletion/insertion: %s%s",		     master->recent->name, VTY_NEWLINE);	}      for (plist = master->num.head; plist; plist = plist->next)	vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum);      for (plist = master->str.head; plist; plist = plist->next)	vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum);    }  return CMD_SUCCESS;}intvty_show_prefix_list_prefix (struct vty *vty, afi_t afi, char *name, 			     char *prefix, enum display_type type){  struct prefix_list *plist;  struct prefix_list_entry *pentry;  struct prefix p;  int ret;  int match;  plist = prefix_list_lookup (afi, name);  if (! plist)    {      vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);      return CMD_WARNING;    }  ret = str2prefix (prefix, &p);  if (ret <= 0)    {      vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE);      return CMD_WARNING;    }  for (pentry = plist->head; pentry; pentry = pentry->next)    {      match = 0;      if (type == normal_display || type == first_match_display)	if (prefix_same (&p, &pentry->prefix))	  match = 1;      if (type == longer_display)	if (prefix_match (&p, &pentry->prefix))	  match = 1;      if (match)	{	  vty_out (vty, "   seq %d %s ", 		   pentry->seq,		   prefix_list_type_str (pentry));	  if (pentry->any)	    vty_out (vty, "any");	  else	    {	      struct prefix *p = &pentry->prefix;	      char buf[BUFSIZ];	      	      vty_out (vty, "%s/%d",		       inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),		       p->prefixlen);	      if (pentry->ge)		vty_out (vty, " ge %d", pentry->ge);	      if (pentry->le)		vty_out (vty, " le %d", pentry->le);	    }	  	  if (type == normal_display || type == first_match_display)	    vty_out (vty, " (hit count: %ld, refcount: %ld)", 		     pentry->hitcnt, pentry->refcnt);	  vty_out (vty, "%s", VTY_NEWLINE);	  if (type == first_match_display)	    return CMD_SUCCESS;	}    }  return CMD_SUCCESS;}intvty_clear_prefix_list (struct vty *vty, afi_t afi, char *name, char *prefix){  struct prefix_master *master;  struct prefix_list *plist;  struct prefix_list_entry *pentry;  int ret;  struct prefix p;  master = prefix_master_get (afi);  if (master == NULL)    return CMD_WARNING;  if (name == NULL && prefix == NULL)    {      for (plist = master->num.head; plist; plist = plist->next)	for (pentry = plist->head; pentry; pentry = pentry->next)	  pentry->hitcnt = 0;      for (plist = master->str.head; plist; plist = plist->next)	for (pentry = plist->head; pentry; pentry = pentry->next)	  pentry->hitcnt = 0;    }  else    {      plist = prefix_list_lookup (afi, name);      if (! plist)	{	  vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);	  return CMD_WARNING;	}      if (prefix)	{	  ret = str2prefix (prefix, &p);	  if (ret <= 0)	    {	      vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE);	      return CMD_WARNING;	    }	}      for (pentry = plist->head; pentry; pentry = pentry->next)	{	  if (prefix)	    {	      if (prefix_match (&pentry->prefix, &p))		pentry->hitcnt = 0;	    }	  else	    pentry->hitcnt = 0;	}    }  return CMD_SUCCESS;}DEFUN (ip_prefix_list,       ip_prefix_list_cmd,       "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, 				  argv[1], argv[2], NULL, NULL);}DEFUN (ip_prefix_list_ge,       ip_prefix_list_ge_cmd,       "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], 				 argv[2], argv[3], NULL);}DEFUN (ip_prefix_list_ge_le,       ip_prefix_list_ge_le_cmd,       "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1], 				  argv[2], argv[3], argv[4]);}DEFUN (ip_prefix_list_le,       ip_prefix_list_le_cmd,       "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1],				  argv[2], NULL, argv[3]);}DEFUN (ip_prefix_list_le_ge,       ip_prefix_list_le_ge_cmd,       "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], NULL, argv[1],				  argv[2], argv[4], argv[3]);}DEFUN (ip_prefix_list_seq,       ip_prefix_list_seq_cmd,       "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],				  argv[3], NULL, NULL);}DEFUN (ip_prefix_list_seq_ge,       ip_prefix_list_seq_ge_cmd,       "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],				  argv[3], argv[4], NULL);}DEFUN (ip_prefix_list_seq_ge_le,       ip_prefix_list_seq_ge_le_cmd,       "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],				  argv[3], argv[4], argv[5]);}DEFUN (ip_prefix_list_seq_le,       ip_prefix_list_seq_le_cmd,       "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],				  argv[3], NULL, argv[4]);}DEFUN (ip_prefix_list_seq_le_ge,       ip_prefix_list_seq_le_ge_cmd,       "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"){  return vty_prefix_list_install (vty, AFI_IP, argv[0], argv[1], argv[2],				  argv[3], argv[5], argv[4]);}DEFUN (no_ip_prefix_list,       no_ip_prefix_list_cmd,       "no ip prefix-list WORD",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, NULL,				    NULL, NULL, NULL);}DEFUN (no_ip_prefix_list_prefix,       no_ip_prefix_list_prefix_cmd,       "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Any prefix match.  Same as \"0.0.0.0/0 le 32\"\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],				    argv[2], NULL, NULL);}DEFUN (no_ip_prefix_list_ge,       no_ip_prefix_list_ge_cmd,       "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],				    argv[2], argv[3], NULL);}DEFUN (no_ip_prefix_list_ge_le,       no_ip_prefix_list_ge_le_cmd,       "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],				    argv[2], argv[3], argv[4]);}DEFUN (no_ip_prefix_list_le,       no_ip_prefix_list_le_cmd,       "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],				    argv[2], NULL, argv[3]);}DEFUN (no_ip_prefix_list_le_ge,       no_ip_prefix_list_le_ge_cmd,       "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Maximum prefix length to be matched\n"       "Maximum prefix length\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], NULL, argv[1],				    argv[2], argv[4], argv[3]);}DEFUN (no_ip_prefix_list_seq,       no_ip_prefix_list_seq_cmd,       "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Any prefix match.  Same as \"0.0.0.0/0 le 32\"\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2],				    argv[3], NULL, NULL);}DEFUN (no_ip_prefix_list_seq_ge,       no_ip_prefix_list_seq_ge_cmd,       "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"       "Minimum prefix length to be matched\n"       "Minimum prefix length\n"){  return vty_prefix_list_uninstall (vty, AFI_IP, argv[0], argv[1], argv[2],				    argv[3], argv[4], NULL);}DEFUN (no_ip_prefix_list_seq_ge_le,       no_ip_prefix_list_seq_ge_le_cmd,       "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",       NO_STR       IP_STR       PREFIX_LIST_STR       "Name of a prefix list\n"       "sequence number of an entry\n"       "Sequence number\n"       "Specify packets to reject\n"       "Specify packets to forward\n"       "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"

⌨️ 快捷键说明

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