This file is indexed.

/usr/include/zorp/packetbuf.h is in libzorpll-6.0-10-dev 6.0.10.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/***************************************************************************
 *
 * This file is covered by a dual licence. You can choose whether you
 * want to use it according to the terms of the GNU GPL version 2, or
 * under the terms of Zorp Professional Firewall System EULA located
 * on the Zorp installation CD.
 *
 ***************************************************************************/

#ifndef ZORP_PACKETBUF_H_INCLUDED
#define ZORP_PACKETBUF_H_INCLUDED

#include <zorp/zorplib.h>

#ifdef __cplusplus
extern "C" {
#endif

/** glib is missing this endianness define */
#define G_HOST_ENDIAN G_BYTE_ORDER
/** glib is missing this endianness define */
#define G_NETWORK_ENDIAN G_BIG_ENDIAN

typedef enum _ZPktBufFlags
{
  Z_PB_NONE             = 0x0000,
  Z_PB_BORROWED         = 0x0001,
} ZPktBufFlags;

/**
 * Buffer intended to hold a single packet.
 **/
typedef struct _ZPktBuf
{
  ZRefCount ref_cnt;
  gsize allocated, length, pos;
  ZPktBufFlags flags;
  guchar *data;
} ZPktBuf;
    
/* Get attributes */
static inline void *z_pktbuf_data(ZPktBuf *self) { return self->data; }
static inline void *z_pktbuf_current(ZPktBuf *self) { return self->data + self->pos; }
static inline void *z_pktbuf_end(ZPktBuf *self) { return self->data + self->length; }
static inline gsize z_pktbuf_size(const ZPktBuf *self) { return self->allocated; }
static inline gsize z_pktbuf_free_size(const ZPktBuf *self) { return self->allocated - self->length; }
static inline gsize z_pktbuf_length(const ZPktBuf *self) { return self->length; }
static inline gsize z_pktbuf_pos(const ZPktBuf *self) { return self->pos; }
static inline ZPktBufFlags z_pktbuf_flags(const ZPktBuf *self) { return self->flags; }

/* Work with the buffer itself, regardless of position */
void z_pktbuf_resize(ZPktBuf *self, gsize size);
gboolean z_pktbuf_copy(ZPktBuf *self, const void *data, gsize length);
void z_pktbuf_relocate(ZPktBuf *self, void *data, gsize length, gboolean is_borrowed);
gboolean z_pktbuf_append(ZPktBuf *self, const void *data, gsize length);
gboolean z_pktbuf_insert(ZPktBuf *self, gsize pos, const void *data, gsize length);
gboolean z_pktbuf_data_equal(ZPktBuf *lhs, ZPktBuf *rhs);

/* Instance control */
ZPktBuf *z_pktbuf_new(void);
ZPktBuf *z_pktbuf_ref(ZPktBuf *self);
void z_pktbuf_unref(ZPktBuf *self);
ZPktBuf *z_pktbuf_part(ZPktBuf *self, gsize pos, gsize len);
void z_pktbuf_dump(const gchar *session_id, const gchar *class_, int level, ZPktBuf *self, const gchar *title);

/* Fancy constructors */
ZPktBuf *z_pktbuf_new_from_gstring(const GString * const str);

static inline void
z_pktbuf_data_dump(const gchar *session_id, const gchar *class_, int level, ZPktBuf *self)
{
  z_pktbuf_dump(session_id, class_, level, self, NULL);
}

/* Position-related operations */
static inline gsize z_pktbuf_available(ZPktBuf *self) { return (self->length - self->pos); }
gboolean z_pktbuf_set_available(ZPktBuf *self, gsize size);

gboolean z_pktbuf_seek(ZPktBuf *self, GSeekType whence, gssize pos);

gboolean z_pktbuf_get_boolean(ZPktBuf *self, gboolean *res);
gboolean z_pktbuf_put_boolean(ZPktBuf *self, gboolean res);
gboolean z_pktbuf_get_boolean16(ZPktBuf *self, gboolean *res);

gboolean z_pktbuf_get_u8(ZPktBuf *self, guint8 *res);
gboolean z_pktbuf_get_u16(ZPktBuf *self, gint e, guint16 *res);
gboolean z_pktbuf_get_u32(ZPktBuf *self, gint e, guint32 *res);
gboolean z_pktbuf_get_u64(ZPktBuf *self, gint e, guint64 *res);

gboolean z_pktbuf_put_u8(ZPktBuf *self, guint8 d);
gboolean z_pktbuf_put_u16(ZPktBuf *self, gint e, guint16 d);
gboolean z_pktbuf_put_u32(ZPktBuf *self, gint e, guint32 d);
gboolean z_pktbuf_put_u64(ZPktBuf *self, gint e, guint64 d);

gboolean z_pktbuf_get_u8s(ZPktBuf *self, gsize n, guint8 *res);
gboolean z_pktbuf_get_u16s(ZPktBuf *self, gint e, gsize n, guint16 *res);
gboolean z_pktbuf_get_u32s(ZPktBuf *self, gint e, gsize n, guint32 *res);
gboolean z_pktbuf_get_u64s(ZPktBuf *self, gint e, gsize n, guint64 *res);

gboolean z_pktbuf_put_u8s(ZPktBuf *self, gsize n, const guint8 *d);
gboolean z_pktbuf_put_u16s(ZPktBuf *self, gint e, gsize n, const guint16 *d);
gboolean z_pktbuf_put_u32s(ZPktBuf *self, gint e, gsize n, const guint32 *d);
gboolean z_pktbuf_put_u64s(ZPktBuf *self, gint e, gsize n, const guint64 *d);

static inline gboolean z_pktbuf_get_u16_le(ZPktBuf *self, guint16 *res) { return z_pktbuf_get_u16(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_get_u64_le(ZPktBuf *self, guint64 *res) { return z_pktbuf_get_u64(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_get_u32_le(ZPktBuf *self, guint32 *res) { return z_pktbuf_get_u32(self, G_LITTLE_ENDIAN, res); }

static inline gboolean z_pktbuf_put_u16_le(ZPktBuf *self, guint16 res) { return z_pktbuf_put_u16(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_put_u32_le(ZPktBuf *self, guint32 res) { return z_pktbuf_put_u32(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_put_u64_le(ZPktBuf *self, guint64 res) { return z_pktbuf_put_u64(self, G_LITTLE_ENDIAN, res); }

static inline gboolean z_pktbuf_get_u16_be(ZPktBuf *self, guint16 *res) { return z_pktbuf_get_u16(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_get_u32_be(ZPktBuf *self, guint32 *res) { return z_pktbuf_get_u32(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_get_u64_be(ZPktBuf *self, guint64 *res) { return z_pktbuf_get_u64(self, G_BIG_ENDIAN, res); }

static inline gboolean z_pktbuf_put_u16_be(ZPktBuf *self, guint16 res) { return z_pktbuf_put_u16(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_put_u32_be(ZPktBuf *self, guint32 res) { return z_pktbuf_put_u32(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_put_u64_be(ZPktBuf *self, guint64 res) { return z_pktbuf_put_u64(self, G_BIG_ENDIAN, res); }

static inline gboolean z_pktbuf_get_s8(ZPktBuf *self, gint8 *res)   { return z_pktbuf_get_u8(self, (guint8*)res); }
static inline gboolean z_pktbuf_get_c8(ZPktBuf *self, gchar *res)   { return z_pktbuf_get_u8(self, (guint8*)res); }
static inline gboolean z_pktbuf_get_s16(ZPktBuf *self, gint e, gint16 *res) { return z_pktbuf_get_u16(self, e, (guint16*)res); }
static inline gboolean z_pktbuf_get_s32(ZPktBuf *self, gint e, gint32 *res) { return z_pktbuf_get_u32(self, e, (guint32*)res); }
static inline gboolean z_pktbuf_get_s64(ZPktBuf *self, gint e, gint64 *res) { return z_pktbuf_get_u64(self, e, (guint64*)res); }

static inline gboolean z_pktbuf_put_s8(ZPktBuf *self, gint8 d)   { return z_pktbuf_put_u8(self, (guint8)d); }
static inline gboolean z_pktbuf_put_c8(ZPktBuf *self, gchar d)   { return z_pktbuf_put_u8(self, (guint8)d); }
static inline gboolean z_pktbuf_put_s16(ZPktBuf *self, gint e, gint16 d) { return z_pktbuf_put_u16(self, e, (guint16)d); }
static inline gboolean z_pktbuf_put_s32(ZPktBuf *self, gint e, gint32 d) { return z_pktbuf_put_u32(self, e, (guint32)d); }
static inline gboolean z_pktbuf_put_s64(ZPktBuf *self, gint e, gint64 d) { return z_pktbuf_put_u64(self, e, (guint64)d); }

static inline gboolean z_pktbuf_get_s16_le(ZPktBuf *self, gint16 *res) { return z_pktbuf_get_s16(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_get_s64_le(ZPktBuf *self, gint64 *res) { return z_pktbuf_get_s64(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_get_s32_le(ZPktBuf *self, gint32 *res) { return z_pktbuf_get_s32(self, G_LITTLE_ENDIAN, res); }

static inline gboolean z_pktbuf_put_s16_le(ZPktBuf *self, gint16 res) { return z_pktbuf_put_s16(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_put_s32_le(ZPktBuf *self, gint32 res) { return z_pktbuf_put_s32(self, G_LITTLE_ENDIAN, res); }
static inline gboolean z_pktbuf_put_s64_le(ZPktBuf *self, gint64 res) { return z_pktbuf_put_s64(self, G_LITTLE_ENDIAN, res); }

static inline gboolean z_pktbuf_get_s16_be(ZPktBuf *self, gint16 *res) { return z_pktbuf_get_s16(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_get_s32_be(ZPktBuf *self, gint32 *res) { return z_pktbuf_get_s32(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_get_s64_be(ZPktBuf *self, gint64 *res) { return z_pktbuf_get_s64(self, G_BIG_ENDIAN, res); }

static inline gboolean z_pktbuf_put_s16_be(ZPktBuf *self, gint16 res) { return z_pktbuf_put_s16(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_put_s32_be(ZPktBuf *self, gint32 res) { return z_pktbuf_put_s32(self, G_BIG_ENDIAN, res); }
static inline gboolean z_pktbuf_put_s64_be(ZPktBuf *self, gint64 res) { return z_pktbuf_put_s64(self, G_BIG_ENDIAN, res); }

static inline gboolean z_pktbuf_get_s8s(ZPktBuf *self, gsize n, gint8 *res)   { return z_pktbuf_get_u8s(self, n, (guint8*)res); }
static inline gboolean z_pktbuf_get_c8s(ZPktBuf *self, gsize n, gchar *res)   { return z_pktbuf_get_u8s(self, n, (guint8*)res); }
static inline gboolean z_pktbuf_get_s16s(ZPktBuf *self, gint e, gsize n, gint16 *res) { return z_pktbuf_get_u16s(self, e, n, (guint16*)res); }
static inline gboolean z_pktbuf_get_s32s(ZPktBuf *self, gint e, gsize n, gint32 *res) { return z_pktbuf_get_u32s(self, e, n, (guint32*)res); }
static inline gboolean z_pktbuf_get_s64s(ZPktBuf *self, gint e, gsize n, gint64 *res) { return z_pktbuf_get_u64s(self, e, n, (guint64*)res); }

static inline gboolean z_pktbuf_put_s8s(ZPktBuf *self, gsize n, const gint8 *d)   { return z_pktbuf_put_u8s(self, n, (const guint8*)d); }
static inline gboolean z_pktbuf_put_c8s(ZPktBuf *self, gsize n, const gchar *d)   { return z_pktbuf_put_u8s(self, n, (const guint8*)d); }
static inline gboolean z_pktbuf_put_s16s(ZPktBuf *self, gint e, gsize n, const gint16 *d) { return z_pktbuf_put_u16s(self, e, n, (const guint16*)d); }
static inline gboolean z_pktbuf_put_s32s(ZPktBuf *self, gint e, gsize n, const gint32 *d) { return z_pktbuf_put_u32s(self, e, n, (const guint32*)d); }
static inline gboolean z_pktbuf_put_s64s(ZPktBuf *self, gint e, gsize n, const gint64 *d) { return z_pktbuf_put_u64s(self, e, n, (const guint64*)d); }

gboolean z_pktbuf_put_string(ZPktBuf *self, const gchar *str);

ZPktBuf* z_pktbuf_split(ZPktBuf *self, gsize at);
ZPktBuf* z_pktbuf_append_pktbuf(ZPktBuf *self, ZPktBuf *other);

#ifdef __cplusplus
}
#endif

#endif