[Snort-users] how to convert sql ipsrc hdrs to quad notation

Mayers, Philip J p.mayers at ...1913...
Sun Oct 14 06:42:04 EDT 2001


A more general way to do this, in postgres land...

CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS
'/usr/lib/pgsql/plpgsql.so' LANGUAGE 'C';

CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler
LANCOMPILER 'PL/pgSQL';

CREATE FUNCTION int8ip_to_str(int8) RETURNS inet AS '
DECLARE
    t inet;
BEGIN
    t = (($1>>24) & 255::int8) || ''.'' ||
        (($1>>16) & 255::int8) || ''.'' ||
        (($1>>8)  & 255::int8) || ''.'' ||
        ($1     & 255::int8);
    RETURN t;
END;
' LANGUAGE 'plpgsql';

create view iphdr_txt as select *,int8ip_to_str(ip_src) as
ipsrc,int8ip_to_str(ip_dst) as ipdst from iphdr;

But basically, the body of the stored procedure. For MySQL, use inet_ntoa...

Regards,
Phil

+------------------------------------------+
| Phil Mayers                              |
| Network & Infrastructure Group           |
| Information & Communication Technologies |
| Imperial College                         |
+------------------------------------------+

-----Original Message-----
From: Andrew R. Baker [mailto:andrewb0x29a at ...131...]
Sent: 12 October 2001 21:52
To: Frontgate Lab; snort-users at lists.sourceforge.net
Subject: Re: [Snort-users] how to convert sql ipsrc hdrs to quad
notation


Script no, but since you are using mysql, you can just do

	SELECT inet_ntoa(iphdr.ip_src) FROM iphdr;

mysql> select distinct inet_ntoa(ip_src) FROM iphdr;
+-------------------+
| inet_ntoa(ip_src) |
+-------------------+
| 10.1.3.2          |
| 10.1.3.3          |
| 10.1.3.12         |

-Andrew


--- Frontgate Lab <mdiwan at ...200...> wrote:
> Hi,
> 
>  does anyone have a script that converts these to dotted quad notation? 
> 
> can you at least guide me in the direction of writting such a script? ie
> the math behind it < where do i find it?
> 
> 
> mysql> SELECT  iphdr.ip_src   FROM  iphdr;
> +------------+
> | ip_src     |
> +------------+
> | 2546232230 |
> | 2546232230 |
> | 2546232230 |
> | 2546232230 |
> | 2546232230 |
> | 2546232230 |
> | 2546232230 |
> | 2546232230 |
> | 3232274123 |
> | 3232274123 |
> | 3232274123 |
> | 3232274123 |
> +------------+
> 12 rows in set (0.00 sec)
> 
> thank you
> 
> 
> Note: The information contained in this message may be privileged and
> confidential and protected from disclosure.  If the reader of this
> message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you
> are hereby notified that any dissemination, distribution or copying of
> this communication is strictly prohibited. If you have received this
> communication in error, please notify us immediately by replying to the
> message and deleting it from your computer.  Thank you.  Wagner Weber &
> Williams
> 
> _______________________________________________
> Snort-users mailing list
> Snort-users at lists.sourceforge.net
> Go to this URL to change user options or unsubscribe:
> https://lists.sourceforge.net/lists/listinfo/snort-users
> Snort-users list archive:
> http://www.geocrawler.com/redir-sf.php3?list=snort-users


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

_______________________________________________
Snort-users mailing list
Snort-users at lists.sourceforge.net
Go to this URL to change user options or unsubscribe:
https://lists.sourceforge.net/lists/listinfo/snort-users
Snort-users list archive:
http://www.geocrawler.com/redir-sf.php3?list=snort-users




More information about the Snort-users mailing list