00001 /* 00002 * $Id: packet.h,v 1.4 2005/09/11 13:45:38 daichik Exp $ 00003 * 00004 * Copyright (c) 2004, Jeroen Asselman 00005 * 00006 *---------------------------------------------------------------------- 00007 * This file is part of gtk-gnutella. 00008 * 00009 * gtk-gnutella is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * gtk-gnutella is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with gtk-gnutella; if not, write to the Free Software 00021 * Foundation, Inc.: 00022 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 *---------------------------------------------------------------------- 00024 */ 00025 00036 #ifndef _packet_h_ 00037 #define _packet_h_ 00038 00039 #include <glib.h> 00040 00041 typedef struct g2packet_s g2packet_t; 00042 struct g2packet_s 00043 { 00044 gboolean compound; 00045 gboolean has_children; 00046 gboolean big_endian; 00047 00048 char control; 00049 int name_length; 00050 char *name; 00051 char *payload; 00052 char *orig_payload; 00053 int payload_length; 00054 }; 00055 00056 g2packet_t *g2_new_packet(); 00057 void g2_free_packet(g2packet_t *packet); 00058 char *g2_packet_get_name(g2packet_t *packet); 00059 g2packet_t *g2_packet_get_next_child(g2packet_t *basepacket); 00060 char *g2_packet_get_payload(g2packet_t *packet, int *length); 00061 void g2_packet_add_child(g2packet_t *packet, g2packet_t *child); 00062 void g2_packet_add_payload(g2packet_t *packet, char *payload, int length); 00063 char *g2_packet_pack(g2packet_t *packet, int *length); 00064 00065 #endif /* _packet_h_ */ 00066 00067 /* vi: set ts=4 sw=4 cindent: */