Discussion:
[Open1x-xsupplicant] general parse error - new eap type in xsupplicant.conf
komarova
2007-02-26 10:54:48 UTC
Permalink
Hello,

I use Xsupplicant-1.2.8 and it works very well with standard eap
methods. But I need to implement my own eap type with xsupplicant and
when I add its name to xsupplicant.conf

eap-md5 {
username = “username”
password = “psw”
}

myType {
}

I get

General Parse Error!

There was a problem with the config file. We cannot continue.

I have added myType’s declaration to
../lib/libxsupconfig/xsupconfig.h
../lib/libxsupconfig/xsupconfig.c
../src/config_grammar.y
../src/config_lexicon.l
../lib/libxsupconfwrite/xsupconfwrite.c
../lib/libxsupconfcheck/xsupconfcheck.c

after that I did ./configure, make, make install
and I have got the same error.

What should I do to make xsupplicant “understand” the modified conf file?

Thank you in advance for help!

Sincerely,

Maryna
Chris Hessing
2007-02-27 17:51:33 UTC
Permalink
Maryna -

Sorry for the long delay in answering you. Unfortunately, in the current Xsupplicant code base adding a new EAP type is painful and very involved. The current development branch of the code has completely scrapped the LEX/YACC config parser in favor of XML, and an easier to use parser system. (Unfortunately, that branch doesn't build on Linux right now. Just Mac OS X and Windows. I hope to have it building on Linux by the end of this week.)

Here are the steps that I take to add something to the parser. (This is a slightly more detailed step-by-step than the one included in xsupconfig.h.)

1. Create the EAP type structure in xsupconfig.h. So, if I wanted to create an EAP method "foo" with a "foo1" and "foo2" option, I would add a structure that looked something like this :

struct config_eap_foo {
char *foo1;
char *foo2;
};

2. Create the initialize_config_foo, delete_config_foo, and dump_config_foo. (I suggest looking at how these functions are implemented for another EAP method, and using that as a pattern.)

2. Add the tokens to the config_lexicon.l file. I would add the following lines to config_lexicon.l :

"foo" {tokenpos+=yyleng; return TK_FOO; }
"foo1" {tokenpos+=yyleng; return TK_FOO1; }
"foo2" {tokenpos+=yyleng; return TK_FOO2; }

3. Define the structure in config_grammer.y. So, add something like this to the config_grammer.y :

struct config_eap_foo *tmp_foo = NULL;

4. Create a set_current_foo() function in config_grammer.y. (Use the other set_current_xxx() functions as a pattern.)

5. Edit cleanup_parse() to check tmp_foo, and call delete_config_eap_foo(),

6. Add %token lines for the three FOOs in step 2. (It doesn't really matter where it goes in the list, but I usually try to keep it in roughly the same order as the list in config_lexicon.l.)

%token TK_FOO
%token TK_FOO1
%token TK_FOO2


7. Add eap_type_foo to the "eap_type_statement" block of the YACC code. (Use another EAP type as a pattern.)

8. Update the "eap_type" statement to include EAP type "foo". (This will involve creating a #define in xsupconfig.h)

9. Create the eap_foo_statement. (You can search for "eap_tls_statement" for an example.)

10. Create the eap_foo_params. (Use "eap_tls_params" as a sample.)

11. Create the eap_foo_param. (This is where you populate your structure with any data you need.) I suggest using "eap_tls_param" as an example.

After all of that, you should be good to go. Also, there is a program in the tools directory that just parses and dumps the config. It is useful for debugging the config pieces.

Hope this helps!
Post by komarova
Hello,
I use Xsupplicant-1.2.8 and it works very well with standard eap
methods. But I need to implement my own eap type with xsupplicant and
when I add its name to xsupplicant.conf
eap-md5 {
username = “username”
password = “psw”
}
myType {
}
I get
General Parse Error!
There was a problem with the config file. We cannot continue.
I have added myType’s declaration to
../lib/libxsupconfig/xsupconfig.h
../lib/libxsupconfig/xsupconfig.c
../src/config_grammar.y
../src/config_lexicon.l
../lib/libxsupconfwrite/xsupconfwrite.c
../lib/libxsupconfcheck/xsupconfcheck.c
after that I did ./configure, make, make install
and I have got the same error.
What should I do to make xsupplicant “understand” the modified conf file?
Thank you in advance for help!
Sincerely,
Maryna
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Open1x-xsupplicant mailing list
https://lists.sourceforge.net/lists/listinfo/open1x-xsupplicant
komarova
2007-02-28 09:00:15 UTC
Permalink
Chris,

thank you very much for these detailed and clear guidelines!

Now I have got xsupplicant working.

Sincerely,
Maryna
Post by Chris Hessing
Maryna -
Sorry for the long delay in answering you. Unfortunately, in the
current Xsupplicant code base adding a new EAP type is painful and
very involved. The current development branch of the code has
completely scrapped the LEX/YACC config parser in favor of XML, and an
easier to use parser system. (Unfortunately, that branch doesn't
build on Linux right now. Just Mac OS X and Windows. I hope to have
it building on Linux by the end of this week.)
Here are the steps that I take to add something to the parser. (This
is a slightly more detailed step-by-step than the one included in
xsupconfig.h.)
1. Create the EAP type structure in xsupconfig.h. So, if I wanted to
create an EAP method "foo" with a "foo1" and "foo2" option, I would
struct config_eap_foo {
char *foo1;
char *foo2;
};
2. Create the initialize_config_foo, delete_config_foo, and
dump_config_foo. (I suggest looking at how these functions are
implemented for another EAP method, and using that as a pattern.)
2. Add the tokens to the config_lexicon.l file. I would add the
"foo" {tokenpos+=yyleng; return TK_FOO; }
"foo1" {tokenpos+=yyleng; return TK_FOO1; }
"foo2" {tokenpos+=yyleng; return TK_FOO2; }
3. Define the structure in config_grammer.y. So, add something like
struct config_eap_foo *tmp_foo = NULL;
4. Create a set_current_foo() function in config_grammer.y. (Use the
other set_current_xxx() functions as a pattern.)
5. Edit cleanup_parse() to check tmp_foo, and call
delete_config_eap_foo(),
6. Add %token lines for the three FOOs in step 2. (It doesn't really
matter where it goes in the list, but I usually try to keep it in
roughly the same order as the list in config_lexicon.l.)
%token TK_FOO
%token TK_FOO1
%token TK_FOO2
7. Add eap_type_foo to the "eap_type_statement" block of the YACC
code. (Use another EAP type as a pattern.)
8. Update the "eap_type" statement to include EAP type "foo". (This
will involve creating a #define in xsupconfig.h)
9. Create the eap_foo_statement. (You can search for
"eap_tls_statement" for an example.)
10. Create the eap_foo_params. (Use "eap_tls_params" as a sample.)
11. Create the eap_foo_param. (This is where you populate your
structure with any data you need.) I suggest using "eap_tls_param" as
an example.
After all of that, you should be good to go. Also, there is a program
in the tools directory that just parses and dumps the config. It is
useful for debugging the config pieces.
Hope this helps!
Loading...