ospf_vty.h
上传用户:xiaozhuqw
上传日期:2009-11-15
资源大小:1338k
文件大小:5k
源码类别:

网络

开发平台:

Unix_Linux

  1. /* OSPF VTY interface.
  2.  * Copyright (C) 2000 Toshiaki Takada
  3.  *
  4.  * This file is part of GNU Zebra.
  5.  *
  6.  * GNU Zebra is free software; you can redistribute it and/or modify it
  7.  * under the terms of the GNU General Public License as published by the
  8.  * Free Software Foundation; either version 2, or (at your option) any
  9.  * later version.
  10.  *
  11.  * GNU Zebra is distributed in the hope that it will be useful, but
  12.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with GNU Zebra; see the file COPYING.  If not, write to the Free
  18.  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19.  * 02111-1307, USA.  
  20.  */
  21. /* Macros. */
  22. #define VTY_GET_UINT32(NAME,V,STR)                                            
  23. {                                                                             
  24.   char *endptr = NULL;                                                        
  25.   (V) = strtoul ((STR), &endptr, 10);                                         
  26.   if (*endptr != '' || ((V) == ULONG_MAX && errno == ERANGE))               
  27.     {                                                                         
  28.       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE);              
  29.       return CMD_WARNING;                                                     
  30.     }                                                                         
  31. }
  32. #define VTY_GET_IPV4_ADDRESS(NAME,V,STR)                                      
  33. {                                                                             
  34.   int retv;                                                                   
  35.   retv = inet_aton ((STR), &(V));                                             
  36.   if (!retv)                                                                  
  37.     {                                                                         
  38.       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE);              
  39.       return CMD_WARNING;                                                     
  40.     }                                                                         
  41. }
  42. #define VTY_GET_IPV4_PREFIX(NAME,V,STR)                                       
  43. {                                                                             
  44.   int retv;                                                                   
  45.   retv = str2prefix_ipv4 ((STR), &(V));                                       
  46.   if (retv <= 0)                                                              
  47.     {                                                                         
  48.       vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE);              
  49.       return CMD_WARNING;                                                     
  50.     }                                                                         
  51. }
  52. #define VTY_GET_OSPF_AREA_ID(V,F,STR)                                         
  53. {                                                                             
  54.   int retv;                                                                   
  55.   retv = ospf_str2area_id ((STR), &(V), &(F));                                
  56.   if (retv < 0)                                                               
  57.     {                                                                         
  58.       vty_out (vty, "%% Invalid OSPF area ID%s", VTY_NEWLINE);                
  59.       return CMD_WARNING;                                                     
  60.     }                                                                         
  61. }
  62. #define VTY_GET_OSPF_AREA_ID_NO_BB(NAME,V,F,STR)                              
  63. {                                                                             
  64.   int retv;                                                                   
  65.   retv = ospf_str2area_id ((STR), &(V), &(F));                                
  66.   if (retv < 0)                                                               
  67.     {                                                                         
  68.       vty_out (vty, "%% Invalid OSPF area ID%s", VTY_NEWLINE);                
  69.       return CMD_WARNING;                                                     
  70.     }                                                                         
  71.   if (OSPF_IS_AREA_ID_BACKBONE ((V)))                                         
  72.     {                                                                         
  73.       vty_out (vty, "%% You can't configure %s to backbone%s",                
  74.                NAME, VTY_NEWLINE);                                            
  75.     }                                                                         
  76. }
  77. /* Prototypes. */
  78. void ospf_vty_init ();
  79. void ospf_vty_show_init ();