"Fossies" - the Fresh Open Source Software Archive

Member "bandwidthd-2.0.1/conf.y" (9 Jan 2005, 3161 Bytes) of package /linux/privat/old/bandwidthd-2.0.1.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bison source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1  %{
    2 #include <stdio.h>
    3 #include <string.h>
    4 #include <unistd.h>
    5 #include <stdlib.h>
    6 #include <unistd.h>
    7 #include <sys/types.h>
    8 #include <signal.h>
    9 #include <sys/socket.h>
   10 #include <netinet/in.h>
   11 #include <arpa/inet.h>
   12 #include "bandwidthd.h"
   13 
   14 extern unsigned int SubnetCount;
   15 extern struct SubnetData SubnetTable[];
   16 extern struct config config;
   17 
   18 int bdconfig_lex(void);
   19 int LineNo = 1;
   20 
   21 void bdconfig_error(const char *str)
   22     {
   23     fprintf(stderr, "Syntax Error \"%s\" on line %d\n", str, LineNo);
   24     syslog(LOG_ERR, "Syntax Error \"%s\" on line %d", str, LineNo);
   25     exit(1);
   26     }
   27 
   28 int bdconfig_wrap()
   29     {
   30     return(1);
   31     }
   32 %}
   33 
   34 %token TOKJUNK TOKSUBNET TOKDEV TOKSLASH TOKSKIPINTERVALS TOKGRAPHCUTOFF 
   35 %token TOKPROMISC TOKOUTPUTCDF TOKRECOVERCDF TOKGRAPH TOKNEWLINE TOKFILTER
   36 %token TOKMETAREFRESH TOKPGSQLCONNECTSTRING TOKSENSORID
   37 %union
   38 {
   39     int number;
   40     char *string;
   41 }
   42 
   43 %token <string> IPADDR
   44 %token <number> NUMBER
   45 %token <string> STRING
   46 %token <number> STATE
   47 %type <string> string
   48 %%
   49 
   50 commands: /* EMPTY */
   51     | commands command
   52     ;
   53 
   54 command:
   55     subnet
   56     |
   57     device
   58     |
   59     skip_intervals
   60     |
   61     graph_cutoff
   62     |
   63     promisc
   64     |
   65     output_cdf
   66     |
   67     recover_cdf
   68     |
   69     graph
   70     |
   71     newline
   72     |
   73     filter
   74     |
   75     meta_refresh
   76     |
   77     pgsql_connect_string
   78     |
   79     sensor_id
   80     ;
   81 
   82 subnet:
   83     subneta
   84     |
   85     subnetb
   86     ;
   87 
   88 newline:
   89     TOKNEWLINE
   90     {
   91     LineNo++;
   92     }
   93     ;
   94 
   95 subneta:
   96     TOKSUBNET IPADDR IPADDR
   97     {
   98     struct in_addr addr, addr2;
   99     
  100     SubnetTable[SubnetCount].ip = inet_network($2) & inet_network($3);
  101         SubnetTable[SubnetCount].mask = inet_network($3);   
  102 
  103     addr.s_addr = ntohl(SubnetTable[SubnetCount].ip);
  104     addr2.s_addr = ntohl(SubnetTable[SubnetCount++].mask);
  105     syslog(LOG_INFO, "Monitoring subnet %s with netmask %s", inet_ntoa(addr), inet_ntoa(addr2));
  106     }
  107     ;
  108 
  109 subnetb:
  110     TOKSUBNET IPADDR TOKSLASH NUMBER
  111     {
  112     unsigned int Subnet, Counter, Mask;
  113     struct in_addr addr, addr2;
  114 
  115     Mask = 1; Mask <<= 31;
  116     for (Counter = 0, Subnet = 0; Counter < $4; Counter++)
  117         {
  118         Subnet >>= 1;
  119         Subnet |= Mask;
  120         }
  121     SubnetTable[SubnetCount].mask = Subnet; 
  122     SubnetTable[SubnetCount].ip = inet_network($2) & Subnet;
  123     addr.s_addr = ntohl(SubnetTable[SubnetCount].ip);
  124     addr2.s_addr = ntohl(SubnetTable[SubnetCount++].mask);
  125     syslog(LOG_INFO, "Monitoring subnet %s with netmask %s", inet_ntoa(addr), inet_ntoa(addr2));
  126     }
  127     ;
  128 
  129 string:
  130     STRING
  131     {
  132     $1[strlen($1)-1] = '\0';
  133     $$ = $1+1;
  134     }
  135     ;
  136 
  137 device:
  138     TOKDEV string
  139     {
  140     config.dev = $2;
  141     }
  142     ;
  143 
  144 filter:
  145     TOKFILTER string
  146     {
  147     config.filter = $2;
  148     }
  149     ;
  150 
  151 meta_refresh:
  152     TOKMETAREFRESH NUMBER
  153     {
  154     config.meta_refresh = $2;
  155     }
  156     ;
  157 
  158 skip_intervals:
  159     TOKSKIPINTERVALS NUMBER
  160     {
  161     config.skip_intervals = $2+1;
  162     }
  163     ;
  164 
  165 graph_cutoff:
  166     TOKGRAPHCUTOFF NUMBER
  167     {
  168     config.graph_cutoff = $2*1024;
  169     }
  170     ;
  171 
  172 promisc:
  173     TOKPROMISC STATE
  174     {
  175     config.promisc = $2;
  176     }
  177     ;
  178 
  179 output_cdf:
  180     TOKOUTPUTCDF STATE
  181     {
  182     config.output_cdf = $2;
  183     }
  184     ;
  185 
  186 recover_cdf:
  187     TOKRECOVERCDF STATE
  188     {
  189     config.recover_cdf = $2;
  190     }
  191     ;
  192 
  193 graph:
  194     TOKGRAPH STATE
  195     {
  196     config.graph = $2;
  197     }
  198     ;
  199 
  200 pgsql_connect_string:
  201     TOKPGSQLCONNECTSTRING string
  202     {
  203     config.db_connect_string = $2;
  204     config.output_database = DB_PGSQL;
  205     }
  206     ;
  207 
  208 sensor_id:
  209     TOKSENSORID string
  210     {
  211     config.sensor_id = $2;
  212     }
  213     ;