Example #1
0
File: sms.c Project: agustim/bmx6
STATIC_FUNC
int create_description_sms(struct tx_frame_iterator *it)
{

        struct avl_node *an = NULL;
        struct json_sms *sms;

        uint8_t *data = tx_iterator_cache_msg_ptr(it);
        uint16_t max_size = tx_iterator_cache_data_space_max(it);
        int pos = 0;

        while ((sms = avl_iterate_item(&json_sms_tree, &an))) {

                if (pos + sizeof (struct description_msg_sms) + sms->text_len > max_size) {
                        dbgf_sys(DBGT_ERR, "Failed adding descriptionSms=%s/%s", smsTx_dir, sms->name);
                        continue;
                }

                struct description_msg_sms *msg = (struct description_msg_sms*) (data + pos);

                memset(msg, 0, sizeof (struct description_msg_sms));
                strcpy(msg->name, sms->name);
                msg->text_len = htons(sms->text_len);
                memcpy(msg->text, sms->text, sms->text_len);

                pos += (sizeof (struct description_msg_sms) + sms->text_len);

                dbgf_track(DBGT_INFO, "added descriptionSms=%s/%s text_len=%d total_len=%d",
                        smsTx_dir, sms->name, sms->text_len, pos);

        }


        return pos;
}
Example #2
0
File: topology.c Project: axn/bmx6
STATIC_FUNC
int create_description_topology(struct tx_frame_iterator *it)
{
        struct avl_node *local_it = NULL;
        struct local_node *local;
        int32_t m = 0;

	struct description_msg_topology *msg = (struct description_msg_topology *) tx_iterator_cache_msg_ptr(it);

	destroy_local_topology_cache();

	if (my_topology_period >= MAX_TOPOLOGY_PERIOD)
		return TLV_TX_DATA_IGNORED;

	task_remove(check_local_topology_cache, NULL);
	task_register(my_topology_period, check_local_topology_cache, NULL, -300000);


        while ((local = avl_iterate_item(&local_tree, &local_it)) && m < tx_iterator_cache_msg_space_max(it)) {

		if (local->neigh && local->neigh->dhn->on && local->best_tp_lndev) {

			struct local_topology_node *ltn = debugMallocReset(sizeof(struct local_topology_node), -300000);

			set_local_topology_node(ltn, local);
			ltn->pkid = local->neigh->dhn->on->global_id.pkid;
			avl_insert(&local_topology_tree, ltn, -300000);

			msg[m].pkid = ltn->pkid;
			msg[m].txBw = umetric_to_fmu8( &ltn->txBw);
			msg[m].rxBw = umetric_to_fmu8(&ltn->rxBw);
			msg[m].txRate = ltn->txRate;
			msg[m].rxRate = ltn->rxRate;

			msg[m].type = 0;
			msg[m].reserved = 0;


			m++;
		}
        }

	if (m)
		return m * sizeof(struct description_msg_topology);

        return TLV_TX_DATA_IGNORED;
}