Click to See Complete Forum and Search --> : Storing HEX in MySQL.


k_preeth
June 9th, 2005, 04:35 AM
Hello,
I am writing a program for packet sniffing in Linux platform using C language. I am using MYSQL as my database for storing packet information like IP, port, packet payload, etc. I have created a table using the following query:

create table idsmatch(sip text,sport integer,dip text,dport integer,payload longtext);

And, i have written a query for insertion to the table like this:

sprintf(query,"INSERT INTO idsmatch(sip,sport,dip,dport,payload)VALUES('%s',%d,'%s',%d,'%s')",
inet_ntoa(ip->saddr),dbsport,inet_ntoa(ip->daddr),dbdport,temp);

I am able to store all values properly except 'temp'.
'temp' is a char array which holds the packet payload. What I want is to store 'temp' in 'HEX' format in the table 'idsmatch'. Please tell me what is to be done for that.
Thanks in advance.
Preeth.

Vaderman
June 10th, 2005, 07:05 AM
Did this (http://www.issociate.de/board/post/221034/Storing_in_HEX_format..html) not help you? ;)

Regards

John