00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00036 #ifndef _core_gmsg_h_
00037 #define _core_gmsg_h_
00038 
00039 #include "gnutella.h"
00040 #include "pmsg.h"
00041 
00042 #include "if/core/search.h"
00043 
00044 struct gnutella_node;
00045 struct route_dest;
00046 struct mqueue;
00047 
00048 #define gmsg_function(p) (((struct gnutella_header *) p)->function)
00049 #define gmsg_hops(p)     (((struct gnutella_header *) p)->hops)
00050 
00051 
00052 
00053 
00054 
00055 void gmsg_init(void);
00056 const gchar *gmsg_name(guint function);
00057 
00058 pmsg_t *gmsg_to_pmsg(gconstpointer msg, guint32 size);
00059 pmsg_t *gmsg_to_ctrl_pmsg(gconstpointer msg, guint32 size);
00060 pmsg_t * gmsg_to_ctrl_pmsg_extend(
00061     gconstpointer msg, guint32 size, pmsg_free_t free_cb, gpointer arg);
00062 pmsg_t *gmsg_split_to_pmsg(gconstpointer head,
00063     gconstpointer data, guint32 size);
00064 pmsg_t * gmsg_split_to_pmsg_extend(gconstpointer head, gconstpointer data,
00065     guint32 size, pmsg_free_t free_cb, gpointer arg);
00066 
00067 void gmsg_mb_sendto_all(const GSList *sl, pmsg_t *mb);
00068 void gmsg_mb_sendto_one(struct gnutella_node *n, pmsg_t *mb);
00069 
00070 void gmsg_sendto_one(struct gnutella_node *n, gconstpointer msg, guint32 size);
00071 void gmsg_ctrl_sendto_one(struct gnutella_node *n,
00072     gconstpointer msg, guint32 size);
00073 void gmsg_split_sendto_one(struct gnutella_node *n,
00074     gconstpointer head, gconstpointer data, guint32 size);
00075 void gmsg_sendto_all(const GSList *l, gconstpointer msg, guint32 size);
00076 void gmsg_split_sendto_all(const GSList *l,
00077     gconstpointer head, gconstpointer data, guint32 size);
00078 void gmsg_split_sendto_all_but_one(const GSList *sl,
00079     const struct gnutella_node *n,
00080     gconstpointer head, gconstpointer data, guint32 size);
00081 void gmsg_sendto_route(struct gnutella_node *n, struct route_dest *rt);
00082 
00083 gboolean gmsg_can_drop(gconstpointer pdu, gint size);
00084 gboolean gmsg_is_oob_query(gconstpointer msg);
00085 gboolean gmsg_split_is_oob_query(gconstpointer head, gconstpointer data);
00086 gint gmsg_cmp(gconstpointer pdu1, gconstpointer pdu2);
00087 gchar *gmsg_infostr(gconstpointer head);
00088 gchar *gmsg_infostr_full(gconstpointer message);
00089 gchar *gmsg_infostr_full_split(gconstpointer head, gconstpointer data);
00090 
00091 void gmsg_install_presend(pmsg_t *mb);
00092 
00093 void gmsg_log_dropped(gconstpointer head,
00094     const gchar *reason, ...) G_GNUC_PRINTF(2, 3);
00095 void gmsg_log_bad(const struct gnutella_node *n,
00096     const gchar *reason, ...) G_GNUC_PRINTF(2, 3);
00097 
00098 void gmsg_sendto_route_ggep(
00099     struct gnutella_node *n, struct route_dest *rt, guint32 regular_size);
00100 void gmsg_sendto_one_ggep(struct gnutella_node *n,
00101     gconstpointer msg, guint32 size, guint32 regular_size);
00102 void gmsg_ctrl_sendto_one_ggep(struct gnutella_node *n,
00103     gconstpointer msg, guint32 size, guint32 regular_size);
00104 void gmsg_sendto_all_ggep(const GSList *sl,
00105     gconstpointer msg, guint32 size, guint32 regular_size);
00106 
00107 void gmsg_search_sendto_one(struct gnutella_node *n, gnet_search_t sh,
00108     gconstpointer msg, guint32 size);
00109 void gmsg_search_sendto_all(const GSList *l, gnet_search_t sh,
00110     gconstpointer msg, guint32 size);
00111 
00112 #endif  
00113 
00114