GNUNET_HashCode zone;
- uint64_t op_id;
+ uint64_t request_id;
uint32_t offset;
};
struct LookupNameContext
{
struct GNUNET_NAMESTORE_Client *nc;
- uint32_t id;
+ uint32_t request_id;
uint32_t record_type;
};
lnr_msg = GNUNET_malloc (r_size);
- lnr_msg->header.type = ntohs (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE);
- lnr_msg->header.size = ntohs (r_size);
- lnr_msg->op_id = htonl (lnc->id);
+ lnr_msg->gns_header.header.type = ntohs (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE);
+ lnr_msg->gns_header.header.size = ntohs (r_size);
+ lnr_msg->gns_header.r_id = htonl (lnc->request_id);
lnr_msg->rd_len = htons (rd_ser_len);
lnr_msg->name_len = htons (name_len);
lnr_msg->expire = GNUNET_TIME_absolute_hton(expire);
struct GNUNET_NAMESTORE_Client *nc;
size_t name_len;
char * name;
- uint32_t id = 0;
+ uint32_t rid = 0;
uint32_t type = 0;
int res;
}
struct LookupNameMessage * ln_msg = (struct LookupNameMessage *) message;
- id = ntohl (ln_msg->op_id);
+ rid = ntohl (ln_msg->gns_header.r_id);
name_len = ntohl (ln_msg->name_len);
type = ntohl (ln_msg->record_type);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up record for name `%s'\n", name);
/* do the actual lookup */
- lnc.id = id;
+ lnc.request_id = rid;
lnc.nc = nc;
lnc.record_type = type;
res = GSN_database->iterate_records(GSN_database->cls, &ln_msg->zone, name, 0, &handle_lookup_name_it, &lnc);
size_t key_len;
char * name;
char * rd_ser;
- uint32_t id = 0;
+ uint32_t rid = 0;
uint32_t rd_ser_len;
uint32_t rd_count;
int res = GNUNET_SYSERR;
struct RecordPutMessage * rp_msg = (struct RecordPutMessage *) message;
- id = ntohl (rp_msg->op_id);
+ rid = ntohl (rp_msg->gns_header.r_id);
key_len = sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);
name_len = ntohs (rp_msg->name_len);
rd_ser_len = ntohs(rp_msg->rd_len);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "RECORD_PUT_RESPONSE");
rpr_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE);
- rpr_msg.op_id = rp_msg->op_id;
+ rpr_msg.op_id = rp_msg->gns_header.r_id;
rpr_msg.header.size = htons (sizeof (struct RecordPutResponseMessage));
if (GNUNET_OK == res)
rpr_msg.op_result = htons (GNUNET_OK);
/* Send response */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "RECORD_CREATE_RESPONSE");
- rcr_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE);
- rcr_msg.op_id = htonl (crc->op_id);
- rcr_msg.header.size = htons (sizeof (struct RecordCreateResponseMessage));
+ rcr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE);
+ rcr_msg.gns_header.r_id = htonl (crc->op_id);
+ rcr_msg.gns_header.header.size = htons (sizeof (struct RecordCreateResponseMessage));
if (GNUNET_OK == res)
rcr_msg.op_result = htons (GNUNET_OK);
else
size_t msg_size_exp;
size_t rd_ser_len;
size_t key_len;
- uint32_t id = 0;
+ uint32_t rid = 0;
char *pkey_tmp;
char *name_tmp;
char *rd_ser;
}
struct RecordCreateMessage * rp_msg = (struct RecordCreateMessage *) message;
- id = ntohl (rp_msg->op_id);
+ rid = ntohl (rp_msg->gns_header.r_id);
name_len = ntohs (rp_msg->name_len);
msg_size = ntohs (message->size);
rd_ser_len = ntohs (rp_msg->rd_len);
crc.pkey = pkey;
crc.rd = rd;
crc.nc = nc;
- crc.op_id = id;
+ crc.op_id = rid;
/* Get existing records for name */
res = GSN_database->iterate_records(GSN_database->cls, &pubkey_hash, name_tmp, 0, &handle_create_record_it, &crc);
size_t name_len;
size_t msg_size;
size_t msg_size_exp;
- uint32_t id = 0;
+ uint32_t rid = 0;
int res = GNUNET_SYSERR;
}
struct RecordRemoveMessage * rp_msg = (struct RecordRemoveMessage *) message;
- id = ntohl (rp_msg->op_id);
+ rid = ntohl (rp_msg->gns_header.r_id);
name_len = ntohs (rp_msg->name_len);
msg_size = ntohs (message->size);
msg_size_exp = sizeof (struct RecordRemoveMessage) + name_len + sizeof (struct GNUNET_NAMESTORE_RecordData);
/* Send response */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "RECORD_REMOVE_RESPONSE");
- rrr_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE);
- rrr_msg.op_id = rp_msg->op_id;
- rrr_msg.header.size = htons (sizeof (struct RecordRemoveResponseMessage));
+ rrr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE);
+ rrr_msg.gns_header.r_id = rp_msg->gns_header.r_id;
+ rrr_msg.gns_header.header.size = htons (sizeof (struct RecordRemoveResponseMessage));
if (GNUNET_OK == res)
rrr_msg.op_result = htons (GNUNET_OK);
else
}
zi = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIteration));
- zi->op_id = ntohl (zis_msg->op_id);
+ zi->request_id = ntohl (zis_msg->gns_header.r_id);
zi->offset = 0;
zi->client = nc;
zi->zone = zis_msg->zone;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_ITERATION_RESPONSE");
- zir_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE);
- zir_msg.op_id = htonl(zi->op_id);
- zir_msg.header.size = htons (sizeof (struct ZoneIterationResponseMessage));
+ zir_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE);
+ zir_msg.gns_header.r_id = htonl(zi->request_id);
+ zir_msg.gns_header.header.size = htons (sizeof (struct ZoneIterationResponseMessage));
GNUNET_SERVER_notification_context_unicast (snc, zi->client->client, (const struct GNUNET_MessageHeader *) &zir_msg, GNUNET_NO);
struct GNUNET_NAMESTORE_Client *nc;
struct GNUNET_NAMESTORE_ZoneIteration *zi;
struct ZoneIterationStopMessage * zis_msg = (struct ZoneIterationStopMessage *) message;
- uint32_t id;
+ uint32_t rid;
nc = client_lookup(client);
if (nc == NULL)
return;
}
- id = ntohl (zis_msg->op_id);
+ rid = ntohl (zis_msg->gns_header.r_id);
for (zi = nc->op_head; zi != NULL; zi = zi->next)
{
- if (zi->op_id == id)
+ if (zi->request_id == rid)
break;
}
if (zi == NULL)
struct GNUNET_NAMESTORE_Client *nc;
struct GNUNET_NAMESTORE_ZoneIteration *zi;
struct ZoneIterationStopMessage * zis_msg = (struct ZoneIterationStopMessage *) message;
- uint32_t id;
+ uint32_t rid;
int res;
nc = client_lookup(client);
return;
}
- id = ntohl (zis_msg->op_id);
+ rid = ntohl (zis_msg->gns_header.r_id);
for (zi = nc->op_head; zi != NULL; zi = zi->next)
{
- if (zi->op_id == id)
+ if (zi->request_id == rid)
break;
}
if (zi == NULL)
/**
* Generic namestore message with op id
*/
-struct GenericMessage
+struct GNUNET_NAMESTORE_Header
{
/**
- * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
+ * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
+ * header.size will be message size
*/
struct GNUNET_MessageHeader header;
/**
- * Operation ID in NBO // BETTER: request ID
+ * Request ID in NBO
*/
- uint32_t op_id;
+ uint32_t r_id;
};
*/
struct LookupNameMessage
{
- /**
- * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME
- */
- struct GNUNET_MessageHeader header;
-
- // FIXME: use 'struct GenericMessage'
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* The zone */
GNUNET_HashCode zone;
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
struct GNUNET_TIME_AbsoluteNBO expire;
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
/* Contenct starts here */
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
};
GNUNET_NETWORK_STRUCT_END
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
};
GNUNET_NETWORK_STRUCT_END
/**
* Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
*/
- struct GNUNET_MessageHeader header;
-
- /**
- * Operation ID in NBO
- */
- uint32_t op_id;
+ struct GNUNET_NAMESTORE_Header gns_header;
struct GNUNET_TIME_AbsoluteNBO expire;
int rd_count = 0;
rd_len = ntohs (msg->rd_len);
- msg_len = ntohs (msg->header.size);
+ msg_len = ntohs (msg->gns_header.header.size);
name_len = ntohs (msg->name_len);
contains_sig = ntohs (msg->contains_sig);
expire = GNUNET_TIME_absolute_ntoh(msg->expire);
process_namestore_message (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_NAMESTORE_Handle *h = cls;
- struct GenericMessage * gm;
+ struct GNUNET_NAMESTORE_Header * gm;
struct GNUNET_NAMESTORE_QueueEntry *qe;
struct GNUNET_NAMESTORE_ZoneIterator *ze;
uint16_t size;
uint16_t type;
- uint32_t op_id = UINT32_MAX;
+ uint32_t r_id = UINT32_MAX;
if (NULL == msg)
{
size = ntohs (msg->size);
type = ntohs (msg->type);
- if (size < sizeof (struct GenericMessage))
+ if (size < sizeof (struct GNUNET_NAMESTORE_Header))
{
GNUNET_break_op (0);
GNUNET_CLIENT_receive (h->client, &process_namestore_message, h,
return;
}
- gm = (struct GenericMessage *) msg;
- op_id = ntohl (gm->op_id);
+ gm = (struct GNUNET_NAMESTORE_Header *) msg;
+ r_id = ntohl (gm->r_id);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, op_id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %i size %i op %u\n", type, size, r_id);
/* Find matching operation */
- if (op_id > h->op_id)
+ if (r_id > h->op_id)
{
/* No matching pending operation found */
GNUNET_break_op (0);
/* Is it a record related operation ? */
for (qe = h->op_head; qe != NULL; qe = qe->next)
{
- if (qe->op_id == op_id)
+ if (qe->op_id == r_id)
break;
}
if (qe != NULL)
/* Is it a zone iteration operation ? */
for (ze = h->z_head; ze != NULL; ze = ze->next)
{
- if (ze->op_id == op_id)
+ if (ze->op_id == r_id)
break;
}
if (ze != NULL)
size_t name_len = 0;
size_t rd_ser_len = 0;
size_t pubkey_len = 0;
- uint32_t id = 0;
+ uint32_t rid = 0;
GNUNET_assert (NULL != h);
GNUNET_assert (NULL != zone_key);
return NULL;
}
- id = get_op_id(h);
+ rid = get_op_id(h);
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
qe->nsh = h;
qe->cont = cont;
qe->cont_cls = cont_cls;
- qe->op_id = id;
+ qe->op_id = rid;
GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
/* set msg_size*/
name_tmp = (char *) &zone_key_tmp[pubkey_len];
rd_tmp = &name_tmp[name_len];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
- msg->header.size = htons (msg_size);
- msg->op_id = htonl (id);
+ msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
+ msg->gns_header.header.size = htons (msg_size);
+ msg->gns_header.r_id = htonl (rid);
msg->key_len = htons (pubkey_len);
memcpy (zone_key_tmp, zone_key, pubkey_len);
msg->signature = *signature;
size_t msg_size = 0;
size_t name_len = 0;
size_t key_len = 0;
- uint32_t id = 0;
+ uint32_t rid = 0;
GNUNET_assert (NULL != h);
GNUNET_assert (NULL != pkey);
return NULL;
}
- id = get_op_id(h);
+ rid = get_op_id(h);
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
qe->nsh = h;
qe->cont = cont;
qe->cont_cls = cont_cls;
- qe->op_id = id;
+ qe->op_id = rid;
GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
/* set msg_size*/
name_tmp = &pkey_tmp[key_len];
rd_tmp = &name_tmp[name_len];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
- msg->header.size = htons (msg_size);
- msg->op_id = htonl (id);
+ msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE);
+ msg->gns_header.header.size = htons (msg_size);
+ msg->gns_header.r_id = htonl (rid);
msg->name_len = htons (name_len);
msg->rd_len = htons (rd_ser_len);
msg->pkey_len = htons (key_len);
size_t rd_ser_len = 0;
size_t msg_size = 0;
size_t name_len = 0;
- uint32_t id = 0;
+ uint32_t rid = 0;
GNUNET_assert (NULL != h);
- id = get_op_id(h);
+ rid = get_op_id(h);
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
qe->nsh = h;
qe->cont = cont;
qe->cont_cls = cont_cls;
- qe->op_id = id;
+ qe->op_id = rid;
/* set msg_size*/
rd_ser_len = GNUNET_NAMESTORE_records_serialize(&rd_ser, 1, rd);
name_tmp = (char *) &msg[1];
rd_tmp = &name_tmp[name_len];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
- msg->header.size = htons (msg_size);
- msg->op_id = htonl (id);
+ msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE);
+ msg->gns_header.header.size = htons (msg_size);
+ msg->gns_header.r_id = htonl (rid);
//msg->signature = *signature;
msg->name_len = htons (name_len);
memcpy (name_tmp, name, name_len);
struct PendingMessage *pe;
size_t msg_size = 0;
size_t name_len = 0;
- uint32_t id = 0;
+ uint32_t rid = 0;
GNUNET_assert (NULL != h);
GNUNET_assert (NULL != zone);
return NULL;
}
- id = get_op_id(h);
+ rid = get_op_id(h);
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
qe->nsh = h;
qe->proc = proc;
qe->proc_cls = proc_cls;
- qe->op_id = id;
+ qe->op_id = rid;
GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, qe);
/* set msg_size*/
pe->size = msg_size;
pe->is_init = GNUNET_NO;
msg = (struct LookupNameMessage *) &pe[1];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
- msg->header.size = htons (msg_size);
- msg->op_id = htonl (id);
+ msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
+ msg->gns_header.header.size = htons (msg_size);
+ msg->gns_header.r_id = htonl (rid);
msg->record_type = htonl (record_type);
msg->zone = *zone;
msg->name_len = htonl (name_len);
struct GNUNET_NAMESTORE_ZoneIterator *it;
struct PendingMessage *pe;
size_t msg_size = 0;
- uint32_t id = 0;
+ uint32_t rid = 0;
GNUNET_assert (NULL != h);
GNUNET_assert (NULL != zone);
- id = get_op_id(h);
+ rid = get_op_id(h);
it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator));
it->h = h;
it->proc = proc;
it->proc_cls = proc;
- it->op_id = id;
+ it->op_id = rid;
it->zone = *zone;
GNUNET_CONTAINER_DLL_insert_tail(h->z_head, h->z_tail, it);
pe->size = msg_size;
pe->is_init = GNUNET_NO;
msg = (struct ZoneIterationStartMessage *) &pe[1];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
- msg->header.size = htons (msg_size);
- msg->op_id = htonl (id);
+ msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
+ msg->gns_header.header.size = htons (msg_size);
+ msg->gns_header.r_id = htonl (rid);
msg->zone = *zone;
msg->must_have_flags = ntohs (must_have_flags);
msg->must_not_have_flags = ntohs (must_not_have_flags);
pe->size = msg_size;
pe->is_init = GNUNET_NO;
msg = (struct ZoneIterationNextMessage *) &pe[1];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
- msg->header.size = htons (msg_size);
- msg->op_id = htonl (it->op_id);
+ msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT);
+ msg->gns_header.header.size = htons (msg_size);
+ msg->gns_header.r_id = htonl (it->op_id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "ZONE_ITERATION_NEXT", GNUNET_h2s(&it->zone));
pe->size = msg_size;
pe->is_init = GNUNET_NO;
msg = (struct ZoneIterationStopMessage *) &pe[1];
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
- msg->header.size = htons (msg_size);
- msg->op_id = htonl (it->op_id);
+ msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP);
+ msg->gns_header.header.size = htons (msg_size);
+ msg->gns_header.r_id = htonl (it->op_id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s'\n", "ZONE_ITERATION_STOP", GNUNET_h2s(&it->zone));