How to Implement a BNF syntax in perl?

2004-02-06 Thread Balaji Thoguluva
Hi,
 
I have a long BNF (Backus-naur form) for parsing a protocol message. Suppose I 
want to implement a BNF like this
 
Response = Status-line
   *(message-header)
   CRLF
   [Message-body]
 
status-Line = SIP-Version SP Status-Code SP Reason-Phrase CRLF
SP = space character
..
.
 
Like this I have a very long BNF. How can I implement this BNF and  parse a 
message that satisfies this BNF in perl ?
Any suggestions would be of great help to me. 
 
Thanks,
Balaji 

Yahoo! India Mobile: Ringtones, Wallpapers, Picture Messages and more.Download now.

Reg. string matching using reg-exp

2004-02-06 Thread Balaji Thoguluva
Hi,
 I am a novice to perl programming. When I execute the following code, I get 
always "No Match". I guess my reg-exp is correct. I also tried changing $line= "INVITE 
sip:[EMAIL PROTECTED] SIP/2.0"; to have double quotes and a backslash char before @ 
symbol. Even then it gives me No Match. I appreciate your help.
 
#!/usr/bin/perl -w
my $line= 'INVITE sip:[EMAIL PROTECTED] SIP/2.0';
if($line =~ /^\s*(\w+)\s*(.*)\s+(sip\/\d+\.\d+)\s*\r\n/i)
{
print "\nSIP Method: ",$1;
print "\nRequest URI: ",$2;
print "\nSIP Version: ",$3;
}
else
{
print "No Match";
}

Thanks,
Balaji

Yahoo! India Mobile: Ringtones, Wallpapers, Picture Messages and more.Download now.

Reg. length of anonymous array

2004-02-12 Thread Balaji Thoguluva
Hi,
 
I am a novice to perl programming. I have a reference to a hash with a hash key as 
a reference to an anonymous array.
 
For clarity, I have something like this structure 
 
my $rhash = {
$rarray => [  ],
};
 
I would like to know the length of the anonymous array containing some elements. 
 
Thanks,
Balaji 
  
 
 

Yahoo! India Education Special: Study in the UK now.

Flushing FileHandle's Buffer

2004-02-17 Thread Balaji Thoguluva
Hi,

   I would like to know if there is a function(other
than close FILEHANDLE) to flush current filehandle's
buffer data to the file. In otherwords, I want to make
sure the following PRINT statement to work immediately
after its execution.

print FILEHANDLE "Flush this data IMMEDIATELY to the
file";

Thanks in Advance,
Balaji
   




  


Yahoo! India Insurance Special: Be informed on the best policies, services, tools and 
more. 
Go to: http://in.insurance.yahoo.com/licspecial/index.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Reg. Net::Pcap

2004-02-21 Thread Balaji Thoguluva
Hi,
 
 I would like to know if there is a way to get packets from already saved tcpdump 
output file (tcpdump -w DumpFile.dmp) using Net::Pcap library and thus parse each 
packet. 
 
 I know that there is a function Net::Pcap::open_offline() that takes a savefile 
as input. But the savefile in this case has to be created again by 
Net::Pcap::dump_open() or I am not sure if Net::Pcap::dump_open() can be given the 
tcpdump output file directly. 
 
Your Suggestions will be of great help.
 
Thanks,
Balaji  
 

Yahoo! India Insurance Special: Be informed on the best policies, services, tools and 
more.

Reg. 'repeated pattern' matching

2004-02-25 Thread Balaji Thoguluva
Hi,
 
I have a question on pattern matching. Assume I have a line like this consisting 
of header field(via) and values(IPaddress) repeated like below
 
via: 192.168.6.100; via:192.168.6.101; via: 203.290.89.90; ..so on
 
I would like to know how many via: header field occur and to get each via header field 
value. I want to know how to loop through each via header field to extract the value 
by pattern matching expressions.
 
Thanks in advance,
Balaji
 
  
 
 

Yahoo! India Insurance Special: Be informed on the best policies, services, tools and 
more.

Reg. Net::Pcap open_live method

2004-02-28 Thread Balaji Thoguluva
Hi,

   I would like to know if Net::PCap::open_live()
method can take 'any' as value for $dev argument. My
intention is to catch packets that come on all network
interfaces of a computer (especially on eth0 and lo,
loopback interface).  

The prototype of open_live is 

Net::Pcap::open_live($dev, $snaplen, $promisc, $to_ms, \$err))


Yahoo! India Insurance Special: Be informed on the best policies, services, tools and 
more. 
Go to: http://in.insurance.yahoo.com/licspecial/index.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Reg. Net::Pcap

2004-03-01 Thread Balaji Thoguluva
Hi,
   I would like to know if 
 
Net::Pcap::open_live($dev, $snaplen, $promisc, $to_ms, \$err))

method can take 'any' as value for $dev argument. My intention is to catch packets 
that come on all network interfaces of a computer (atleast I want from eth0 and lo, 
loopback interface). I have also tried $promisc = 1. It doesn't seem to catch packets 
on all interface. I would appreciate your ideas.
 
Thanks,
Balaji
 
  




Yahoo! India Insurance Special: Be informed on the best policies, services, tools and 
more.

Re: Reg. Net::Pcap

2004-03-01 Thread Balaji Thoguluva
Hi Bill,
 
 I appreciate your ideas. I am the root of the system. As you say, it is not 
possible to catch packets simultaneously on more than one interface or all interfaces. 
But there are tools like tcpdump.  tcpdump with -i option of  'any' can catch packets 
on all interfaces. Even the Pcap library in C supports 'any' value for dev paramater 
for open_live method. I am guessing why Net::Pcap library doesn't provide option of 
'any' for open_live method. I thought Net::PCap is exact equivalent to Pcap library. 
 
 As you say, one of the ways I could solve this problem is to catch packets 
separately from 2 interfaces and then merge the files by timestamp values in to a 
single value. Is there any other way?
 
Thanks,
Balaji   
 
   

WC -Sx- Jones <[EMAIL PROTECTED]> wrote:
Balaji Thoguluva wrote:
> Hi,
> I would like to know if 
> 
> Net::Pcap::open_live($dev, $snaplen, $promisc, $to_ms, \$err))
> 
> method can take 'any' as value for $dev argument. My intention 
> is to catch packets that come on all network interfaces of a computer
>(atleast I want from eth0 and lo, loopback interface). I have also tried
>$promisc = 1. It doesn't seem to catch packets on all interface. I would
> appreciate your ideas.
> 
> Thanks,
> Balaji


two possible issues -

One, you must be root on most systems to see raw packets or to evenplace 
the interface into promiscuous mode.

Two, you can only look at one interface at a time.

But, yes, the $dev param can be set to any correct interface. As far as 
the detail of packets - how do you set the verbose-ness of the interface?


-Bill-
__Sx__
http://youve-reached-the.endoftheinternet.org/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Yahoo! India Insurance Special: Be informed on the best policies, services, tools and 
more.