Re: $INCLUDE directive
pankaj <[email protected]> Fri, 11 Apr 2003 21:28:47 +0530 (IST)
| Newsgroups | gmane.comp.gnu.radius.general,gmane.comp.gnu.radius.bugs |
|---|---|
| Message-ID | <Pine.LNX.4.44.0304112037260.21949-600000@gadhwal.intranet.pspl.co.in> |
it takes requests from a text file "SIPAuthenticationHeaders", containing request lines. each request is a list of attribute=value pairs. attached file SIPAuthenticationHeaders is the requests file and av.l and av.y are the flex/bison files. again, corresponding normal and conked output is attached. pankaj _______________________________________________ Help-gnu-radius mailing list [email protected] http://mail.gnu.org/mailman/listinfo/help-gnu-radius
av.l
(text/plain, 1 KB)
%{
#include <string>
#include "Util.h"
# ifndef YYSTYPE
# define YYSTYPE char*
# define YYSTYPE_IS_TRIVIAL 1
# endif
# define COMMA 257
# define EQUAL 258
# define DIGEST 259
# define ID 260
# define QSTRING 261
# define HSTRING 262
extern YYSTYPE yylval;
%}
ws [ \t]+
comma ,
equal =
hstring [0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f]*
qstring \"[^\"]*\"
id [a-z]*
%%
{ws} ;
{comma} { /* PRINT ("COMMA"); */ return COMMA; }
{equal} { /* PRINT ("EQUAL"); */ return EQUAL; }
{hstring} { /* PRINT ("HSTRING"); */ printf ("lexer => %s\n", yytext); yylval = yytext; return HSTRING; }
{qstring} { /* PRINT ("QSTRING"); */ printf ("lexer => %s\n", yytext); yylval = yytext; return QSTRING; }
{id} { /* PRINT ("ID"); */ yylval = yytext; return ID; }
Digest { /* PRINT ("DIGEST"); */ return DIGEST; }
<<EOF>> { return EOF; }
%%
/*
int main (void) {
printf ("calling yy_scan_string\n");
yy_scan_string ("abc=123, xyz=\"xyz\"");
while (EOF!=yylex()) {}
}
*/
av.y
(text/plain, 2 KB)
%{
#include <string>
#include "Util.h"
#include "Attribute.h"
#include "TV.h"
#define YYSTYPE char*
#define YYPARSE_PARAM avmap
extern int yylex ();
int yyerror (char* error);
const int N = 10;
const char* attributes[] = {
"username",
"qop",
"realm",
"algorithm",
"nc",
"nonce",
"opaque",
"uri",
"cnonce",
"response" };
AttributeSet attributeSet (attributes, attributes+N);
const char* id;
char *hstring, *qstring;
%}
%token COMMA
%token EQUAL
%token DIGEST
%token ID
%token QSTRING
%token HSTRING
%%
MESSAGE: DIGEST AVLIST { } | { };
AVLIST: AVLIST COMMA AVPAIR { } | AVPAIR { };
AVPAIR:
I EQUAL H {
/*
cout << " id = " << id << endl;
cout << " hstring = " << hstring << endl;
*/
(*((NameTVMap*)avmap))[id] = new TV (TV::HSTR, hstring);
}
|
I EQUAL Q {
/*
cout << " id = " << id << endl;
cout << " qstring = " << qstring << endl;
*/
(*((NameTVMap*)avmap))[id] = new TV (TV::QSTR, qstring);
}
;
/* pankaj - verify whether this is required!! */
H: HSTRING {
// copy the entire string
cout << "parser => hstring=" << $1 << endl;
cout << "parser => strlen(hstring)=" << strlen($1) << endl;
hstring=new char[strlen($1)+1];
strncpy(hstring,$1,strlen($1));
cout << "parser => hstring=" << hstring << endl;
cout << "parser => strlen(hstring)=" << strlen(hstring) << endl;
};
/* pankaj - verify whether this is required!! */
Q: QSTRING {
// remove the quotes and copy the rest of the string
cout << "parser => qstring=" << $1 << endl;
cout << "parser => strlen(qstring)=" << strlen($1) << endl;
qstring=new char[strlen($1)-1];
strncpy(qstring,$1+1,strlen($1)-2);
cout << "parser => qstring=" << qstring << endl;
cout << "parser => strlen(qstring)=" << strlen(qstring) << endl;
}
| {
};
I: ID {
/* pankaj - convert to lower before lookup */
id = *(attributeSet.find($1));
};
%%
int yyerror (char* error) { PRINT ("error in parsing :-("); return -1; }
/*
int main (void) {
yyparse();
}
*/
normal
(text/plain, 2 KB)
dict/compat dict/livingston processing SIP auth header REQUEST_STRING: MD5Reject::onRequest REQUEST_REJECT RESPONSE_STRING: Digest algorithm="MD5", nonce="", opaque="", qop="auth", realm="pspl.co.in", stale="false", processing SIP auth header lexer => "[email protected]" parser => qstring="[email protected]" parser => strlen(qstring)=19 parser => [email protected] parser => strlen(qstring)=17 lexer => "auth" parser => qstring="auth" parser => strlen(qstring)=6 parser => qstring=auth parser => strlen(qstring)=4 lexer => "pspl.co.in" parser => qstring="pspl.co.in" parser => strlen(qstring)=12 parser => qstring=pspl.co.in parser => strlen(qstring)=10 lexer => "MD5" parser => qstring="MD5" parser => strlen(qstring)=5 parser => qstring=MD5 parser => strlen(qstring)=3 lexer => 00000001 parser => hstring=00000001 parser => strlen(hstring)=8 parser => hstring=00000001 parser => strlen(hstring)=8 lexer => "" parser => qstring="" parser => strlen(qstring)=2 parser => qstring= parser => strlen(qstring)=0 lexer => "" parser => qstring="" parser => strlen(qstring)=2 parser => qstring= parser => strlen(qstring)=0 lexer => "sip:registrar.pspl.co.in" parser => qstring="sip:registrar.pspl.co.in" parser => strlen(qstring)=26 parser => qstring=sip:registrar.pspl.co.in parser => strlen(qstring)=24 lexer => "0123456789abcdef" parser => qstring="0123456789abcdef" parser => strlen(qstring)=18 parser => qstring=0123456789abcdef parser => strlen(qstring)=16 lexer => "0123456789abcdef" parser => qstring="0123456789abcdef" parser => strlen(qstring)=18 parser => qstring=0123456789abcdef parser => strlen(qstring)=16 REQUEST_STRING: Digest username="[email protected]", qop="auth", realm="pspl.co.in", algorithm="MD5", nc=00000001, nonce="", opaque="", uri="sip:registrar.pspl.co.in", cnonce="0123456789abcdef", response="0123456789abcdef" MD5Challenge::onRequest processing SIP auth header REQUEST_STRING: MD5Accept::onRequest
conked
(text/plain, 2 KB)
dict/digest dict/compat dict/livingston processing SIP auth header REQUEST_STRING: MD5Reject::onRequest REQUEST_REJECT RESPONSE_STRING: Digest algorithm="MD5", nonce="", opaque="", qop="auth", realm="pspl.co.in", stale="false", processing SIP auth header lexer => "[email protected]" parser => qstring="[email protected]" parser => strlen(qstring)=19 parser => [email protected] parser => strlen(qstring)=17 lexer => "auth" parser => qstring="auth" parser => strlen(qstring)=6 parser => qstring=authܱB parser => strlen(qstring)=8 lexer => "pspl.co.in" parser => qstring="pspl.co.in" parser => strlen(qstring)=12 parser => qstring=pspl.co.in parser => strlen(qstring)=10 lexer => "MD5" parser => qstring="MD5" parser => strlen(qstring)=5 parser => qstring=MD5 parser => strlen(qstring)=3 lexer => 00000001 parser => hstring=00000001 parser => strlen(hstring)=8 parser => hstring=00000001 parser => strlen(hstring)=8 lexer => "" parser => qstring="" parser => strlen(qstring)=2 parser => qstring= parser => strlen(qstring)=0 lexer => "" parser => qstring="" parser => strlen(qstring)=2 parser => qstring= parser => strlen(qstring)=0 lexer => "sip:registrar.pspl.co.in" parser => qstring="sip:registrar.pspl.co.in" parser => strlen(qstring)=26 parser => qstring=sip:registrar.pspl.co.in parser => strlen(qstring)=24 lexer => "0123456789abcdef" parser => qstring="0123456789abcdef" parser => strlen(qstring)=18 parser => qstring=0123456789abcdef parser => strlen(qstring)=16 lexer => "0123456789abcdef" parser => qstring="0123456789abcdef" parser => strlen(qstring)=18 parser => qstring=0123456789abcdef parser => strlen(qstring)=16 REQUEST_STRING: Digest username="[email protected]", qop="auth", realm="pspl.co.in", algorithm="MD5", nc=00000001, nonce="", opaque="", uri="sip:registrar.pspl.co.in", cnonce="0123456789abcdef", response="0123456789abcdef" MD5Challenge::onRequest processing SIP auth header REQUEST_STRING: MD5Challenge::onRequest
SIPAuthenticationHeaders
(text/plain, 212 B)
Digest username="[email protected]", qop="auth", realm="pspl.co.in", algorithm="MD5", nc=00000001, nonce="", opaque="", uri="sip:registrar.pspl.co.in", cnonce="0123456789abcdef", response="0123456789abcdef"