struct GNUNET_MessageHeader *msg;
env = GNUNET_MQ_msg_extra (msg, payload_size, GNUNET_MY_MESSAGE_TYPE);
-memcpy (&msg[1], &payload, payload_size);
+GNUNET_memcpy (&msg[1],
+ &payload,
+ payload_size);
// Send message via message queue 'mq'
GNUNET_mq_send (mq, env);
-
int rc;
int key_len;
unsigned char* key_buf;
-
+
key_len = element_length_in_bytes(k) < 33 ? 3 : element_length_in_bytes(k);
key_buf = (unsigned char*) malloc(key_len);
element_to_bytes(key_buf, k);
- memcpy (key->aes_key, key_buf, GNUNET_CRYPTO_AES_KEY_LENGTH);
+ GNUNET_memcpy (key->aes_key, key_buf, GNUNET_CRYPTO_AES_KEY_LENGTH);
GNUNET_assert (0 ==
gcry_cipher_open (handle, GCRY_CIPHER_AES256,
GCRY_CIPHER_MODE_CFB, 0));
unsigned char iv[16];
char* tmp;
uint32_t len;
-
+
init_aes(k, 1, &handle, &skey, iv);
tmp = GNUNET_malloc (size);
//AES_cbc_encrypt(ct->data, pt->data, ct->len, &key, iv, AES_DECRYPT);
- GNUNET_assert (0 == gcry_cipher_decrypt (handle, tmp, size, ct, size));
+ GNUNET_assert (0 == gcry_cipher_decrypt (handle, tmp, size, ct, size));
gcry_cipher_close (handle);
/* TODO make less crufty */
-
+
/* get real length */
len = 0;
len = len
struct GNUNET_ABE_AbeKey *prv_key;
int size;
char *tmp;
-
+
prv_key = GNUNET_new (struct GNUNET_ABE_AbeKey);
prv_key->prv = gabe_keygen(key->pub, key->msk, attrs);
size = gabe_pub_serialize(key->pub, &tmp);
{
char *ptr;
uint32_t *len;
-
+
*result = GNUNET_malloc (12 + cph_buf_len + aes_buf_len);
ptr = *result;
len = (uint32_t*) ptr;
len = (uint32_t*) ptr;
*len = htonl (aes_buf_len);
ptr += 4;
- memcpy (ptr, aes_buf, aes_buf_len);
+ GNUNET_memcpy (ptr, aes_buf, aes_buf_len);
ptr += aes_buf_len;
len = (uint32_t*) ptr;
*len = htonl (cph_buf_len);
ptr += 4;
- memcpy (ptr, cph_buf, cph_buf_len);
+ GNUNET_memcpy (ptr, cph_buf, cph_buf_len);
return 12 + cph_buf_len + aes_buf_len;
}
*aes_buf_len = ntohl (*len);
ptr += 4;
*aes_buf = GNUNET_malloc (*aes_buf_len);
- memcpy(*aes_buf, ptr, *aes_buf_len);
+ GNUNET_memcpy(*aes_buf, ptr, *aes_buf_len);
ptr += *aes_buf_len;
len = (uint32_t*)ptr;
*cph_buf_len = ntohl (*len);
ptr += 4;
*cph_buf = GNUNET_malloc (*cph_buf_len);
- memcpy(*cph_buf, ptr, *cph_buf_len);
+ GNUNET_memcpy(*cph_buf, ptr, *cph_buf_len);
return buf_len;
}
&prv_len);
key->pub = gabe_pub_unserialize (pub, pub_len);
key->prv = gabe_prv_unserialize (key->pub, prv, prv_len);
-
+
GNUNET_free (pub);
GNUNET_free (prv);
return key;
&msk_len);
key->pub = gabe_pub_unserialize (pub, pub_len);
key->msk = gabe_msk_unserialize (key->pub, msk, msk_len);
-
+
GNUNET_free (pub);
GNUNET_free (msk);
* The issuer
*/
struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
-
+
/**
* The subject
*/
struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
-
+
/**
* The issued attribute
*/
char *issuer_attribute;
-
+
/**
* The delegated attribute
*/
* DLL
*/
struct CredentialRecordEntry *prev;
-
+
/**
* Number of references in delegation chains
*/
}
cleanup_delegation_set (vrh->root_set);
GNUNET_free_non_null (vrh->issuer_attribute);
- for (cr_entry = vrh->cred_chain_head;
+ for (cr_entry = vrh->cred_chain_head;
NULL != vrh->cred_chain_head;
cr_entry = vrh->cred_chain_head)
{
else
rmsg->cred_found = htonl (GNUNET_NO);
- GNUNET_assert (-1 !=
+ GNUNET_assert (-1 !=
GNUNET_CREDENTIAL_delegation_chain_serialize (vrh->delegation_chain_size,
dd,
vrh->cred_chain_size,
"Got %d attrs\n", rd_count);
// Each OR
- for (uint32_t i=0; i < rd_count; i++)
+ for (uint32_t i=0; i < rd_count; i++)
{
if (GNUNET_GNSRECORD_TYPE_ATTRIBUTE != rd[i].record_type)
continue;
/**
* Check if this delegation already matches one of our credentials
*/
- for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL;
+ for(cred_pointer = vrh->cred_chain_head; cred_pointer != NULL;
cred_pointer = cred_pointer->next)
{
- if(0 != memcmp (&set->subject_key,
+ if(0 != memcmp (&set->subject_key,
&cred_pointer->credential->issuer_key,
sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
continue;
return;
}
-}
+}
/**
}
/**
- * Check for attributes from the issuer and follow the chain
+ * Check for attributes from the issuer and follow the chain
* till you get the required subject's attributes
*/
char issuer_attribute_name[strlen (vrh->issuer_attribute) + strlen (".gnu") + 1];
"Looking up %s\n", issuer_attribute_name);
ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
- memcpy (ds_entry->issuer_key,
- &vrh->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
+ GNUNET_memcpy (ds_entry->issuer_key,
+ &vrh->issuer_key,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute);
ds_entry->handle = vrh;
ds_entry->lookup_attribute = GNUNET_strdup (vrh->issuer_attribute);
static void
handle_verify (void *cls,
- const struct VerifyMessage *v_msg)
+ const struct VerifyMessage *v_msg)
{
struct VerifyRequestHandle *vrh;
struct GNUNET_SERVICE_Client *client = cls;
"Received VERIFY message\n");
utf_in = (const char *) &v_msg[1];
GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
- GNUNET_memcpy (issuer_attribute, attr, ntohs (v_msg->issuer_attribute_len));
+ GNUNET_memcpy (issuer_attribute,
+ attr,
+ ntohs (v_msg->issuer_attribute_len));
issuer_attribute[ntohs (v_msg->issuer_attribute_len)] = '\0';
vrh = GNUNET_new (struct VerifyRequestHandle);
GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
if (0 == strlen (issuer_attribute))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No issuer attribute provided!\n");
send_lookup_response (vrh);
return;
* TODO: cleanup!
*/
credentials_count = ntohl(v_msg->c_count);
- credential_data_size = ntohs (v_msg->header.size)
+ credential_data_size = ntohs (v_msg->header.size)
- sizeof (struct VerifyMessage)
- ntohs (v_msg->issuer_attribute_len)
- 1;
credentials_count,
credentials))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Cannot deserialize credentials!\n");
send_lookup_response (vrh);
return;
static void
handle_collect (void *cls,
- const struct CollectMessage *c_msg)
+ const struct CollectMessage *c_msg)
{
char attr[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
char issuer_attribute[GNUNET_CREDENTIAL_MAX_LENGTH + 1];
utf_in = (const char *) &c_msg[1];
GNUNET_STRINGS_utf8_tolower (utf_in, attrptr);
- GNUNET_memcpy (issuer_attribute, attr, ntohs (c_msg->issuer_attribute_len));
+ GNUNET_memcpy (issuer_attribute,
+ attr,
+ ntohs (c_msg->issuer_attribute_len));
issuer_attribute[ntohs (c_msg->issuer_attribute_len)] = '\0';
vrh = GNUNET_new (struct VerifyRequestHandle);
GNUNET_CONTAINER_DLL_insert (vrh_head, vrh_tail, vrh);
if (0 == strlen (issuer_attribute))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No issuer attribute provided!\n");
send_lookup_response (vrh);
return;
int i;
if (data_size < sizeof (struct GNUNET_CREDENTIAL_DelegationRecord))
return NULL; /* malformed */
- memcpy (&sets,
- data,
- sizeof (sets));
+ GNUNET_memcpy (&sets,
+ data,
+ sizeof (sets));
cdata = data;
struct GNUNET_CREDENTIAL_DelegationSet set[ntohl(sets.set_count)];
if (GNUNET_OK != GNUNET_CREDENTIAL_delegation_set_deserialize (GNUNET_ntohll (sets.data_size),
}
tmp_data_size = GNUNET_CREDENTIAL_delegation_set_get_size (entries,
set);
-
+
if (-1 == tmp_data_size)
{
GNUNET_free (tmp_str);
return GNUNET_OK;
}
case GNUNET_GNSRECORD_TYPE_CREDENTIAL:
- {
+ {
struct GNUNET_CREDENTIAL_Credential *cred;
cred = GNUNET_CREDENTIAL_credential_from_string (s);
sig,
sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
GNUNET_free (sig);
-
+
tmp = json_object_get (res, "expiration");
if (0 == json_is_integer (tmp))
{
GNUNET_free (cred);
return NULL;
}
- cred->expiration.abs_value_us = json_integer_value (tmp);
+ cred->expiration.abs_value_us = json_integer_value (tmp);
return cred;
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Issuer in credential malformed\n");
return NULL;
- }
+ }
subject = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key);
if (NULL == subject)
{
GNUNET_STRINGS_base64_encode ((char*)&cred->signature,
sizeof (struct GNUNET_CRYPTO_EcdsaSignature),
&signature);
- memcpy (attribute,
- cred->issuer_attribute,
- cred->issuer_attribute_len);
+ GNUNET_memcpy (attribute,
+ cred->issuer_attribute,
+ cred->issuer_attribute_len);
attribute[cred->issuer_attribute_len] = '\0';
cred_obj = json_object ();
json_object_set_new (cred_obj, "issuer", json_string (issuer));
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Missing issuer attribute\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
tmp = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map,
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
GNUNET_CRYPTO_ecdsa_public_key_from_string (tmp,
strlen (tmp),
&handle->issuer_key))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed subject\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
handle->ego_lookup = GNUNET_IDENTITY_ego_lookup (cfg,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Missing issuer attribute\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
tmp = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map,
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
GNUNET_CRYPTO_ecdsa_public_key_from_string (tmp,
strlen (tmp),
&handle->issuer_key))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed subject\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
if (GNUNET_OK !=
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Missing expiration\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
expiration_str = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Expiration malformed\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed expiration: %s\n", expiration_str);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Missing issuer attribute\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->issuer_attr = GNUNET_strdup(GNUNET_CONTAINER_multihashmap_get
+ handle->issuer_attr = GNUNET_strdup(GNUNET_CONTAINER_multihashmap_get
(handle->rest_handle->url_param_map,
&key));
GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_CREDENTIAL_SUBJECT_KEY,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed subject\n");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
if (GNUNET_OK !=
switch (sa->sa_family)
{
case AF_INET:
- memcpy (&ds->ss,
- sa,
- sizeof (struct sockaddr_in));
+ GNUNET_memcpy (&ds->ss,
+ sa,
+ sizeof (struct sockaddr_in));
break;
case AF_INET6:
- memcpy (&ds->ss,
- sa,
- sizeof (struct sockaddr_in6));
+ GNUNET_memcpy (&ds->ss,
+ sa,
+ sizeof (struct sockaddr_in6));
break;
default:
GNUNET_break (0);
ii = GNUNET_malloc (sizeof (struct IndexInfo) + slen);
ii->file_id = *file_id;
ii->filename = (const char *) &ii[1];
- memcpy (&ii[1],
- filename,
- slen);
+ GNUNET_memcpy (&ii[1],
+ filename,
+ slen);
GNUNET_CONTAINER_DLL_insert (indexed_files_head,
indexed_files_tail,
ii);
req = GNUNET_malloc (sizeof (struct Request) + hlen);
req->cat = cat;
req->hostname = (char *) &req[1];
- memcpy (req->hostname,
- hostname,
- hlen);
+ GNUNET_memcpy (req->hostname,
+ hostname,
+ hlen);
GNUNET_CONTAINER_DLL_insert (todo_head,
todo_tail,
req);
res->data_size = data_size;
res->record_type = record_type;
res->data = &res[1];
- GNUNET_memcpy (&res[1], data, data_size);
+ GNUNET_memcpy (&res[1],
+ data,
+ data_size);
GNUNET_CONTAINER_DLL_insert (rh->dns_result_head,
rh->dns_result_tail,
res);
continue_with_gns2dns (ac);
return;
}
- memcpy (&ss,
- addr,
- addrlen);
+ GNUNET_memcpy (&ss,
+ addr,
+ addrlen);
switch (ss.ss_family)
{
case AF_INET:
('\0' != cdata[data_size - 1]) )
return NULL; /* malformed */
/* need to memcpy for alignment */
- memcpy (&vpn,
- data,
- sizeof (vpn));
+ GNUNET_memcpy (&vpn,
+ data,
+ sizeof (vpn));
GNUNET_asprintf (&vpn_str,
"%u %s %s",
(unsigned int) ntohs (vpn.proto),
cdata = data;
if (data_size < sizeof (struct GNUNET_GNSRECORD_BoxRecord))
return NULL; /* malformed */
- memcpy (&box,
- data,
- sizeof (box));
+ GNUNET_memcpy (&box,
+ data,
+ sizeof (box));
rt = ntohl (box.record_type);
ival = GNUNET_GNSRECORD_value_to_string (rt,
&cdata[sizeof (box)],
GNUNET_GNSRECORD_records_get_size (unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
- unsigned int i;
size_t ret;
ret = sizeof (struct NetworkRecord) * rd_count;
- for (i=0;i<rd_count;i++)
+ for (unsigned int i=0;i<rd_count;i++)
{
GNUNET_assert ((ret + rd[i].data_size) >= ret);
ret += rd[i].data_size;
char *dest)
{
struct NetworkRecord rec;
- unsigned int i;
size_t off;
off = 0;
- for (i=0;i<rd_count;i++)
+ for (unsigned int i=0;i<rd_count;i++)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Serializing record %u with flags %d and expiration time %llu\n",
{
if (off + sizeof (rec) > len)
return GNUNET_SYSERR;
- GNUNET_memcpy (&rec, &src[off], sizeof (rec));
+ GNUNET_memcpy (&rec,
+ &src[off],
+ sizeof (rec));
dest[i].expiration_time = GNUNET_ntohll (rec.expiration_time);
dest[i].data_size = ntohl ((uint32_t) rec.data_size);
dest[i].record_type = ntohl (rec.record_type);
* Attribute result callback
*/
GNUNET_IDENTITY_PROVIDER_AttributeResult ar_cb;
-
+
/**
* Revocation result callback
*/
it->finish_cb (it->finish_cb_cls);
free_it (it);
}
- if (NULL != op)
+ if (NULL != op)
{
if (NULL != op->ar_cb)
op->ar_cb (op->cls,
/**
- * List all attributes for a local identity.
+ * List all attributes for a local identity.
* This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle`
* for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and
* #GNUNET_IDENTITY_PROVIDER_get_attributes_stop. @a proc will be called once
GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET);
msg->id = htonl (rid);
msg->identity = *identity;
- memcpy (&msg[1],
- ticket,
- sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket));
+ GNUNET_memcpy (&msg[1],
+ ticket,
+ sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket));
if (NULL == h->mq)
op->env = env;
else
void *data)
{
char text[] = "pong";
+
*data_size = strlen(text)+1;
- memcpy(data, text, *data_size);
+ GNUNET_memcpy (data,
+ text,
+ *data_size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends (to all): %s\n", text);
struct pingpong_msg
{
int peer;
- enum pingpong msg;
+ enum pingpong msg;
};
static void service_connect (void *cls,
{
struct MulticastPeerContext *mc_peer = (struct MulticastPeerContext*)cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer #%u (%s) sent a join request.\n",
- mc_peer->peer,
+ "Peer #%u (%s) sent a join request.\n",
+ mc_peer->peer,
GNUNET_i2s (multicast_peers[mc_peer->peer]->id));
}
-static int
+static int
notify (void *cls,
size_t *data_size,
void *data)
*data_size = sizeof (struct pingpong_msg);
GNUNET_memcpy(data, pp_msg, *data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Peer #%u sents ping to origin\n", mc_peer->peer);
return GNUNET_YES;
const struct GNUNET_MessageHeader *join_msg)
{
struct MulticastPeerContext *mc_peer = (struct MulticastPeerContext*)cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer #%u (%s) received a decision from origin: %s\n",
- mc_peer->peer,
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Peer #%u (%s) received a decision from origin: %s\n",
+ mc_peer->peer,
GNUNET_i2s (multicast_peers[mc_peer->peer]->id),
(GNUNET_YES == is_admitted)?"accepted":"rejected");
-
+
if (GNUNET_YES == is_admitted)
{
GNUNET_MULTICAST_member_to_origin (members[mc_peer->peer],
0,
notify,
cls);
-
+
}
}
static void
-member_message (void *cls,
+member_message (void *cls,
const struct GNUNET_MULTICAST_MessageHeader *msg)
{
struct MulticastPeerContext *mc_peer = (struct MulticastPeerContext*)cls;
if (PONG == pp_msg->msg && mc_peer->peer == pp_msg->peer)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "peer #%i (%s) receives a pong\n",
+ "peer #%i (%s) receives a pong\n",
mc_peer->peer,
GNUNET_i2s (multicast_peers[mc_peer->peer]->id));
mc_peer->test_ok = GNUNET_OK;
uint8_t data_size = ntohs (join_msg->size);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"origin got a join request...\n");
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"origin receives: '%s'\n", (char *)&join_msg[1]);
char data[] = "Come in!";
join_resp->type = htons (123);
GNUNET_memcpy (&join_resp[1], data, data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"origin sends: '%s'\n", data);
GNUNET_MULTICAST_join_decision (jh,
uint64_t message_id,
uint64_t fragment_offset,
uint64_t flags,
- struct GNUNET_MULTICAST_ReplayHandle *rh)
+ struct GNUNET_MULTICAST_ReplayHandle *rh)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin replay msg\n");
static int
-origin_notify (void *cls,
- size_t *data_size,
+origin_notify (void *cls,
+ size_t *data_size,
void *data)
{
struct pingpong_msg *rcv_pp_msg = (struct pingpong_msg*)cls;
pp_msg->peer = rcv_pp_msg->peer;
pp_msg->msg = PONG;
*data_size = sizeof (struct pingpong_msg);
- memcpy(data, pp_msg, *data_size);
+ GNUNET_memcpy(data, pp_msg, *data_size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends pong\n");
- return GNUNET_YES;
+ return GNUNET_YES;
}
req++;
struct pingpong_msg *pp_msg = (struct pingpong_msg *) req;
-
+
if (1 != pp_msg->msg) {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "origin didn't reveice a correct request");
}
static void
origin_message (void *cls,
- const struct GNUNET_MULTICAST_MessageHeader *msg)
+ const struct GNUNET_MULTICAST_MessageHeader *msg)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin message msg\n");
}
{
group_key = GNUNET_CRYPTO_eddsa_key_create ();
GNUNET_CRYPTO_eddsa_key_get_public (group_key, &group_pub_key);
-
+
GNUNET_CRYPTO_hash (&group_pub_key, sizeof (group_pub_key), &group_pub_key_hash);
origin = GNUNET_MULTICAST_origin_start (cfg,
group_key,
{
multicast_peer->key = GNUNET_CRYPTO_ecdsa_key_create ();
- sprintf(data, "Hi, I am peer #%u (%s). Can I enter?",
+ sprintf(data, "Hi, I am peer #%u (%s). Can I enter?",
multicast_peer->peer,
GNUNET_i2s (multicast_peers[multicast_peer->peer]->id));
uint8_t data_size = strlen (data) + 1;
GNUNET_memcpy (&join_msg[1], data, data_size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Peer #%u (%s) tries to join multicast group %s\n",
+ "Peer #%u (%s) tries to join multicast group %s\n",
multicast_peer->peer,
GNUNET_i2s (multicast_peers[multicast_peer->peer]->id),
GNUNET_h2s (&group_pub_key_hash));
multicast_peers[mc_peer->peer]->id = pinfo->result.id;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Got peer information of %s (%s)\n",
- (0 == mc_peer->peer)? "origin" : "member",
+ "Got peer information of %s (%s)\n",
+ (0 == mc_peer->peer)? "origin" : "member",
GNUNET_i2s (pinfo->result.id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Create peer #%u (%s)\n",
+ "Create peer #%u (%s)\n",
mc_peer->peer,
GNUNET_i2s (multicast_peers[mc_peer->peer]->id));
/* connect to multicast service of members */
op[mc_peer->peer] =
GNUNET_TESTBED_service_connect (/* Closure for operation */
- NULL,
+ NULL,
/* The peer whose service to connect to */
peers[mc_peer->peer],
/* The name of the service */
if (NULL == ca_result)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Connection adapter not created for peer #%u (%s)\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Connection adapter not created for peer #%u (%s)\n",
mc_peer->peer,
GNUNET_i2s (multicast_peers[mc_peer->peer]->id));
if (0 == mc_peer->peer)
{
- // Get GNUnet identity of members
- for (int i = 0; i<PEERS_REQUESTED; i++)
+ // Get GNUnet identity of members
+ for (int i = 0; i<PEERS_REQUESTED; i++)
{
pi_op[i] = GNUNET_TESTBED_peer_get_information (peers[i],
GNUNET_TESTBED_PIT_IDENTITY,
* @param PEERS_REQUESTED size of the 'peers' array
* @param links_succeeded number of links between peers that were created
* @param links_failed number of links testbed was unable to establish
- */
+ */
static void
testbed_master (void *cls,
struct GNUNET_TESTBED_RunHandle *h,
multicast_peers = GNUNET_new_array (PEERS_REQUESTED, struct MulticastPeerContext*);
// Create test contexts for members
- for (int i = 0; i<PEERS_REQUESTED; i++)
+ for (int i = 0; i<PEERS_REQUESTED; i++)
{
multicast_peers[i] = GNUNET_new (struct MulticastPeerContext);
multicast_peers[i]->peer = i;
int ret;
char const *config_file;
- if (strstr (argv[0], "_line") != NULL)
+ if (strstr (argv[0], "_line") != NULL)
{
config_file = "test_multicast_line.conf";
}
{
config_file = "test_multicast_star.conf";
}
- else
+ else
{
config_file = "test_multicast_star.conf";
}
result = GNUNET_SYSERR;
ret =
GNUNET_TESTBED_test_run ("test-multicast-multipeer",
- config_file,
+ config_file,
/* number of peers to start */
- PEERS_REQUESTED,
+ PEERS_REQUESTED,
/* Event mask - set to 0 for no event notifications */
- 0LL,
+ 0LL,
/* Controller event callback */
- NULL,
+ NULL,
/* Closure for controller event callback */
- NULL,
+ NULL,
/* called when testbed setup is complete */
- testbed_master,
+ testbed_master,
/* Closure for the test_master callback */
- NULL);
+ NULL);
if ( (GNUNET_OK != ret) || (GNUNET_OK != result) )
return 1;
return 0;
sa);
sa->nc = nc;
sa->rsm = (const struct RecordStoreMessage *) &sa[1];
- memcpy (&sa[1],
- rp_msg,
- ntohs (rp_msg->gns_header.header.size));
+ GNUNET_memcpy (&sa[1],
+ rp_msg,
+ ntohs (rp_msg->gns_header.header.size));
sa->zm_pos = monitor_head;
sa->conv_name = conv_name;
GNUNET_array_grow (sa->rd,
sa->rd_count,
rd_clean_off);
- memcpy (sa->rd,
- rd_clean,
- sizeof (struct GNUNET_GNSRECORD_Data) * rd_clean_off);
+ GNUNET_memcpy (sa->rd,
+ rd_clean,
+ sizeof (struct GNUNET_GNSRECORD_Data) * rd_clean_off);
continue_store_activity (sa);
}
}
GNUNET_break (0);
return NULL;
}
- memcpy (label,
- req->hostname,
- dot - req->hostname);
+ GNUNET_memcpy (label,
+ req->hostname,
+ dot - req->hostname);
label[dot - req->hostname] = '\0';
return label;
}
GNUNET_free (rawp);
return NULL;
}
- memcpy (raw,
- rawp,
- *raw_size);
+ GNUNET_memcpy (raw,
+ rawp,
+ *raw_size);
GNUNET_free (rawp);
return raw;
}
req = GNUNET_malloc (sizeof (struct Request) + hlen);
req->zone = zone;
req->hostname = (char *) &req[1];
- memcpy (req->hostname,
- hostname,
- hlen);
+ GNUNET_memcpy (req->hostname,
+ hostname,
+ hlen);
req->id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
UINT16_MAX);
GNUNET_CRYPTO_hash (req->hostname,
ip_pkt.dst_ip = other->s_addr;
ip_pkt.checksum =
htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header)));
- memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header));
+ GNUNET_memcpy (&packet[off],
+ &ip_pkt,
+ sizeof (struct ip_header));
off += sizeof (struct ip_header);
icmp_pkt.type = ICMP_TIME_EXCEEDED;
icmp_pkt.code = 0;
icmp_pkt.checksum = 0;
icmp_pkt.unused = 0;
- memcpy (&packet[off], &icmp_pkt, sizeof (struct icmp_ttl_exceeded_header));
+ GNUNET_memcpy (&packet[off],
+ &icmp_pkt,
+ sizeof (struct icmp_ttl_exceeded_header));
off += sizeof (struct icmp_ttl_exceeded_header);
/* ip header of the presumably 'lost' udp packet */
ip_pkt.dst_ip = dummy.s_addr;
ip_pkt.checksum =
htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header)));
- memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header));
+ GNUNET_memcpy (&packet[off],
+ &ip_pkt,
+ sizeof (struct ip_header));
off += sizeof (struct ip_header);
/* build UDP header */
udp_pkt.dst_port = htons (NAT_TRAV_PORT);
udp_pkt.length = htons (port);
udp_pkt.crc = 0;
- memcpy (&packet[off], &udp_pkt, sizeof (struct udp_header));
+ GNUNET_memcpy (&packet[off],
+ &udp_pkt,
+ sizeof (struct udp_header));
off += sizeof (struct udp_header);
/* set ICMP checksum */
((uint16_t *) & packet[sizeof (struct ip_header)],
sizeof (struct icmp_ttl_exceeded_header) +
sizeof (struct ip_header) + sizeof (struct udp_header)));
- memcpy (&packet[sizeof (struct ip_header)], &icmp_pkt,
- sizeof (struct icmp_ttl_exceeded_header));
+ GNUNET_memcpy (&packet[sizeof (struct ip_header)],
+ &icmp_pkt,
+ sizeof (struct icmp_ttl_exceeded_header));
memset (&dst, 0, sizeof (dst));
dst.sin_family = AF_INET;
ip_pkt.dst_ip = other->s_addr;
ip_pkt.checksum =
htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header)));
- memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header));
+ GNUNET_memcpy (&packet[off],
+ &ip_pkt,
+ sizeof (struct ip_header));
off = sizeof (ip_pkt);
/* icmp reply: time exceeded */
icmp_ttl.code = 0;
icmp_ttl.checksum = 0;
icmp_ttl.unused = 0;
- memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header));
+ GNUNET_memcpy (&packet[off],
+ &icmp_ttl,
+ sizeof (struct icmp_ttl_exceeded_header));
off += sizeof (struct icmp_ttl_exceeded_header);
/* ip header of the presumably 'lost' udp packet */
ip_pkt.checksum = 0;
ip_pkt.checksum =
htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header)));
- memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header));
+ GNUNET_memcpy (&packet[off],
+ &ip_pkt,
+ sizeof (struct ip_header));
off += sizeof (struct ip_header);
icmp_echo.type = ICMP_ECHO;
icmp_echo.checksum = 0;
icmp_echo.checksum =
htons (calc_checksum
- ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header)));
- memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header));
+ ((uint16_t *) &icmp_echo, sizeof (struct icmp_echo_header)));
+ GNUNET_memcpy (&packet[off],
+ &icmp_echo,
+ sizeof (struct icmp_echo_header));
/* no go back to calculate ICMP packet checksum */
off = sizeof (struct ip_header);
((uint16_t *) & packet[off],
sizeof (struct icmp_ttl_exceeded_header) +
sizeof (struct ip_header) + sizeof (struct icmp_echo_header)));
- memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header));
+ GNUNET_memcpy (&packet[off],
+ &icmp_ttl,
+ sizeof (struct icmp_ttl_exceeded_header));
/* prepare for transmission */
memset (&dst, 0, sizeof (dst));
ip_pkt.checksum =
htons (calc_checksum ((uint16_t *) & ip_pkt,
sizeof (struct ip_header)));
- memcpy (&packet[off],
- &ip_pkt,
- sizeof (struct ip_header));
+ GNUNET_memcpy (&packet[off],
+ &ip_pkt,
+ sizeof (struct ip_header));
off += sizeof (struct ip_header);
icmp_echo.type = ICMP_ECHO;
htons (calc_checksum
((uint16_t *) & icmp_echo,
sizeof (struct icmp_echo_header)));
- memcpy (&packet[off],
- &icmp_echo,
- sizeof (struct icmp_echo_header));
+ GNUNET_memcpy (&packet[off],
+ &icmp_echo,
+ sizeof (struct icmp_echo_header));
off += sizeof (struct icmp_echo_header);
memset (&dst, 0, sizeof (dst));
return;
}
off = 0;
- memcpy (&ip_pkt, &buf[off], sizeof (struct ip_header));
+ GNUNET_memcpy (&ip_pkt,
+ &buf[off],
+ sizeof (struct ip_header));
off += sizeof (struct ip_header);
- memcpy (&icmp_ttl, &buf[off], sizeof (struct icmp_ttl_exceeded_header));
+ GNUNET_memcpy (&icmp_ttl,
+ &buf[off],
+ sizeof (struct icmp_ttl_exceeded_header));
off += sizeof (struct icmp_ttl_exceeded_header);
if ((ICMP_TIME_EXCEEDED != icmp_ttl.type) || (0 != icmp_ttl.code))
{
source_ip.s_addr = ip_pkt.src_ip;
/* skip 2nd IP header */
- memcpy (&ip_pkt, &buf[off], sizeof (struct ip_header));
+ GNUNET_memcpy (&ip_pkt,
+ &buf[off],
+ sizeof (struct ip_header));
off += sizeof (struct ip_header);
switch (ip_pkt.proto)
return;
}
/* grab ICMP ECHO content */
- memcpy (&icmp_echo, &buf[off], sizeof (struct icmp_echo_header));
+ GNUNET_memcpy (&icmp_echo,
+ &buf[off],
+ sizeof (struct icmp_echo_header));
port = (uint16_t) ntohl (icmp_echo.reserved);
break;
case IPPROTO_UDP:
return;
}
/* grab UDP content */
- memcpy (&udp_pkt, &buf[off], sizeof (struct udp_header));
+ GNUNET_memcpy (&udp_pkt,
+ &buf[off],
+ sizeof (struct udp_header));
port = ntohs (udp_pkt.length);
break;
default:
ch->hole_external);
/* build sockaddr storage with port number */
- memset (&ss, 0, sizeof (ss));
- memcpy (&ss, addr, addrlen);
+ memset (&ss,
+ 0,
+ sizeof (ss));
+ GNUNET_memcpy (&ss,
+ addr,
+ addrlen);
switch (addr->sa_family)
{
case AF_INET:
size_t array_size;
array_size = sizeof(struct RegexCombineCtx *) * src->size;
- memcpy (dst->children,
- src->children,
- array_size);
+ GNUNET_memcpy (dst->children,
+ src->children,
+ array_size);
for (unsigned int i = 0; i < src->size; i++)
{
src->children[i] = NULL;
newctx = new_regex_ctx(ctx->size);
newctx->s = GNUNET_strdup (tmp);
if (children != NULL)
- memcpy (newctx->children, children, sizeof (*children) * ctx->size);
+ GNUNET_memcpy (newctx->children,
+ children,
+ sizeof (*children) * ctx->size);
ctx->children[c2i(tmp[0], ctx->size)] = newctx;
}
}
* @param a
* @param b
*
- * @return
+ * @return
*/
static int is_in_view (uint32_t a, uint32_t b)
{
rps_peer->cur_view_count,
view_size);
//*rps_peer->cur_view = *peers;
- memcpy (rps_peer->cur_view,
- peers,
- view_size * sizeof (struct GNUNET_PeerIdentity));
+ GNUNET_memcpy (rps_peer->cur_view,
+ peers,
+ view_size * sizeof (struct GNUNET_PeerIdentity));
to_file ("/tmp/rps/count_in_views.txt",
"%" PRIu64 " %" PRIu32 "",
rps_peer->index,
int rc;
int key_len;
unsigned char* key_buf;
-
+
key_len = element_length_in_bytes(k) < 33 ? 3 : element_length_in_bytes(k);
key_buf = (unsigned char*) malloc(key_len);
element_to_bytes(key_buf, k);
- memcpy (key->aes_key, key_buf, GNUNET_CRYPTO_AES_KEY_LENGTH);
+ GNUNET_memcpy (key->aes_key,
+ key_buf,
+ GNUNET_CRYPTO_AES_KEY_LENGTH);
GNUNET_assert (0 ==
gcry_cipher_open (handle, GCRY_CIPHER_AES256,
GCRY_CIPHER_MODE_CFB, 0));
unsigned char iv[16];
char* tmp;
uint32_t len;
-
+
init_aes(k, 1, &handle, &skey, iv);
tmp = GNUNET_malloc (size);
//AES_cbc_encrypt(ct->data, pt->data, ct->len, &key, iv, AES_DECRYPT);
- GNUNET_assert (0 == gcry_cipher_decrypt (handle, tmp, size, ct, size));
+ GNUNET_assert (0 == gcry_cipher_decrypt (handle, tmp, size, ct, size));
gcry_cipher_close (handle);
/* TODO make less crufty */
-
+
/* get real length */
len = 0;
len = len
struct GNUNET_CRYPTO_AbeKey *prv_key;
int size;
char *tmp;
-
+
prv_key = GNUNET_new (struct GNUNET_CRYPTO_AbeKey);
prv_key->prv = gabe_keygen(key->pub, key->msk, attrs);
size = gabe_pub_serialize(key->pub, &tmp);
{
char *ptr;
uint32_t *len;
-
+
*result = GNUNET_malloc (12 + cph_buf_len + aes_buf_len);
ptr = *result;
len = (uint32_t*) ptr;
len = (uint32_t*) ptr;
*len = htonl (aes_buf_len);
ptr += 4;
- memcpy (ptr, aes_buf, aes_buf_len);
+ GNUNET_memcpy (ptr, aes_buf, aes_buf_len);
ptr += aes_buf_len;
len = (uint32_t*) ptr;
*len = htonl (cph_buf_len);
ptr += 4;
- memcpy (ptr, cph_buf, cph_buf_len);
+ GNUNET_memcpy (ptr, cph_buf, cph_buf_len);
return 12 + cph_buf_len + aes_buf_len;
}
*aes_buf_len = ntohl (*len);
ptr += 4;
*aes_buf = GNUNET_malloc (*aes_buf_len);
- memcpy(*aes_buf, ptr, *aes_buf_len);
+ GNUNET_memcpy (*aes_buf, ptr, *aes_buf_len);
ptr += *aes_buf_len;
len = (uint32_t*)ptr;
*cph_buf_len = ntohl (*len);
ptr += 4;
*cph_buf = GNUNET_malloc (*cph_buf_len);
- memcpy(*cph_buf, ptr, *cph_buf_len);
+ GNUNET_memcpy (*cph_buf, ptr, *cph_buf_len);
return buf_len;
}
&prv_len);
key->pub = gabe_pub_unserialize (pub, pub_len);
key->prv = gabe_prv_unserialize (key->pub, prv, prv_len);
-
+
GNUNET_free (pub);
GNUNET_free (prv);
return key;
&msk_len);
key->pub = gabe_pub_unserialize (pub, pub_len);
key->msk = gabe_msk_unserialize (key->pub, msk, msk_len);
-
+
GNUNET_free (pub);
GNUNET_free (msk);