Re: setting User-Name to 'modified' mac address

2004-10-19 Thread Kyriaki Gali
you can do this in perl

my $example = 11-c0-4f-40-47-b4;

$example =~ /(\d+)\-(\w\d)\-(\d\w)\-(\d+)\-(\d+)\-(\w\d)/;

my $one = ${1};#11
my $two = ${2};#c0
etc...

when you have more than one digits you must write \d+ and also for words
\w+.
regular expretions are case sensitive for example if you have a word and a
digit you write this \w\d
and when you want to get it you put $ not %.



Kyriaki Gali,
IT Applications Specialist
Kinetix Tele.com Support Center,
Tel  Fax: +30 2310 256140
GSM: +30 6947 723737
http://www.kinetix.gr
e-mail: [EMAIL PROTECTED]
- Original Message - 
From: Jose Guevarra [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 19, 2004 2:31 AM
Subject: RE: setting User-Name to 'modified' mac address


 Ok Posix expressions are supported here then shouldn't putting parenthases
 around the hex characters give me groups %{1}...%{6}?

 I do this

 DEFAULT Calling-Station-Id =~

([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-

([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])
 User-Name := `%{1}%{2}%{3}%{4}%{5}%{6}`

 Instead of getting a mac address with no '-' I get a long weird
combination
 of
 hex and '-'.  I mapped out the ${x} groups and they are not what I expect

 for example:
 11-c0-4f-40-47-b4

 becomes groups

 %{1} = 11
 %{2} = c0-4f
 %{3} = 4f-40-47
 %{4} = 40-47-b4
 %{5} = 47-b4
 %{6} = b4

 Is my regex wrong or what?

 Thanks,




 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan
DeKok
 Sent: Monday, October 18, 2004 11:40 AM
 To: [EMAIL PROTECTED]
 Subject: Re: setting User-Name to 'modified' mac address

 Jose Guevarra [EMAIL PROTECTED] wrote:
  In my hints file i have
 
  DEFAULT Calling-Station-Id =~
 (\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)
  User-Name := `%{0}`
 
  This should set the User Name to the hex characters in the mac address
  or 'something' at least

   Or something...

   And if you're going to use %{0}, you don't need regular expressions.
 Just use %{Calling-Station-Id}

  However, in debug mode I can see that User-Name is not modified.
 
  In perl i can use the regex below and it seems to work

   Perl supports \w in regular expressions.  Posix expressions (which the
 libraries from your system the server uses) do not support \w.

   Alan DeKok.


 -
 List info/subscribe/unsubscribe? See
 http://www.freeradius.org/list/users.html


 -
 List info/subscribe/unsubscribe? See
http://www.freeradius.org/list/users.html


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: setting User-Name to 'modified' mac address(continued)

2004-10-19 Thread Alan DeKok
Jose Guevarra [EMAIL PROTECTED] wrote:
Perl supports \w in regular expressions.  Posix expressions (which
 the libraries from your system the server uses) do not support \w.
 
 how do I tell which 'libraries' are being used hence the supported regex
 syntax/capabilities?

  Your system uses Posix regular expressions.

  Perl doesn't use your system libraries to implement regular
expressions.  It has its own code ot do that.

  Alan DeKok.


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: setting User-Name to 'modified' mac address

2004-10-18 Thread Jose Guevarra
Hmmm,
  
 I've been been trying to use regex to get the 12 hex characters in the
Calling-Station-Id but, I must be doing something wrong.

In my hints file i have

DEFAULT Calling-Station-Id =~ 
(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)
User-Name := `%{0}`
 
This should set the User Name to the hex characters in the mac address
or 'something' at least

However, in debug mode I can see that User-Name is not modified.

In perl i can use the regex below and it seems to work

PERL
-=-=-=-=-==-==-=-=-=-=-==-=-
my $string = '23-00-ab-fa-ee-23';

if( $string =~ /(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)/ )
{
 print $1,$2,$3,$4,$5,$6;
}
-=-=-=-=-==-==-=-=-=-=-==-=-

What am I doing wrong? How do I fix it?

Thanks,




On Fri, 2004-10-15 at 09:03, Alan DeKok wrote:
 Jose Guevarra [EMAIL PROTECTED] wrote:
   I have freeradius authenticating mac addresses listed in a MySQL
  database.  It works! But, the mac address passed by the client(hp 2650)
  is in the form 00-00-00-00-00-00. I set the 'user name' to the 'calling
  station id' in the 'hints' file like so
  
  User-Name := %i
  
  Is it possible to filter out the - or : or put it into any format I
  like?
 
   Yes.  Use regular expressions.  See doc/variables.txt
 
   Alan DeKok.
 
 - 
 List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: setting User-Name to 'modified' mac address

2004-10-18 Thread Alan DeKok
Jose Guevarra [EMAIL PROTECTED] wrote:
 In my hints file i have
 
 DEFAULT Calling-Station-Id =~  (\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)
   User-Name := `%{0}`
  
 This should set the User Name to the hex characters in the mac address
 or 'something' at least

  Or something...

  And if you're going to use %{0}, you don't need regular expressions.
Just use %{Calling-Station-Id}

 However, in debug mode I can see that User-Name is not modified.
 
 In perl i can use the regex below and it seems to work

  Perl supports \w in regular expressions.  Posix expressions (which
the libraries from your system the server uses) do not support \w.

  Alan DeKok.


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


RE: setting User-Name to 'modified' mac address

2004-10-18 Thread Jose Guevarra
Ok Posix expressions are supported here then shouldn't putting parenthases
around the hex characters give me groups %{1}...%{6}?

I do this 

DEFAULT Calling-Station-Id =~
([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-
([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9]) 
User-Name := `%{1}%{2}%{3}%{4}%{5}%{6}`

Instead of getting a mac address with no '-' I get a long weird combination
of 
hex and '-'.  I mapped out the ${x} groups and they are not what I expect

for example:
11-c0-4f-40-47-b4

becomes groups

%{1} = 11
%{2} = c0-4f
%{3} = 4f-40-47
%{4} = 40-47-b4
%{5} = 47-b4
%{6} = b4

Is my regex wrong or what?

Thanks,




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alan DeKok
Sent: Monday, October 18, 2004 11:40 AM
To: [EMAIL PROTECTED]
Subject: Re: setting User-Name to 'modified' mac address

Jose Guevarra [EMAIL PROTECTED] wrote:
 In my hints file i have
 
 DEFAULT Calling-Station-Id =~
(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)
   User-Name := `%{0}`
  
 This should set the User Name to the hex characters in the mac address 
 or 'something' at least

  Or something...

  And if you're going to use %{0}, you don't need regular expressions.
Just use %{Calling-Station-Id}

 However, in debug mode I can see that User-Name is not modified.
 
 In perl i can use the regex below and it seems to work

  Perl supports \w in regular expressions.  Posix expressions (which the
libraries from your system the server uses) do not support \w.

  Alan DeKok.


-
List info/subscribe/unsubscribe? See
http://www.freeradius.org/list/users.html


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


RE: setting User-Name to 'modified' mac address(continued)

2004-10-18 Thread Jose Guevarra
 Alan,

   Perl supports \w in regular expressions.  Posix expressions (which
the libraries from your system the server uses) do not support \w.

how do I tell which 'libraries' are being used hence the supported regex
syntax/capabilities?

Thanks,



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jose
Guevarra
Sent: Monday, October 18, 2004 4:31 PM
To: [EMAIL PROTECTED]
Subject: RE: setting User-Name to 'modified' mac address

Ok Posix expressions are supported here then shouldn't putting parenthases
around the hex characters give me groups %{1}...%{6}?

I do this 

DEFAULT Calling-Station-Id =~
([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-
([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9]) 
User-Name := `%{1}%{2}%{3}%{4}%{5}%{6}`

Instead of getting a mac address with no '-' I get a long weird combination
of hex and '-'.  I mapped out the ${x} groups and they are not what I expect

for example:
11-c0-4f-40-47-b4

becomes groups

%{1} = 11
%{2} = c0-4f
%{3} = 4f-40-47
%{4} = 40-47-b4
%{5} = 47-b4
%{6} = b4

Is my regex wrong or what?

Thanks,




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alan DeKok
Sent: Monday, October 18, 2004 11:40 AM
To: [EMAIL PROTECTED]
Subject: Re: setting User-Name to 'modified' mac address

Jose Guevarra [EMAIL PROTECTED] wrote:
 In my hints file i have
 
 DEFAULT Calling-Station-Id =~
(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)
   User-Name := `%{0}`
  
 This should set the User Name to the hex characters in the mac address 
 or 'something' at least

  Or something...

  And if you're going to use %{0}, you don't need regular expressions.
Just use %{Calling-Station-Id}

 However, in debug mode I can see that User-Name is not modified.
 
 In perl i can use the regex below and it seems to work

  Perl supports \w in regular expressions.  Posix expressions (which the
libraries from your system the server uses) do not support \w.

  Alan DeKok.


-
List info/subscribe/unsubscribe? See
http://www.freeradius.org/list/users.html


-
List info/subscribe/unsubscribe? See
http://www.freeradius.org/list/users.html


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: setting User-Name to 'modified' mac address

2004-10-15 Thread Alan DeKok
Jose Guevarra [EMAIL PROTECTED] wrote:
  I have freeradius authenticating mac addresses listed in a MySQL
 database.  It works! But, the mac address passed by the client(hp 2650)
 is in the form 00-00-00-00-00-00. I set the 'user name' to the 'calling
 station id' in the 'hints' file like so
 
 User-Name := %i
 
 Is it possible to filter out the - or : or put it into any format I
 like?

  Yes.  Use regular expressions.  See doc/variables.txt

  Alan DeKok.

- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html