scanner.l (70735) | scanner.l (75110) |
---|---|
1%{ 2/* 3 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that: (1) source code distributions 8 * retain the above copyright notice and this paragraph in its entirety, (2) --- 5 unchanged lines hidden (view full) --- 14 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 * the University nor the names of its contributors may be used to endorse 16 * or promote products derived from this software without specific prior 17 * written permission. 18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 * | 1%{ 2/* 3 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that: (1) source code distributions 8 * retain the above copyright notice and this paragraph in its entirety, (2) --- 5 unchanged lines hidden (view full) --- 14 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 * the University nor the names of its contributors may be used to endorse 16 * or promote products derived from this software without specific prior 17 * written permission. 18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 * |
22 * $FreeBSD: head/contrib/libpcap/scanner.l 70735 2001-01-07 00:26:32Z archie $ | 22 * $FreeBSD: head/contrib/libpcap/scanner.l 75110 2001-04-03 04:32:48Z fenner $ |
23 */ 24 25#ifndef lint 26static const char rcsid[] = | 23 */ 24 25#ifndef lint 26static const char rcsid[] = |
27 "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.60 1999/11/17 04:09:58 assar Exp $ (LBL)"; | 27 "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.70 2000/10/28 10:18:40 guy Exp $ (LBL)"; |
28#endif 29 | 28#endif 29 |
30#ifdef HAVE_CONFIG_H 31#include "config.h" 32#endif 33 |
|
30#include <sys/types.h> 31#include <sys/time.h> 32 33#include <ctype.h> 34#include <unistd.h> 35#include <string.h> 36 37#include "pcap-int.h" 38 39#include "gencode.h" 40#include <pcap-namedb.h> 41#ifdef INET6 42#include <netdb.h> 43#include <sys/socket.h> | 34#include <sys/types.h> 35#include <sys/time.h> 36 37#include <ctype.h> 38#include <unistd.h> 39#include <string.h> 40 41#include "pcap-int.h" 42 43#include "gencode.h" 44#include <pcap-namedb.h> 45#ifdef INET6 46#include <netdb.h> 47#include <sys/socket.h> |
48/* Workaround for AIX 4.3 */ 49#if !defined(AI_NUMERICHOST) 50#define AI_NUMERICHOST 0x04 51#endif |
|
44#endif /*INET6*/ 45#include "tokdefs.h" 46 | 52#endif /*INET6*/ 53#include "tokdefs.h" 54 |
47#include "gnuc.h" | |
48#ifdef HAVE_OS_PROTO_H 49#include "os-proto.h" 50#endif 51 52static int stoi(char *); 53static inline int xdtoi(int); 54 55#ifdef FLEX_SCANNER 56#define YY_NO_UNPUT | 55#ifdef HAVE_OS_PROTO_H 56#include "os-proto.h" 57#endif 58 59static int stoi(char *); 60static inline int xdtoi(int); 61 62#ifdef FLEX_SCANNER 63#define YY_NO_UNPUT |
57#undef YY_INPUT 58#define YY_INPUT(buf, result, max)\ 59 {\ 60 char *src = in_buffer;\ 61 int i;\ 62\ 63 if (*src == 0)\ 64 result = YY_NULL;\ 65 else {\ 66 for (i = 0; *src && i < max; ++i)\ 67 buf[i] = *src++;\ 68 in_buffer += i;\ 69 result = i;\ 70 }\ 71 } | 64static YY_BUFFER_STATE in_buffer; |
72#else | 65#else |
66static char *in_buffer; 67 |
|
73#undef getc 74#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++) 75#endif 76 77#define yylval pcap_lval 78extern YYSTYPE yylval; 79 | 68#undef getc 69#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++) 70#endif 71 72#define yylval pcap_lval 73extern YYSTYPE yylval; 74 |
80static char *in_buffer; 81 | |
82%} 83 84N ([0-9]+|(0X|0x)[0-9A-Fa-f]+) 85B ([0-9A-Fa-f][0-9A-Fa-f]?) 86W ([0-9A-Fa-f][0-9A-Fa-f]?[0-9A-Fa-f]?[0-9A-Fa-f]?) 87 88%a 15000 89%o 17000 90%e 6000 91%k 4000 92%p 19000 | 75%} 76 77N ([0-9]+|(0X|0x)[0-9A-Fa-f]+) 78B ([0-9A-Fa-f][0-9A-Fa-f]?) 79W ([0-9A-Fa-f][0-9A-Fa-f]?[0-9A-Fa-f]?[0-9A-Fa-f]?) 80 81%a 15000 82%o 17000 83%e 6000 84%k 4000 85%p 19000 |
86%n 2000 |
|
93 94V680 {W}:{W}:{W}:{W}:{W}:{W}:{W}:{W} 95 96V670 ::{W}:{W}:{W}:{W}:{W}:{W}:{W} 97V671 {W}::{W}:{W}:{W}:{W}:{W}:{W} 98V672 {W}:{W}::{W}:{W}:{W}:{W}:{W} 99V673 {W}:{W}:{W}::{W}:{W}:{W}:{W} 100V674 {W}:{W}:{W}:{W}::{W}:{W}:{W} --- 68 unchanged lines hidden (view full) --- 169 170V6 ({V680}|{V670}|{V671}|{V672}|{V673}|{V674}|{V675}|{V676}|{V677}|{V660}|{V661}|{V662}|{V663}|{V664}|{V665}|{V666}|{V650}|{V651}|{V652}|{V653}|{V654}|{V655}|{V640}|{V641}|{V642}|{V643}|{V644}|{V630}|{V631}|{V632}|{V633}|{V620}|{V621}|{V622}|{V610}|{V611}|{V600}|{V6604}|{V6504}|{V6514}|{V6524}|{V6534}|{V6544}|{V6554}|{V6404}|{V6414}|{V6424}|{V6434}|{V6444}|{V6304}|{V6314}|{V6324}|{V6334}|{V6204}|{V6214}|{V6224}|{V6104}|{V6114}|{V6004}) 171 172%% 173dst return DST; 174src return SRC; 175 176link|ether|ppp|slip return LINK; | 87 88V680 {W}:{W}:{W}:{W}:{W}:{W}:{W}:{W} 89 90V670 ::{W}:{W}:{W}:{W}:{W}:{W}:{W} 91V671 {W}::{W}:{W}:{W}:{W}:{W}:{W} 92V672 {W}:{W}::{W}:{W}:{W}:{W}:{W} 93V673 {W}:{W}:{W}::{W}:{W}:{W}:{W} 94V674 {W}:{W}:{W}:{W}::{W}:{W}:{W} --- 68 unchanged lines hidden (view full) --- 163 164V6 ({V680}|{V670}|{V671}|{V672}|{V673}|{V674}|{V675}|{V676}|{V677}|{V660}|{V661}|{V662}|{V663}|{V664}|{V665}|{V666}|{V650}|{V651}|{V652}|{V653}|{V654}|{V655}|{V640}|{V641}|{V642}|{V643}|{V644}|{V630}|{V631}|{V632}|{V633}|{V620}|{V621}|{V622}|{V610}|{V611}|{V600}|{V6604}|{V6504}|{V6514}|{V6524}|{V6534}|{V6544}|{V6554}|{V6404}|{V6414}|{V6424}|{V6434}|{V6444}|{V6304}|{V6314}|{V6324}|{V6334}|{V6204}|{V6214}|{V6224}|{V6104}|{V6114}|{V6004}) 165 166%% 167dst return DST; 168src return SRC; 169 170link|ether|ppp|slip return LINK; |
177fddi return LINK; | 171fddi|tr return LINK; |
178arp return ARP; 179rarp return RARP; 180ip return IP; 181tcp return TCP; 182udp return UDP; 183icmp return ICMP; 184igmp return IGMP; 185igrp return IGRP; 186pim return PIM; 187 188ip6 return IPV6; 189icmp6 return ICMPV6; 190ah return AH; 191esp return ESP; 192 193atalk return ATALK; | 172arp return ARP; 173rarp return RARP; 174ip return IP; 175tcp return TCP; 176udp return UDP; 177icmp return ICMP; 178igmp return IGMP; 179igrp return IGRP; 180pim return PIM; 181 182ip6 return IPV6; 183icmp6 return ICMPV6; 184ah return AH; 185esp return ESP; 186 187atalk return ATALK; |
188aarp return AARP; |
|
194decnet return DECNET; 195lat return LAT; 196sca return SCA; 197moprc return MOPRC; 198mopdl return MOPDL; 199 200iso return ISO; 201esis return ESIS; 202es-is return ESIS; 203isis return ISIS; 204is-is return ISIS; | 189decnet return DECNET; 190lat return LAT; 191sca return SCA; 192moprc return MOPRC; 193mopdl return MOPDL; 194 195iso return ISO; 196esis return ESIS; 197es-is return ESIS; 198isis return ISIS; 199is-is return ISIS; |
200clnp return CLNP; |
|
205 206host return HOST; 207net return NET; 208mask return MASK; 209port return PORT; 210proto return PROTO; 211protochain { 212#ifdef NO_PROTOCHAIN --- 14 unchanged lines hidden (view full) --- 227and|"&&" return AND; 228or|"||" return OR; 229not return '!'; 230 231len|length return LEN; 232inbound return INBOUND; 233outbound return OUTBOUND; 234 | 201 202host return HOST; 203net return NET; 204mask return MASK; 205port return PORT; 206proto return PROTO; 207protochain { 208#ifdef NO_PROTOCHAIN --- 14 unchanged lines hidden (view full) --- 223and|"&&" return AND; 224or|"||" return OR; 225not return '!'; 226 227len|length return LEN; 228inbound return INBOUND; 229outbound return OUTBOUND; 230 |
231vlan return VLAN; 232 |
|
235[ \n\t] ; 236[+\-*/:\[\]!<>()&|=] return yytext[0]; 237">=" return GEQ; 238"<=" return LEQ; 239"!=" return NEQ; 240"==" return '='; 241"<<" return LSH; 242">>" return RSH; --- 24 unchanged lines hidden (view full) --- 267[^ \[\]\t\n\-_.A-Za-z0-9!<>()&|=]+i { 268 bpf_error("illegal token: %s\n", yytext); } 269. { bpf_error("illegal char '%c'", *yytext); } 270%% 271void 272lex_init(buf) 273 char *buf; 274{ | 233[ \n\t] ; 234[+\-*/:\[\]!<>()&|=] return yytext[0]; 235">=" return GEQ; 236"<=" return LEQ; 237"!=" return NEQ; 238"==" return '='; 239"<<" return LSH; 240">>" return RSH; --- 24 unchanged lines hidden (view full) --- 265[^ \[\]\t\n\-_.A-Za-z0-9!<>()&|=]+i { 266 bpf_error("illegal token: %s\n", yytext); } 267. { bpf_error("illegal char '%c'", *yytext); } 268%% 269void 270lex_init(buf) 271 char *buf; 272{ |
273#ifdef FLEX_SCANNER 274 in_buffer = yy_scan_string(buf); 275#else |
|
275 in_buffer = buf; | 276 in_buffer = buf; |
276 yyrestart(NULL); | 277#endif |
277} 278 279/* | 278} 279 280/* |
281 * Do any cleanup necessary after parsing. 282 */ 283void 284lex_cleanup() 285{ 286#ifdef FLEX_SCANNER 287 if (in_buffer != NULL) 288 yy_delete_buffer(in_buffer); 289 in_buffer = NULL; 290#endif 291} 292 293/* |
|
280 * Also define a yywrap. Note that if we're using flex, it will 281 * define a macro to map this identifier to pcap_wrap. 282 */ 283int 284yywrap() 285{ 286 return 1; 287} --- 32 unchanged lines hidden (view full) --- 320 s += 1; 321 } 322 } 323 while (*s) 324 n = n * base + xdtoi(*s++); 325 326 return n; 327} | 294 * Also define a yywrap. Note that if we're using flex, it will 295 * define a macro to map this identifier to pcap_wrap. 296 */ 297int 298yywrap() 299{ 300 return 1; 301} --- 32 unchanged lines hidden (view full) --- 334 s += 1; 335 } 336 } 337 while (*s) 338 n = n * base + xdtoi(*s++); 339 340 return n; 341} |
328 | |