WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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/>.
*/
#endif
if ( (GNUNET_YES != abstract) &&
(GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (unixpath)) )
+ GNUNET_DISK_directory_create_for_file (unixpath)) )
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"mkdir",
unixpath);
check_start (void *cls,
const struct GNUNET_ARM_Message *amsg)
{
- uint16_t size;
- const char *servicename;
-
(void) cls;
- size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
- servicename = (const char *) &amsg[1];
- if ( (0 == size) ||
- (servicename[size - 1] != '\0') )
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (amsg);
return GNUNET_OK;
}
check_stop (void *cls,
const struct GNUNET_ARM_Message *amsg)
{
- uint16_t size;
- const char *servicename;
-
(void) cls;
- size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
- servicename = (const char *) &amsg[1];
- if ( (0 == size) ||
- (servicename[size - 1] != '\0') )
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (amsg);
return GNUNET_OK;
}
* Task triggered whenever we receive a SIGCHLD (child
* process died).
*
- * @param cls closure, NULL
+ * @param cls closure, NULL
*/
static void
maint_child_death (void *cls)
start_system = GNUNET_CONFIGURATION_get_value_yesno (cfg,
"ARM",
"START_SYSTEM_SERVICES");
- if ( (GNUNET_NO == start_user) &&
+ if ( (GNUNET_NO == start_user) &&
(GNUNET_NO == start_system) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
};
+
+/**
+ * Convert ATS properties from host to network byte order.
+ *
+ * @param nbo[OUT] value written
+ * @param hbo value read
+ */
+static void
+properties_hton (struct PropertiesNBO *nbo,
+ const struct GNUNET_ATS_Properties *hbo)
+{
+ nbo->delay = GNUNET_TIME_relative_hton (hbo->delay);
+ nbo->goodput_out = htonl (hbo->goodput_out);
+ nbo->goodput_in = htonl (hbo->goodput_in);
+ nbo->utilization_out = htonl (hbo->utilization_out);
+ nbo->utilization_in = htonl (hbo->utilization_in);
+ nbo->distance = htonl (hbo->distance);
+ nbo->mtu = htonl (hbo->mtu);
+ nbo->nt = htonl ((uint32_t) hbo->nt);
+ nbo->cc = htonl ((uint32_t) hbo->cc);
+}
+
+
/**
* Re-establish the connection to the ATS service.
*
(void) pid;
if (fc->session_id == sr->slot)
- {
- fc->sr = sr;
- return GNUNET_NO;
- }
+ {
+ fc->sr = sr;
+ return GNUNET_NO;
+ }
return GNUNET_YES;
}
: GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD);
m->peer = ar->pid;
m->session_id = htonl (ar->slot);
- // FIXME: convert endianess here!
- // m->properties = ar->properties;
+ properties_hton (&m->properties,
+ &ar->properties);
GNUNET_memcpy (&m[1],
ar->address,
alen);
alen = strlen (address) + 1;
ar = GNUNET_malloc (sizeof (struct GNUNET_ATS_SessionRecord) + alen);
ar->ath = ath;
- ar->slot = 42; // FIXME: make up unique number!
+ ar->slot = s;
ar->session = session;
ar->address = (const char *) &ar[1];
ar->pid = *pid;
GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE);
m->session_id = htonl (ar->slot);
m->peer = ar->pid;
- // FIXME: convert endianess here!
- // m->properties = ar->properties;
+ properties_hton (&m->properties,
+ &ar->properties);
GNUNET_MQ_send (ath->mq,
ev);
}
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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/>.
*/
check_client_index_start (void *cls,
const struct IndexStartMessage *ism)
{
- uint16_t msize;
char *fn;
- msize = ntohs (ism->header.size);
- if (((const char *) ism)[msize - 1] != '\0')
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (ism);
if (0 != ism->reserved)
{
GNUNET_break (0);
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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/>.
*/
check_lookup (void *cls,
const struct LookupMessage *l_msg)
{
- size_t msg_size;
- const char* name;
+ size_t nlen;
(void) cls;
- msg_size = ntohs (l_msg->header.size);
- if (msg_size < sizeof (struct LookupMessage))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- name = (const char *) &l_msg[1];
- if ( ('\0' != name[msg_size - sizeof (struct LookupMessage) - 1]) ||
- (strlen (name) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) )
+ GNUNET_MQ_check_zero_termination (l_msg);
+ nlen = ntohs (l_msg->header.size) - sizeof (struct LookupMessage);
+ if (nlen > GNUNET_DNSPARSER_MAX_NAME_LENGTH)
{
GNUNET_break (0);
return GNUNET_SYSERR;
{
uint32_t name_len;
size_t src_size;
- const char *name_tmp;
(void) cls;
name_len = ntohl (ll_msg->label_len);
GNUNET_break (0);
return GNUNET_SYSERR;
}
-
- name_tmp = (const char *) &ll_msg[1];
- if ('\0' != name_tmp[name_len -1])
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (ll_msg);
return GNUNET_OK;
}
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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/>.
*/
const struct AnnounceMessage *am)
{
struct ClientEntry *ce = cls;
- const char *regex;
- uint16_t size;
- size = ntohs (am->header.size) - sizeof (*am);
- regex = (const char *) &am[1];
- if ('\0' != regex[size - 1])
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (am);
if (NULL != ce->ah)
{
/* only one announcement per client allowed */
const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
{
struct TransportClient *tc = cls;
- const char *addr;
uint16_t size;
if (CT_NONE != tc->type)
size = ntohs (cam->header.size) - sizeof (*cam);
if (0 == size)
return GNUNET_OK; /* receive-only communicator */
- addr = (const char *) &cam[1];
- if ('\0' != addr[size-1])
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (cam);
return GNUNET_OK;
}
const struct GNUNET_TRANSPORT_AddAddressMessage *aam)
{
struct TransportClient *tc = cls;
- const char *addr;
- uint16_t size;
if (CT_COMMUNICATOR != tc->type)
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
- size = ntohs (aam->header.size) - sizeof (*aam);
- if (0 == size)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- addr = (const char *) &aam[1];
- if ('\0' != addr[size-1])
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (aam);
return GNUNET_OK;
}
const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
{
struct TransportClient *tc = cls;
- const char *addr;
- uint16_t size;
if (CT_COMMUNICATOR != tc->type)
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
- size = ntohs (aqm->header.size) - sizeof (*aqm);
- if (0 == size)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- addr = (const char *) &aqm[1];
- if ('\0' != addr[size-1])
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (aqm);
return GNUNET_OK;
}
return -1;
}
if ((size_t) bytes_read > SIZE_MAX)
- {
+ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"/etc/resolv.conf file too large to mmap. "
"DNS resolution will not be possible.\n");
GNUNET_DISK_file_close (fh);
- return -1;
+ return -1;
}
buf = GNUNET_DISK_file_map (fh,
&mh,
pos);
GNUNET_DNSPARSER_free_record (pos->record);
GNUNET_free (pos->record);
- GNUNET_free (pos);
+ GNUNET_free (pos);
}
}
if (NULL == rc->records_head)
struct GNUNET_SERVICE_Client *client)
{
char fqdn[255];
-
+
if ( (NULL != my_domain) &&
(NULL == strchr (hostname,
(unsigned char) '.')) &&
sizeof (fqdn),
"%s.%s",
hostname,
- my_domain);
+ my_domain);
}
else if (strlen (hostname) < 255)
{
direction = ntohl (get->direction);
if (GNUNET_NO == direction)
{
- /* IP from hostname */
- const char *hostname;
-
- hostname = (const char *) &get[1];
- if (hostname[size - 1] != '\0')
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_zero_termination (get);
return GNUNET_OK;
}
af = ntohl (get->af);
/**
- * Add information about a host from /etc/hosts
+ * Add information about a host from /etc/hosts
* to our cache.
*
* @param hostname the name of the host
rec = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_Record));
rec->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS;
rec->type = rec_type;
- rec->dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
+ rec->dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
rec->name = GNUNET_strdup (hostname);
rec->data.raw.data = GNUNET_memdup (data,
data_size);
/**
* Extract host information from a line in /etc/hosts
- *
+ *
* @param line the line to parse
* @param line_len number of bytes in @a line
*/
return;
}
if ((size_t) bytes_read > SIZE_MAX)
- {
+ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"/etc/hosts file too large to mmap. "
"DNS resolution will not be possible.\n");
GNUNET_DISK_file_close (fh);
- return;
+ return;
}
buf = GNUNET_DISK_file_map (fh,
&mh,