Jump to content
Sign in to follow this  
arcker

Help with tcp struct

Recommended Posts

arcker

hi,

I simply need a little help to convert this structure in autoit :

typedef struct data_packet_struct{
    int16_t   packet_version;
    u_int32_t crc32_value;
    u_int32_t timestamp;
    int16_t   return_code;
    char      host_name[MAX_HOSTNAME_LENGTH];
    char      svc_description[MAX_DESCRIPTION_LENGTH];
    char      plugin_output[MAX_PLUGINOUTPUT_LENGTH];
        }data_packet;

so far i made this work :

$tBinary = DllStructCreate("byte[720]")
DllStructSetData($tBinary,1,$recv)
;ConsoleWrite("packet version " & DllStructGetData($tBinary,1,2) & @crlf)
$tPacket= DllStructCreate("byte[2];byte[6];byte[4];byte[2];char[64];char[128];char[512]",DllStructGetPtr($tBinary))
ConsoleWrite("packet version " & DllStructGetData($tPacket,1) & @crlf)
ConsoleWrite("crc32_value " & DllStructGetData($tPacket,2) & @crlf)
ConsoleWrite("timestamp binary " & DllStructGetData($tPacket,3) & @crlf)
ConsoleWrite("timestamp " & _DateAdd( 's',int("0x" & "48BD36C6"), "1970/01/01 00:00:00")  & @crlf)
ConsoleWrite("timestamp " & _DateAdd( 's',int("0x" & Hex(DllStructGetData($tPacket,3))), "1970/01/01 00:00:00")  & @crlf)
ConsoleWrite("return code " & DllStructGetData($tPacket,4,1) & @crlf)
ConsoleWrite("host_name " & DllStructGetData($tPacket,5) & @crlf)
ConsoleWrite("description " & DllStructGetData($tPacket,6) & @crlf)
ConsoleWrite("OutPut " & DllStructGetData($tPacket,7) & @crlf)

but as you can see i use byte[x] with different sizes.

I need to have a better structure to get the real sizeof and calculate a crc32 from it.

The purpose is to make an nsca client for nagios.


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.