This file is part of GNUnet.
Copyright (C) 2013, 2016 GNUnet e.V.
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public Liceidentity as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public Liceidentity for more details.
-
- You should have received a copy of the GNU General Public Liceidentity
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*/
static int
check_identity_result_code (void *cls,
- const struct GNUNET_IDENTITY_ResultCodeMessage *rcm)
+ const struct ResultCodeMessage *rcm)
{
uint16_t size = ntohs (rcm->header.size) - sizeof (*rcm);
const char *str = (const char *) &rcm[1];
if (0 == size)
return GNUNET_OK;
- if ('\0' != str[size - sizeof (*rcm) - 1])
+ if ('\0' != str[size - 1])
{
GNUNET_break (0);
return GNUNET_SYSERR;
*/
static void
handle_identity_result_code (void *cls,
- const struct GNUNET_IDENTITY_ResultCodeMessage *rcm)
+ const struct ResultCodeMessage *rcm)
{
struct GNUNET_IDENTITY_Handle *h = cls;
struct GNUNET_IDENTITY_Operation *op;
*/
static int
check_identity_update (void *cls,
- const struct GNUNET_IDENTITY_UpdateMessage *um)
+ const struct UpdateMessage *um)
{
uint16_t size = ntohs (um->header.size);
uint16_t name_len = ntohs (um->name_len);
const char *str = (const char *) &um[1];
- if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) ||
+ if ( (size != name_len + sizeof (struct UpdateMessage)) ||
( (0 != name_len) &&
('\0' != str[name_len - 1])) )
{
*/
static void
handle_identity_update (void *cls,
- const struct GNUNET_IDENTITY_UpdateMessage *um)
+ const struct UpdateMessage *um)
{
struct GNUNET_IDENTITY_Handle *h = cls;
uint16_t name_len = ntohs (um->name_len);
*/
static int
check_identity_set_default (void *cls,
- const struct GNUNET_IDENTITY_SetDefaultMessage *sdm)
+ const struct SetDefaultMessage *sdm)
{
- uint16_t size = ntohs (sdm->header.size);
+ uint16_t size = ntohs (sdm->header.size) - sizeof (*sdm);
uint16_t name_len = ntohs (sdm->name_len);
const char *str = (const char *) &sdm[1];
- if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) ||
+ if ( (size != name_len) ||
( (0 != name_len) &&
('\0' != str[name_len - 1]) ) )
{
*/
static void
handle_identity_set_default (void *cls,
- const struct GNUNET_IDENTITY_SetDefaultMessage *sdm)
+ const struct SetDefaultMessage *sdm)
{
struct GNUNET_IDENTITY_Handle *h = cls;
struct GNUNET_IDENTITY_Operation *op;
static void
reconnect (void *cls)
{
- GNUNET_MQ_hd_var_size (identity_result_code,
- GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
- struct GNUNET_IDENTITY_ResultCodeMessage);
- GNUNET_MQ_hd_var_size (identity_update,
- GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE,
- struct GNUNET_IDENTITY_UpdateMessage);
- GNUNET_MQ_hd_var_size (identity_set_default,
- GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT,
- struct GNUNET_IDENTITY_SetDefaultMessage);
struct GNUNET_IDENTITY_Handle *h = cls;
struct GNUNET_MQ_MessageHandler handlers[] = {
- make_identity_result_code_handler (h),
- make_identity_update_handler (h),
- make_identity_set_default_handler (h),
+ GNUNET_MQ_hd_var_size (identity_result_code,
+ GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
+ struct ResultCodeMessage,
+ h),
+ GNUNET_MQ_hd_var_size (identity_update,
+ GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE,
+ struct UpdateMessage,
+ h),
+ GNUNET_MQ_hd_var_size (identity_set_default,
+ GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT,
+ struct SetDefaultMessage,
+ h),
GNUNET_MQ_handler_end ()
};
struct GNUNET_MQ_Envelope *env;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to identity service.\n");
GNUNET_assert (NULL == h->mq);
- h->mq = GNUNET_CLIENT_connecT (h->cfg,
+ h->mq = GNUNET_CLIENT_connect (h->cfg,
"identity",
handlers,
&mq_error_handler,
{
struct GNUNET_IDENTITY_Operation *op;
struct GNUNET_MQ_Envelope *env;
- struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
+ struct GetDefaultMessage *gdm;
size_t slen;
if (NULL == h->mq)
return NULL;
slen = strlen (service_name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage))
{
GNUNET_break (0);
return NULL;
GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
gdm->name_len = htons (slen);
gdm->reserved = htons (0);
- memcpy (&gdm[1],
+ GNUNET_memcpy (&gdm[1],
service_name,
slen);
GNUNET_MQ_send (h->mq,
{
struct GNUNET_IDENTITY_Operation *op;
struct GNUNET_MQ_Envelope *env;
- struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
+ struct SetDefaultMessage *sdm;
size_t slen;
if (NULL == h->mq)
return NULL;
slen = strlen (service_name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage))
{
GNUNET_break (0);
return NULL;
sdm->name_len = htons (slen);
sdm->reserved = htons (0);
sdm->private_key = *ego->pk;
- memcpy (&sdm[1],
+ GNUNET_memcpy (&sdm[1],
service_name,
slen);
GNUNET_MQ_send (h->mq,
{
struct GNUNET_IDENTITY_Operation *op;
struct GNUNET_MQ_Envelope *env;
- struct GNUNET_IDENTITY_CreateRequestMessage *crm;
+ struct CreateRequestMessage *crm;
struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
size_t slen;
if (NULL == h->mq)
return NULL;
slen = strlen (name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage))
{
GNUNET_break (0);
return NULL;
pk = GNUNET_CRYPTO_ecdsa_key_create ();
crm->private_key = *pk;
GNUNET_free (pk);
- memcpy (&crm[1],
+ GNUNET_memcpy (&crm[1],
name,
slen);
GNUNET_MQ_send (h->mq,
{
struct GNUNET_IDENTITY_Operation *op;
struct GNUNET_MQ_Envelope *env;
- struct GNUNET_IDENTITY_RenameMessage *grm;
+ struct RenameMessage *grm;
size_t slen_old;
size_t slen_new;
char *dst;
return NULL;
slen_old = strlen (old_name) + 1;
slen_new = strlen (new_name) + 1;
- if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
+ if ( (slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
+ (slen_old + slen_new >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage)) )
{
GNUNET_break (0);
return NULL;
grm->old_name_len = htons (slen_old);
grm->new_name_len = htons (slen_new);
dst = (char *) &grm[1];
- memcpy (dst,
+ GNUNET_memcpy (dst,
old_name,
slen_old);
- memcpy (&dst[slen_old],
+ GNUNET_memcpy (&dst[slen_old],
new_name,
slen_new);
GNUNET_MQ_send (h->mq,
{
struct GNUNET_IDENTITY_Operation *op;
struct GNUNET_MQ_Envelope *env;
- struct GNUNET_IDENTITY_DeleteMessage *gdm;
+ struct DeleteMessage *gdm;
size_t slen;
if (NULL == h->mq)
return NULL;
slen = strlen (name) + 1;
- if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
+ if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage))
{
GNUNET_break (0);
return NULL;
GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
gdm->name_len = htons (slen);
gdm->reserved = htons (0);
- memcpy (&gdm[1],
+ GNUNET_memcpy (&gdm[1],
name,
slen);
GNUNET_MQ_send (h->mq,