178064Sume/* $KAME: parser.y,v 1.8 2000/11/08 03:03:34 jinmei Exp $ */ 262638Skris 355505Sshin/* 455505Sshin * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 555505Sshin * All rights reserved. 655505Sshin * 755505Sshin * Redistribution and use in source and binary forms, with or without 855505Sshin * modification, are permitted provided that the following conditions 955505Sshin * are met: 1055505Sshin * 1. Redistributions of source code must retain the above copyright 1155505Sshin * notice, this list of conditions and the following disclaimer. 1255505Sshin * 2. Redistributions in binary form must reproduce the above copyright 1355505Sshin * notice, this list of conditions and the following disclaimer in the 1455505Sshin * documentation and/or other materials provided with the distribution. 1555505Sshin * 3. Neither the name of the project nor the names of its contributors 1655505Sshin * may be used to endorse or promote products derived from this software 1755505Sshin * without specific prior written permission. 1855505Sshin * 1955505Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2055505Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2155505Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2255505Sshin * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2355505Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2455505Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2555505Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2655505Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2755505Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2855505Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2955505Sshin * SUCH DAMAGE. 3055505Sshin * 3155505Sshin * $FreeBSD: releng/11.0/usr.sbin/rrenumd/parser.y 281143 2015-04-06 09:42:23Z glebius $ 3255505Sshin */ 3355505Sshin 3455505Sshin%{ 3555505Sshin#include <sys/param.h> 3655505Sshin#include <sys/ioctl.h> 3755505Sshin#include <sys/socket.h> 3855505Sshin#include <sys/uio.h> 3978064Sume#include <sys/queue.h> 4055505Sshin 4155505Sshin#include <net/if.h> 4255505Sshin 4355505Sshin#include <netinet/in.h> 4455505Sshin#include <netinet/in_var.h> 4555505Sshin#include <netinet/icmp6.h> 4655505Sshin 47106054Swollman#include <limits.h> 4855505Sshin#include <netdb.h> 4955505Sshin#include <string.h> 5078064Sume#include <stdio.h> 5155505Sshin 5255505Sshin#include "rrenumd.h" 5355505Sshin 5455505Sshinstruct config_is_set { 5562638Skris u_short cis_dest : 1; 5655505Sshin} cis; 5755505Sshin 5862638Skrisstruct dst_list *dl_head; 5962638Skrisstruct payload_list *pl_head, ple_cur; 6062638Skrisu_int retry; 6162638Skrischar errbuf[LINE_MAX]; 6255505Sshin 6362638Skrisextern int lineno; 64173412Skevloextern void yyerror(const char *s); 65173412Skevloextern int yylex(void); 66173412Skevlostatic struct payload_list * pllist_lookup(int seqnum); 67173412Skevlostatic void pllist_enqueue(struct payload_list *pl_entry); 6855505Sshin 6962638Skris#define MAX_RETRYNUM 10 /* upper limit of retry in this rrenumd program */ 7062638Skris#define MAX_SEQNUM 256 /* upper limit of seqnum in this rrenumd program */ 7162638Skris#define NOSPEC -1 7255505Sshin 7355505Sshin%} 7455505Sshin 7555505Sshin%union { 7662638Skris u_long num; 7755505Sshin struct { 7862638Skris char *cp; 7962638Skris int len; 8055505Sshin } cs; 8162638Skris struct in_addr addr4; 8262638Skris struct in6_addr addr6; 8355505Sshin struct { 8462638Skris struct in6_addr addr; 8562638Skris u_char plen; 8655505Sshin } prefix; 8762638Skris struct dst_list *dl; 8862638Skris struct payload_list *pl; 8962638Skris struct sockaddr *sa; 9055505Sshin} 9155505Sshin 9255505Sshin%token <num> ADD CHANGE SETGLOBAL 9355505Sshin%token DEBUG_CMD DEST_CMD RETRY_CMD SEQNUM_CMD 9455505Sshin%token MATCH_PREFIX_CMD MAXLEN_CMD MINLEN_CMD 9555505Sshin%token USE_PREFIX_CMD KEEPLEN_CMD 9655505Sshin%token VLTIME_CMD PLTIME_CMD 9755505Sshin%token RAF_ONLINK_CMD RAF_AUTO_CMD RAF_DECRVALID_CMD RAF_DECRPREFD_CMD 9855505Sshin%token <num> DAYS HOURS MINUTES SECONDS INFINITY 9955505Sshin%token <num> ON OFF 10055505Sshin%token BCL ECL EOS ERROR 10155505Sshin%token <cs> NAME HOSTNAME QSTRING DECSTRING 10255505Sshin%token <addr4> IPV4ADDR 10355505Sshin%token <addr6> IPV6ADDR 10455505Sshin%token <num> PREFIXLEN 10555505Sshin 10655505Sshin%type <num> retrynum seqnum rrenum_cmd 10755505Sshin%type <num> prefixlen maxlen minlen keeplen vltime pltime 10855505Sshin%type <num> lifetime days hours minutes seconds 10955505Sshin%type <num> decstring 11055505Sshin%type <num> raf_onlink raf_auto raf_decrvalid raf_decrprefd flag 11162638Skris%type <dl> dest_addrs dest_addr sin sin6 11255505Sshin%type <pl> rrenum_statement 11355505Sshin%type <cs> ifname 11455505Sshin%type <prefix> prefixval 11555505Sshin 11655505Sshin%% 11755505Sshinconfig: 11855505Sshin /* empty */ 11955505Sshin | statements 12055505Sshin ; 12155505Sshin 12255505Sshinstatements: 12355505Sshin statement 12455505Sshin | statements statement 12555505Sshin ; 12655505Sshin 12755505Sshinstatement: 12855505Sshin debug_statement 12955505Sshin | destination_statement 13055505Sshin | rrenum_statement_without_seqnum 13155505Sshin | rrenum_statement_with_seqnum 13255505Sshin | error EOS 13355505Sshin { 13455505Sshin yyerrok; 13555505Sshin } 13655505Sshin | EOS 13755505Sshin ; 13855505Sshin 13955505Sshindebug_statement: 14055505Sshin DEBUG_CMD flag EOS 14155505Sshin { 14255505Sshin#ifdef YYDEBUG 14355505Sshin yydebug = $2; 14455505Sshin#endif /* YYDEBUG */ 14555505Sshin } 14655505Sshin ; 14755505Sshin 14855505Sshindestination_statement: 14955505Sshin DEST_CMD dest_addrs retrynum EOS 15055505Sshin { 15155505Sshin dl_head = $2; 15255505Sshin retry = $3; 15355505Sshin } 15455505Sshin ; 15555505Sshin 15655505Sshindest_addrs: 15755505Sshin dest_addr 15855505Sshin | dest_addrs dest_addr 15955505Sshin { 16055505Sshin $2->dl_next = $1; 16155505Sshin $$ = $2; 16255505Sshin } 16355505Sshin ; 16455505Sshin 16555505Sshindest_addr : 16662638Skris sin 16755505Sshin { 16862638Skris with_v4dest = 1; 16962638Skris } 17062638Skris | sin6 17162638Skris { 17255505Sshin with_v6dest = 1; 17355505Sshin } 17455505Sshin | sin6 ifname 17555505Sshin { 17655505Sshin struct sockaddr_in6 *sin6; 17755505Sshin 17855505Sshin sin6 = (struct sockaddr_in6 *)$1->dl_dst; 17955505Sshin sin6->sin6_scope_id = if_nametoindex($2.cp); 18055505Sshin with_v6dest = 1; 18155505Sshin $$ = $1; 18255505Sshin } 18355505Sshin | HOSTNAME 18455505Sshin { 18555505Sshin struct sockaddr_storage *ss; 18655505Sshin struct addrinfo hints, *res; 18755505Sshin int error; 18855505Sshin 18955505Sshin memset(&hints, 0, sizeof(hints)); 19055505Sshin hints.ai_flags = AI_CANONNAME; 19162638Skris hints.ai_family = AF_UNSPEC; 19255505Sshin hints.ai_socktype = SOCK_RAW; 19355505Sshin hints.ai_protocol = 0; 19455505Sshin error = getaddrinfo($1.cp, 0, &hints, &res); 19555505Sshin if (error) { 19678064Sume snprintf(errbuf, sizeof(errbuf), 19778064Sume "name resolution failed for %s:%s", 19878064Sume $1.cp, gai_strerror(error)); 19955505Sshin yyerror(errbuf); 20055505Sshin } 20155505Sshin ss = (struct sockaddr_storage *)malloc(sizeof(*ss)); 20255505Sshin memset(ss, 0, sizeof(*ss)); 20355505Sshin memcpy(ss, res->ai_addr, res->ai_addr->sa_len); 20455505Sshin freeaddrinfo(res); 20555505Sshin 20655505Sshin $$ = (struct dst_list *) 20755505Sshin malloc(sizeof(struct dst_list)); 20855505Sshin memset($$, 0, sizeof(struct dst_list)); 20955505Sshin $$->dl_dst = (struct sockaddr *)ss; 21055505Sshin } 21155505Sshin ; 21255505Sshin 21362638Skrissin: 21462638Skris IPV4ADDR 21562638Skris { 21662638Skris struct sockaddr_in *sin; 21762638Skris 21862638Skris sin = (struct sockaddr_in *)malloc(sizeof(*sin)); 21962638Skris memset(sin, 0, sizeof(*sin)); 22062638Skris sin->sin_len = sizeof(*sin); 22162638Skris sin->sin_family = AF_INET; 22262638Skris sin->sin_addr = $1; 22362638Skris 22462638Skris $$ = (struct dst_list *) 22562638Skris malloc(sizeof(struct dst_list)); 22662638Skris memset($$, 0, sizeof(struct dst_list)); 22762638Skris $$->dl_dst = (struct sockaddr *)sin; 22862638Skris } 22962638Skris ; 23062638Skris 23155505Sshinsin6: 23255505Sshin IPV6ADDR 23355505Sshin { 23455505Sshin struct sockaddr_in6 *sin6; 23555505Sshin 23655505Sshin sin6 = (struct sockaddr_in6 *)malloc(sizeof(*sin6)); 23755505Sshin memset(sin6, 0, sizeof(*sin6)); 23855505Sshin sin6->sin6_len = sizeof(*sin6); 23955505Sshin sin6->sin6_family = AF_INET6; 24055505Sshin sin6->sin6_addr = $1; 24155505Sshin 24255505Sshin $$ = (struct dst_list *) 24355505Sshin malloc(sizeof(struct dst_list)); 24455505Sshin memset($$, 0, sizeof(struct dst_list)); 24555505Sshin $$->dl_dst = (struct sockaddr *)sin6; 24655505Sshin } 24755505Sshin 24855505Sshinifname: 24955505Sshin NAME 25055505Sshin { 25155505Sshin $$.cp = strdup($1.cp); 25255505Sshin $$.len = $1.len; 25355505Sshin } 25455505Sshin | QSTRING 25555505Sshin { 25655505Sshin $1.cp[$1.len - 1] = 0; 25755505Sshin $$.cp = strdup(&$1.cp[1]); 25855505Sshin $$.len = $1.len - 2; 25955505Sshin } 26055505Sshin ; 26155505Sshin 26255505Sshinretrynum: 26355505Sshin /* empty */ 26455505Sshin { 26555505Sshin $$ = 2; 26655505Sshin } 26755505Sshin | RETRY_CMD decstring 26855505Sshin { 26955505Sshin if ($2 > MAX_RETRYNUM) 27055505Sshin $2 = MAX_RETRYNUM; 27155505Sshin $$ = $2; 27255505Sshin } 27355505Sshin ; 27455505Sshin 27555505Sshinrrenum_statement_with_seqnum: 27655505Sshin SEQNUM_CMD seqnum 27755505Sshin { 27855505Sshin if (pllist_lookup($2)) { 27978064Sume snprintf(errbuf, sizeof(errbuf), 28078064Sume "duplicate seqnum %ld specified at %d", 28178064Sume $2, lineno); 28255505Sshin yyerror(errbuf); 28355505Sshin } 28455505Sshin } 28555505Sshin BCL rrenum_statement EOS ECL EOS 28655505Sshin { 28755505Sshin $5->pl_irr.rr_seqnum = $2; 28855505Sshin pllist_enqueue($5); 28955505Sshin } 29055505Sshin ; 29155505Sshin 29255505Sshinseqnum: 29355505Sshin /* empty */ 29455505Sshin { 29555505Sshin $$ = 0; 29655505Sshin } 29755505Sshin | decstring 29855505Sshin { 29955505Sshin if ($1 > MAX_SEQNUM) { 30078064Sume snprintf(errbuf, sizeof(errbuf), 30178064Sume "seqnum %ld is illegal for this program. " 30278064Sume "should be between 0 and %d", 30378064Sume $1, MAX_SEQNUM); 30455505Sshin yyerror(errbuf); 30555505Sshin } 30655505Sshin $$ = $1; 30755505Sshin } 30855505Sshin ; 30955505Sshin 31055505Sshinrrenum_statement_without_seqnum: 31155505Sshin rrenum_statement EOS 31255505Sshin { 31355505Sshin if (pllist_lookup(0)) { 31478064Sume snprintf(errbuf, sizeof(errbuf), 31578064Sume "duplicate seqnum %d specified at %d", 31678064Sume 0, lineno); 31755505Sshin yyerror(errbuf); 31855505Sshin } 31955505Sshin $1->pl_irr.rr_seqnum = 0; 32055505Sshin pllist_enqueue($1); 32155505Sshin } 32255505Sshin ; 32355505Sshin 32455505Sshinrrenum_statement: 32555505Sshin match_prefix_definition use_prefix_definition 32655505Sshin { 32755505Sshin $$ = (struct payload_list *) 32855505Sshin malloc(sizeof(struct payload_list)); 32955505Sshin memcpy($$, &ple_cur, sizeof(ple_cur)); 33055505Sshin } 33155505Sshin ; 33255505Sshin 33355505Sshinmatch_prefix_definition: 33455505Sshin rrenum_cmd MATCH_PREFIX_CMD prefixval maxlen minlen 33555505Sshin { 33655505Sshin struct icmp6_router_renum *irr; 33755505Sshin struct rr_pco_match *rpm; 33855505Sshin 33955505Sshin irr = (struct icmp6_router_renum *)&ple_cur.pl_irr; 34055505Sshin rpm = (struct rr_pco_match *)(irr + 1); 34155505Sshin memset(rpm, 0, sizeof(*rpm)); 34255505Sshin 34355505Sshin rpm->rpm_code = $1; 34455505Sshin rpm->rpm_prefix = $3.addr; 34555505Sshin rpm->rpm_matchlen = $3.plen; 34655505Sshin rpm->rpm_maxlen = $4; 34755505Sshin rpm->rpm_minlen = $5; 34855505Sshin } 34955505Sshin ; 35055505Sshin 35155505Sshinrrenum_cmd: 35255505Sshin /* empty */ 35355505Sshin { 35455505Sshin $$ = RPM_PCO_ADD; 35555505Sshin } 35655505Sshin | ADD 35755505Sshin | CHANGE 35855505Sshin | SETGLOBAL 35955505Sshin ; 36055505Sshin 36155505Sshinprefixval: 36255505Sshin IPV6ADDR prefixlen 36355505Sshin { 36455505Sshin $$.addr = $1; 36555505Sshin $$.plen = $2; 36655505Sshin } 36755505Sshin ; 36855505Sshin 36955505Sshinprefixlen: 37055505Sshin /* empty */ 37155505Sshin { 37255505Sshin $$ = 64; 37355505Sshin } 37455505Sshin | PREFIXLEN 37555505Sshin ; 37655505Sshin 37755505Sshinmaxlen: 37855505Sshin /* empty */ 37955505Sshin { 38055505Sshin $$ = 128; 38155505Sshin } 38255505Sshin | MAXLEN_CMD decstring 38355505Sshin { 38455505Sshin if ($2 > 128) 38555505Sshin $2 = 128; 38655505Sshin $$ = $2; 38755505Sshin } 38855505Sshin ; 38955505Sshin 39055505Sshinminlen: 39155505Sshin /* empty */ 39255505Sshin { 39355505Sshin $$ = 0; 39455505Sshin } 39555505Sshin | MINLEN_CMD decstring 39655505Sshin { 39755505Sshin if ($2 > 128) 39855505Sshin $2 = 128; 39955505Sshin $$ = $2; 40055505Sshin } 40155505Sshin ; 40255505Sshin 40355505Sshinuse_prefix_definition: 40455505Sshin /* empty */ 40555505Sshin { 40655505Sshin struct icmp6_router_renum *irr; 40755505Sshin struct rr_pco_match *rpm; 40855505Sshin struct rr_pco_use *rpu; 40955505Sshin 41055505Sshin irr = (struct icmp6_router_renum *)&ple_cur.pl_irr; 41155505Sshin rpm = (struct rr_pco_match *)(irr + 1); 41255505Sshin rpu = (struct rr_pco_use *)(rpm + 1); 41355505Sshin memset(rpu, 0, sizeof(*rpu)); 41455505Sshin } 41555505Sshin | USE_PREFIX_CMD prefixval keeplen use_prefix_values 41655505Sshin { 41755505Sshin struct icmp6_router_renum *irr; 41855505Sshin struct rr_pco_match *rpm; 41955505Sshin struct rr_pco_use *rpu; 42055505Sshin 42155505Sshin irr = (struct icmp6_router_renum *)&ple_cur.pl_irr; 42255505Sshin rpm = (struct rr_pco_match *)(irr + 1); 42355505Sshin rpu = (struct rr_pco_use *)(rpm + 1); 42455505Sshin 42555505Sshin rpu->rpu_prefix = $2.addr; 42655505Sshin rpu->rpu_uselen = $2.plen; 42755505Sshin rpu->rpu_keeplen = $3; 42855505Sshin } 42955505Sshin ; 43055505Sshin 43155505Sshinuse_prefix_values: 43255505Sshin /* empty */ 43355505Sshin { 43455505Sshin struct icmp6_router_renum *irr; 43555505Sshin struct rr_pco_match *rpm; 43655505Sshin struct rr_pco_use *rpu; 43755505Sshin 43855505Sshin irr = (struct icmp6_router_renum *)&ple_cur.pl_irr; 43955505Sshin rpm = (struct rr_pco_match *)(irr + 1); 44055505Sshin rpu = (struct rr_pco_use *)(rpm + 1); 44155505Sshin memset(rpu, 0, sizeof(*rpu)); 44255505Sshin 44378064Sume rpu->rpu_vltime = htonl(DEF_VLTIME); 44478064Sume rpu->rpu_pltime = htonl(DEF_PLTIME); 44555505Sshin rpu->rpu_ramask = 0; 44655505Sshin rpu->rpu_flags = 0; 44755505Sshin } 44855505Sshin | BCL vltime pltime raf_onlink raf_auto raf_decrvalid raf_decrprefd ECL 44955505Sshin { 45055505Sshin struct icmp6_router_renum *irr; 45155505Sshin struct rr_pco_match *rpm; 45255505Sshin struct rr_pco_use *rpu; 45355505Sshin 45455505Sshin irr = (struct icmp6_router_renum *)&ple_cur.pl_irr; 45555505Sshin rpm = (struct rr_pco_match *)(irr + 1); 45655505Sshin rpu = (struct rr_pco_use *)(rpm + 1); 45755505Sshin memset(rpu, 0, sizeof(*rpu)); 45855505Sshin 45955505Sshin rpu->rpu_vltime = $2; 46055505Sshin rpu->rpu_pltime = $3; 46162638Skris if ($4 == NOSPEC) { 46255505Sshin rpu->rpu_ramask &= 46362638Skris ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; 46462638Skris } else { 46555505Sshin rpu->rpu_ramask |= 46662638Skris ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; 46762638Skris if ($4 == ON) { 46855505Sshin rpu->rpu_raflags |= 46962638Skris ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; 47062638Skris } else { 47155505Sshin rpu->rpu_raflags &= 47262638Skris ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; 47362638Skris } 47455505Sshin } 47562638Skris if ($5 == NOSPEC) { 47655505Sshin rpu->rpu_ramask &= 47762638Skris ICMP6_RR_PCOUSE_RAFLAGS_AUTO; 47862638Skris } else { 47955505Sshin rpu->rpu_ramask |= 48062638Skris ICMP6_RR_PCOUSE_RAFLAGS_AUTO; 48162638Skris if ($5 == ON) { 48255505Sshin rpu->rpu_raflags |= 48362638Skris ICMP6_RR_PCOUSE_RAFLAGS_AUTO; 48462638Skris } else { 48555505Sshin rpu->rpu_raflags &= 48662638Skris ~ICMP6_RR_PCOUSE_RAFLAGS_AUTO; 48762638Skris } 48855505Sshin } 48955505Sshin rpu->rpu_flags = 0; 49062638Skris if ($6 == ON) { 49155505Sshin rpu->rpu_flags |= 49262638Skris ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME; 49362638Skris } 49462638Skris if ($7 == ON) { 49555505Sshin rpu->rpu_flags |= 49662638Skris ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME; 49762638Skris } 49855505Sshin } 49955505Sshin ; 50055505Sshin 50155505Sshinkeeplen: 50255505Sshin /* empty */ 50355505Sshin { 50455505Sshin $$ = 0; 50555505Sshin } 50655505Sshin | KEEPLEN_CMD decstring 50755505Sshin { 50855505Sshin if ($2 > 128) 50955505Sshin $2 = 128; 51055505Sshin $$ = $2; 51155505Sshin } 51255505Sshin ; 51355505Sshin 51455505Sshin 51555505Sshinvltime: 51655505Sshin /* empty */ 51755505Sshin { 51878064Sume $$ = htonl(DEF_VLTIME); 51955505Sshin } 52055505Sshin | VLTIME_CMD lifetime 52155505Sshin { 52255505Sshin $$ = htonl($2); 52355505Sshin } 52455505Sshin ; 52555505Sshin 52655505Sshinpltime: 52755505Sshin /* empty */ 52855505Sshin { 52978064Sume $$ = htonl(DEF_PLTIME); 53055505Sshin } 53155505Sshin | PLTIME_CMD lifetime 53255505Sshin { 53355505Sshin $$ = htonl($2); 53455505Sshin } 53555505Sshin 53655505Sshinraf_onlink: 53755505Sshin /* empty */ 53855505Sshin { 53955505Sshin $$ = NOSPEC; 54055505Sshin } 54155505Sshin | RAF_ONLINK_CMD flag 54255505Sshin { 54355505Sshin $$ = $2; 54455505Sshin } 54555505Sshin ; 54655505Sshin 54755505Sshinraf_auto: 54855505Sshin /* empty */ 54955505Sshin { 55055505Sshin $$ = NOSPEC; 55155505Sshin } 55255505Sshin | RAF_AUTO_CMD flag 55355505Sshin { 55455505Sshin $$ = $2; 55555505Sshin } 55655505Sshin ; 55755505Sshin 55855505Sshinraf_decrvalid: 55955505Sshin /* empty */ 56055505Sshin { 56155505Sshin $$ = NOSPEC; 56255505Sshin } 56355505Sshin | RAF_DECRVALID_CMD flag 56455505Sshin { 56555505Sshin $$ = $2; 56655505Sshin } 56755505Sshin ; 56855505Sshin 56955505Sshinraf_decrprefd: 57055505Sshin /* empty */ 57155505Sshin { 57255505Sshin $$ = NOSPEC; 57355505Sshin } 57455505Sshin | RAF_DECRPREFD_CMD flag 57555505Sshin { 57655505Sshin $$ = $2; 57755505Sshin } 57855505Sshin ; 57955505Sshin 58055505Sshinflag: 58178064Sume ON { $$ = ON; } 58278064Sume | OFF { $$ = OFF; } 58355505Sshin ; 58455505Sshin 58555505Sshinlifetime: 58655505Sshin decstring 58755505Sshin | INFINITY 58855505Sshin { 58955505Sshin $$ = 0xffffffff; 59055505Sshin } 59155505Sshin | days hours minutes seconds 59255505Sshin { 59355505Sshin int d, h, m, s; 59455505Sshin 59555505Sshin d = $1 * 24 * 60 * 60; 59655505Sshin h = $2 * 60 * 60; 59755505Sshin m = $3 * 60; 59855505Sshin s = $4; 59955505Sshin $$ = d + h + m + s; 60055505Sshin } 60155505Sshin ; 60255505Sshin 60355505Sshindays: 60455505Sshin /* empty */ 60555505Sshin { 60655505Sshin $$ = 0; 60755505Sshin } 60855505Sshin | DAYS 60955505Sshin ; 61055505Sshin 61155505Sshinhours: 61255505Sshin /* empty */ 61355505Sshin { 61455505Sshin $$ = 0; 61555505Sshin } 61655505Sshin | HOURS 61755505Sshin ; 61855505Sshin 61955505Sshinminutes: 62055505Sshin /* empty */ 62155505Sshin { 62255505Sshin $$ = 0; 62355505Sshin } 62455505Sshin | MINUTES 62555505Sshin ; 62655505Sshin 62755505Sshinseconds: 62855505Sshin /* empty */ 62955505Sshin { 63055505Sshin $$ = 0; 63155505Sshin } 63255505Sshin | SECONDS 63355505Sshin ; 63455505Sshin 63555505Sshindecstring: 63655505Sshin DECSTRING 63755505Sshin { 63855505Sshin int dval; 63955505Sshin 64055505Sshin dval = atoi($1.cp); 64155505Sshin $$ = dval; 64255505Sshin } 64355505Sshin ; 64455505Sshin 64555505Sshin%% 64655505Sshin 64755505Sshinstatic struct payload_list * 64855505Sshinpllist_lookup(int seqnum) 64955505Sshin{ 65055505Sshin struct payload_list *pl; 65155505Sshin for (pl = pl_head; pl && pl->pl_irr.rr_seqnum != seqnum; 65255505Sshin pl = pl->pl_next) 65355505Sshin continue; 65455505Sshin return (pl); 65555505Sshin} 65655505Sshin 65755505Sshinstatic void 65855505Sshinpllist_enqueue(struct payload_list *pl_entry) 65955505Sshin{ 66055505Sshin struct payload_list *pl, *pl_last; 66178064Sume 66278064Sume pl_last = NULL; 66355505Sshin for (pl = pl_head; 66455505Sshin pl && pl->pl_irr.rr_seqnum < pl_entry->pl_irr.rr_seqnum; 66555505Sshin pl_last = pl, pl = pl->pl_next) 66655505Sshin continue; 66778064Sume if (pl_last) 66878064Sume pl_last->pl_next = pl_entry; 66978064Sume else 67078064Sume pl_head = pl_entry; 67155505Sshin 67255505Sshin return; 67355505Sshin} 674