modules/pc/protocol_config.h

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following functions.
  1. Command

   1 #ifndef READ_PROTOCOL_CONFIG
   2 #define READ_PROTOCOL_CONFIG
   3 
   4 /***************************************
   5   $Revision: 1.21 $
   6 
   7   Protocol config module (pc).  This is the protocol that the admin uses to
   8   talk to the server.
   9 
  10   Status: NOT REVUED, TESTED
  11 
  12   
  13   
  14   ******************/ /******************
  15   Copyright (c) 1999,2000,2001,2002               RIPE NCC
  16  
  17   All Rights Reserved
  18   
  19   Permission to use, copy, modify, and distribute this software and its
  20   documentation for any purpose and without fee is hereby granted,
  21   provided that the above copyright notice appear in all copies and that
  22   both that copyright notice and this permission notice appear in
  23   supporting documentation, and that the name of the author not be
  24   used in advertising or publicity pertaining to distribution of the
  25   software without specific, written prior permission.
  26   
  27   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  28   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
  29   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
  30   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  31   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  32   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33   ***************************************/
  34 
  35 #define DEFAULT_USER_NAME "user"
  36 
  37 /*+ Log message +*/
  38 #define LOG_CONFIG "[%d] %s %s %s\n"
  39 
  40 /*+ This propmt is sent to the user. +*/
  41 /*
  42 #define PROMPT  "\nwhois R.I.P. config> "
  43 #define PROMPT  "\nwhois \033[0;1;33;40mR.I.P.\033[0m config> "
  44 */
  45 
  46 /*+ This login propmt is sent to the user. +*/
  47 #define LOGIN_PROMPT  "\nlogin: "
  48 
  49 /*+ This password propmt is sent to the user. +*/
  50 #define PASSWD_PROMPT  "password: "
  51 
  52 /* XXX Why doesn't invisible work ???!?!?!
  53 
  54 http://www.dee.ufpb.br/~bob/tools/ansi.html
  55 http://cs.wwc.edu/~bellmi/ANSI_escape_codes.html
  56 
  57 #define ECHO_ON "\033[8m"
  58 */
  59 
  60 /* Use reverse video instead - grrr. */
  61 #define ECHO_ON "\033[33;43m"
  62 
  63 #define ECHO_OFF "\033[0m"
  64 
  65 #define CLEAR_SCREEN "\033[2J"
  66 
  67 /*+ This welcome message is sent to the user, upon connecting. +*/
  68 /*
  69 #define WELCOME  "Welcome to the whois R.I.P. server.\n"
  70 */
  71 
  72 #define HELP_ERROR        "Invalid help command: "
  73 #define HELP_HELP         "Print help information."
  74 #define HELP_QUIT         "Quit the server."
  75 #define HELP_SAVE         "Save a structure/object."
  76 #define HELP_SAVE_ACCESS_TREE "Saves the access control tree."
  77 #define HELP_SHOW         "Show the values of: (type show for a list)"
  78 #define HELP_SHOW_ERROR   "Invalid show command: "
  79 #define HELP_SHOW_CONST   "The values of a constant used in the server."
  80 #define HELP_SHOW_CONSTS  "The values of constants used in the server.\n"\
  81                           "(This is set from values in properties object.)"
  82 #define HELP_SHOW_PROPS   "The values of properties in the properties file."
  83 #define HELP_SHOW_THREADS "The properties of the client's thread."
  84 #define HELP_SHOW_WHOIS   "The values of the whois query module."
  85 #define HELP_SHOW_ACCESS  "The access to server."
  86 #define HELP_SHOW_ACL     "The access control list for server."
  87 #define HELP_SHOW_AUTO_SAVE "The access control list auto save status."
  88 #define HELP_SHOW_ERR     "Show the setup of the error path system"
  89 #define HELP_SHOW_MACROS  "Show the currently defined macros of the error path system"
  90 #define HELP_SHOW_UPTIME  "Show system uptime statistics"
  91 
  92 #define HELP_SET          "Set the values of: (type set for a list)"
  93 #define HELP_SET_ERROR    "Invalid set command: "
  94 #define HELP_SET_CONST    "Set the values of a constants: (type set const name=value)"
  95 #define HELP_SET_CONSTS   "Set the values of constants used in the server.\n"\
  96                           "(This is set from values in properties object.)"
  97 #define HELP_SET_PROPS    "Set the values of properties in the properties file."
  98 #define HELP_SET_AUTO_SAVE "Sets the auto saving of the access tree to SQL."
  99 #define HELP_SET_ACL      "Create/modify acl entries[A for a given address or prefix.\n" \
 100 "\tSyntax:  set acl ip[/prefixlength] column=value,column=value...\n" \
 101 "\tColumn names as in acl display. Unset columns are inherited."
 102 #define HELP_SET_NODENY   "Set the deny counter in the access tree to 0\n"\
 103                           "\tSyntax:  set nodeny ip"
 104 #define HELP_STOP         "Stop activities (type stop for a list)"
 105 #define HELP_STOP_QUERY   "Stop a query thread (arguments are: <socket #> <thread #>)"
 106 #define HELP_SET_UPDATES  "Pause/resume all update threads: \n"\
 107                           "\tSyntax: set updates {pause|resume}"
 108 #define HELP_SET_QUERIES  "Pause/resume all queries: \n"\
 109                           "\tSyntax: set queries {pause|resume}"
 110 #define HELP_SET_INITRX   "Reload radix trees for a given source: \n"\
 111                           "\tSyntax: set initrx <source>" 
 112 #define HELP_SET_ERR      "Modify the error path system.\n"\
 113                           "\tSyntax: set err <errspec>\n"\
 114                           "\tFor details of <errspec> please see the error specification document\n"
 115 
 116 #define HELP_SET_MACRO    "Set a new macro in the error path system"
 117 #define HELP_SET_COUNTER "Reset the counter for the given thread. Argument: thread_id"
 118 
 119 
 120 #define PC_RET_QUIT     (0xabcdef) /* make it really uniq */
 121 #define PC_RET_ERR      (1)
 122 
 123 
 124 void PC_interact(int sock);
 125 
 126 
 127 /*+ Each command has a +*/
 128 typedef struct _command {
 129   const char *name;                          /*+ Name to be invoked. +*/
 130   int (*function)(char *, GString *, sk_conn_st *);/*+ Function to be invoked. +*/
 131   const char *help;                                /*+ Command help. +*/
 132 } Command;
     /* [<][>][^][v][top][bottom][index][help] */
 133 
 134 int show_commands(Command *comm, char *comm_name, GString *output);
 135 
 136 #ifdef PC_IMPL
 137 
 138 /*+
 139  * Contains the command definitions
 140 +*/
 141 struct _command command[] = {
 142   {"help"   , command_help   , HELP_HELP   },
 143   {"quit"   , command_quit   , HELP_QUIT   },
 144   {"save"   , command_save   , HELP_SAVE   },
 145   {"show"   , command_show   , HELP_SHOW   },
 146   {"stop"   , command_stop   , HELP_STOP   },
 147   {"set"    , command_set    , HELP_SET    },
 148   {"purify" , command_purify , "trigger a new memory-in-use report" },
 149   {NULL     , NULL           , NULL        }
 150 };
 151 
 152 /*+
 153  * Contains the save commands
 154 +*/
 155 struct _command save[] = {
 156   {"access_tree", save_access_tree, HELP_SAVE_ACCESS_TREE },
 157   {NULL         , NULL            , NULL                  }
 158 };
 159 
 160 /*+
 161  * Contains the show commands
 162 +*/
 163 struct _command show[] = {
 164   {"const"    , show_const    , HELP_SHOW_CONST     },
 165   {"consts"   , show_consts   , HELP_SHOW_CONSTS    },
 166   {"props"    , show_props    , HELP_SHOW_PROPS     },
 167   {"threads"  , show_threads  , HELP_SHOW_THREADS   },
 168   {"whois"    , show_whois    , HELP_SHOW_WHOIS     },
 169   {"access"   , show_access   , HELP_SHOW_ACCESS    },
 170   {"acl"      , show_acl      , HELP_SHOW_ACL       },
 171   {"auto_save", show_auto_save, HELP_SHOW_AUTO_SAVE },
 172   {"err"      , show_err      , HELP_SHOW_ERR       },
 173   {"macros"   , show_macros   , HELP_SHOW_MACROS    },
 174   {"uptime"   , show_uptime   , HELP_SHOW_UPTIME    },
 175   {NULL       , NULL          , NULL                }
 176 };
 177  
 178 /*+
 179  * Contains the set commands
 180 +*/
 181 struct _command set[] = {
 182   {"acl"      , set_acl       , HELP_SET_ACL       },
 183   {"nodeny"   , set_nodeny    , HELP_SET_NODENY    },
 184   {"updates"  , set_updates   , HELP_SET_UPDATES   },
 185   {"queries"  , set_queries   , HELP_SET_QUERIES   },
 186   {"err"      , set_err       , HELP_SET_ERR       },
 187   {"macro"    , set_macro     , HELP_SET_MACRO     }, 
 188 /*  {"counter", set_counter   , HELP_SET_COUNTER   },*/
 189   {"auto_save",  set_auto_save, HELP_SET_AUTO_SAVE },
 190   {"initrx"   ,  set_initrx   , HELP_SET_INITRX    },
 191   {NULL       , NULL          , NULL               }
 192 };
 193 
 194 struct _command stop[] = {
 195 /*  {"query"  , stop_query  , HELP_STOP_QUERY  },*/
 196   {NULL     , NULL        , NULL            }
 197 };
 198 
 199 #else
 200 
 201 extern struct _command command[], save[], show[], set[], stop[]; 
 202 
 203 #endif /* PC_IMPL */
 204 
 205 int command_execute(Command *comm, char *comm_name,
 206                     char *input, GString *output, sk_conn_st *condat) ;
 207 
 208 #endif /* READ_PROTOCOL_CONFIG */

/* [<][>][^][v][top][bottom][index][help] */