예제 #1
0
void msg_release_stat_msg(adm_stat_msg_t *msg)
{
	AMP_DEBUG_ENTRY("msg_release_stat_msg","(0x%x)",
			          (unsigned long) msg);

	if(msg != NULL)
	{
		mid_release(msg->code);
		midcol_destroy(&(msg->generators));
		SRELEASE(msg);
	}

	AMP_DEBUG_EXIT("msg_release_stat_msg","->.",NULL);
}
예제 #2
0
파일: mid.c 프로젝트: brnrc/ion-dtn
/******************************************************************************
 *
 * \par Function Name: midcol_copy
 *
 * \par Purpose: Copies a MID collection
 *
 * \retval  NULL - Failure
 *         !NULL - The copied MID collection
 *
 * \param[in]  mids  MID collection to be copied.
 *
 * \par Notes:
 *		1. This is a deep copy.
 *
 * Modification History:
 *  MM/DD/YY  AUTHOR         DESCRIPTION
 *  --------  ------------   ---------------------------------------------
 *  11/14/12  E. Birrane     Initial implementation,
 *****************************************************************************/
Lyst midcol_copy(Lyst mids)
{
	Lyst result = NULL;
	LystElt elt;
	mid_t *cur_mid = NULL;
	mid_t *new_mid = NULL;

	DTNMP_DEBUG_ENTRY("midcol_copy","(%#llx)",(unsigned long) mids);

	/* Step 0: Sanity Check. */
	if(mids == NULL)
	{
		DTNMP_DEBUG_ERR("midcol_copy","Bad Args.",NULL);
		DTNMP_DEBUG_EXIT("midcol_copy","->NULL.",NULL);
		return NULL;
	}

	/* Build the Lyst. */
	if((result = lyst_create()) == NULL)
	{
		DTNMP_DEBUG_ERR("midcol_copy","Unable to create lyst.",NULL);
		DTNMP_DEBUG_EXIT("midcol_copy","->NULL.",NULL);
		return NULL;
	}

	/* Walking copy. */
	int success = 1;
	for(elt = lyst_first(mids); elt; elt = lyst_next(elt))
	{
		cur_mid = (mid_t *) lyst_data(elt);
		if((new_mid = mid_copy(cur_mid)) == NULL)
		{
			DTNMP_DEBUG_ERR("midcol_copy","Fsiled to copy MID.",NULL);
			midcol_destroy(&result);

			DTNMP_DEBUG_EXIT("midcol_copy","->NULL.",NULL);
			return NULL;
		}
		else
		{
			lyst_insert_last(result,mid_copy(cur_mid));
		}
	}

	DTNMP_DEBUG_EXIT("midcol_copy","->%#llx.",(unsigned long) result);
	return result;
}
예제 #3
0
파일: report.c 프로젝트: brnrc/ion-dtn
void rpt_release_defs(rpt_defs_t *msg)
{
	DTNMP_DEBUG_ENTRY("rpt_release_defs","(0x%x)",
			          (unsigned long) msg);

	if(msg != NULL)
	{
		if(msg->defs != NULL)
		{
			midcol_destroy(&(msg->defs));
		}

		MRELEASE(msg);
	}

	DTNMP_DEBUG_EXIT("rpt_release_defs","->.",NULL);
}
예제 #4
0
파일: report.c 프로젝트: brnrc/ion-dtn
/* Release functions.*/
void rpt_release_lst(rpt_items_t *msg)
{

	DTNMP_DEBUG_ENTRY("rpt_release_lst","(0x%x)",
			          (unsigned long) msg);

	if(msg != NULL)
	{
		if(msg->contents != NULL)
		{
			midcol_destroy(&(msg->contents));
		}
		MRELEASE(msg);
	}

	DTNMP_DEBUG_EXIT("rpt_release_lst","->.",NULL);
}
예제 #5
0
파일: mid.c 프로젝트: brnrc/ion-dtn
/******************************************************************************
 *
 * \par Function Name: midcol_deserialize
 *
 * \par Purpose: Deserialize a MID collection into a Lyst.
 *
 * \retval NULL - Failure
 *        !NULL - The created Lyst.
 *
 * \param[in]  buffer      The buffer holding the MC.
 * \param[in]  buffer_size The size of the buffer, in bytes.
 * \param[out] bytes_used  The # bytes consumed in the deserialization.
 *
 * \par Notes:
 *		1. The created Lyst must be freed when done.
 *		2. Reminder: A Lyst is a pointer to a LystStruct.
 *
 * Modification History:
 *  MM/DD/YY  AUTHOR         DESCRIPTION
 *  --------  ------------   ---------------------------------------------
 *  11/14/12  E. Birrane     Initial implementation,
 *  06/17/13  E. Birrane     Updated to ION 3.1.3, moved to uvast
 *****************************************************************************/
