Merge commit 'origin/ser_core_cvs'
[sip-router] / cfg.lex
1 /*
2  * $Id$
3  *
4  * scanner for cfg files
5  *
6  * Copyright (C) 2001-2003 FhG Fokus
7  *
8  * This file is part of ser, a free SIP server.
9  *
10  * ser is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version
14  *
15  * For a license to use the ser software under conditions
16  * other than those described here, or to purchase support for this
17  * software, please contact iptel.org by e-mail at the following addresses:
18  *    info@iptel.org
19  *
20  * ser is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28  *
29  * History:
30  * -------
31  *  2003-01-29  src_port added (jiri)
32  *  2003-01-23  mhomed added (jiri)
33  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
34  *  2003-04-01  added dst_port, proto (tcp, udp, tls), af(inet, inet6) (andrei)
35  *  2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
36  *  2003-04-12  added force_rport, chdir and wdir (andrei)
37  *  2003-04-22  strip_tail added (jiri)
38  *  2003-07-03  tls* (disable, certificate, private_key, ca_list, verify,
39  *               require_certificate added (andrei)
40  *  2003-07-06  more tls config. vars added: tls_method, tls_port_no (andrei)
41  *  2003-10-02  added {,set_}advertised_{address,port} (andrei)
42  *  2003-10-07  added hex and octal numbers support (andrei)
43  *  2003-10-10  replaced len_gt w/ msg:len (andrei)
44  *  2003-10-13  added fifo_dir (andrei)
45  *  2003-10-28  added tcp_accept_aliases (andrei)
46  *  2003-11-29  added {tcp_send, tcp_connect, tls_*}_timeout (andrei)
47  *  2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
48  *  2004-04-28  added sock_mode (replaces fifo_mode), sock_user &
49  *               sock_group  (andrei)
50  *  2004-05-03  applied multicast support patch from janakj
51  *              added MCAST_TTL (andrei)
52  *  2004-10-08  more escapes: \", \xHH, \nnn and minor optimizations (andrei)
53  *  2004-10-19  added FROM_URI and TO_URI (andrei)
54  *  2004-11-30  added force_send_socket
55  *  2005-07-08  added tcp_connection_lifetime, tcp_poll_method,
56  *               tcp_max_connections (andrei)
57  *  2005-07-11  added dns_retr_{time,no}, dns_servers_no, dns_use_search_list,
58  *              dns_try_ipv6 (andrei)
59  *  2005-12-11  added onsend_route, snd_{ip,port,proto,af},
60  *              to_{ip,port} (andrei)
61  *  2005-12-12  separated drop, exit, break, return, added RETCODE (andrei)
62  *  2005-12-19  select framework (mma)
63  *  2006-09-11  added dns cache (use, flags, ttls, mem ,gc) & dst blacklist
64  *              options (andrei)
65  *  2006-10-13  added STUN_ALLOW_STUN, STUN_ALLOW_FP, STUN_REFRESH_INTERVAL
66  *              (vlada)
67  *  2007-06-07  added SHM_FORCE_ALLOC, MLOCK_PAGES, REAL_TIME, RT_PRIO,
68  *              RT_POLICY, RT_TIMER1_PRIO, RT_TIMER1_POLICY, RT_TIMER2_PRIO,
69  *              RT_TIMER2_POLICY (andrei)
70  *  2007-06-16  added DNS_SRV_LB, DNS_TRY_NAPTR (andrei)
71  *  2007-06-18  added DNS_{UDP,TCP,TLS}_PREF (andrei)
72  *  2007-09-10  introduced phone2tel option which allows NOT to consider
73  *              user=phone URIs as TEL URIs (jiri)
74  *  2007-10-10  added DNS_SEARCH_FMATCH (mma)
75  *  2007-11-28  added TCP_OPT_{FD_CACHE, DEFER_ACCEPT, DELAYED_ACK, SYNCNT,
76  *              LINGER2, KEEPALIVE, KEEPIDLE, KEEPINTVL, KEEPCNT} (andrei)
77  *  2008-01-24  added CFG_DESCRIPTION used by cfg_var (Miklos)
78  *  2008-11-28  added support for kamailio pvars and avp/pvar guessing (andrei)
79  *  2008-12-11  added support for "string1" "string2" (andrei)
80  *  2009-03-10  added SET_USERPHONE action (Miklos)
81 */
82
83
84 %{
85         #include "dprint.h"
86         #include "globals.h"
87         #include "mem/mem.h"
88         #include <string.h>
89         #include <stdlib.h>
90         #include "ip_addr.h"
91         #include "usr_avp.h"
92         #include "select.h"
93         #include "cfg.tab.h"
94         #include "sr_compat.h"
95
96         /* states */
97         #define INITIAL_S               0
98         #define COMMENT_S               1
99         #define COMMENT_LN_S            2
100         #define STRING_S                3
101         #define ATTR_S                  4  /* avp/attr */
102         #define SELECT_S                5
103         #define AVP_PVAR_S              6  /* avp or pvar */
104         #define PVAR_P_S                7  /* pvar: $(...)  or $foo(...)*/
105         #define PVARID_S                8  /* $foo.bar...*/
106         #define STR_BETWEEN_S           9
107
108         #define STR_BUF_ALLOC_UNIT      128
109         struct str_buf{
110                 char* s;
111                 char* crt;
112                 int left;
113         };
114
115
116         static int comment_nest=0;
117         static int p_nest=0;
118         static int state=0, old_state=0, old_initial=0;
119         static struct str_buf s_buf;
120         int line=1;
121         int column=1;
122         int startcolumn=1;
123         int startline=1;
124         static int ign_lines=0;
125         static int ign_columns=0;
126
127         static char* addchar(struct str_buf *, char);
128         static char* addstr(struct str_buf *, char*, int);
129         static void count();
130         static void count_more();
131         static void count_ignore();
132
133
134 %}
135
136 /* start conditions */
137 %x STRING1 STRING2 STR_BETWEEN COMMENT COMMENT_LN ATTR SELECT AVP_PVAR PVAR_P 
138 %x PVARID
139
140 /* config script types : #!SER  or #!KAMAILIO or #!MAX_COMPAT */
141 SER_CFG                 SER
142 KAMAILIO_CFG    KAMAILIO|OPENSER
143 MAXCOMPAT_CFG   MAXCOMPAT|ALL
144
145 /* action keywords */
146 FORWARD forward
147 FORWARD_TCP     forward_tcp
148 FORWARD_UDP     forward_udp
149 FORWARD_TLS     forward_tls
150 FORWARD_SCTP    forward_sctp
151 DROP    "drop"|"exit"
152 RETURN  "return"
153 BREAK   "break"
154 SEND    send
155 SEND_TCP        send_tcp
156 LOG             log
157 ERROR   error
158 ROUTE   route
159 ROUTE_FAILURE failure_route
160 ROUTE_ONREPLY onreply_route
161 ROUTE_BRANCH branch_route
162 ROUTE_SEND onsend_route
163 EXEC    exec
164 FORCE_RPORT             "force_rport"|"add_rport"
165 FORCE_TCP_ALIAS         "force_tcp_alias"|"add_tcp_alias"
166 UDP_MTU         "udp_mtu"
167 UDP_MTU_TRY_PROTO       "udp_mtu_try_proto"
168 SETFLAG         setflag
169 RESETFLAG       resetflag
170 ISFLAGSET       isflagset
171 FLAGS_DECL      "flags"|"bool"
172 SETAVPFLAG      setavpflag
173 RESETAVPFLAG    resetavpflag
174 ISAVPFLAGSET    isavpflagset
175 AVPFLAGS_DECL   avpflags
176 SET_HOST                "rewritehost"|"sethost"|"seth"
177 SET_HOSTPORT    "rewritehostport"|"sethostport"|"sethp"
178 SET_HOSTPORTTRANS       "rewritehostporttrans"|"sethostporttrans"|"sethpt"
179 SET_USER                "rewriteuser"|"setuser"|"setu"
180 SET_USERPASS    "rewriteuserpass"|"setuserpass"|"setup"
181 SET_PORT                "rewriteport"|"setport"|"setp"
182 SET_URI                 "rewriteuri"|"seturi"
183 REVERT_URI              "revert_uri"
184 PREFIX                  "prefix"
185 STRIP                   "strip"
186 STRIP_TAIL              "strip_tail"
187 SET_USERPHONE           "userphone"
188 APPEND_BRANCH   "append_branch"
189 IF                              "if"
190 ELSE                    "else"
191 SET_ADV_ADDRESS "set_advertised_address"
192 SET_ADV_PORT    "set_advertised_port"
193 FORCE_SEND_SOCKET       "force_send_socket"
194 SWITCH                  "switch"
195 CASE                    "case"
196 DEFAULT                 "default"
197 WHILE                   "while"
198
199 /*ACTION LVALUES*/
200 URIHOST                 "uri:host"
201 URIPORT                 "uri:port"
202
203 MAX_LEN                 "max_len"
204
205
206 /* condition keywords */
207 METHOD  method
208 /* hack -- the second element in first line is referable
209    as either uri or status; it only would makes sense to
210    call it "uri" from route{} and status from onreply_route{}
211 */
212 URI             "uri"|"status"
213 FROM_URI        "from_uri"
214 TO_URI          "to_uri"
215 SRCIP   src_ip
216 SRCPORT src_port
217 DSTIP   dst_ip
218 DSTPORT dst_port
219 SNDIP   snd_ip
220 SNDPORT snd_port
221 SNDPROTO        snd_proto|to_proto
222 SNDAF           snd_af|to_af
223 TOIP    to_ip
224 TOPORT  to_port
225 PROTO   proto
226 AF              af
227 MYSELF  myself
228 MSGLEN                  "msg:len"
229 RETCODE \$\?|\$retcode
230 /* operators */
231 EQUAL   =
232 EQUAL_T ==
233 GT      >
234 LT      <
235 GTE     >=
236 LTE     <=
237 DIFF    !=
238 MATCH   =~
239 ADDEQ     "+="
240 NOT             !|"not"
241 LOG_AND         "and"|"&&"
242 BIN_AND         "&"
243 LOG_OR          "or"|"||"
244 BIN_OR          "|"
245 PLUS    "+"
246 MINUS   "-"
247
248 /* Attribute specification */
249 ATTR_MARK   "%"
250 VAR_MARK    "$"
251 SELECT_MARK  "@"
252 ATTR_FROM         "f"
253 ATTR_TO           "t"
254 ATTR_FROMURI      "fr"
255 ATTR_TOURI       "tr"
256 ATTR_FROMUSER     "fu"
257 ATTR_TOUSER       "tu"
258 ATTR_FROMDOMAIN   "fd"
259 ATTR_TODOMAIN     "td"
260 ATTR_GLOBAL       "g"
261
262 /* avp prefix */
263 AVP_PREF        (([ft][rud]?)|g)\.
264
265 /* config vars. */
266 DEBUG   debug
267 FORK    fork
268 LOGSTDERROR     log_stderror
269 LOGFACILITY     log_facility
270 LISTEN          listen
271 ALIAS           alias
272 DNS              dns
273 REV_DNS  rev_dns
274 DNS_TRY_IPV6    dns_try_ipv6
275 DNS_TRY_NAPTR   dns_try_naptr
276 DNS_SRV_LB              dns_srv_lb|dns_srv_loadbalancing
277 DNS_UDP_PREF    dns_udp_pref|dns_udp_preference
278 DNS_TCP_PREF    dns_tcp_pref|dns_tcp_preference
279 DNS_TLS_PREF    dns_tls_pref|dns_tls_preference
280 DNS_SCTP_PREF   dns_sctp_pref|dns_sctp_preference
281 DNS_RETR_TIME   dns_retr_time
282 DNS_RETR_NO             dns_retr_no
283 DNS_SERVERS_NO  dns_servers_no
284 DNS_USE_SEARCH  dns_use_search_list
285 DNS_SEARCH_FMATCH       dns_search_full_match
286 /* dns cache */
287 DNS_CACHE_INIT  dns_cache_init
288 DNS_USE_CACHE   use_dns_cache
289 DNS_USE_FAILOVER        use_dns_failover
290 DNS_CACHE_FLAGS         dns_cache_flags
291 DNS_CACHE_NEG_TTL       dns_cache_negative_ttl
292 DNS_CACHE_MIN_TTL       dns_cache_min_ttl
293 DNS_CACHE_MAX_TTL       dns_cache_max_ttl
294 DNS_CACHE_MEM           dns_cache_mem
295 DNS_CACHE_GC_INT        dns_cache_gc_interval
296 DNS_CACHE_DEL_NONEXP    dns_cache_del_nonexp|dns_cache_delete_nonexpired
297 /* blacklist */
298 DST_BLST_INIT   dst_blacklist_init
299 USE_DST_BLST            use_dst_blacklist
300 DST_BLST_MEM            dst_blacklist_mem
301 DST_BLST_TTL            dst_blacklist_expire|dst_blacklist_ttl
302 DST_BLST_GC_INT         dst_blacklist_gc_interval
303
304
305 PORT    port
306 STAT    statistics
307 MAXBUFFER maxbuffer
308 CHILDREN children
309 CHECK_VIA       check_via
310 PHONE2TEL       phone2tel
311 SYN_BRANCH syn_branch
312 MEMLOG          "memlog"|"mem_log"
313 MEMDBG          "memdbg"|"mem_dbg"
314 SIP_WARNING sip_warning
315 SERVER_SIGNATURE server_signature
316 REPLY_TO_VIA reply_to_via
317 USER            "user"|"uid"
318 GROUP           "group"|"gid"
319 CHROOT          "chroot"
320 WDIR            "workdir"|"wdir"
321 MHOMED          mhomed
322 DISABLE_TCP             "disable_tcp"
323 TCP_CHILDREN    "tcp_children"
324 TCP_ACCEPT_ALIASES      "tcp_accept_aliases"
325 TCP_SEND_TIMEOUT        "tcp_send_timeout"
326 TCP_CONNECT_TIMEOUT     "tcp_connect_timeout"
327 TCP_CON_LIFETIME        "tcp_connection_lifetime"
328 TCP_POLL_METHOD         "tcp_poll_method"
329 TCP_MAX_CONNECTIONS     "tcp_max_connections"
330 TCP_NO_CONNECT          "tcp_no_connect"
331 TCP_SOURCE_IPV4         "tcp_source_ipv4"
332 TCP_SOURCE_IPV6         "tcp_source_ipv6"
333 TCP_OPT_FD_CACHE        "tcp_fd_cache"
334 TCP_OPT_BUF_WRITE       "tcp_buf_write"|"tcp_async"
335 TCP_OPT_CONN_WQ_MAX     "tcp_conn_wq_max"
336 TCP_OPT_WQ_MAX          "tcp_wq_max"
337 TCP_OPT_RD_BUF          "tcp_rd_buf_size"
338 TCP_OPT_WQ_BLK          "tcp_wq_blk_size"
339 TCP_OPT_DEFER_ACCEPT "tcp_defer_accept"
340 TCP_OPT_DELAYED_ACK     "tcp_delayed_ack"
341 TCP_OPT_SYNCNT          "tcp_syncnt"
342 TCP_OPT_LINGER2         "tcp_linger2"
343 TCP_OPT_KEEPALIVE       "tcp_keepalive"
344 TCP_OPT_KEEPIDLE        "tcp_keepidle"
345 TCP_OPT_KEEPINTVL       "tcp_keepintvl"
346 TCP_OPT_KEEPCNT         "tcp_keepcnt"
347 TCP_OPT_CRLF_PING       "tcp_crlf_ping"
348 DISABLE_TLS             "disable_tls"|"tls_disable"
349 ENABLE_TLS              "enable_tls"|"tls_enable"
350 TLSLOG                  "tlslog"|"tls_log"
351 TLS_PORT_NO             "tls_port_no"
352 TLS_METHOD              "tls_method"
353 TLS_VERIFY              "tls_verify"
354 TLS_REQUIRE_CERTIFICATE "tls_require_certificate"
355 TLS_CERTIFICATE "tls_certificate"
356 TLS_PRIVATE_KEY "tls_private_key"
357 TLS_CA_LIST             "tls_ca_list"
358 TLS_HANDSHAKE_TIMEOUT   "tls_handshake_timeout"
359 TLS_SEND_TIMEOUT        "tls_send_timeout"
360 DISABLE_SCTP    "disable_sctp"
361 ENABLE_SCTP     "enable_sctp"
362 SCTP_CHILDREN   "sctp_children"
363 SCTP_SOCKET_RCVBUF      "sctp_socket_rcvbuf"|"sctp_socket_receive_buffer"
364 SCTP_SOCKET_SNDBUF      "sctp_socket_sndbuf"|"sctp_socket_send_buffer"
365 SCTP_AUTOCLOSE  "sctp_autoclose"
366 SCTP_SEND_TTL   "sctp_send_ttl"
367 SCTP_SEND_RETRIES       "sctp_send_retries"
368 ADVERTISED_ADDRESS      "advertised_address"
369 ADVERTISED_PORT         "advertised_port"
370 DISABLE_CORE            "disable_core_dump"
371 OPEN_FD_LIMIT           "open_files_limit"
372 SHM_FORCE_ALLOC         "shm_force_alloc"
373 MLOCK_PAGES                     "mlock_pages"
374 REAL_TIME                       "real_time"
375 RT_PRIO                         "rt_prio"
376 RT_POLICY                       "rt_policy"
377 RT_TIMER1_PRIO          "rt_timer1_prio"|"rt_fast_timer_prio"|"rt_ftimer_prio"
378 RT_TIMER1_POLICY        "rt_timer1_policy"|"rt_ftimer_policy"
379 RT_TIMER2_PRIO          "rt_timer2_prio"|"rt_stimer_prio"
380 RT_TIMER2_POLICY        "rt_timer2_policy"|"rt_stimer_policy"
381 MCAST_LOOPBACK          "mcast_loopback"
382 MCAST_TTL               "mcast_ttl"
383 TOS                     "tos"
384 PMTU_DISCOVERY  "pmtu_discovery"
385 KILL_TIMEOUT    "exit_timeout"|"ser_kill_timeout"
386 MAX_WLOOPS              "max_while_loops"
387
388 /* stun config variables */
389 STUN_REFRESH_INTERVAL "stun_refresh_interval"
390 STUN_ALLOW_STUN "stun_allow_stun"
391 STUN_ALLOW_FP "stun_allow_fp"
392
393 SERVER_ID     "server_id"
394
395 CFG_DESCRIPTION         "description"|"descr"|"desc"
396
397 LOADMODULE      loadmodule
398 LOADPATH        loadpath
399 MODPARAM        modparam
400
401 /* values */
402 YES                     "yes"|"true"|"on"|"enable"
403 NO                      "no"|"false"|"off"|"disable"
404 UDP                     "udp"|"UDP"
405 TCP                     "tcp"|"TCP"
406 TLS                     "tls"|"TLS"
407 SCTP            "sctp"|"SCTP"
408 INET            "inet"|"INET"
409 INET6           "inet6"|"INET6"
410 SSLv23                  "sslv23"|"SSLv23"|"SSLV23"
411 SSLv2                   "sslv2"|"SSLv2"|"SSLV2"
412 SSLv3                   "sslv3"|"SSLv3"|"SSLV3"
413 TLSv1                   "tlsv1"|"TLSv1"|"TLSV1"
414
415 LETTER          [a-zA-Z]
416 DIGIT           [0-9]
417 ALPHANUM        {LETTER}|{DIGIT}|[_]
418 ID                      {LETTER}{ALPHANUM}*
419 HEX                     [0-9a-fA-F]
420 HEXNUMBER       0x{HEX}+
421 OCTNUMBER       0[0-7]+
422 DECNUMBER       0|([1-9]{DIGIT}*)
423 BINNUMBER       [0-1]+b
424 HEX4            {HEX}{1,4}
425 IPV6ADDR        ({HEX4}":"){7}{HEX4}|({HEX4}":"){1,7}(":"{HEX4}){1,7}|":"(":"{HEX4}){1,7}|({HEX4}":"){1,7}":"|"::"
426 QUOTES          \"
427 TICK            \'
428 SLASH           "/"
429 SEMICOLON       ;
430 RPAREN          \)
431 LPAREN          \(
432 LBRACE          \{
433 RBRACE          \}
434 LBRACK          \[
435 RBRACK          \]
436 COMMA           ","
437 COLON           ":"
438 STAR            \*
439 DOT                     \.
440 CR                      \n
441
442
443
444 COM_LINE        #
445 COM_START       "/\*"
446 COM_END         "\*/"
447
448 EAT_ABLE        [\ \t\b\r]
449
450 %%
451
452
453 <INITIAL>{EAT_ABLE}     { count(); }
454
455 <INITIAL>{FORWARD}      {count(); yylval.strval=yytext; return FORWARD; }
456 <INITIAL>{FORWARD_TCP}  {count(); yylval.strval=yytext; return FORWARD_TCP; }
457 <INITIAL>{FORWARD_TLS}  {count(); yylval.strval=yytext; return FORWARD_TLS; }
458 <INITIAL>{FORWARD_SCTP} {count(); yylval.strval=yytext; return FORWARD_SCTP;}
459 <INITIAL>{FORWARD_UDP}  {count(); yylval.strval=yytext; return FORWARD_UDP; }
460 <INITIAL>{DROP} { count(); yylval.strval=yytext; return DROP; }
461 <INITIAL>{RETURN}       { count(); yylval.strval=yytext; return RETURN; }
462 <INITIAL>{BREAK}        { count(); yylval.strval=yytext; return BREAK; }
463 <INITIAL>{SEND} { count(); yylval.strval=yytext; return SEND; }
464 <INITIAL>{SEND_TCP}     { count(); yylval.strval=yytext; return SEND_TCP; }
465 <INITIAL>{LOG}  { count(); yylval.strval=yytext; return LOG_TOK; }
466 <INITIAL>{ERROR}        { count(); yylval.strval=yytext; return ERROR; }
467 <INITIAL>{SETFLAG}      { count(); yylval.strval=yytext; return SETFLAG; }
468 <INITIAL>{RESETFLAG}    { count(); yylval.strval=yytext; return RESETFLAG; }
469 <INITIAL>{ISFLAGSET}    { count(); yylval.strval=yytext; return ISFLAGSET; }
470 <INITIAL>{FLAGS_DECL}   { count(); yylval.strval=yytext; return FLAGS_DECL; }
471 <INITIAL>{SETAVPFLAG}   { count(); yylval.strval=yytext; return SETAVPFLAG; }
472 <INITIAL>{RESETAVPFLAG} { count(); yylval.strval=yytext; return RESETAVPFLAG; }
473 <INITIAL>{ISAVPFLAGSET} { count(); yylval.strval=yytext; return ISAVPFLAGSET; }
474 <INITIAL>{AVPFLAGS_DECL}        { count(); yylval.strval=yytext; return AVPFLAGS_DECL; }
475 <INITIAL>{MSGLEN}       { count(); yylval.strval=yytext; return MSGLEN; }
476 <INITIAL>{RETCODE}      { count(); yylval.strval=yytext; return RETCODE; }
477 <INITIAL>{ROUTE}        { count(); yylval.strval=yytext; return ROUTE; }
478 <INITIAL>{ROUTE_ONREPLY}        { count(); yylval.strval=yytext;
479                                                                 return ROUTE_ONREPLY; }
480 <INITIAL>{ROUTE_FAILURE}        { count(); yylval.strval=yytext;
481                                                                 return ROUTE_FAILURE; }
482 <INITIAL>{ROUTE_BRANCH} { count(); yylval.strval=yytext; return ROUTE_BRANCH; }
483 <INITIAL>{ROUTE_SEND} { count(); yylval.strval=yytext; return ROUTE_SEND; }
484 <INITIAL>{EXEC} { count(); yylval.strval=yytext; return EXEC; }
485 <INITIAL>{SET_HOST}     { count(); yylval.strval=yytext; return SET_HOST; }
486 <INITIAL>{SET_HOSTPORT} { count(); yylval.strval=yytext; return SET_HOSTPORT; }
487 <INITIAL>{SET_HOSTPORTTRANS}    { count(); yylval.strval=yytext; return SET_HOSTPORTTRANS; }
488 <INITIAL>{SET_USER}     { count(); yylval.strval=yytext; return SET_USER; }
489 <INITIAL>{SET_USERPASS} { count(); yylval.strval=yytext; return SET_USERPASS; }
490 <INITIAL>{SET_PORT}     { count(); yylval.strval=yytext; return SET_PORT; }
491 <INITIAL>{SET_URI}      { count(); yylval.strval=yytext; return SET_URI; }
492 <INITIAL>{REVERT_URI}   { count(); yylval.strval=yytext; return REVERT_URI; }
493 <INITIAL>{PREFIX}       { count(); yylval.strval=yytext; return PREFIX; }
494 <INITIAL>{STRIP}        { count(); yylval.strval=yytext; return STRIP; }
495 <INITIAL>{STRIP_TAIL}   { count(); yylval.strval=yytext; return STRIP_TAIL; }
496 <INITIAL>{APPEND_BRANCH}        { count(); yylval.strval=yytext;
497                                                                 return APPEND_BRANCH; }
498 <INITIAL>{SET_USERPHONE}        { count(); yylval.strval=yytext;
499                                                                 return SET_USERPHONE; }
500 <INITIAL>{FORCE_RPORT}  { count(); yylval.strval=yytext; return FORCE_RPORT; }
501 <INITIAL>{FORCE_TCP_ALIAS}      { count(); yylval.strval=yytext;
502                                                                 return FORCE_TCP_ALIAS; }
503 <INITIAL>{UDP_MTU}      { count(); yylval.strval=yytext; return UDP_MTU; }
504 <INITIAL>{UDP_MTU_TRY_PROTO}    { count(); yylval.strval=yytext;
505                                                                         return UDP_MTU_TRY_PROTO; }
506 <INITIAL>{IF}   { count(); yylval.strval=yytext; return IF; }
507 <INITIAL>{ELSE} { count(); yylval.strval=yytext; return ELSE; }
508
509 <INITIAL>{SET_ADV_ADDRESS}      { count(); yylval.strval=yytext;
510                                                                                 return SET_ADV_ADDRESS; }
511 <INITIAL>{SET_ADV_PORT} { count(); yylval.strval=yytext;
512                                                                                 return SET_ADV_PORT; }
513 <INITIAL>{FORCE_SEND_SOCKET}    {       count(); yylval.strval=yytext;
514                                                                         return FORCE_SEND_SOCKET; }
515 <INITIAL>{SWITCH}       { count(); yylval.strval=yytext; return SWITCH; }
516 <INITIAL>{CASE} { count(); yylval.strval=yytext; return CASE; }
517 <INITIAL>{DEFAULT}      { count(); yylval.strval=yytext; return DEFAULT; }
518 <INITIAL>{WHILE}        { count(); yylval.strval=yytext; return WHILE; }
519
520 <INITIAL>{URIHOST}      { count(); yylval.strval=yytext; return URIHOST; }
521 <INITIAL>{URIPORT}      { count(); yylval.strval=yytext; return URIPORT; }
522
523 <INITIAL>{MAX_LEN}      { count(); yylval.strval=yytext; return MAX_LEN; }
524
525 <INITIAL>{METHOD}       { count(); yylval.strval=yytext; return METHOD; }
526 <INITIAL>{URI}  { count(); yylval.strval=yytext; return URI; }
527 <INITIAL>{FROM_URI}     { count(); yylval.strval=yytext; return FROM_URI; }
528 <INITIAL>{TO_URI}       { count(); yylval.strval=yytext; return TO_URI; }
529 <INITIAL>{SRCIP}        { count(); yylval.strval=yytext; return SRCIP; }
530 <INITIAL>{SRCPORT}      { count(); yylval.strval=yytext; return SRCPORT; }
531 <INITIAL>{DSTIP}        { count(); yylval.strval=yytext; return DSTIP; }
532 <INITIAL>{DSTPORT}      { count(); yylval.strval=yytext; return DSTPORT; }
533 <INITIAL>{SNDIP}        { count(); yylval.strval=yytext; return SNDIP; }
534 <INITIAL>{SNDPORT}      { count(); yylval.strval=yytext; return SNDPORT; }
535 <INITIAL>{SNDPROTO}     { count(); yylval.strval=yytext; return SNDPROTO; }
536 <INITIAL>{SNDAF}        { count(); yylval.strval=yytext; return SNDAF; }
537 <INITIAL>{TOIP}         { count(); yylval.strval=yytext; return TOIP; }
538 <INITIAL>{TOPORT}       { count(); yylval.strval=yytext; return TOPORT; }
539 <INITIAL>{PROTO}        { count(); yylval.strval=yytext; return PROTO; }
540 <INITIAL>{AF}   { count(); yylval.strval=yytext; return AF; }
541 <INITIAL>{MYSELF}       { count(); yylval.strval=yytext; return MYSELF; }
542
543 <INITIAL>{DEBUG}        { count(); yylval.strval=yytext; return DEBUG_V; }
544 <INITIAL>{FORK}         { count(); yylval.strval=yytext; return FORK; }
545 <INITIAL>{LOGSTDERROR}  { yylval.strval=yytext; return LOGSTDERROR; }
546 <INITIAL>{LOGFACILITY}  { yylval.strval=yytext; return LOGFACILITY; }
547 <INITIAL>{LISTEN}       { count(); yylval.strval=yytext; return LISTEN; }
548 <INITIAL>{ALIAS}        { count(); yylval.strval=yytext; return ALIAS; }
549 <INITIAL>{DNS}  { count(); yylval.strval=yytext; return DNS; }
550 <INITIAL>{REV_DNS}      { count(); yylval.strval=yytext; return REV_DNS; }
551 <INITIAL>{DNS_TRY_IPV6} { count(); yylval.strval=yytext;
552                                                                 return DNS_TRY_IPV6; }
553 <INITIAL>{DNS_TRY_NAPTR}        { count(); yylval.strval=yytext;
554                                                                 return DNS_TRY_NAPTR; }
555 <INITIAL>{DNS_SRV_LB}   { count(); yylval.strval=yytext;
556                                                                 return DNS_SRV_LB; }
557 <INITIAL>{DNS_UDP_PREF} { count(); yylval.strval=yytext;
558                                                                 return DNS_UDP_PREF; }
559 <INITIAL>{DNS_TCP_PREF} { count(); yylval.strval=yytext;
560                                                                 return DNS_TCP_PREF; }
561 <INITIAL>{DNS_TLS_PREF} { count(); yylval.strval=yytext;
562                                                                 return DNS_TLS_PREF; }
563 <INITIAL>{DNS_SCTP_PREF}        { count(); yylval.strval=yytext;
564                                                                 return DNS_SCTP_PREF; }
565 <INITIAL>{DNS_RETR_TIME}        { count(); yylval.strval=yytext;
566                                                                 return DNS_RETR_TIME; }
567 <INITIAL>{DNS_RETR_NO}  { count(); yylval.strval=yytext;
568                                                                 return DNS_RETR_NO; }
569 <INITIAL>{DNS_SERVERS_NO}       { count(); yylval.strval=yytext;
570                                                                 return DNS_SERVERS_NO; }
571 <INITIAL>{DNS_USE_SEARCH}       { count(); yylval.strval=yytext;
572                                                                 return DNS_USE_SEARCH; }
573 <INITIAL>{DNS_SEARCH_FMATCH}    { count(); yylval.strval=yytext;
574                                                                 return DNS_SEARCH_FMATCH; }
575 <INITIAL>{DNS_CACHE_INIT}       { count(); yylval.strval=yytext;
576                                                                 return DNS_CACHE_INIT; }
577 <INITIAL>{DNS_USE_CACHE}        { count(); yylval.strval=yytext;
578                                                                 return DNS_USE_CACHE; }
579 <INITIAL>{DNS_USE_FAILOVER}     { count(); yylval.strval=yytext;
580                                                                 return DNS_USE_FAILOVER; }
581 <INITIAL>{DNS_CACHE_FLAGS}      { count(); yylval.strval=yytext;
582                                                                 return DNS_CACHE_FLAGS; }
583 <INITIAL>{DNS_CACHE_NEG_TTL}    { count(); yylval.strval=yytext;
584                                                                 return DNS_CACHE_NEG_TTL; }
585 <INITIAL>{DNS_CACHE_MIN_TTL}    { count(); yylval.strval=yytext;
586                                                                 return DNS_CACHE_MIN_TTL; }
587 <INITIAL>{DNS_CACHE_MAX_TTL}    { count(); yylval.strval=yytext;
588                                                                 return DNS_CACHE_MAX_TTL; }
589 <INITIAL>{DNS_CACHE_MEM}        { count(); yylval.strval=yytext;
590                                                                 return DNS_CACHE_MEM; }
591 <INITIAL>{DNS_CACHE_GC_INT}     { count(); yylval.strval=yytext;
592                                                                 return DNS_CACHE_GC_INT; }
593 <INITIAL>{DNS_CACHE_DEL_NONEXP} { count(); yylval.strval=yytext;
594                                                                 return DNS_CACHE_DEL_NONEXP; }
595 <INITIAL>{DST_BLST_INIT}        { count(); yylval.strval=yytext;
596                                                                 return DST_BLST_INIT; }
597 <INITIAL>{USE_DST_BLST} { count(); yylval.strval=yytext;
598                                                                 return USE_DST_BLST; }
599 <INITIAL>{DST_BLST_MEM} { count(); yylval.strval=yytext;
600                                                                 return DST_BLST_MEM; }
601 <INITIAL>{DST_BLST_TTL} { count(); yylval.strval=yytext;
602                                                                 return DST_BLST_TTL; }
603 <INITIAL>{DST_BLST_GC_INT}      { count(); yylval.strval=yytext;
604                                                                 return DST_BLST_GC_INT; }
605 <INITIAL>{PORT} { count(); yylval.strval=yytext; return PORT; }
606 <INITIAL>{STAT} { count(); yylval.strval=yytext; return STAT; }
607 <INITIAL>{MAXBUFFER}    { count(); yylval.strval=yytext; return MAXBUFFER; }
608 <INITIAL>{CHILDREN}     { count(); yylval.strval=yytext; return CHILDREN; }
609 <INITIAL>{CHECK_VIA}    { count(); yylval.strval=yytext; return CHECK_VIA; }
610 <INITIAL>{PHONE2TEL}    { count(); yylval.strval=yytext; return PHONE2TEL; }
611 <INITIAL>{SYN_BRANCH}   { count(); yylval.strval=yytext; return SYN_BRANCH; }
612 <INITIAL>{MEMLOG}       { count(); yylval.strval=yytext; return MEMLOG; }
613 <INITIAL>{MEMDBG}       { count(); yylval.strval=yytext; return MEMDBG; }
614 <INITIAL>{SIP_WARNING}  { count(); yylval.strval=yytext; return SIP_WARNING; }
615 <INITIAL>{USER}         { count(); yylval.strval=yytext; return USER; }
616 <INITIAL>{GROUP}        { count(); yylval.strval=yytext; return GROUP; }
617 <INITIAL>{CHROOT}       { count(); yylval.strval=yytext; return CHROOT; }
618 <INITIAL>{WDIR} { count(); yylval.strval=yytext; return WDIR; }
619 <INITIAL>{MHOMED}       { count(); yylval.strval=yytext; return MHOMED; }
620 <INITIAL>{DISABLE_TCP}  { count(); yylval.strval=yytext; return DISABLE_TCP; }
621 <INITIAL>{TCP_CHILDREN} { count(); yylval.strval=yytext; return TCP_CHILDREN; }
622 <INITIAL>{TCP_ACCEPT_ALIASES}   { count(); yylval.strval=yytext;
623                                                                         return TCP_ACCEPT_ALIASES; }
624 <INITIAL>{TCP_SEND_TIMEOUT}             { count(); yylval.strval=yytext;
625                                                                         return TCP_SEND_TIMEOUT; }
626 <INITIAL>{TCP_CONNECT_TIMEOUT}          { count(); yylval.strval=yytext;
627                                                                         return TCP_CONNECT_TIMEOUT; }
628 <INITIAL>{TCP_CON_LIFETIME}             { count(); yylval.strval=yytext;
629                                                                         return TCP_CON_LIFETIME; }
630 <INITIAL>{TCP_POLL_METHOD}              { count(); yylval.strval=yytext;
631                                                                         return TCP_POLL_METHOD; }
632 <INITIAL>{TCP_MAX_CONNECTIONS}  { count(); yylval.strval=yytext;
633                                                                         return TCP_MAX_CONNECTIONS; }
634 <INITIAL>{TCP_NO_CONNECT}               { count(); yylval.strval=yytext;
635                                                                         return TCP_NO_CONNECT; }
636 <INITIAL>{TCP_SOURCE_IPV4}              { count(); yylval.strval=yytext;
637                                                                         return TCP_SOURCE_IPV4; }
638 <INITIAL>{TCP_SOURCE_IPV6}              { count(); yylval.strval=yytext;
639                                                                         return TCP_SOURCE_IPV6; }
640 <INITIAL>{TCP_OPT_FD_CACHE}             { count(); yylval.strval=yytext;
641                                                                         return TCP_OPT_FD_CACHE; }
642 <INITIAL>{TCP_OPT_CONN_WQ_MAX}  { count(); yylval.strval=yytext;
643                                                                         return TCP_OPT_CONN_WQ_MAX; }
644 <INITIAL>{TCP_OPT_WQ_MAX}       { count(); yylval.strval=yytext;
645                                                                         return TCP_OPT_WQ_MAX; }
646 <INITIAL>{TCP_OPT_RD_BUF}       { count(); yylval.strval=yytext;
647                                                                         return TCP_OPT_RD_BUF; }
648 <INITIAL>{TCP_OPT_WQ_BLK}       { count(); yylval.strval=yytext;
649                                                                         return TCP_OPT_WQ_BLK; }
650 <INITIAL>{TCP_OPT_BUF_WRITE}    { count(); yylval.strval=yytext;
651                                                                         return TCP_OPT_BUF_WRITE; }
652 <INITIAL>{TCP_OPT_DEFER_ACCEPT} { count(); yylval.strval=yytext;
653                                                                         return TCP_OPT_DEFER_ACCEPT; }
654 <INITIAL>{TCP_OPT_DELAYED_ACK}  { count(); yylval.strval=yytext;
655                                                                         return TCP_OPT_DELAYED_ACK; }
656 <INITIAL>{TCP_OPT_SYNCNT}               { count(); yylval.strval=yytext;
657                                                                         return TCP_OPT_SYNCNT; }
658 <INITIAL>{TCP_OPT_LINGER2}              { count(); yylval.strval=yytext;
659                                                                         return TCP_OPT_LINGER2; }
660 <INITIAL>{TCP_OPT_KEEPALIVE}    { count(); yylval.strval=yytext;
661                                                                         return TCP_OPT_KEEPALIVE; }
662 <INITIAL>{TCP_OPT_KEEPIDLE}             { count(); yylval.strval=yytext;
663                                                                         return TCP_OPT_KEEPIDLE; }
664 <INITIAL>{TCP_OPT_KEEPINTVL}    { count(); yylval.strval=yytext;
665                                                                         return TCP_OPT_KEEPINTVL; }
666 <INITIAL>{TCP_OPT_KEEPCNT}      { count(); yylval.strval=yytext;
667                                                                         return TCP_OPT_KEEPCNT; }
668 <INITIAL>{TCP_OPT_CRLF_PING}    { count(); yylval.strval=yytext;
669                                                                         return TCP_OPT_CRLF_PING; }
670 <INITIAL>{DISABLE_TLS}  { count(); yylval.strval=yytext; return DISABLE_TLS; }
671 <INITIAL>{ENABLE_TLS}   { count(); yylval.strval=yytext; return ENABLE_TLS; }
672 <INITIAL>{TLSLOG}               { count(); yylval.strval=yytext; return TLS_PORT_NO; }
673 <INITIAL>{TLS_PORT_NO}  { count(); yylval.strval=yytext; return TLS_PORT_NO; }
674 <INITIAL>{TLS_METHOD}   { count(); yylval.strval=yytext; return TLS_METHOD; }
675 <INITIAL>{TLS_VERIFY}   { count(); yylval.strval=yytext; return TLS_VERIFY; }
676 <INITIAL>{TLS_REQUIRE_CERTIFICATE}      { count(); yylval.strval=yytext;
677                                                                                 return TLS_REQUIRE_CERTIFICATE; }
678 <INITIAL>{TLS_CERTIFICATE}      { count(); yylval.strval=yytext;
679                                                                                 return TLS_CERTIFICATE; }
680 <INITIAL>{TLS_PRIVATE_KEY}      { count(); yylval.strval=yytext;
681                                                                                 return TLS_PRIVATE_KEY; }
682 <INITIAL>{TLS_CA_LIST}  { count(); yylval.strval=yytext;
683                                                                                 return TLS_CA_LIST; }
684 <INITIAL>{TLS_HANDSHAKE_TIMEOUT}        { count(); yylval.strval=yytext;
685                                                                                 return TLS_HANDSHAKE_TIMEOUT; }
686 <INITIAL>{TLS_SEND_TIMEOUT}     { count(); yylval.strval=yytext;
687                                                                                 return TLS_SEND_TIMEOUT; }
688 <INITIAL>{DISABLE_SCTP} { count(); yylval.strval=yytext; return DISABLE_SCTP;}
689 <INITIAL>{ENABLE_SCTP}  { count(); yylval.strval=yytext; return ENABLE_SCTP;}
690 <INITIAL>{SCTP_CHILDREN}        { count(); yylval.strval=yytext;
691                                                                                 return SCTP_CHILDREN; }
692 <INITIAL>{SCTP_SOCKET_RCVBUF}   { count(); yylval.strval=yytext;
693                                                                                 return SCTP_SOCKET_RCVBUF; }
694 <INITIAL>{SCTP_SOCKET_SNDBUF}   { count(); yylval.strval=yytext;
695                                                                                 return SCTP_SOCKET_SNDBUF; }
696 <INITIAL>{SCTP_AUTOCLOSE}       { count(); yylval.strval=yytext;
697                                                                                 return SCTP_AUTOCLOSE; }
698 <INITIAL>{SCTP_SEND_TTL}        { count(); yylval.strval=yytext;
699                                                                                 return SCTP_SEND_TTL; }
700 <INITIAL>{SCTP_SEND_RETRIES}    { count(); yylval.strval=yytext;
701                                                                                 return SCTP_SEND_RETRIES; }
702 <INITIAL>{SERVER_SIGNATURE}     { count(); yylval.strval=yytext; return SERVER_SIGNATURE; }
703 <INITIAL>{REPLY_TO_VIA} { count(); yylval.strval=yytext; return REPLY_TO_VIA; }
704 <INITIAL>{ADVERTISED_ADDRESS}   {       count(); yylval.strval=yytext;
705                                                                         return ADVERTISED_ADDRESS; }
706 <INITIAL>{ADVERTISED_PORT}              {       count(); yylval.strval=yytext;
707                                                                         return ADVERTISED_PORT; }
708 <INITIAL>{DISABLE_CORE}         {       count(); yylval.strval=yytext;
709                                                                         return DISABLE_CORE; }
710 <INITIAL>{OPEN_FD_LIMIT}                {       count(); yylval.strval=yytext;
711                                                                         return OPEN_FD_LIMIT; }
712 <INITIAL>{SHM_FORCE_ALLOC}              {       count(); yylval.strval=yytext;
713                                                                         return SHM_FORCE_ALLOC; }
714 <INITIAL>{MLOCK_PAGES}          {       count(); yylval.strval=yytext;
715                                                                         return MLOCK_PAGES; }
716 <INITIAL>{REAL_TIME}            {       count(); yylval.strval=yytext;
717                                                                         return REAL_TIME; }
718 <INITIAL>{RT_PRIO}              {       count(); yylval.strval=yytext;
719                                                                         return RT_PRIO; }
720 <INITIAL>{RT_POLICY}            {       count(); yylval.strval=yytext;
721                                                                         return RT_POLICY; }
722 <INITIAL>{RT_TIMER1_PRIO}               {       count(); yylval.strval=yytext;
723                                                                         return RT_TIMER1_PRIO; }
724 <INITIAL>{RT_TIMER1_POLICY}             {       count(); yylval.strval=yytext;
725                                                                         return RT_TIMER1_POLICY; }
726 <INITIAL>{RT_TIMER2_PRIO}               {       count(); yylval.strval=yytext;
727                                                                         return RT_TIMER2_PRIO; }
728 <INITIAL>{RT_TIMER2_POLICY}             {       count(); yylval.strval=yytext;
729                                                                         return RT_TIMER2_POLICY; }
730 <INITIAL>{MCAST_LOOPBACK}               {       count(); yylval.strval=yytext;
731                                                                         return MCAST_LOOPBACK; }
732 <INITIAL>{MCAST_TTL}            {       count(); yylval.strval=yytext;
733                                                                         return MCAST_TTL; }
734 <INITIAL>{TOS}                  {       count(); yylval.strval=yytext;
735                                                                         return TOS; }
736 <INITIAL>{PMTU_DISCOVERY}               {       count(); yylval.strval=yytext;
737                                                                         return PMTU_DISCOVERY; }
738 <INITIAL>{KILL_TIMEOUT}                 {       count(); yylval.strval=yytext;
739                                                                         return KILL_TIMEOUT; }
740 <INITIAL>{MAX_WLOOPS}                   {       count(); yylval.strval=yytext;
741                                                                         return MAX_WLOOPS; }
742 <INITIAL>{SERVER_ID}  { count(); yylval.strval=yytext; return SERVER_ID;}
743 <INITIAL>{CFG_DESCRIPTION}      { count(); yylval.strval=yytext; return CFG_DESCRIPTION; }
744 <INITIAL>{LOADMODULE}   { count(); yylval.strval=yytext; return LOADMODULE; }
745 <INITIAL>{LOADPATH}             { count(); yylval.strval=yytext; return LOADPATH; }
746 <INITIAL>{MODPARAM}     { count(); yylval.strval=yytext; return MODPARAM; }
747
748 <INITIAL>{STUN_REFRESH_INTERVAL} { count(); yylval.strval=yytext; return STUN_REFRESH_INTERVAL;}
749 <INITIAL>{STUN_ALLOW_STUN} { count(); yylval.strval=yytext; return STUN_ALLOW_STUN;}
750 <INITIAL>{STUN_ALLOW_FP} { count(); yylval.strval=yytext; return STUN_ALLOW_FP;}
751
752 <INITIAL>{EQUAL}        { count(); return EQUAL; }
753 <INITIAL>{ADDEQ}          { count(); return ADDEQ; }
754 <INITIAL>{EQUAL_T}      { count(); return EQUAL_T; }
755 <INITIAL>{GT}   { count(); return GT; }
756 <INITIAL>{LT}   { count(); return LT; }
757 <INITIAL>{GTE}  { count(); return GTE; }
758 <INITIAL>{LTE}  { count(); return LTE; }
759 <INITIAL>{DIFF} { count(); return DIFF; }
760 <INITIAL>{MATCH}        { count(); return MATCH; }
761 <INITIAL>{NOT}          { count(); return NOT; }
762 <INITIAL>{LOG_AND}      { count(); return LOG_AND; }
763 <INITIAL>{BIN_AND}      { count(); return BIN_AND; }
764 <INITIAL>{LOG_OR}       { count(); return LOG_OR;  }
765 <INITIAL>{BIN_OR}       { count(); return BIN_OR;  }
766 <INITIAL>{PLUS}         { count(); return PLUS; }
767 <INITIAL>{MINUS}        { count(); return MINUS; }
768
769 <INITIAL>{SELECT_MARK}  { count(); state = SELECT_S; BEGIN(SELECT); return SELECT_MARK; }
770 <SELECT>{ID}            { count(); addstr(&s_buf, yytext, yyleng);
771                           yylval.strval=s_buf.s;
772                           memset(&s_buf, 0, sizeof(s_buf));
773                           return ID;
774                         }
775 <SELECT>{DOT}           { count(); return DOT; }
776 <SELECT>{LBRACK}        { count(); return LBRACK; }
777 <SELECT>{RBRACK}        { count(); return RBRACK; }
778 <SELECT>{DECNUMBER}     { count(); yylval.intval=atoi(yytext);return NUMBER; }
779 <SELECT>{HEXNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 16); return NUMBER; }
780 <SELECT>{OCTNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 8); return NUMBER; }
781 <SELECT>{BINNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 2); return NUMBER; }
782
783
784 <INITIAL>{ATTR_MARK}    { count(); state = ATTR_S; BEGIN(ATTR);
785                                                         return ATTR_MARK; }
786 <ATTR>{ATTR_FROM}       { count(); return ATTR_FROM; }
787 <ATTR>{ATTR_TO}         { count(); return ATTR_TO; }
788 <ATTR>{ATTR_FROMURI}    { count(); return ATTR_FROMURI; }
789 <ATTR>{ATTR_TOURI}      { count(); return ATTR_TOURI; }
790 <ATTR>{ATTR_FROMUSER}   { count(); return ATTR_FROMUSER; }
791 <ATTR>{ATTR_TOUSER}     { count(); return ATTR_TOUSER; }
792 <ATTR>{ATTR_FROMDOMAIN} { count(); return ATTR_FROMDOMAIN; }
793 <ATTR>{ATTR_TODOMAIN}   { count(); return ATTR_TODOMAIN; }
794 <ATTR>{ATTR_GLOBAL}     { count(); return ATTR_GLOBAL; }
795 <ATTR>{DOT}             { count(); return DOT; }
796 <ATTR>{LBRACK}          { count(); return LBRACK; }
797 <ATTR>{RBRACK}          { count(); return RBRACK; }
798 <ATTR>{STAR}                    { count(); return STAR; }
799 <ATTR>{DECNUMBER}               { count(); yylval.intval=atoi(yytext);return NUMBER; }
800 <ATTR>{ID}                              { count(); addstr(&s_buf, yytext, yyleng);
801                                                         yylval.strval=s_buf.s;
802                                                         memset(&s_buf, 0, sizeof(s_buf));
803                                                         state = INITIAL_S;
804                                                         BEGIN(INITIAL);
805                                                         return ID;
806                                                 }
807
808 <INITIAL>{VAR_MARK}{LPAREN}     {
809                                                                 switch(sr_cfg_compat){
810                                                                         case SR_COMPAT_SER:
811                                                                                 state=ATTR_S; BEGIN(ATTR);
812                                                                                 yyless(1);
813                                                                                 count();
814                                                                                 return ATTR_MARK;
815                                                                                 break;
816                                                                         case SR_COMPAT_KAMAILIO:
817                                                                         case SR_COMPAT_MAX:
818                                                                         default:
819                                                                                 state = PVAR_P_S; BEGIN(PVAR_P);
820                                                                                 p_nest=1; yymore();
821                                                                                 break;
822                                                                 }
823                                                         }
824         /* eat everything between 2 () and return PVAR token and a string
825            containing everything (including $ and ()) */
826 <PVAR_P>{RPAREN}                        {       p_nest--;
827                                                                 if (p_nest==0){
828                                                                         count();
829                                                                         addstr(&s_buf, yytext, yyleng);
830                                                                         yylval.strval=s_buf.s;
831                                                                         memset(&s_buf, 0, sizeof(s_buf));
832                                                                         state=INITIAL_S;
833                                                                         BEGIN(INITIAL);
834                                                                         return PVAR;
835                                                                 }
836                                                                 yymore();
837                                                         }
838 <PVAR_P>{LPAREN}                        { p_nest++; yymore(); }
839 <PVAR_P>.                                       { yymore(); }
840
841 <PVARID>{ID}|'.'                        {yymore(); }
842 <PVARID>{LPAREN}                        {       state = PVAR_P_S; BEGIN(PVAR_P);
843                                                                 p_nest=1; yymore(); }
844 <PVARID>.                                       { yyless(0); state=INITIAL_S; BEGIN(INITIAL);
845                                                                 return PVAR;
846                                                         }
847
848
849 <INITIAL>{VAR_MARK}                     {
850                                                                 switch(sr_cfg_compat){
851                                                                         case SR_COMPAT_SER:
852                                                                                 count();
853                                                                                 state=ATTR_S; BEGIN(ATTR);
854                                                                                 return ATTR_MARK;
855                                                                                 break;
856                                                                         case SR_COMPAT_KAMAILIO:
857                                                                                 state=PVARID_S; BEGIN(PVARID);
858                                                                                 yymore();
859                                                                                 break;
860                                                                         case SR_COMPAT_MAX:
861                                                                         default: 
862                                                                                 state=AVP_PVAR_S; BEGIN(AVP_PVAR);
863                                                                                 yymore();
864                                                                                 break;
865                                                                 }
866                                                         }
867         /* avp prefix detected -> go to avp mode */
868 <AVP_PVAR>{AVP_PREF}            |
869 <AVP_PVAR>{ID}{LBRACK}          { state = ATTR_S; BEGIN(ATTR); yyless(1); count();
870                                                           return ATTR_MARK; }
871 <AVP_PVAR>{ID}{LPAREN}          { state = PVAR_P_S; p_nest=1; BEGIN(PVAR_P);
872                                                                 yymore(); }
873 <AVP_PVAR>{ID}                          {       count(); addstr(&s_buf, yytext, yyleng);
874                                                                 yylval.strval=s_buf.s;
875                                                                 memset(&s_buf, 0, sizeof(s_buf));
876                                                                 state = INITIAL_S;
877                                                                 BEGIN(INITIAL);
878                                                                 return AVP_OR_PVAR;
879                                                         }
880
881 <INITIAL>{IPV6ADDR}             { count(); yylval.strval=yytext; return IPV6ADDR; }
882 <INITIAL>{DECNUMBER}            { count(); yylval.intval=atoi(yytext);return NUMBER; }
883 <INITIAL>{HEXNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 16);
884                                                         return NUMBER; }
885 <INITIAL>{OCTNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 8);
886                                                         return NUMBER; }
887 <INITIAL>{BINNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 2); return NUMBER; }
888 <INITIAL>{YES}                  { count(); yylval.intval=1; return NUMBER; }
889 <INITIAL>{NO}                   { count(); yylval.intval=0; return NUMBER; }
890 <INITIAL>{TCP}                  { count(); return TCP; }
891 <INITIAL>{UDP}                  { count(); return UDP; }
892 <INITIAL>{TLS}                  { count(); return TLS; }
893 <INITIAL>{SCTP}                 { count(); return SCTP; }
894 <INITIAL>{INET}                 { count(); yylval.intval=AF_INET; return NUMBER; }
895 <INITIAL>{INET6}                { count();
896                                                 #ifdef USE_IPV6
897                                                   yylval.intval=AF_INET6;
898                                                 #else
899                                                   yylval.intval=-1; /* no match*/
900                                                 #endif
901                                                   return NUMBER; }
902 <INITIAL>{SSLv23}               { count(); yylval.strval=yytext; return SSLv23; }
903 <INITIAL>{SSLv2}                { count(); yylval.strval=yytext; return SSLv2; }
904 <INITIAL>{SSLv3}                { count(); yylval.strval=yytext; return SSLv3; }
905 <INITIAL>{TLSv1}                { count(); yylval.strval=yytext; return TLSv1; }
906
907 <INITIAL>{COMMA}                { count(); return COMMA; }
908 <INITIAL>{SEMICOLON}    { count(); return SEMICOLON; }
909 <INITIAL>{COLON}        { count(); return COLON; }
910 <INITIAL>{STAR}         { count(); return STAR; }
911 <INITIAL>{RPAREN}       { count(); return RPAREN; }
912 <INITIAL>{LPAREN}       { count(); return LPAREN; }
913 <INITIAL>{LBRACE}       { count(); return LBRACE; }
914 <INITIAL>{RBRACE}       { count(); return RBRACE; }
915 <INITIAL>{LBRACK}       { count(); return LBRACK; }
916 <INITIAL>{RBRACK}       { count(); return RBRACK; }
917 <INITIAL>{SLASH}        { count(); return SLASH; }
918 <INITIAL>{DOT}          { count(); return DOT; }
919 <INITIAL>\\{CR}         {count(); } /* eat the escaped CR */
920 <INITIAL>{CR}           { count();/* return CR;*/ }
921
922
923 <INITIAL,SELECT>{QUOTES} { count(); old_initial = YY_START; 
924                                                         old_state = state; state=STRING_S;
925                                                         BEGIN(STRING1); }
926 <INITIAL>{TICK} { count(); old_initial = YY_START; old_state = state;
927                                         state=STRING_S; BEGIN(STRING2); }
928
929
930 <STRING1>{QUOTES} { count_more(); 
931                                                 yytext[yyleng-1]=0; yyleng--;
932                                                 addstr(&s_buf, yytext, yyleng);
933                                                 BEGIN(STR_BETWEEN);
934                                         }
935 <STRING2>{TICK}  { count_more(); state=old_state; BEGIN(old_initial);
936                                                 yytext[yyleng-1]=0; yyleng--;
937                                                 addstr(&s_buf, yytext, yyleng);
938                                                 yylval.strval=s_buf.s;
939                                                 memset(&s_buf, 0, sizeof(s_buf));
940                                                 return STRING;
941                                         }
942 <STRING2>.|{EAT_ABLE}|{CR}      { yymore(); }
943
944 <STRING1>\\n            { count_more(); addchar(&s_buf, '\n'); }
945 <STRING1>\\r            { count_more(); addchar(&s_buf, '\r'); }
946 <STRING1>\\a            { count_more(); addchar(&s_buf, '\a'); }
947 <STRING1>\\t            { count_more(); addchar(&s_buf, '\t'); }
948 <STRING1>\\{QUOTES}     { count_more(); addchar(&s_buf, '"');  }
949 <STRING1>\\\\           { count_more(); addchar(&s_buf, '\\'); }
950 <STRING1>\\x{HEX}{1,2}  { count_more(); addchar(&s_buf,
951                                                                                         (char)strtol(yytext+2, 0, 16)); }
952  /* don't allow \[0-7]{1}, it will eat the backreferences from
953     subst_uri if allowed (although everybody should use '' in subt_uri) */
954 <STRING1>\\[0-7]{2,3}   { count_more(); addchar(&s_buf,
955                                                                                         (char)strtol(yytext+1, 0, 8));  }
956 <STRING1>\\{CR}         { count_more(); } /* eat escaped CRs */
957 <STRING1>.|{EAT_ABLE}|{CR}      { count_more(); addchar(&s_buf, *yytext); }
958
959 <STR_BETWEEN>{EAT_ABLE}|{CR}    { count_ignore(); }
960 <STR_BETWEEN>{QUOTES}                   { count_more(); state=STRING_S;
961                                                                   BEGIN(STRING1);}
962 <STR_BETWEEN>.                                  {       
963                                                                         yyless(0); /* reparse it */
964                                                                         /* ignore the whitespace now that is
965                                                                           counted, return saved string value */
966                                                                         state=old_state; BEGIN(old_initial);
967                                                                         yylval.strval=s_buf.s;
968                                                                         memset(&s_buf, 0, sizeof(s_buf));
969                                                                         return STRING;
970                                                                 }
971
972 <INITIAL,COMMENT>{COM_START}    { count(); comment_nest++; state=COMMENT_S;
973                                                                                 BEGIN(COMMENT); }
974 <COMMENT>{COM_END}                              { count(); comment_nest--;
975                                                                                 if (comment_nest==0){
976                                                                                         state=INITIAL_S;
977                                                                                         BEGIN(INITIAL);
978                                                                                 }
979                                                                 }
980 <COMMENT>.|{EAT_ABLE}|{CR}                              { count(); };
981
982 <INITIAL>{COM_LINE}!{SER_CFG}{CR}               { count();
983                                                                                         sr_cfg_compat=SR_COMPAT_SER;}
984 <INITIAL>{COM_LINE}!{KAMAILIO_CFG}{CR}  { count(); 
985                                                                                         sr_cfg_compat=SR_COMPAT_KAMAILIO;}
986 <INITIAL>{COM_LINE}!{MAXCOMPAT_CFG}{CR} { count(); 
987                                                                                                 sr_cfg_compat=SR_COMPAT_MAX;}
988 <INITIAL>{COM_LINE}.*{CR}       { count(); }
989
990 <INITIAL>{ID}                   { count(); addstr(&s_buf, yytext, yyleng);
991                                                                         yylval.strval=s_buf.s;
992                                                                         memset(&s_buf, 0, sizeof(s_buf));
993                                                                         return ID; }
994
995 <SELECT>.               { unput(yytext[0]); state = INITIAL_S; BEGIN(INITIAL); } /* Rescan the token in INITIAL state */
996
997
998 <<EOF>>                                                 {
999                                                                         switch(state){
1000                                                                                 case STR_BETWEEN_S:
1001                                                                                         state=old_state;
1002                                                                                         BEGIN(old_initial);
1003                                                                                         yylval.strval=s_buf.s;
1004                                                                                         memset(&s_buf, 0, sizeof(s_buf));
1005                                                                                         return STRING;
1006                                                                                 case STRING_S:
1007                                                                                         LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF in"
1008                                                                                                                 " unclosed string\n");
1009                                                                                         if (s_buf.s){
1010                                                                                                 pkg_free(s_buf.s);
1011                                                                                                 memset(&s_buf, 0,
1012                                                                                                                         sizeof(s_buf));
1013                                                                                         }
1014                                                                                         break;
1015                                                                                 case COMMENT_S:
1016                                                                                         LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF:"
1017                                                                                                                 " %d comments open\n", comment_nest);
1018                                                                                         break;
1019                                                                                 case COMMENT_LN_S:
1020                                                                                         LOG(L_CRIT, "ERROR: unexpected EOF:"
1021                                                                                                                 "comment line open\n");
1022                                                                                         break;
1023                                                                                 case  ATTR_S:
1024                                                                                         LOG(L_CRIT, "ERROR: unexpected EOF"
1025                                                                                                         " while parsing"
1026                                                                                                         " avp name\n");
1027                                                                                         break;
1028                                                                                 case PVARID_S:
1029                                                                                         p_nest=0;
1030                                                                                 case PVAR_P_S: 
1031                                                                                         LOG(L_CRIT, "ERROR: unexpected EOF"
1032                                                                                                         " while parsing pvar name"
1033                                                                                                         " (%d paranthesis open)\n",
1034                                                                                                         p_nest);
1035                                                                                         break;
1036                                                                                 case AVP_PVAR_S:
1037                                                                                         LOG(L_CRIT, "ERROR: unexpected EOF"
1038                                                                                                         " while parsing"
1039                                                                                                         " avp or pvar name\n");
1040                                                                         }
1041                                                                         return 0;
1042                                                                 }
1043
1044 %%
1045
1046
1047 static char* addchar(struct str_buf* dst, char c)
1048 {
1049         return addstr(dst, &c, 1);
1050 }
1051
1052
1053
1054 static char* addstr(struct str_buf* dst_b, char* src, int len)
1055 {
1056         char *tmp;
1057         unsigned size;
1058         unsigned used;
1059
1060         if (dst_b->left<(len+1)){
1061                 used=(unsigned)(dst_b->crt-dst_b->s);
1062                 size=used+len+1;
1063                 /* round up to next multiple */
1064                 size+= STR_BUF_ALLOC_UNIT-size%STR_BUF_ALLOC_UNIT;
1065                 tmp=pkg_malloc(size);
1066                 if (tmp==0) goto error;
1067                 if (dst_b->s){
1068                         memcpy(tmp, dst_b->s, used);
1069                         pkg_free(dst_b->s);
1070                 }
1071                 dst_b->s=tmp;
1072                 dst_b->crt=dst_b->s+used;
1073                 dst_b->left=size-used;
1074         }
1075         memcpy(dst_b->crt, src, len);
1076         dst_b->crt+=len;
1077         *(dst_b->crt)=0;
1078         dst_b->left-=len;
1079
1080         return dst_b->s;
1081 error:
1082         LOG(L_CRIT, "ERROR:lex:addstr: memory allocation error\n");
1083         return 0;
1084 }
1085
1086
1087
1088 /** helper function for count_*(). */
1089 static void count_lc(int* l, int* c)
1090 {
1091         int i;
1092         for (i=0; i<yyleng;i++){
1093                 if (yytext[i]=='\n'){
1094                         (*l)++;
1095                         (*c)=1;
1096                 }else if (yytext[i]=='\t'){
1097                         (*c)++;
1098                         /*(*c)+=8 -((*c)%8);*/
1099                 }else{
1100                         (*c)++;
1101                 }
1102         }
1103 }
1104
1105
1106
1107 /* helper function */
1108 static void count_restore_ignored()
1109 {
1110         if (ign_lines) /* ignored line(s) => column has changed */
1111                 column=ign_columns;
1112         else
1113                 column+=ign_columns;
1114         line+=ign_lines;
1115         ign_lines=ign_columns=0;
1116 }
1117
1118
1119
1120 /** count/record position for stuff added to the current token. */
1121 static void count_more()
1122 {
1123         count_restore_ignored();
1124         count_lc(&line, &column);
1125 }
1126
1127
1128
1129 /** count/record position for a new token. */
1130 static void count()
1131 {
1132         count_restore_ignored();
1133         startline=line;
1134         startcolumn=column;
1135         count_more();
1136 }
1137
1138
1139
1140 /** record discarded stuff (not contained in the token) so that
1141     the next token position can be adjusted properly*/
1142 static void count_ignore()
1143 {
1144         count_lc(&ign_lines, &ign_columns);
1145 }
1146
1147
1148 /* replacement yywrap, removes libfl dependency */
1149 int yywrap()
1150 {
1151         return 1;
1152 }