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

📄 ospf_vty.c

📁 router source code for the ospdf.
💻 C
📖 第 1 页 / 共 5 页
字号:
DEFUN (ospf_area_range_not_advertise,       ospf_area_range_not_advertise_cmd,       "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",       "OSPF area parameters\n"       "OSPF area ID in IP address format\n"       "OSPF area ID as a decimal value\n"       "Summarize routes matching address/mask (border routers only)\n"       "Area range prefix\n"       "DoNotAdvertise this range\n"){  struct ospf *ospf = vty->index;  struct prefix_ipv4 p;  struct in_addr area_id;  int format;  VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);  VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);  ospf_area_range_set (ospf, area_id, &p, 0);  return CMD_SUCCESS;}DEFUN (no_ospf_area_range,       no_ospf_area_range_cmd,       "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",       NO_STR       "OSPF area parameters\n"       "OSPF area ID in IP address format\n"       "OSPF area ID as a decimal value\n"       "Summarize routes matching address/mask (border routers only)\n"       "Area range prefix\n"){  struct ospf *ospf = vty->index;  struct prefix_ipv4 p;  struct in_addr area_id;  int format;  VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);  VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);  ospf_area_range_unset (ospf, area_id, &p);  return CMD_SUCCESS;}ALIAS (no_ospf_area_range,       no_ospf_area_range_advertise_cmd,       "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",       NO_STR       "OSPF area parameters\n"       "OSPF area ID in IP address format\n"       "OSPF area ID as a decimal value\n"       "Summarize routes matching address/mask (border routers only)\n"       "Area range prefix\n"       "Advertise this range (default)\n"       "DoNotAdvertise this range\n");ALIAS (no_ospf_area_range,       no_ospf_area_range_cost_cmd,       "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",       NO_STR       "OSPF area parameters\n"       "OSPF area ID in IP address format\n"       "OSPF area ID as a decimal value\n"       "Summarize routes matching address/mask (border routers only)\n"       "Area range prefix\n"       "User specified metric for this range\n"       "Advertised metric for this range\n");ALIAS (no_ospf_area_range,       no_ospf_area_range_advertise_cost_cmd,       "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",       NO_STR       "OSPF area parameters\n"       "OSPF area ID in IP address format\n"       "OSPF area ID as a decimal value\n"       "Summarize routes matching address/mask (border routers only)\n"       "Area range prefix\n"       "Advertise this range (default)\n"       "User specified metric for this range\n"       "Advertised metric for this range\n");DEFUN (ospf_area_range_substitute,       ospf_area_range_substitute_cmd,       "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",       "OSPF area parameters\n"       "OSPF area ID in IP address format\n"       "OSPF area ID as a decimal value\n"       "Summarize routes matching address/mask (border routers only)\n"       "Area range prefix\n"       "Announce area range as another prefix\n"       "Network prefix to be announced instead of range\n"){  struct ospf *ospf = vty->index;  struct prefix_ipv4 p, s;  struct in_addr area_id;  int format;  VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);  VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);  VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);  ospf_area_range_substitute_set (ospf, area_id, &p, &s);  return CMD_SUCCESS;}DEFUN (no_ospf_area_range_substitute,       no_ospf_area_range_substitute_cmd,       "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",       NO_STR       "OSPF area parameters\n"       "OSPF area ID in IP address format\n"       "OSPF area ID as a decimal value\n"       "Summarize routes matching address/mask (border routers only)\n"       "Area range prefix\n"       "Announce area range as another prefix\n"       "Network prefix to be announced instead of range\n"){  struct ospf *ospf = vty->index;  struct prefix_ipv4 p, s;  struct in_addr area_id;  int format;  VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);  VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);  VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);  ospf_area_range_substitute_unset (ospf, area_id, &p);  return CMD_SUCCESS;}/* Command Handler Logic in VLink stuff is delicate!!ALTER AT YOUR OWN RISK!!!!Various dummy values are used to represent 'NoChange' state forVLink configuration NOT being changed by a VLink command, andspecial syntax is used within the command strings so that thetyped in command verbs can be seen in the configuration commandbacckend handler.  This is to drastically reduce the verbeagerequired to coe up with a reasonably compatible Cisco VLink command- Matthew Grant <grantma@anathoth.gen.nz> Wed, 21 Feb 2001 15:13:52 +1300*//* Configuration data for virtual links  */ struct ospf_vl_config_data {  struct vty *vty;		/* vty stuff */  struct in_addr area_id;	/* area ID from command line */  int format;			/* command line area ID format */  struct in_addr vl_peer;	/* command line vl_peer */  int auth_type;		/* Authehntication type, if given */  char *auth_key;		/* simple password if present */  int crypto_key_id;		/* Cryptographic key ID */  char *md5_key;		/* MD5 authentication key */  int hello_interval;	        /* Obvious what these are... */  int retransmit_interval;   int transmit_delay;  int dead_interval;};voidospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, 			  struct vty *vty){  memset (vl_config, 0, sizeof (struct ospf_vl_config_data));  vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;  vl_config->vty = vty;}struct ospf_vl_data *ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config){  struct ospf_area *area;  struct ospf_vl_data *vl_data;  struct vty *vty;  struct in_addr area_id;  vty = vl_config->vty;  area_id = vl_config->area_id;  if (area_id.s_addr == OSPF_AREA_BACKBONE)    {      vty_out (vty, 	       "Configuring VLs over the backbone is not allowed%s",               VTY_NEWLINE);      return NULL;    }  area = ospf_area_get (ospf, area_id, vl_config->format);  if (area->external_routing != OSPF_AREA_DEFAULT)    {      if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)	vty_out (vty, "Area %s is %s%s",		 inet_ntoa (area_id),#ifdef HAVE_NSSA		 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",#else		 "stub",#endif /* HAVE_NSSA */		 		 VTY_NEWLINE);      else	vty_out (vty, "Area %ld is %s%s",		 (u_long)ntohl (area_id.s_addr),#ifdef HAVE_NSSA		 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",#else		 "stub",#endif /* HAVE_NSSA */		 		 VTY_NEWLINE);	      return NULL;    }    if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)    {      vl_data = ospf_vl_data_new (area, vl_config->vl_peer);      if (vl_data->vl_oi == NULL)	{	  vl_data->vl_oi = ospf_vl_new (ospf, vl_data);	  ospf_vl_add (ospf, vl_data);	  ospf_spf_calculate_schedule (ospf);	}    }  return vl_data;}intospf_vl_set_security (struct ospf_vl_data *vl_data,		      struct ospf_vl_config_data *vl_config){  struct crypt_key *ck;  struct vty *vty;  struct interface *ifp = vl_data->vl_oi->ifp;  vty = vl_config->vty;  if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)    {      SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);      IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;    }  if (vl_config->auth_key)    {      memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);      strncpy (IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, 	       OSPF_AUTH_SIMPLE_SIZE);    }  else if (vl_config->md5_key)    {      if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) 	  != NULL)	{	  vty_out (vty, "OSPF: Key %d already exists%s",		   vl_config->crypto_key_id, VTY_NEWLINE);	  return CMD_WARNING;	}      ck = ospf_crypt_key_new ();      ck->key_id = vl_config->crypto_key_id;      memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);      strncpy (ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);            ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);    }  else if (vl_config->crypto_key_id != 0)    {      /* Delete a key */      if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, 				 vl_config->crypto_key_id) == NULL)	{	  vty_out (vty, "OSPF: Key %d does not exist%s", 		   vl_config->crypto_key_id, VTY_NEWLINE);	  return CMD_WARNING;	}            ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);    }    return CMD_SUCCESS;}intospf_vl_set_timers (struct ospf_vl_data *vl_data,		    struct ospf_vl_config_data *vl_config){  struct interface *ifp = ifp = vl_data->vl_oi->ifp;  /* Virtual Link data initialised to defaults, so only set     if a value given */  if (vl_config->hello_interval)    {      SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);      IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;    }  if (vl_config->dead_interval)    {      SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);      IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;    }  if (vl_config->retransmit_interval)    {      SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);      IF_DEF_PARAMS (ifp)->retransmit_interval	= vl_config->retransmit_interval;    }    if (vl_config->transmit_delay)    {      SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);      IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;    }    return CMD_SUCCESS;}/* The business end of all of the above */intospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config){  struct ospf_vl_data *vl_data;  int ret;  vl_data = ospf_find_vl_data (ospf, vl_config);  if (!vl_data)    return CMD_WARNING;    /* Process this one first as it can have a fatal result, which can     only logically occur if the virtual link exists already     Thus a command error does not result in a change to the     running configuration such as unexpectedly altered timer      values etc.*/  ret = ospf_vl_set_security (vl_data, vl_config);  if (ret != CMD_SUCCESS)    return ret;  /* Set any time based parameters, these area already range checked */  ret = ospf_vl_set_timers (vl_data, vl_config);  if (ret != CMD_SUCCESS)    return ret;  return CMD_SUCCESS;}/* This stuff exists to make specifying all the alias commands A LOT simpler */#define VLINK_HELPSTR_IPADDR \       "OSPF area parameters\n" \       "OSPF area ID in IP address format\n" \       "OSPF area ID as a decimal value\n" \       "Configure a virtual link\n" \       "Router ID of the remote ABR\n"#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \       "Enable authentication on this virtual link\n" \       "dummy string \n" #define VLINK_HELPSTR_AUTHTYPE_ALL \       VLINK_HELPSTR_AUTHTYPE_SIMPLE \       "Use null authentication\n" \       "Use message-digest authentication\n"#define VLINK_HELPSTR_TIME_PARAM_NOSECS \       "Time between HELLO packets\n" \       "Time between retransmitting lost link state advertisements\n" \       "Link state transmit delay\n" \       "Interval after which a neighbor is declared dead\n"#define VLINK_HELPSTR_TIME_PARAM \       VLINK_HELPSTR_TIME_PARAM_NOSECS \       "Seconds\n"#define VLINK_HELPSTR_AUTH_SIMPLE \       "Authentication password (key)\n" \       "The OSPF password (key)"#define VLINK_HELPSTR_AUTH_MD5 \       "Message digest authentication password (key)\n" \       "dummy string \n" \       "Key ID\n" \       "Use MD5 algorithm\n" \       "The OSPF password (key)"DEFUN (ospf_area_vlink,       ospf_area_vlink_cmd,       "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",       VLINK_HELPSTR_IPADDR){  struct ospf *ospf = vty->index;  struct ospf_vl_config_data vl_config;  char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];  char md5_key[OSPF_AUTH_MD5_SIZE+1];   int i;  int ret;    ospf_vl_config_data_init(&vl_config, vty);  /* Read off first 2 parameters and check them */  ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);  if (ret < 0)    {      vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);      return CMD_WARNING;    }  ret = inet_aton (argv[1], &vl_config.vl_peer);  if (! ret)    {      vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",               VTY_NEWLINE);      return CMD_WARNING;    }  if (argc <=2)    {      /* Thats all folks! - BUGS B. strikes again!!!*/      return  ospf_vl_set (ospf, &vl_config);    }  /* Deal with other parameters */  for (i=2; i < argc; i++)    {      /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */      switch (argv[i][0])	{	case 'a':	  if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)	    {	      /* authentication-key - this option can occur anywhere on 		 command line.  At start of command line		 must check for authentication option. */	      memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);	      strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);	      vl_config.auth_key = auth_key;	      i++;	    }	  else if (strncmp (argv[i], "authentication", 14) == 0)	    {	      /* authentication  - this option can only occur at start		 of command line */	      vl_config.auth_type = OSPF_AUTH_SIMPLE;	      if ((i+1) < argc)		{		  if (strncmp (argv[i+1], "n", 1) == 0)		    {		      /* "authentication null" */		      vl_config.auth_type = OSPF_AUTH_NULL;		      i++;		    }		  else if (strncmp (argv[i+1], "m", 1) == 0			   && strcmp (argv[i+1], "message-digest-") != 0)		    {		      /* "authentication message-digest" */ 

⌨️ 快捷键说明

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