X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=src%2Fpacket.h;h=de32e6a6b1ee6a2e00e7ae6e663d5949187d908a;hb=b9de5036b3ad61f268a686466abfc55915c786f4;hp=a5726db7ab7d1970a4a3bb081e98fa441c4098e7;hpb=75d48312f938ebe055459e9be96cdd1c3c4279be;p=udpgate.git diff --git a/src/packet.h b/src/packet.h index a5726db..de32e6a 100644 --- a/src/packet.h +++ b/src/packet.h @@ -27,6 +27,18 @@ G_BEGIN_DECLS +#define HOSTIP_GUINT32_TO_STRING(hostip_guint32) \ + (udpgate_printf_alloca("%d.%d.%d.%d", \ + ((hostip_guint32)>>24U)&0xFFU, \ + ((hostip_guint32)>>16U)&0xFFU, \ + ((hostip_guint32)>> 8U)&0xFFU, \ + ((hostip_guint32)>> 0U)&0xFFU)) +/* Do not use nested udpgate_printf_alloca() - macros cannot nest! */ +#define SOCKADDR_IN_TO_STRING(sockaddr_in_pointer) ({ \ + const gchar *_hostip_string=HOSTIP_GUINT32_TO_STRING(ntohl((sockaddr_in_pointer)->sin_addr.s_addr)); \ + udpgate_printf_alloca("%s:%d",_hostip_string,ntohs((sockaddr_in_pointer)->sin_port)); \ + }) + #define PACKET_HEADER "UDPGate0" #define PACKET_ELEM_ATTR_MANDATORY (0x80000000) @@ -39,6 +51,7 @@ enum packet_elem_type { }; gpointer packet_assembly(size_t *packet_length_pointer,GHashTable *values); +gboolean packet_recognized(gconstpointer packet,size_t packet_length); GHashTable *packet_disassembly(gconstpointer packet,size_t packet_length); void packet_disassembly_destroy(GHashTable *hash);