64 #define ADDRESS_INIT(type, len, data) {type, len, data, NULL}
65 #define ADDRESS_INIT_NONE ADDRESS_INIT(AT_NONE, 0, NULL)
85 set_address(
address *addr,
int addr_type,
int addr_len,
const void *addr_data) {
88 ws_assert(addr_data == NULL);
91 ws_assert(addr_type != AT_NONE);
93 ws_assert(addr_data != NULL);
95 addr->type = addr_type;
97 addr->data = addr_data;
117 set_address_tvb(
address *addr,
int addr_type,
int addr_len,
tvbuff_t *tvb,
int offset) {
122 ws_assert(addr_type != AT_NONE);
126 set_address(addr, addr_type, addr_len, p);
141 int addr_type,
int addr_len,
const void *addr_data) {
144 addr->type = addr_type;
147 ws_assert(addr_data == NULL);
152 ws_assert(addr_type != AT_NONE);
154 ws_assert(addr_data != NULL);
155 addr->data = addr->priv =
wmem_memdup(scope, addr_data, addr_len);
156 addr->len = addr_len;
173 int addr_type,
int addr_len,
tvbuff_t *tvb,
int offset) {
177 alloc_address_wmem(scope, addr, addr_type, addr_len, p);
190 if (addr1->type > addr2->type)
return 1;
191 if (addr1->type < addr2->type)
return -1;
192 if (addr1->len > addr2->len)
return 1;
193 if (addr1->len < addr2->len)
return -1;
194 if (addr1->len == 0) {
202 return memcmp(addr1->data, addr2->data, addr1->len);
216 static inline gboolean
223 if (addr1->type == addr2->type &&
224 addr1->len == addr2->len &&
226 memcmp(addr1->data, addr2->data, addr1->len) == 0))
242 static inline gboolean
243 addresses_data_equal(
const address *addr1,
const address *addr2) {
244 if ( addr1->len == addr2->len
245 && memcmp(addr1->data, addr2->data, addr1->len) == 0
261 set_address(to, from->type, from->len, from->data);
273 alloc_address_wmem(scope, to, from->type, from->len, from->data);
283 copy_address_wmem(NULL, to, from);
294 if (addr->type != AT_NONE && addr->len > 0 && addr->priv != NULL) {
297 ws_assert(addr->data == addr->priv);
309 free_address_wmem(NULL, addr);
319 add_address_to_hash(guint hash_val,
const address *addr) {
320 const guint8 *hash_data = (
const guint8 *)(addr)->data;
323 for (idx = 0; idx < (addr)->len; idx++) {
324 hash_val += hash_data[idx];
325 hash_val += ( hash_val << 10 );
326 hash_val ^= ( hash_val >> 6 );
338 static inline guint64
339 add_address_to_hash64(guint64 hash_val,
const address *addr) {
340 const guint8 *hash_data = (
const guint8 *)(addr)->data;
343 for (idx = 0; idx < (addr)->len; idx++) {
344 hash_val += hash_data[idx];
345 hash_val += ( hash_val << 10 );
346 hash_val ^= ( hash_val >> 6 );
351 WS_DLL_PUBLIC guint address_to_bytes(
const address *addr, guint8 *buf, guint buf_len);
const guint8 * tvb_get_ptr(tvbuff_t *tvb, const gint offset, const gint length)
Definition: tvbuff.c:1006
void * wmem_memdup(wmem_allocator_t *allocator, const void *source, const size_t size)
Definition: wmem_miscutl.c:19
void wmem_free(wmem_allocator_t *allocator, void *ptr)
Definition: wmem_core.c:62
Definition: wmem_allocator.h:27
Definition: tvbuff-int.h:35