Lyst midcol_deserialize(unsigned char *buffer,
		                uint32_t buffer_size,
		                uint32_t *bytes_used)
{
	unsigned char *cursor = NULL;
	Lyst result = NULL;
	uint32_t bytes = 0;
	uvast num = 0;
	mid_t *cur_mid = NULL;
	uint32_t i = 0;

	DTNMP_DEBUG_ENTRY("midcol_deserialize","(%#llx,%d,%#llx)",
			          (unsigned long) buffer, buffer_size,
			          (unsigned long) bytes_used);

	/* Step 0: Sanity Check. */
	if((buffer == NULL) || (buffer_size == 0) || (bytes_used == NULL))
	{
		DTNMP_DEBUG_ERR("mid_deserialize_mc","Bad Args", NULL);
		DTNMP_DEBUG_EXIT("mid_deserialize_mc","->NULL",NULL);
		return NULL;
	}

	*bytes_used = 0;
	cursor = buffer;

	/* Step 1: Create the Lyst. */
	if((result = lyst_create()) == NULL)
	{
		DTNMP_DEBUG_ERR("midcol_deserialize","Can't create lyst.", NULL);
		DTNMP_DEBUG_EXIT("midcol_deserialize","->NULL",NULL);
		return NULL;
	}

	/* Step 2: Grab # MIDs in the collection. */
	if((bytes = utils_grab_sdnv(cursor, buffer_size, &num)) == 0)
	{
		DTNMP_DEBUG_ERR("midcol_deserialize","Can't parse SDNV.", NULL);
		lyst_destroy(result);

		DTNMP_DEBUG_EXIT("midcol_deserialize","->NULL",NULL);
		return NULL;
	}
	else
	{
		cursor += bytes;
		buffer_size -= bytes;
		*bytes_used += bytes;
	}

	/* Step 3: Grab Mids. */
	for(i = 0; i < num; i++)
	{
		/* Deserialize ith MID. */
		if((cur_mid = mid_deserialize(cursor, buffer_size, &bytes)) == NULL)
		{
			DTNMP_DEBUG_ERR("mid_deserialize_mc","Can't grab MID #%d.", i);
			midcol_destroy(&result);

			DTNMP_DEBUG_EXIT("mid_deserialize_mc","->NULL",NULL);
			return NULL;
		}
		else
		{
			cursor += bytes;
			buffer_size -= bytes;
			*bytes_used += bytes;
		}

		/* Drop it in the lyst in order. */
		lyst_insert_last(result, cur_mid);
	}

	DTNMP_DEBUG_EXIT("midcol_deserialize","->%#llx",(unsigned long)result);
	return result;
}
예제 #6
0
void ui_print_val(uint8_t type, uint8_t *data, uint32_t length)
{
	uint32_t bytes = 0;

	if(data == NULL)
	{
		printf("NULL");
		return;
	}



	switch(type)
	{
		case AMP_TYPE_VAR:
		{
			var_t *cd = var_deserialize(data, length, &bytes);
			char *str = var_to_string(cd);
			printf("%s", str);
			SRELEASE(str);
			var_release(cd);
		}
			break;

		case AMP_TYPE_INT:
			printf("%d", utils_deserialize_int(data, length, &bytes));
			break;

		case AMP_TYPE_TS:
		case AMP_TYPE_UINT:
			printf("%d", utils_deserialize_uint(data, length, &bytes));
			break;

		case AMP_TYPE_VAST:
			printf(VAST_FIELDSPEC, utils_deserialize_vast(data, length, &bytes));
			break;

		case AMP_TYPE_SDNV:
		case AMP_TYPE_UVAST:
			printf(UVAST_FIELDSPEC, utils_deserialize_uvast(data, length, &bytes));
			break;

		case AMP_TYPE_REAL32:
			printf("%f", utils_deserialize_real32(data, length, &bytes));
			break;

		case AMP_TYPE_REAL64:
			printf("%f", utils_deserialize_real64(data, length, &bytes));
			break;

		case AMP_TYPE_STRING:
			{
				char* tmp = NULL;
				tmp = utils_deserialize_string(data, length, &bytes);
				printf("%s", tmp);
				SRELEASE(tmp);
			}
			break;

		case AMP_TYPE_BLOB:
			{
				blob_t *blob = blob_deserialize(data, length, &bytes);
				char *str = blob_to_str(blob);
				printf("%s", str);
				SRELEASE(str);
				SRELEASE(blob);
			}
			break;

		case AMP_TYPE_DC:
			{
				uint32_t bytes = 0;
				Lyst dc = dc_deserialize(data, length, &bytes);
				ui_print_dc(dc);
				dc_destroy(&dc);
			}
			break;

		case AMP_TYPE_MID:
			{
				uint32_t bytes = 0;
				mid_t *mid = mid_deserialize(data, length, &bytes);
				ui_print_mid(mid);
				mid_release(mid);
			}
			break;

		case AMP_TYPE_MC:
			{
				uint32_t bytes = 0;
				Lyst mc = midcol_deserialize(data, length, &bytes);
				ui_print_mc(mc);
				midcol_destroy(&mc);
			}
			break;
			// \todo: Expression has no priority. Need to re-think priority.

		case AMP_TYPE_EXPR:
			{
				uint32_t bytes = 0;
				expr_t *expr = expr_deserialize(data, length, &bytes);
				ui_print_expr(expr);
				expr_release(expr);
			}
			break;

/*		case DTNMP_TYPE_DEF:
			{
				uint32_t bytes = 0;
				def_gen_t *def = def_deserialize_gen(data, length, &bytes);
				ui_print_def(def);
				def_release_gen(def);
			}
			break;
*/
		case AMP_TYPE_TRL:
			{
				uint32_t bytes = 0;
				trl_t *trl = trl_deserialize(data, length, &bytes);
				ui_print_trl(trl);
				trl_release(trl);
			}
			break;

		case AMP_TYPE_TABLE:
			{
				uint32_t bytes = 0;
				table_t *table = table_deserialize(data, length, &bytes);
				ui_print_table(table);
				table_destroy(table, 1);
			}
			break;

		case AMP_TYPE_SRL:
			{
				uint32_t bytes = 0;
				srl_t *srl = srl_deserialize(data, length, &bytes);
				ui_print_srl(srl);
				srl_release(srl);
			}
			break;

		default:
			printf("Unknown.");
	}
}