~ubuntu-branches/ubuntu/karmic/gtk-gnutella/karmic

« back to all changes in this revision

Viewing changes to src/ggep.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Kleineidam
  • Date: 2004-05-22 15:26:55 UTC
  • Revision ID: james.westby@ubuntu.com-20040522152655-lyi6iaswmy4hq4wy
Tags: upstream-0.93.3.0
ImportĀ upstreamĀ versionĀ 0.93.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: ggep.h,v 1.12 2003/07/19 22:08:59 rmanfredi Exp $
 
3
 *
 
4
 * Copyright (c) 2002-2003, Raphael Manfredi
 
5
 *
 
6
 * Gnutella Generic Extension Protocol (GGEP).
 
7
 *
 
8
 *----------------------------------------------------------------------
 
9
 * This file is part of gtk-gnutella.
 
10
 *
 
11
 *  gtk-gnutella is free software; you can redistribute it and/or modify
 
12
 *  it under the terms of the GNU General Public License as published by
 
13
 *  the Free Software Foundation; either version 2 of the License, or
 
14
 *  (at your option) any later version.
 
15
 *
 
16
 *  gtk-gnutella is distributed in the hope that it will be useful,
 
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 *  GNU General Public License for more details.
 
20
 *
 
21
 *  You should have received a copy of the GNU General Public License
 
22
 *  along with gtk-gnutella; if not, write to the Free Software
 
23
 *  Foundation, Inc.:
 
24
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
25
 *----------------------------------------------------------------------
 
26
 */
 
27
 
 
28
#ifndef _ggep_h_
 
29
#define _ggep_h_
 
30
 
 
31
#include "extensions.h"
 
32
 
 
33
#include <glib.h>
 
34
 
 
35
#define GGEP_MAGIC              '\xc3'          /* GGEP extension prefix */
 
36
 
 
37
/*
 
38
 * GGEP Extension Header Flags.
 
39
 */
 
40
 
 
41
#define GGEP_F_LAST             '\x80'          /* Last extension in GGEP block */
 
42
#define GGEP_F_COBS             '\x40'          /* Whether COBS was used on payload */
 
43
#define GGEP_F_DEFLATE  '\x20'          /* Whether payload was deflated */
 
44
#define GGEP_F_MBZ              '\x10'          /* Bits that Must Be Zero */
 
45
#define GGEP_F_IDLEN    '\x0f'          /* Where ID length is stored */
 
46
 
 
47
/*
 
48
 * GGEP Length Encoding.
 
49
 */
 
50
 
 
51
#define GGEP_L_CONT             '\x80'          /* Continuation present */
 
52
#define GGEP_L_LAST             '\x40'          /* Last byte */
 
53
#define GGEP_L_VALUE    '\x3f'          /* Value */
 
54
#define GGEP_L_VSHIFT   6
 
55
 
 
56
#define GGEP_L_XFLAGS   (GGEP_L_CONT | GGEP_L_LAST)
 
57
 
 
58
/*
 
59
 * The "H" extension
 
60
 */
 
61
 
 
62
#define GGEP_H_SHA1             0x01            /* Binary SHA1 */
 
63
#define GGEP_H_BITPRINT 0x02            /* Bitprint (SHA1 + Tiger tree root) */
 
64
#define GGEP_H_MD5              0x03            /* Binary MD5 */
 
65
#define GGEP_H_UUID             0x04            /* Binary UUID (GUID-like) */
 
66
#define GGEP_H_MD4              0x05            /* Binary MD4 */
 
67
 
 
68
/*
 
69
 * Flags for ggep_ext_write() and friends.
 
70
 */
 
71
 
 
72
#define GGEP_W_LAST             0x00000001      /* This is the last extension */
 
73
#define GGEP_W_COBS             0x00000002      /* Attempt COBS encoding, if needed */
 
74
#define GGEP_W_DEFLATE  0x00000004      /* Attempt payload compression */
 
75
#define GGEP_W_FIRST    0x00000008      /* First extension, write GGEP_MAGIC */
 
76
 
 
77
/*
 
78
 * Public interface.
 
79
 */
 
80
 
 
81
struct iovec;
 
82
 
 
83
gint ggep_decode_into(extvec_t *exv, gchar *buf, gint len);
 
84
 
 
85
gint ggep_ext_write(
 
86
        gchar *buf, gint len,
 
87
        gchar *id, gchar *payload, gint plen,
 
88
        guint32 wflags);
 
89
 
 
90
gint ggep_ext_writev(
 
91
        gchar *buf, gint len,
 
92
        gchar *id, struct iovec *iov, gint iovcnt,
 
93
        guint32 wflags);
 
94
 
 
95
void ggep_ext_mark_last(guchar *start);
 
96
 
 
97
#endif  /* _ggep_h_ */
 
98
 
 
99
/* vi: set ts=4: */
 
100