## modules/up/src/rpsl/rpsl/schema_rpsl.cc

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

## FUNCTIONS

This source file includes following functions.

1. addClass
2. initializeBase
3. initializeFromFile
4. initializeFromString
5. initialize

       1 //  $Id: schema_rpsl.cc,v 1.2 2000/08/03 11:16:31 engin Exp $
       2 //
       3 //  Copyright (c) 1994 by the University of Southern California
       4 //  All rights reserved.
       5 //
       6 //  Permission to use, copy, modify, and distribute this software and its
       7 //  documentation in source and binary forms for lawful non-commercial
       8 //  purposes and without fee is hereby granted, provided that the above
       9 //  copyright notice appear in all copies and that both the copyright
      10 //  notice and this permission notice appear in supporting documentation,
      11 //  and that any documentation, advertising materials, and other materials
      12 //  related to such distribution and use acknowledge that the software was
      13 //  developed by the University of Southern California, Information
      14 //  Sciences Institute. The name of the USC may not be used to endorse or
      15 //  promote products derived from this software without specific prior
      16 //  written permission.
      17 //
      18 //  THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY
      19 //  REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY
      20 //  PURPOSE.  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
      21 //  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
      22 //  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
      23 //  TITLE, AND NON-INFRINGEMENT.
      24 //
      25 //  IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
      26 //  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, TORT,
      27 //  OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, THE USE
      28 //  OR PERFORMANCE OF THIS SOFTWARE.
      29 //
      30 //  Questions concerning this software should be directed to
      31 //  ratoolset@isi.edu.
      32 //
      33 //  Author(s): Cengiz Alaettinoglu <cengiz@ISI.EDU>
      34
      35 #include "config.h"
      36
      37 #include <fstream.h>
      38 #include <cstring>
      39 #include "gnu/std.h"
      40
      41 #include "schema.hh"
      42 #include "object.hh"
      43 #include "rpsl.y.hh"
      44 #include "rptype.hh"
      45
      46 #define NO          0
      47 #define PRS         1
      48 #define MAN         1
      49 #define SNG         1
      50 #define HDN         1
      51 #define KEY         1
      52 #define IDX         1
      53 #define OBS         1
      54
      55
      56 char Schema::dictionary_text[] = "";
      57
      58 #define CMN_ATTRS "
      59 attr:  notify           syntax(email),                                         optional,  multiple
      60 attr:  remarks                                                                 optional,  multiple
      61 attr:  source           syntax(special,source),                                mandatory, single,   internal
      62 attr:  integrity        syntax(rpsl_word),                                     optional, single,   internal
      63 attr:  changed          syntax(special, changed),                              mandatory,  multiple
      64 attr:  delete                                                                  optional,  single, deleted
      65 attr:  override                                                                optional,  single"
      66
      67 static char base_text[] = "class: dictionary
      68 attr:  dictionary       syntax(rpsl_word),                                     mandatory, single,   key
      69 attr:  rp-attribute     syntax(special,rp-attribute),                          optional,  multiple
      70 attr:  typedef          syntax(special,typedef),                               optional,  multiple
      71 attr:  protocol         syntax(special,protocol),                              optional,  multiple
      72 attr:  notify           syntax(email),                                         optional,  multiple
      73 attr:  remarks                                                                 optional,  multiple
      74 attr:  source           syntax(rpsl_word),                                     mandatory, single,   internal
      75 attr:  integrity        syntax(rpsl_word),                                     optional, single,   internal
      76 attr:  changed          optional,  multiple
      77 attr:  deleted                                                                 optional,  single, deleted
      78 attr:  descr                                                                   mandatory, single
      79 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
      80 attr:  tech-c                                                                  mandatory, multiple, lookup
      81 attr:  admin-c                                                                 optional,  multiple, lookup
      82
      83 dictionary: rpsl
      84 descr:   rpsl dictionary
      85 admin-c: Cengiz Alaettinoglu
      86 tech-c: Cengiz Alaettinoglu
      87 mnt-by: MNT-CENGIZ
      88 changed: cengiz@isi.edu 19980324
      89 source: RPS-WG
      90 typedef: ListOfIPv4Prefix list of Address_Prefix
      91 typedef: Date integer[19000000,20000000]
      92 typedef: as_number-as_set_name union as_number, as_set_name
      93 typedef: ListOfas_number list of as_number
      94 typedef: ListOfas_number-as_set_name list of as_number-as_set_name
      95 typedef: ListOfas_set_name  list of as_set_name
      96 typedef: ListOfroute_set_name  list of route_set_name
      97 typedef: as_number-as_set_name-route_set_name-IPv4Prefix
      98          union as_number, as_set_name, route_set_name, Address_Prefix
      99 typedef: ListOfas_number-as_set_name-route_set_name-IPv4Prefix
     100          list of as_number-as_set_name-route_set_name-IPv4Prefix
     101 typedef: ListOfrpsl_word List of rpsl_word
     102 rp-attribute: # preference, smaller values represent higher preferences
     103               pref
     104               operator=(integer[0, 65535])
     105 rp-attribute: # BGP multi_exit_discriminator attribute
     106               med
     107               operator=(union integer[0, 65535], enum[igp_cost])
     108               # to set med to the IGP metric: med = igp_cost;
     109               #operator=(enum[igp_cost])
     110 rp-attribute: # BGP destination preference attribute (dpa)
     111               dpa
     112               operator=(integer[0, 65535])
     113 rp-attribute: # BGP aspath attribute
     114               aspath
     115               # prepends AS numbers from last to first order
     116               prepend(as_number, ...)
     117 typedef:      # a community value in RPSL is either
     118               #  - a 4 byte integer
     119               #  - internet, no_export, no_advertise (see RFC-1997)
     120               community_elm union
     121               integer[1, 4294967295],
     122               enum[internet, no_export, no_advertise]
     123 typedef:      # list of community values { 40, no_export, 3561:70}
     124               community_list
     125               list of community_elm
     126 #typedef:      # source list
     127 #              sources enum[RIPE, APNIC, MCI, INTERNIC, ARIN]
     128 #typedef:      country enum[NL, GB, UK, NL, DE, TR, PL, PT, IE, RU, AU, JP, TO, AT, IT]
     129 rp-attribute: # BGP community attribute
     130               community
     131               # set to a list of communities
     132               operator=(community_list)
     133               # order independent equality comparison
     134               operator==(community_list)
     135               # append community values
     136               operator.=(community_list)
     137               append(community_elm, ...)
     138               # delete community values
     139               delete(community_elm, ...)
     140               # a filter: true if one of community values is contained
     141               contains(community_elm, ...)
     142               # shortcut to contains: community(no_export, {3561,70})
     143               operator()(community_elm, ...)
     144 rp-attribute: # next hop router in a static route
     145               next-hop
     146               operator=(ipv4_address)       # a router address
     147               operator=(enum[self])         # router's own address
     148 rp-attribute: # cost of a static route
     149               cost
     150               operator=(integer[0, 65535])
     151 protocol: BGP4
     152           # as number of the peer router
     153           MANDATORY asno(as_number)
     154           # enable flap damping
     155           OPTIONAL flap_damp()
     156           OPTIONAL flap_damp(integer[0,65535],# penalty per flap
     157                              integer[0,65535],# penalty value for supression
     158                              integer[0,65535],# penalty value for reuse
     159                              integer[0,65535],# halflife in secs when up
     160                              integer[0,65535],# halflife in secs when down
     161                              integer[0,65535])# maximum penalty
     162 protocol: OSPF
     163 protocol: RIP
     164 protocol: IGRP
     165 protocol: IS-IS
     166 protocol: STATIC
     167 protocol: RIPng
     168 protocol: DVMRP
     169 protocol: PIM-DM
     170 protocol: PIM-SM
     171 protocol: CBT
     172 protocol: MOSPF
     173 ";
     174
     175 static char classes_text[] = "class: mntner
     176 attr:  mntner           syntax(rpsl_word),                                     mandatory, single,   key
     177 attr:  auth             syntax(special, auth),                                 mandatory, multiple
     178 attr:  upd-to           syntax(email),                                         mandatory, multiple
     179 attr:  mnt-nfy          syntax(email),                                         optional,  multiple                   " CMN_ATTRS "
     180 attr:  descr                                                                   mandatory, multiple
     181 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     182 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     183 attr:  tech-c           syntax(special,nichdl),                                optional,  multiple, lookup
     184
     185 class: person
     186 attr:  person           syntax(special,person),                                mandatory, single,   lookup
     187 attr:  nic-hdl          syntax(special,nichdl),                                mandatory, single,   key
     188 attr:  address                                                                 mandatory, multiple
     189 attr:  phone            syntax(special,phone),                                 mandatory, multiple
     190 attr:  fax-no           syntax(special,phone),                                 optional,  multiple
     191 attr:  e-mail           syntax(email),                                         optional,  multiple, lookup           " CMN_ATTRS "
     192 attr:  mnt-by           syntax(list of rpsl_word),                             optional,  multiple, lookup
     193
     194 class: role
     195 attr:  role             syntax(special,person),                                mandatory, single,   lookup
     196 attr:  nic-hdl          syntax(special,nichdl),                                mandatory, single,   key
     197 attr:  address                                                                 mandatory, multiple
     198 attr:  phone            syntax(special,phone),                                 mandatory, multiple
     199 attr:  fax-no           syntax(special,phone),                                 optional,  multiple
     200 attr:  e-mail           syntax(email),                                         mandatory, multiple, lookup
     201 attr:  trouble                                                                 optional,  multiple                   " CMN_ATTRS "
     202 attr:  mnt-by           syntax(list of rpsl_word),                             optional,  multiple, lookup
     203 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     204 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     205
     206 class: route
     207 attr:  route            syntax(address_prefix),                                mandatory, single,   key, lookup
     208 attr:  origin           syntax(as_number),                                     mandatory, single,   key, lookup
     209 attr:  member-of        syntax(ListOfroute_set_name),                          optional,  multiple, lookup
     210 attr:  inject           syntax(special, inject),                               optional,  multiple
     211 attr:  components       syntax(special, components),                           optional,  single
     212 attr:  aggr-bndry       syntax(special, aggr-bndry),                           optional,  single
     213 attr:  aggr-mtd         syntax(special, aggr-mtd),                             optional,  single
     214 attr:  export-comps     syntax(special, filter),                               optional,  single
     215 attr:  holes            syntax(ListOfIPv4Prefix),                              optional,  multiple                   " CMN_ATTRS "
     216 attr:  descr                                                                   mandatory, single
     217 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     218 attr:  admin-c          syntax(special,nichdl),                                optional,  multiple, lookup
     219 attr:  tech-c           syntax(special,nichdl),                                optional,  multiple, lookup
     220 attr:  cross-nfy        syntax(list of rpsl_word),                             optional,  multiple
     221 attr:  cross-mnt        syntax(list of rpsl_word),                             optional,  multiple
     222
     223 class: route-set
     224 attr:  route-set        syntax(route_set_name),                                mandatory, single,   key
     225 attr:  members          syntax(special, rs-members),                           optional,  multiple, lookup
     226 attr:  mbrs-by-ref      syntax(list of rpsl_Word),                             optional,  multiple, lookup           " CMN_ATTRS "
     227 attr:  descr                                                                   mandatory, single
     228 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     229 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     230 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     231
     232 class: as-set
     233 attr:  as-set           syntax(as_set_name),                                   mandatory, single,   key
     234 attr:  members          syntax(list of union as_number, as_set_name),          optional,  multiple, lookup
     235 attr:  mbrs-by-ref      syntax(list of rpsl_word),                             optional,  multiple, lookup           " CMN_ATTRS "
     236 attr:  descr                                                                   mandatory, single
     237 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     238 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     239 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     240
     241 class: rtr-set
     242 attr:  rtr-set        syntax(rtr_set_name),                                       mandatory, single,   key
     243 attr:  members        syntax(list of union rtr_set_name, dns_name, ipv4_address), optional,  multiple, lookup
     244 attr:  mbrs-by-ref    syntax(list of rpsl_Word),                                  optional,  multiple, lookup           " CMN_ATTRS "
     245 attr:  descr                                                                      mandatory, single
     246 attr:  mnt-by         syntax(list of rpsl_word),                                  mandatory, multiple, lookup
     247 attr:  admin-c        syntax(special,nichdl),                                     mandatory, multiple, lookup
     248 attr:  tech-c         syntax(special,nichdl),                                     mandatory, multiple, lookup
     249
     250 class: peering-set
     251 attr:  peering-set    syntax(peering_set_name),                                   mandatory, single,   key
     252 attr:  peering        syntax(special, peering),                                   mandatory, multiple                   " CMN_ATTRS "
     253 attr:  descr                                                                      mandatory, single
     254 attr:  mnt-by         syntax(list of rpsl_word),                                  mandatory, multiple, lookup
     255 attr:  admin-c        syntax(special,nichdl),                                     mandatory, multiple, lookup
     256 attr:  tech-c         syntax(special,nichdl),                                     mandatory, multiple, lookup
     257
     258 class: filter-set
     259 attr:  filter-set       syntax(filter_set_name),                               mandatory, single,   key
     260 attr:  filter           syntax(special, filter),                               mandatory, single                       " CMN_ATTRS "
     261 attr:  descr                                                                   mandatory, single
     262 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     263 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     264 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     265
     266 class: aut-num
     267 attr:  aut-num          syntax(as_number),                                     mandatory, single,   key
     268 attr:  as-name          syntax(rpsl_word),                                     optional, single,   lookup
     269 attr:  member-of        syntax(List Of AS_set_name),                           optional,  multiple, lookup
     270 attr:  import           syntax(special,import),                                optional,  multiple
     271 attr:  export           syntax(special,export),                                optional,  multiple
     272 attr:  default          syntax(special,default),                               optional,  multiple                   " CMN_ATTRS "
     273 attr:  descr                                                                   mandatory, multiple
     274 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     275 attr:  mnt-routes       syntax(special, mnt-routes),                           optional,  multiple, lookup
     276 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     277 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     278 attr:  cross-nfy        syntax(list of rpsl_word),                             optional,  multiple
     279 attr:  cross-mnt        syntax(list of rpsl_word),                             optional,  multiple
     280
     281 class: inet-rtr
     282 attr:  inet-rtr         syntax(dns_name),                                      mandatory, single,   key
     283 attr:  alias            syntax(dns_name),                                      optional,  multiple, lookup
     284 attr:  local-as         syntax(as_number),                                     mandatory, single,   lookup
     285 attr:  ifaddr           syntax(special,ifaddr),                                mandatory, multiple
     286 attr:  peer             syntax(special,peer),                                  optional,  multiple                   " CMN_ATTRS "
     287 attr:  member-of        syntax(List Of rtr_set_name),                          optional,  multiple, lookup
     288 attr:  descr                                                                   optional,  multiple
     289 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     290 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     291 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     292
     293 class: inetnum
     294 attr:  inetnum          syntax(range of ipv4_address),                         mandatory, single,   key
     295 attr:  netname          syntax(rpsl_word),                                     mandatory, single,   lookup
     296 attr:  country          syntax(special, country),                              mandatory, multiple
     297 attr:  rev-srv                                                                 optional,  multiple, lookup
     298 attr:  status           syntax(special,status_inet),                           mandatory, single
     299 attr:  mnt-lower        syntax(ListOfrpsl_word),                               optional,  multiple                   " CMN_ATTRS "
     300 attr:  descr                                                                   mandatory, multiple
     301 attr:  mnt-by           syntax(list of rpsl_word),                             optional,  multiple, lookup
     302 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     303 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     304
     305 class: inet6num
     306 attr:  inet6num          syntax(ipv6_prefix),                                  mandatory, single,   key
     307 attr:  netname           syntax(rpsl_word),                                    mandatory, single,   lookup
     308 attr:  country           syntax(special, country),                             mandatory, multiple
     309 attr:  rev-srv                                                                 optional,  multiple, lookup
     310 attr:  status                                                                  optional, generated, single
     311 attr:  mnt-lower        syntax(ListOfrpsl_word),                               optional,  multiple                   " CMN_ATTRS "
     312 attr:  descr                                                                   mandatory, multiple
     313 attr:  mnt-by           syntax(list of rpsl_word),                             optional,  multiple, lookup
     314 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     315 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     316
     317 class: domain
     318 attr:  domain           syntax(union dns_name, rpsl_word),                     mandatory, single,   key
     319 attr:  sub-dom                                                                 optional,  multiple, lookup
     320 attr:  dom-net                                                                 optional,  multiple
     321 attr:  zone-c          syntax(special,nichdl),                                 mandatory, multiple, lookup
     322 attr:  nserver                                                                 optional,  multiple, lookup
     323 attr:  refer           syntax(special, refer),    optional, single
     324 attr:  mnt-lower        syntax(ListOfrpsl_word),                               optional,  multiple                   " CMN_ATTRS "
     325 attr:  descr                                                                   mandatory, multiple
     326 attr:  mnt-by           syntax(list of rpsl_word),                             optional,  multiple, lookup
     327 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     328 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     329
     330 class: limerick
     331 attr:  limerick                                                                mandatory, single,   key
     332 attr:  text                                                                    mandatory, multiple
     333 attr:  author          syntax(special,nichdl),                                 mandatory, multiple, lookup           " CMN_ATTRS "
     334 attr:  descr                                                                   optional,  single
     335 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory, multiple, lookup
     336 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     337
     338 class: as-block
     339 attr:  as-block         syntax(union as_number, range of as_number),           mandatory, single,   key
     340 attr:  mnt-lower        syntax(ListOfrpsl_word),                               optional,  multiple                   " CMN_ATTRS "
     341 attr:  descr                                                                   mandatory, single
     342 attr:  mnt-by           syntax(list of rpsl_word),                             mandatory,  multiple, lookup
     343 attr:  admin-c          syntax(special,nichdl),                                mandatory, multiple, lookup
     344 attr:  tech-c           syntax(special,nichdl),                                mandatory, multiple, lookup
     345
     346 class: key-cert
     347 attr:  key-cert       mandatory, single,    key,        syntax(keycrtname)
     348 attr:  method         generated, optional, single,      syntax(rpsl_word)
     349 attr:  owner          generated, optional, multiple
     350 attr:  fingerpr       generated, optional, single
     351 attr:  certif         mandatory, single                        " CMN_ATTRS "
     352 attr:  mnt-by         mandatory, multiple, lookup,      syntax(list of rpsl_word)
     353
     354 class: peval
     355 attr:  peval            syntax(special,filter),                                 optional,  single
     356
     357 class: repository
     358 attr:  repository           mandatory,  single,  key,   syntax(rpsl_word)
     359 attr:  query-address        mandatory,  multiple
     360 attr:  response-auth-type   mandatory,  multiple
     361 attr:  submit-address       mandatory,  multiple
     362 attr:  submit-auth-type     mandatory,  multiple
     363 attr:  repository-cert      mandatory,  multiple
     364 attr:  expire               mandatory,  single
     365 attr:  heartbeat-interval   mandatory,  single
     366 attr:  descr                optional,   multiple
     367 attr:  admin-c              mandatory,  multiple, lookup
     368 attr:  tech-c               mandatory,  multiple, lookup
     369 attr:  mnt-by               mandatory,  multiple, lookup " CMN_ATTRS "
     370 ";
     371
     372 void Schema::addClass(AttrClass *clss) {
         /* [<][>][^][v][top][bottom][index][help] */
     373    classes[lastClass++] = clss;
     374 }
     375
     376 void Schema::initializeBase() {
         /* [<][>][^][v][top][bottom][index][help] */
     377    static bool initializeBaseDone = false;
     378    if (initializeBaseDone)
     379       return;
     380    initializeBaseDone = true;
     381
     382    AttrClass *classClass = new AttrClass(strdup("class"));
     383    AttrClass *clss = NULL;
     384
     385    addClass(classClass);
     386    classClass->addAttr(new AttrAttr(strdup("class"), ATTR_GENERIC,
     387                                     RPType::newRPType("rpsl_word"),
     388                                     AttrAttr::LOOKUP));
     389    classClass->addAttr(new AttrAttr(strdup("attr"), ATTR_ATTR,
     390                                     (RPType *) NULL,
     391                                     AttrAttr::MULTIVALUED));
     392
     393    dictionary = initializeFromString(base_text, "dictionary");
     394 }
     395
     396 List<Object> *Schema::initializeFromFile(char *filename) {
         /* [<][>][^][v][top][bottom][index][help] */
     397    Object *o;
     398    const AttrAttr *attr;
     399    char *class_name;
     400    bool code = true;
     401    List<Object> *result = new List<Object>;
     402    AttrClass *clss = NULL;
     403
     404    initializeBase();
     405
     406    ifstream in(filename);
     407    if (!in)
     408       return result;
     409
     410    while (in) {
     411       o = new Object;
     412       code = o->read(in);
     413       if (! code) {
     414          delete o;
     415          continue;
     416       }
     417
     418       code = o->scan();
     419       if (o->has_error)
     420          delete o;
     421       else {
     422          if (! strcasecmp(o->type->name, "class")) {
     423             AttrGenericIterator<ItemWORD> cname(o, "class");
     424             AttrIterator<AttrAttr>  attrItr(o, "attr");
     425             char *name = cname.first()->word;
     426
     427             addClass(clss = new AttrClass(strdup(name)));
     428             clss->object = o;
     429             //cerr << "Reading "<< name << " class definition..." << endl;
     430
     431             for (attr = attrItr.first(); attr; attr = attrItr.next())
     432                clss->addAttr((AttrAttr *) attr);
     433
     434          }
     435
     436          result->append(o);
     437       }
     438    }
     439
     440    return result;
     441 }
     442
     443 Object *Schema::initializeFromString(char *class_text, char *lookFor) {
         /* [<][>][^][v][top][bottom][index][help] */
     444    Object *o;
     445    const AttrAttr *attr;
     446    char *class_name;
     447    Object *result = (Object *) NULL;
     448    AttrClass *clss = NULL;
     449    int count = 0;
     450
     451    initializeBase();
     452
     453    do {
     454       count++;
     455       o = new Object;
     456       if (count == 2 && ! dictionary)
     457          dictionary = o;
     458
     459       o->scan(class_text, strlen(class_text));
     460
     461       if (o->has_error)
     462          delete o;
     463       else {
     464          if (!strcasecmp(o->type->name, "class")) {
     465             AttrGenericIterator<ItemWORD> cname(o, "class");
     466             AttrIterator<AttrAttr>  attrItr(o, "attr");
     467             char *name = cname.first()->word;
     468
     469             addClass(clss = new AttrClass(strdup(name)));
     470             clss->object = o;
     471             // cerr << "Reading "<< name << " class definition..." << endl;
     472
     473             for (attr = attrItr.first(); attr; attr = attrItr.next())
     474                clss->addAttr((AttrAttr *) attr);
     475
     476             //delete o;
     477          }
     478
     479          if (lookFor && ! strcasecmp(o->type->name, lookFor))
     480             result = o;
     481       }
     482
     483       class_text = strstr(class_text, "\n\n");
     484       if (class_text)
     485          class_text += 2;
     486    } while (class_text);
     487
     488    return result;
     489 }
     490
     491 void Schema::initialize() {
         /* [<][>][^][v][top][bottom][index][help] */
     492    initializeBase();
     493    initializeFromString(classes_text);
     494 }
     495
     496 static RPSLKeyword rpsl_keywords[] = {
     497    RPSLKeyword("true",     KEYW_TRUE,     1),
     498    RPSLKeyword("false",    KEYW_FALSE,    1),
     499    RPSLKeyword("action",   KEYW_ACTION,   1),
     500    RPSLKeyword("accept",   KEYW_ACCEPT,   1),
     501    RPSLKeyword("announce", KEYW_ANNOUNCE, 1),
     502    RPSLKeyword("from",     KEYW_FROM,     1),
     503    RPSLKeyword("to",       KEYW_TO,       1),
     504    RPSLKeyword("at",       KEYW_AT,       1),
     505    RPSLKeyword("any",      KEYW_ANY,      1),
     506    RPSLKeyword("protocol", KEYW_PROTOCOL, 1),
     507    RPSLKeyword("into",     KEYW_INTO,     1),
     508    RPSLKeyword("refine",   KEYW_REFINE,   1),
     509    RPSLKeyword("except",   KEYW_EXCEPT,   1),
     510    RPSLKeyword("static",   KEYW_STATIC,   1),
     511    RPSLKeyword("networks", KEYW_NETWORKS, 1),
     512    RPSLKeyword("masklen",  KEYW_MASKLEN,  1),
     513    RPSLKeyword("peeras",   KEYW_PEERAS,   1),
     514
     515    RPSLKeyword("atomic",   KEYW_ATOMIC,   1),
     516    RPSLKeyword("inbound",  KEYW_INBOUND,  1),
     517    RPSLKeyword("outbound", KEYW_OUTBOUND, 1),
     518
     519    RPSLKeyword("or",       OP_OR ,        1),
     520    RPSLKeyword("and",      OP_AND,        1),
     521    RPSLKeyword("not",      OP_NOT,        1),
     522
     523    RPSLKeyword("union",        KEYW_UNION,        1),
     524    RPSLKeyword("range",        KEYW_RANGE,        1),
     525    RPSLKeyword("list",         KEYW_LIST,         1),
     526    RPSLKeyword("of",           KEYW_OF,           1),
     527    RPSLKeyword("operator",     KEYW_OPERATOR,     1),
     528    RPSLKeyword("upon",         KEYW_UPON,         1),
     529    RPSLKeyword("have-components", KEYW_HAVE_COMPONENTS, 1),
     530    RPSLKeyword("exclude",      KEYW_EXCLUDE,      1),
     531
     532    RPSLKeyword("syntax",       KEYW_SYNTAX,       1),
     533    RPSLKeyword("special",      KEYW_SPECIAL,      1),
     534    RPSLKeyword("optional",     KEYW_OPTIONAL,     1),
     535    RPSLKeyword("mandatory",    KEYW_MANDATORY,    1),
     536    RPSLKeyword("internal",     KEYW_INTERNAL,     1),
     537    RPSLKeyword("single",       KEYW_SINGLEVALUED, 1),
     538    RPSLKeyword("multiple",     KEYW_MULTIVALUED,  1),
     539    RPSLKeyword("lookup",       KEYW_LOOKUP,       1),
     540    RPSLKeyword("key",          KEYW_KEY,          1),
     541    RPSLKeyword("deleted",      KEYW_DELETED,      1),
     542    RPSLKeyword("generated",    KEYW_GENERATED,    1),
     543    RPSLKeyword("none",         KEYW_NONE,         1),
     544    RPSLKeyword("mail-from",    KEYW_MAILFROM,     1),
     545    RPSLKeyword("crypt-pw",     KEYW_CRYPTPW,      1),
     546    RPSLKeyword("assigned",     KEYW_ASSIGNED,     1),
     547    RPSLKeyword("allocated",    KEYW_ALLOCATED,    1),
     548    RPSLKeyword("PA",           KEYW_PA,           1),
     549    RPSLKeyword("PI",           KEYW_PI,           1),
     550    RPSLKeyword("unspecified",  KEYW_UNSPECIFIED,  1),
     551    RPSLKeyword("ext",          KEYW_EXT,          1),
     552    RPSLKeyword("simple",       KEYW_SIMPLE,       1),
     553    RPSLKeyword("ripe",         KEYW_RIPE,         1),
     554    RPSLKeyword("internic",     KEYW_INTERNIC,     1),
     555    RPSLKeyword("clientaddress",KEYW_CLIENTADDRESS,1),
     556    RPSLKeyword(NULL,       0,             0)
     557 };
     558
     559 static RPSLKeyword rpsl_rules[] = {
     560    RPSLKeyword("changed",           ATTR_CHANGED,           1),
     561    RPSLKeyword("import",            ATTR_IMPORT,            1),
     562    RPSLKeyword("export",            ATTR_EXPORT,            1),
     563    RPSLKeyword("default",           ATTR_DEFAULT,           1),
     564    RPSLKeyword("ifaddr",            ATTR_IFADDR,            1),
     565    RPSLKeyword("peer",              ATTR_PEER,              1),
     566    RPSLKeyword("rp-attribute",      ATTR_RP_ATTR,           1),
     567    RPSLKeyword("typedef",           ATTR_TYPEDEF,           1),
     568    RPSLKeyword("protocol",          ATTR_PROTOCOL,          1),
     569    RPSLKeyword("filter",            ATTR_FILTER,            1),
     570    RPSLKeyword("peering",           ATTR_PEERING,           1),
     571    RPSLKeyword("blobs",             ATTR_BLOBS,             1),
     572    RPSLKeyword("mnt-routes",        ATTR_MNT_ROUTES,        1),
     573    RPSLKeyword("components",        ATTR_COMPONENTS,        1),
     574    RPSLKeyword("inject",            ATTR_INJECT,            1),
     575    RPSLKeyword("aggr-mtd",          ATTR_AGGR_MTD,          1),
     576    RPSLKeyword("aggr-bndry",        ATTR_AGGR_BNDRY,        1),
     577    RPSLKeyword("rs-members",        ATTR_RS_MEMBERS,        1),
     578    RPSLKeyword("nichdl",            ATTR_NICHDL,            1),
     579    RPSLKeyword("auth",              ATTR_AUTH,              1),
     580    RPSLKeyword("status_inet",       ATTR_STATUS_INET,       1),
     581    RPSLKeyword("phone",             ATTR_PHONE,             1),
     582    RPSLKeyword("source",            ATTR_SOURCE,            1),
     583    RPSLKeyword("refer",             ATTR_REFER,             1),
     584    RPSLKeyword("country",           ATTR_COUNTRY,           1),
     585    RPSLKeyword("person",            ATTR_PERSON,            1),
     586    RPSLKeyword(NULL, 0,                                     1)
     587 };
     588
     589 Schema schema(rpsl_keywords, rpsl_rules);

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