Release: 1.0.3 -> 1.0.4cvs
[udpgate.git] / src / packet.h
index a5726db..de32e6a 100644 (file)
 
 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);