Annotation of embedaddon/bird/proto/radv/config.Y, revision 1.1

1.1     ! misho       1: /*
        !             2:  *     BIRD -- Router Advertisement Configuration
        !             3:  *
        !             4:  *
        !             5:  *     Can be freely distributed and used under the terms of the GNU GPL.
        !             6:  */
        !             7: 
        !             8: CF_HDR
        !             9: 
        !            10: #include "proto/radv/radv.h"
        !            11: 
        !            12: CF_DEFINES
        !            13: 
        !            14: #define RADV_CFG ((struct radv_config *) this_proto)
        !            15: #define RADV_IFACE ((struct radv_iface_config *) this_ipatt)
        !            16: #define RADV_PREFIX this_radv_prefix
        !            17: #define RADV_RDNSS (&this_radv_rdnss)
        !            18: #define RADV_DNSSL (&this_radv_dnssl)
        !            19: 
        !            20: static struct radv_prefix_config *this_radv_prefix;
        !            21: static struct radv_rdnss_config this_radv_rdnss;
        !            22: static struct radv_dnssl_config this_radv_dnssl;
        !            23: static list radv_dns_list;     /* Used by radv_rdnss and radv_dnssl */
        !            24: static u8 radv_mult_val;       /* Used by radv_mult for second return value */
        !            25: 
        !            26: 
        !            27: CF_DECLS
        !            28: 
        !            29: CF_KEYWORDS(RADV, PREFIX, INTERFACE, MIN, MAX, RA, DELAY, INTERVAL,
        !            30:        MANAGED, OTHER, CONFIG, LINK, MTU, REACHABLE, TIME, RETRANS,
        !            31:        TIMER, CURRENT, HOP, LIMIT, DEFAULT, VALID, PREFERRED, MULT,
        !            32:        LIFETIME, SKIP, ONLINK, AUTONOMOUS, RDNSS, DNSSL, NS, DOMAIN,
        !            33:        LOCAL, TRIGGER, SENSITIVE, PREFERENCE, LOW, MEDIUM, HIGH)
        !            34: 
        !            35: %type<i> radv_mult radv_sensitive radv_preference
        !            36: 
        !            37: CF_GRAMMAR
        !            38: 
        !            39: CF_ADDTO(proto, radv_proto)
        !            40: 
        !            41: radv_proto_start: proto_start RADV
        !            42: {
        !            43:   this_proto = proto_config_new(&proto_radv, $1);
        !            44:   init_list(&RADV_CFG->patt_list);
        !            45:   init_list(&RADV_CFG->pref_list);
        !            46:   init_list(&RADV_CFG->rdnss_list);
        !            47:   init_list(&RADV_CFG->dnssl_list);
        !            48: };
        !            49: 
        !            50: radv_proto_item:
        !            51:    proto_item
        !            52:  | INTERFACE radv_iface
        !            53:  | PREFIX radv_prefix { add_tail(&RADV_CFG->pref_list, NODE this_radv_prefix); }
        !            54:  | RDNSS { init_list(&radv_dns_list); } radv_rdnss { add_tail_list(&RADV_CFG->rdnss_list, &radv_dns_list); }
        !            55:  | DNSSL { init_list(&radv_dns_list); } radv_dnssl { add_tail_list(&RADV_CFG->dnssl_list, &radv_dns_list); }
        !            56:  | TRIGGER prefix {
        !            57:      RADV_CFG->trigger_prefix = $2.addr;
        !            58:      RADV_CFG->trigger_pxlen = $2.len;
        !            59:      RADV_CFG->trigger_valid = 1;
        !            60:    }
        !            61:  ;
        !            62: 
        !            63: radv_proto_opts:
        !            64:    /* empty */
        !            65:  | radv_proto_opts radv_proto_item ';'
        !            66:  ;
        !            67: 
        !            68: radv_proto:
        !            69:    radv_proto_start proto_name '{' radv_proto_opts '}';
        !            70: 
        !            71: 
        !            72: radv_iface_start:
        !            73: {
        !            74:   this_ipatt = cfg_allocz(sizeof(struct radv_iface_config));
        !            75:   add_tail(&RADV_CFG->patt_list, NODE this_ipatt);
        !            76:   init_list(&this_ipatt->ipn_list);
        !            77:   init_list(&RADV_IFACE->pref_list);
        !            78:   init_list(&RADV_IFACE->rdnss_list);
        !            79:   init_list(&RADV_IFACE->dnssl_list);
        !            80: 
        !            81:   RADV_IFACE->min_ra_int = -1; /* undefined */
        !            82:   RADV_IFACE->max_ra_int = DEFAULT_MAX_RA_INT;
        !            83:   RADV_IFACE->min_delay = DEFAULT_MIN_DELAY;
        !            84:   RADV_IFACE->current_hop_limit = DEFAULT_CURRENT_HOP_LIMIT;
        !            85:   RADV_IFACE->default_lifetime = -1;
        !            86:   RADV_IFACE->default_lifetime_sensitive = 1;
        !            87:   RADV_IFACE->default_preference = RA_PREF_MEDIUM;
        !            88: };
        !            89: 
        !            90: radv_iface_item:
        !            91:    MIN RA INTERVAL expr { RADV_IFACE->min_ra_int = $4; if ($4 < 3) cf_error("Min RA interval must be at least 3"); }
        !            92:  | MAX RA INTERVAL expr { RADV_IFACE->max_ra_int = $4; if (($4 < 4) || ($4 > 1800)) cf_error("Max RA interval must be in range 4-1800"); }
        !            93:  | MIN DELAY expr { RADV_IFACE->min_delay = $3; if ($3 <= 0) cf_error("Min delay must be positive"); }
        !            94:  | MANAGED bool { RADV_IFACE->managed = $2; }
        !            95:  | OTHER CONFIG bool { RADV_IFACE->other_config = $3; }
        !            96:  | LINK MTU expr { RADV_IFACE->link_mtu = $3; if ($3 < 0) cf_error("Link MTU must be 0 or positive"); }
        !            97:  | REACHABLE TIME expr { RADV_IFACE->reachable_time = $3; if (($3 < 0) || ($3 > 3600000)) cf_error("Reachable time must be in range 0-3600000"); }
        !            98:  | RETRANS TIMER expr { RADV_IFACE->retrans_timer = $3; if ($3 < 0) cf_error("Retrans timer must be 0 or positive"); }
        !            99:  | CURRENT HOP LIMIT expr { RADV_IFACE->current_hop_limit = $4; if (($4 < 0) || ($4 > 255))  cf_error("Current hop limit must be in range 0-255"); }
        !           100:  | DEFAULT LIFETIME expr radv_sensitive {
        !           101:      RADV_IFACE->default_lifetime = $3;
        !           102:      if (($3 < 0) || ($3 > 9000))  cf_error("Default lifetime must be in range 0-9000");
        !           103:      if ($4 != -1) RADV_IFACE->default_lifetime_sensitive = $4;
        !           104:    }
        !           105:  | DEFAULT PREFERENCE radv_preference { RADV_IFACE->default_preference = $3; }
        !           106:  | PREFIX radv_prefix { add_tail(&RADV_IFACE->pref_list, NODE this_radv_prefix); }
        !           107:  | RDNSS { init_list(&radv_dns_list); } radv_rdnss { add_tail_list(&RADV_IFACE->rdnss_list, &radv_dns_list); }
        !           108:  | DNSSL { init_list(&radv_dns_list); } radv_dnssl { add_tail_list(&RADV_IFACE->dnssl_list, &radv_dns_list); }
        !           109:  | RDNSS LOCAL bool { RADV_IFACE->rdnss_local = $3; }
        !           110:  | DNSSL LOCAL bool { RADV_IFACE->dnssl_local = $3; }
        !           111:  ;
        !           112: 
        !           113: radv_preference:
        !           114:    LOW { $$ = RA_PREF_LOW; }
        !           115:  | MEDIUM { $$ = RA_PREF_MEDIUM; }
        !           116:  | HIGH { $$ = RA_PREF_HIGH; }
        !           117: 
        !           118: radv_iface_finish:
        !           119: {
        !           120:   struct radv_iface_config *ic = RADV_IFACE;
        !           121: 
        !           122:   if (ic->min_ra_int == (u32) -1)
        !           123:     ic->min_ra_int = MAX_(ic->max_ra_int / 3, 3);
        !           124: 
        !           125:   if (ic->default_lifetime == (u32) -1)
        !           126:     ic->default_lifetime = 3 * ic->max_ra_int;
        !           127: 
        !           128:   if ((ic->min_ra_int > 3) &&
        !           129:       (ic->min_ra_int > (ic->max_ra_int * 3 / 4)))
        !           130:     cf_error("Min RA interval must be at most 3/4 * Max RA interval %d %d", ic->min_ra_int, ic->max_ra_int);
        !           131: 
        !           132:   if ((ic->default_lifetime > 0) && (ic->default_lifetime < ic->max_ra_int))
        !           133:     cf_error("Default lifetime must be either 0 or at least Max RA interval");
        !           134: };
        !           135: 
        !           136: 
        !           137: radv_iface_opts:
        !           138:    /* empty */
        !           139:  | radv_iface_opts radv_iface_item ';'
        !           140:  ;
        !           141: 
        !           142: radv_iface_opt_list:
        !           143:    /* empty */
        !           144:  | '{' radv_iface_opts '}'
        !           145:  ;
        !           146: 
        !           147: radv_iface:
        !           148:   radv_iface_start iface_patt_list_nopx radv_iface_opt_list radv_iface_finish;
        !           149: 
        !           150: 
        !           151: radv_prefix_start: prefix
        !           152: {
        !           153:   this_radv_prefix = cfg_allocz(sizeof(struct radv_prefix_config));
        !           154:   RADV_PREFIX->prefix = $1.addr;
        !           155:   RADV_PREFIX->pxlen = $1.len;
        !           156: 
        !           157:   RADV_PREFIX->onlink = 1;
        !           158:   RADV_PREFIX->autonomous = 1;
        !           159:   RADV_PREFIX->valid_lifetime = DEFAULT_VALID_LIFETIME;
        !           160:   RADV_PREFIX->preferred_lifetime = DEFAULT_PREFERRED_LIFETIME;
        !           161: };
        !           162: 
        !           163: radv_prefix_item:
        !           164:    SKIP bool { RADV_PREFIX->skip = $2; }
        !           165:  | ONLINK bool { RADV_PREFIX->onlink = $2; }
        !           166:  | AUTONOMOUS bool { RADV_PREFIX->autonomous = $2; }
        !           167:  | VALID LIFETIME expr radv_sensitive {
        !           168:      RADV_PREFIX->valid_lifetime = $3;
        !           169:      if ($3 < 0) cf_error("Valid lifetime must be 0 or positive");
        !           170:      if ($4 != -1) RADV_PREFIX->valid_lifetime_sensitive = $4;
        !           171:    }
        !           172:  | PREFERRED LIFETIME expr radv_sensitive {
        !           173:      RADV_PREFIX->preferred_lifetime = $3;
        !           174:      if ($3 < 0) cf_error("Preferred lifetime must be 0 or positive");
        !           175:      if ($4 != -1) RADV_PREFIX->preferred_lifetime_sensitive = $4;
        !           176:    }
        !           177:  ;
        !           178: 
        !           179: radv_prefix_finish:
        !           180: {
        !           181:   if (RADV_PREFIX->preferred_lifetime > RADV_PREFIX->valid_lifetime)
        !           182:     cf_error("Preferred lifetime must be at most Valid lifetime");
        !           183: 
        !           184:   if (RADV_PREFIX->valid_lifetime_sensitive > RADV_PREFIX->preferred_lifetime_sensitive)
        !           185:     cf_error("Valid lifetime sensitive requires that Preferred lifetime is sensitive too");
        !           186: };
        !           187: 
        !           188: radv_prefix_opts:
        !           189:    /* empty */
        !           190:  | radv_prefix_opts radv_prefix_item ';'
        !           191:  ;
        !           192: 
        !           193: radv_prefix_opt_list:
        !           194:    /* empty */
        !           195:  | '{' radv_prefix_opts '}'
        !           196:  ;
        !           197: 
        !           198: radv_prefix:
        !           199:   radv_prefix_start radv_prefix_opt_list radv_prefix_finish;
        !           200: 
        !           201: 
        !           202: 
        !           203: radv_rdnss_node: ipa
        !           204: {
        !           205:   struct radv_rdnss_config *cf = cfg_allocz(sizeof(struct radv_rdnss_config));
        !           206:   add_tail(&radv_dns_list, NODE cf);
        !           207: 
        !           208:   cf->server = $1;
        !           209:   cf->lifetime_mult = DEFAULT_DNS_LIFETIME_MULT;
        !           210: };
        !           211: 
        !           212: radv_rdnss_start:
        !           213: {
        !           214:   RADV_RDNSS->lifetime = 0;
        !           215:   RADV_RDNSS->lifetime_mult = DEFAULT_DNS_LIFETIME_MULT;
        !           216: };
        !           217: 
        !           218: radv_rdnss_item:
        !           219:  | NS radv_rdnss_node
        !           220:  | LIFETIME radv_mult { RADV_RDNSS->lifetime = $2; RADV_RDNSS->lifetime_mult = radv_mult_val; }
        !           221:  ;
        !           222: 
        !           223: radv_rdnss_finish:
        !           224: {
        !           225:   if (EMPTY_LIST(radv_dns_list))
        !           226:     cf_error("No nameserver in RDNSS section");
        !           227: 
        !           228:   struct radv_rdnss_config *cf;
        !           229:   WALK_LIST(cf, radv_dns_list)
        !           230:   {
        !           231:     cf->lifetime = RADV_RDNSS->lifetime;
        !           232:     cf->lifetime_mult = RADV_RDNSS->lifetime_mult;
        !           233:   }
        !           234: };
        !           235: 
        !           236: radv_rdnss_opts:
        !           237:    /* empty */
        !           238:  | radv_rdnss_opts radv_rdnss_item ';'
        !           239:  ;
        !           240: 
        !           241: radv_rdnss:
        !           242:    radv_rdnss_node
        !           243:  | '{' radv_rdnss_start radv_rdnss_opts '}' radv_rdnss_finish
        !           244:  ;
        !           245: 
        !           246: 
        !           247: radv_dnssl_node: TEXT
        !           248: {
        !           249:   struct radv_dnssl_config *cf = cfg_allocz(sizeof(struct radv_dnssl_config));
        !           250:   add_tail(&radv_dns_list, NODE cf);
        !           251: 
        !           252:   cf->domain = $1;
        !           253:   cf->lifetime_mult = DEFAULT_DNS_LIFETIME_MULT;
        !           254: 
        !           255:   if (radv_process_domain(cf) < 0)
        !           256:     cf_error("Invalid domain dame");
        !           257: };
        !           258: 
        !           259: radv_dnssl_start:
        !           260: {
        !           261:   RADV_DNSSL->lifetime = 0;
        !           262:   RADV_DNSSL->lifetime_mult = DEFAULT_DNS_LIFETIME_MULT;
        !           263: };
        !           264: 
        !           265: radv_dnssl_item:
        !           266:  | DOMAIN radv_dnssl_node
        !           267:  | LIFETIME radv_mult { RADV_DNSSL->lifetime = $2; RADV_DNSSL->lifetime_mult = radv_mult_val; }
        !           268:  ;
        !           269: 
        !           270: radv_dnssl_finish:
        !           271: {
        !           272:   if (EMPTY_LIST(radv_dns_list))
        !           273:     cf_error("No domain in DNSSL section");
        !           274: 
        !           275:   struct radv_dnssl_config *cf;
        !           276:   WALK_LIST(cf, radv_dns_list)
        !           277:   {
        !           278:     cf->lifetime = RADV_DNSSL->lifetime;
        !           279:     cf->lifetime_mult = RADV_DNSSL->lifetime_mult;
        !           280:   }
        !           281: };
        !           282: 
        !           283: radv_dnssl_opts:
        !           284:    /* empty */
        !           285:  | radv_dnssl_opts radv_dnssl_item ';'
        !           286:  ;
        !           287: 
        !           288: radv_dnssl:
        !           289:    radv_dnssl_node
        !           290:  | '{' radv_dnssl_start radv_dnssl_opts '}' radv_dnssl_finish
        !           291:  ;
        !           292: 
        !           293: 
        !           294: radv_mult:
        !           295:    expr { $$ = $1; radv_mult_val = 0; }
        !           296:  | MULT expr { $$ = 0; radv_mult_val = $2; if (($2 < 1) || ($2 > 254)) cf_error("Multiplier must be in range 1-254"); }
        !           297:  ;
        !           298: 
        !           299: radv_sensitive:
        !           300:    /* empty */ { $$ = -1; }
        !           301:  | SENSITIVE bool { $$ = $2; }
        !           302:  ;
        !           303: 
        !           304: CF_CODE
        !           305: 
        !           306: CF_END

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>