/*
This file is part of GNUnet
- (C) 2010-2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2014 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
return NULL;
}
memcpy (&dcert, &udp_payload[*off], sizeof (struct GNUNET_TUN_DnsCertRecord));
- (*off) += sizeof (sizeof (struct GNUNET_TUN_DnsCertRecord));
+ (*off) += sizeof (struct GNUNET_TUN_DnsCertRecord);
cert = GNUNET_new (struct GNUNET_DNSPARSER_CertRecord);
cert->cert_type = ntohs (dcert.cert_type);
cert->cert_tag = ntohs (dcert.cert_tag);
GNUNET_DNSPARSER_bin_to_hex (const void *data,
size_t data_size)
{
- GNUNET_break (0); // FIXME: not implemented
- return NULL;
+ char *ret;
+ size_t off;
+ const uint8_t *idata;
+
+ idata = data;
+ ret = GNUNET_malloc (data_size * 2 + 1);
+ for (off = 0; off < data_size; off++)
+ sprintf (&ret[off * 2],
+ "%02x",
+ idata[off]);
+ return ret;
}
GNUNET_DNSPARSER_hex_to_bin (const char *hex,
void *data)
{
- GNUNET_break (0); // FIXME: not implemented
- return 0;
+ size_t data_size;
+ size_t off;
+ uint8_t *idata;
+ unsigned int h;
+ char in[3];
+
+ data_size = strlen (hex) / 2;
+ idata = data;
+ in[2] = '\0';
+ for (off = 0; off < data_size; off++)
+ {
+ in[0] = tolower ((int) hex[off * 2]);
+ in[1] = tolower ((int) hex[off * 2 + 1]);
+ if (1 != sscanf (in, "%x", &h))
+ return off;
+ idata[off] = (uint8_t) h;
+ }
+ return off;
}
-
/* end of dnsparser.c */