예제 #1
0
파일: adm.c 프로젝트: brnrc/ion-dtn
void adm_destroy()
{
   LystElt elt = 0;

   for (elt = lyst_first(gAdmData); elt; elt = lyst_next(elt))
   {
	   adm_datadef_t *cur = (adm_datadef_t *) lyst_data(elt);
	   mid_release(cur->mid);
	   MRELEASE(cur);
   }
   lyst_destroy(gAdmData);
   gAdmData = NULL;

   for (elt = lyst_first(gAdmCtrls); elt; elt = lyst_next(elt))
   {
	   adm_ctrl_t *cur = (adm_ctrl_t *) lyst_data(elt);
	   mid_release(cur->mid);
	   MRELEASE(cur);
   }
   lyst_destroy(gAdmCtrls);
   gAdmCtrls = NULL;

   lyst_destroy(gAdmLiterals);
   gAdmLiterals = NULL;

   lyst_destroy(gAdmOps);
   gAdmOps = NULL;

}
예제 #2
0
expr_result_t ion_outduct_get_all(Lyst params)
{
	datacol_entry_t *entry = (datacol_entry_t*)lyst_data(lyst_first(params));
	unsigned long val = 0;
	char name[256];
	expr_result_t result;
	result.type = EXPR_TYPE_BLOB;

	NmbpOutduct outduct;
	int success = 0;

	memset(name,'\0',256);
	memcpy(name,entry->value, entry->length);

	result.length = 0;
	result.value = NULL;
	bpnm_outduct_get(name, &outduct, &success);
	if(success != 0)
	{
		result.length = sizeof(NmbpInduct);
		result.value = (uint8_t*) STAKE(result.length);
		memset(result.value, 0, result.length);
		memcpy(result.value, &outduct, result.length);
	}

	return result;
}
예제 #3
0
expr_result_t ion_outduct_get_name(Lyst params)
{

	datacol_entry_t *entry = (datacol_entry_t*)lyst_data(lyst_first(params));
	unsigned long val = 0;
	char name[256];
	expr_result_t result;
	result.type = EXPR_TYPE_STRING;

	result.length = 0;
	result.value = NULL;

	NmbpOutduct outduct;
	int success = 0;

	memset(name,'\0',256);
	memcpy(name,entry->value, entry->length);

	bpnm_outduct_get(name, &outduct, &success);
	if(success != 0)
	{
		result.length = (uint64_t) strlen(outduct.outductName) + 1;
		result.value = (uint8_t*) STAKE(result.length);
		memset(result.value, 0, result.length);
		memcpy(result.value, outduct.outductName, result.length);
	}

	return result;
}
예제 #4
0
int ui_print_agents()
{
  int i = 0;
  LystElt element = NULL;
  agent_t * agent = NULL;

  AMP_DEBUG_ENTRY("ui_print_agents","()",NULL);

  printf("\n------------- Known Agents --------------\n");

  element = lyst_first(known_agents);
  if(element == NULL)
  {
	  printf("[None]\n");
  }
  while(element != NULL)
  {
	  i++;
	  if((agent = lyst_data(element)) == NULL)
	  {
		  printf("%d) NULL?\n", i);
	  }
	  else
	  {
		  printf("%d) %s\n", i, (char *) agent->agent_eid.name);
	  }
	  element = lyst_next(element);
  }

  printf("\n------------- ************ --------------\n");
  printf("\n");

  AMP_DEBUG_EXIT("ui_print_agents","->%d", (i));
  return i;
}
예제 #5
0
expr_result_t ltp_get_eng_in_seg_unk_snd_cnt(Lyst params)
{
	datacol_entry_t *entry = (datacol_entry_t*)lyst_data(lyst_first(params));
	unsigned long val = 0;
	unsigned int engineId = 0;
	expr_result_t result;
	result.type = EXPR_TYPE_UINT32;
	result.length = 0;
	result.value = NULL;

	/* \todo: Check for NULL entry here. */
	NmltpSpan span;
	int success = 0;

	memcpy(&val, entry->value, sizeof(val));
	engineId = val;

	ltpnm_span_get(engineId, &span, &success);
	if(success != 0)
	{
		val = span.inputSegUnkSenderCount;
		result.value = adm_copy_integer((uint8_t*)&val, sizeof(val), &(result.length));
	}
	return result;
}
예제 #6
0
파일: adm.c 프로젝트: brnrc/ion-dtn
adm_ctrl_t* adm_find_ctrl_by_name(char *name)
{
	LystElt elt = 0;
	adm_ctrl_t *cur = NULL;

	DTNMP_DEBUG_ENTRY("adm_find_ctrl_by_name","(%s)", name);

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

	/* Step 1 - Go lookin'. */
	for(elt = lyst_first(gAdmData); elt; elt = lyst_next(elt))
	{
		cur = (adm_ctrl_t*) lyst_data(elt);

		if(memcmp(name, cur->name, strlen(cur->name)) == 0)
		{
			break;
		}

		cur = NULL;
	}

	/* Step 2 - Return what we found, or NULL. */
	DTNMP_DEBUG_EXIT("adm_find_ctrl_by_name", "->%llx.", cur);
	return cur;
}
예제 #7
0
파일: report.c 프로젝트: brnrc/ion-dtn
void rpt_release_prod(rpt_prod_t *msg)
{

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

	if(msg != NULL)
	{
		LystElt elt;
		rule_time_prod_t *item;

		for(elt = lyst_first(msg->defs); elt; elt = lyst_next(elt))
		{
			item = (rule_time_prod_t *) lyst_data(elt);

			rule_release_time_prod_entry(item);
			/* \todo Double check we don't need to kill the ELT here versus as
			 * part of lyst_destroy.
			 */
		}

		lyst_destroy(msg->defs);

		MRELEASE(msg);
	}

	DTNMP_DEBUG_EXIT("rpt_release_prod","->.",NULL);
}
예제 #8
0
파일: adm.c 프로젝트: brnrc/ion-dtn
adm_ctrl_t* adm_find_ctrl_by_idx(int idx)
{
	LystElt elt = 0;
	int i = 0;
	adm_ctrl_t *cur = NULL;

	DTNMP_DEBUG_ENTRY("adm_find_ctrl_by_idx","(%d)", idx);

	/* Step 1 - Go lookin'. */
	for(elt = lyst_first(gAdmCtrls); elt; elt = lyst_next(elt))
	{
		cur = (adm_ctrl_t*) lyst_data(elt);
		if(i == idx)
		{
			break;
		}
		i++;
		cur = NULL;
	}

	/* Step 2 - Return what we found, or NULL. */

	DTNMP_DEBUG_EXIT("adm_find_ctrl_by_idx", "->%llx.", cur);
	return cur;
}
예제 #9
0
파일: mid.c 프로젝트: brnrc/ion-dtn
/******************************************************************************
 *
 * \par Function Name: midcol_destroy
 *
 * \par Purpose: Destroy MID collection in a Lyst.
 *
 * \retval  NULL - Failure
 *         !NULL - The copied MID collection
 *
 * \param[in,out] mids The lyst being destroyed.
 *
 * \par Notes:
 *		1. We pass a double pointer for the honor of making sure the lyst is set
 *         to NULL when finished.
 *
 * Modification History:
 *  MM/DD/YY  AUTHOR         DESCRIPTION
 *  --------  ------------   ---------------------------------------------
 *  11/14/12  E. Birrane     Initial implementation,
 *****************************************************************************/
void midcol_destroy(Lyst *mids)
{
	LystElt elt;
	mid_t *cur_mid = NULL;

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

	/*
	 * Step 0: Make sure we even have a lyst. Not an error if not, since we
	 * are destroying anyway.
	 */
	if((mids == NULL) || (*mids == NULL))
	{
		DTNMP_DEBUG_ERR("midcol_destroy","Bad Args.",NULL);
		DTNMP_DEBUG_EXIT("midcol_destroy","->.", NULL);
		return;
	}

	/* Step 1: Walk through the MIDs releasing as you go. */
    for(elt = lyst_first(*mids); elt; elt = lyst_next(elt))
    {
    	cur_mid = (mid_t *) lyst_data(elt);

    	if(cur_mid != NULL)
    	{
    		mid_release(cur_mid);
    	}
    }

    /* Step 2: Destroy and zero out the lyst. */
    lyst_destroy(*mids);
    *mids = NULL;

    DTNMP_DEBUG_EXIT("midcol_destroy","->.", NULL);
}
예제 #10
0
파일: adm.c 프로젝트: brnrc/ion-dtn
adm_datadef_t *adm_find_datadef(mid_t *mid)
{
	LystElt elt = 0;
	adm_datadef_t *cur = NULL;

	DTNMP_DEBUG_ENTRY("adm_find_datadef","(%llx)", mid);

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

	/* Step 1 - Go lookin'. */
	for(elt = lyst_first(gAdmData); elt; elt = lyst_next(elt))
	{
		cur = (adm_datadef_t*) lyst_data(elt);

		/* Step 1.1 - Determine if we need to account for parameters. */
		if (mid_compare(mid, cur->mid, 0) == 0)
		{
			break;
		}

/**

		if(cur->num_parms == 0)
		{
			/ * Step 1.1.1 - If no params, straight compare * /
			if((mid->raw_size == cur->mid_len) &&
				(memcmp(mid->raw, cur->mid, mid->raw_size) == 0))
			{
				break;
			}
		}
		else
		{
			uvast tmp;
			unsigned char *cursor = (unsigned char*) &(cur->mid[1]);
			/ * Grab size less paramaters. Which is SDNV at [1]. * /
			/ * \todo: We need a more refined compare here.  For example, the
			 *        code below will not work if tag values are used.
			 * /
			unsigned long byte = decodeSdnv(&tmp, cursor);
			if(memcmp(mid->raw, cur->mid, tmp + byte + 1) == 0)
			{
				break;
			}
		}
	*/
		cur = NULL;
	}

	/* Step 2 - Return what we found, or NULL. */

	DTNMP_DEBUG_EXIT("adm_find_datadef", "->%llx.", cur);
	return cur;
}
예제 #11
0
expr_result_t ltp_get_eng_all(Lyst params)
{
	datacol_entry_t *entry = (datacol_entry_t*)lyst_data(lyst_first(params));
	unsigned long val = 0;
	unsigned int engineId = 0;
	expr_result_t result;
	result.type = EXPR_TYPE_UINT32;

	/* \todo: Check for NULL entry here. */
	NmltpSpan span;
	int success = 0;

	memcpy(&val, entry->value, sizeof(val));
	engineId = val;

	result.length = 0;
	result.value = NULL;
	ltpnm_span_get(engineId, &span, &success);
	if(success != 0)
	{
		result.value = (uint8_t*) STAKE(sizeof(span));
		memcpy(result.value, &span, sizeof(span));
		result.length = sizeof(span);
	}

	return result;
}
예제 #12
0
파일: nm_mgr.c 프로젝트: brnrc/ion-dtn
int mgr_agent_remove(eid_t* in_eid)
{
	agent_t 	*agent 		= NULL;
	Object 		*entry		= NULL;
	LystElt		elt;

	DTNMP_DEBUG_ENTRY("mgr_agent_remove","(0x%#llx)", (unsigned long) in_eid);

	/* Step 0: Sanity Checks. */
	if(in_eid == NULL)
	{
		DTNMP_DEBUG_ERR("remove_agent","Specified EID was null.", NULL);
		DTNMP_DEBUG_EXIT("remove_agent","", NULL);
		return -1;
	}

	lockResource(&agents_mutex);

	elt = lyst_first(known_agents);
	while(elt != NULL)
	{
		if(strcmp(in_eid->name, ((agent_t *) lyst_data(elt))->agent_eid.name) == 0)
		{
			agent = (agent_t *) lyst_data(elt);
			lyst_delete(elt);
			break;
		}
		else
		{
			elt = lyst_next(elt);
		}
	}

	unlockResource(&agents_mutex);

	if(agent == NULL)
	{
		DTNMP_DEBUG_ERR("remove_agent", "No agent %s found in hashtable", in_eid->name);
		DTNMP_DEBUG_EXIT("remove_agent", "->0", NULL);
		return 0;
	}

	rpt_clear_lyst(&(agent->reports), &(agent->mutex), 1);
	def_lyst_clear(&(agent->custom_defs), &(agent->mutex), 1);

	killResourceLock(&(agent->mutex));
	MRELEASE(agent);

	DTNMP_DEBUG_EXIT("remove_agent", "->1", NULL);
	return 1;
}
예제 #13
0
파일: report.c 프로젝트: brnrc/ion-dtn
/**
 * \brief Cleans up a lyst of data reports.
 *
 * \author Ed Birrane
 *
 * \param[in,out] reportLyst  THe lyst to be cleared.
 */
void rpt_clear_lyst(Lyst *list, ResourceLock *mutex, int destroy)
{
    LystElt elt;
    rpt_data_t *cur_rpt = NULL;

    DTNMP_DEBUG_ENTRY("rpt_clear_lyst","(0x%x, 0x%x, %d)",
			          (unsigned long) list, (unsigned long) mutex, destroy);

    if((list == NULL) || (*list == NULL))
    {
    	DTNMP_DEBUG_ERR("rpt_clear_lyst","Bad Params.", NULL);
    	return;
    }

    if(mutex != NULL)
    {
    	lockResource(mutex);
    }

    /* Free any reports left in the reports list. */
    for (elt = lyst_first(*list); elt; elt = lyst_next(elt))
    {
        /* Grab the current report */
        if((cur_rpt = (rpt_data_t*) lyst_data(elt)) == NULL)
        {
        	DTNMP_DEBUG_WARN("rpt_clear_lyst","Can't get report from lyst!", NULL);
        }
        else
        {
        	rpt_release_data(cur_rpt);
        }
    }

    lyst_clear(*list);

    if(destroy != 0)
    {
    	lyst_destroy(*list);
    	*list = NULL;
    }

    if(mutex != NULL)
    {
    	unlockResource(mutex);
    }

    DTNMP_DEBUG_EXIT("rpt_clear_lyst","->.", NULL);
}
예제 #14
0
void ctrl_clear_lyst(Lyst *list, ResourceLock *mutex, int destroy)
{
	LystElt elt;
	ctrl_exec_t *entry = NULL;

	AMP_DEBUG_ENTRY("ctrl_clear_lyst","(0x%x, 0x%x, %d)",
			          (unsigned long) list, (unsigned long) mutex, destroy);

    if((list == NULL) || (*list == NULL))
    {
    	AMP_DEBUG_ERR("ctrl_clear_lyst","Bad Params.", NULL);
    	return;
    }

	if(mutex != NULL)
	{
		lockResource(mutex);
	}

	/* Free any reports left in the reports list. */
	for (elt = lyst_first(*list); elt; elt = lyst_next(elt))
	{
		/* Grab the current item */
		if((entry = (ctrl_exec_t *) lyst_data(elt)) == NULL)
		{
			AMP_DEBUG_ERR("ctrl_clear_lyst","Can't get report from lyst!", NULL);
		}
		else
		{
			ctrl_release(entry);
		}
	}

	lyst_clear(*list);

	if(destroy != 0)
	{
		lyst_destroy(*list);
		*list = NULL;
	}

	if(mutex != NULL)
	{
		unlockResource(mutex);
	}

	AMP_DEBUG_EXIT("ctrl_clear_lyst","->.",NULL);
}
예제 #15
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;
}
예제 #16
0
파일: nm_mgr.c 프로젝트: brnrc/ion-dtn
agent_t* mgr_agent_get(eid_t* in_eid)
{
	Object 	 *entry 		= NULL;
	agent_t *agent			= NULL;

	DTNMP_DEBUG_ENTRY("mgr_agent_get","(0x%#llx)", (unsigned long) in_eid);

	/* Step 0: Sanity Check. */
	if(in_eid == NULL)
	{
		DTNMP_DEBUG_ERR("mgr_agent_get","Null argument", NULL);
		DTNMP_DEBUG_EXIT("mgr_agent_get", "->NULL", NULL);
		return NULL;
	}

	/* Step 1: Lock agent mutex, walk list looking for match. */
	lockResource(&agents_mutex);

	LystElt elt = lyst_first(known_agents);
	while(elt != NULL)
	{
		agent = (agent_t *) lyst_data(elt);
		if(strcmp(in_eid->name, agent->agent_eid.name) == 0)
		{
			break;
		}
		else
		{
			agent = NULL;
			elt = lyst_next(elt);
		}
	}

	unlockResource(&agents_mutex);

	if(agent == NULL)
	{
		DTNMP_DEBUG_EXIT("mgr_agent_get", "->NULL", NULL);
	}
	else
	{
		DTNMP_DEBUG_EXIT("mgr_agent_get","->Agent %s", agent->agent_eid.name);
	}

	return agent;
}
예제 #17
0
expr_result_t ion_induct_get_over_byte(Lyst params)
{
	char *name = (char *) lyst_data(lyst_first(params));
	NmbpInduct induct;
	int success = 0;
	expr_result_t result;
	result.type = EXPR_TYPE_UINT32;

	result.length = 0;
	result.value = NULL;
	bpnm_induct_get(name, &induct, &success);
	if(success != 0)
	{
		result.value = adm_copy_integer((uint8_t*)&(induct.bundleOverflowBytes),
			                 sizeof(induct.bundleOverflowBytes),
			                 &(result.length));
	}
	return result;
}
예제 #18
0
expr_result_t ion_outduct_get_deq_byte(Lyst params)
{
	char *name = (char *) lyst_data(lyst_first(params));
	NmbpOutduct outduct;
	int success = 0;
	expr_result_t result;
	result.type = EXPR_TYPE_UINT32;

	result.length = 0;
	result.value = NULL;
	bpnm_outduct_get(name, &outduct, &success);
	if(success != 0)
	{
		result.value = adm_copy_integer((uint8_t*)&(outduct.bundleDequeuedBytes),
			                 sizeof(outduct.bundleDequeuedBytes),
			                 &(result.length));
	}
	return result;
}
예제 #19
0
파일: ltpei.c 프로젝트: brnrc/ion-dtn
void	ltpei_discard_extensions(Lyst extensions)
{
	LystElt			elt;
	LtpExtensionInbound	*ext;

	CHKVOID(extensions);
	while ((elt = lyst_first(extensions)) != NULL)
	{
		ext = (LtpExtensionInbound *) lyst_data(elt);
		if (ext->value)
		{
			MRELEASE(ext->value);
		}

		MRELEASE(ext);
		lyst_delete(elt);
	}

	lyst_destroy(extensions);
}
예제 #20
0
void ui_print_mc(Lyst mc)
{
	LystElt elt = NULL;
	int i = 0;
	mid_t *mid = NULL;

	printf("{ ");

	for(elt = lyst_first(mc); elt; elt = lyst_next(elt))
	{
		if(i > 0)
		{
			printf(", ");
		}
		i++;
		mid = lyst_data(elt);
		ui_print_mid(mid);
	}

	printf(" }");

}
예제 #21
0
/*
 * We need to find out a description for the entry so we can print it out.
 * So, if entry is <RPT MID> <int d1><int d2><int d3> we need to match the items
 * to elements of the report definition.
 *
 */
void ui_print_entry(rpt_entry_t *entry, uvast *mid_sizes, uvast *data_sizes)
{
	LystElt elt = NULL;
	def_gen_t *cur_def = NULL;
	uint8_t del_def = 0;

	if((entry == NULL) || (mid_sizes == NULL) || (data_sizes == NULL))
	{
		AMP_DEBUG_ERR("ui_print_entry","Bad Args.", NULL);
		return;
	}

	/* Step 1: Calculate sizes...*/
    *mid_sizes = *mid_sizes + entry->id->raw_size;

    for(elt = lyst_first(entry->contents->datacol); elt; elt = lyst_next(elt))
    {
    	blob_t *cur = lyst_data(elt);
        *data_sizes = *data_sizes + cur->length;
    }
    *data_sizes = *data_sizes + entry->contents->hdr.length;

	/* Step 1: Print the MID associated with the Entry. */
    printf(" (");
    ui_print_mid(entry->id);
	printf(") has %d values.", entry->contents->hdr.length);


    /*
     * Step 2: Try and find the metadata associated with each
     *         value in the TDC. Since the TDC is already typed, the
     *         needed meta-data information is simply the
     *         "name" of the data.
     *
     *         i Only computed data definitions, reports, and macros
     *         need names. Literals, controls, and atomic data do
     *         not (currently) define extra meta-data for their
     *         definitions.
     *
     *         \todo: Consider printing names for each return
     *         value from a control.
     */

    cur_def = NULL;

	if(MID_GET_FLAG_ID(entry->id->flags) == MID_ATOMIC)
	{
		adm_datadef_t *ad_entry = adm_find_datadef(entry->id);

		/* Fake a def_gen_t for now. */
		if(ad_entry != NULL)
		{
	    	Lyst tmp = lyst_create();
	    	lyst_insert(tmp,mid_copy(ad_entry->mid));
	    	cur_def = def_create_gen(mid_copy(ad_entry->mid), ad_entry->type, tmp);
	    	del_def = 1;
		}
	}
	else if(MID_GET_FLAG_ID(entry->id->flags) == MID_COMPUTED)
	{
		var_t *cd = NULL;
	    if(MID_GET_FLAG_ISS(entry->id->flags) == 0)
	    {
	    	cd = var_find_by_id(gAdmComputed, NULL, entry->id);
	    }
	    else
	    {
	    	cd = var_find_by_id(gMgrVDB.compdata, &(gMgrVDB.compdata_mutex), entry->id);
	    }

	    // Fake a def_gen just for this CD item.
	    if(cd != NULL)
	    {
	    	Lyst tmp = lyst_create();
	    	lyst_insert(tmp,mid_copy(cd->id));
	    	cur_def = def_create_gen(mid_copy(cd->id), cd->value.type, tmp);
	    	del_def = 1;
	    }
	}
	else if(MID_GET_FLAG_ID(entry->id->flags) == MID_REPORT)
	{
	    if(MID_GET_FLAG_ISS(entry->id->flags) == 0)
	    {
	    	cur_def = def_find_by_id(gAdmRpts, NULL, entry->id);
	    }
	    else
	    {
	    	cur_def = def_find_by_id(gMgrVDB.reports, &(gMgrVDB.reports_mutex), entry->id);
	    }
	}
	else if(MID_GET_FLAG_ID(entry->id->flags) == MID_MACRO)
	{
	    if(MID_GET_FLAG_ISS(entry->id->flags) == 0)
	    {
	    	cur_def = def_find_by_id(gAdmMacros, NULL, entry->id);
	    }
	    else
	    {
	    	cur_def = def_find_by_id(gMgrVDB.macros, &(gMgrVDB.macros_mutex), entry->id);
	    }

	}

	/* Step 3: Print the TDC holding data for the entry. */
    ui_print_tdc(entry->contents, cur_def);

    if(del_def)
    {
    	def_release_gen(cur_def);
    }
    return;
}
예제 #22
0
파일: bsspclo.c 프로젝트: brnrc/ion-dtn
static int	isInOrder(Lyst streams, Bundle *bundle)
{
	LystElt		elt;
	BundleStream	*stream;

	for (elt = lyst_first(streams); elt; elt = lyst_next(elt))
	{
		stream = lyst_data(elt);
		if (stream->source.nodeNbr < bundle->id.source.c.nodeNbr)
		{
			continue;
		}

		if (stream->source.nodeNbr > bundle->id.source.c.nodeNbr)
		{
			break;
		}

		if (stream->source.serviceNbr < bundle->id.source.c.serviceNbr)
		{
			continue;
		}

		if (stream->source.serviceNbr > bundle->id.source.c.serviceNbr)
		{
			break;
		}

		if (stream->dest.nodeNbr < bundle->destination.c.nodeNbr)
		{
			continue;
		}

		if (stream->dest.nodeNbr > bundle->destination.c.nodeNbr)
		{
			break;
		}

		if (stream->dest.serviceNbr < bundle->destination.c.serviceNbr)
		{
			continue;
		}

		if (stream->dest.serviceNbr > bundle->destination.c.serviceNbr)
		{
			break;
		}

		/*	Found matching stream.				*/

		if (bundle->id.creationTime.seconds
				> stream->lastBundle.seconds
		|| (bundle->id.creationTime.seconds
				== stream->lastBundle.seconds
			&& bundle->id.creationTime.count
				> stream->lastBundle.count))
		{
			stream->lastBundle.seconds =
					bundle->id.creationTime.seconds;
			stream->lastBundle.count =
					bundle->id.creationTime.count;
			return 1;
		}

		return 0;
	}

	stream = (BundleStream *) MTAKE(sizeof(BundleStream));
	if (stream == NULL)
	{
		return 0;
	}

	if (elt)
	{
		elt = lyst_insert_before(elt, stream);
	}
	else
	{
		elt = lyst_insert_last(streams, stream);
	}

	if (elt == NULL)
	{
		MRELEASE(stream);
		return 0;
	}

	stream->source.nodeNbr = bundle->id.source.c.nodeNbr;
	stream->source.serviceNbr = bundle->id.source.c.serviceNbr;
	stream->dest.nodeNbr = bundle->destination.c.nodeNbr;
	stream->dest.serviceNbr = bundle->destination.c.serviceNbr;
	stream->lastBundle.seconds = bundle->id.creationTime.seconds;
	stream->lastBundle.count = bundle->id.creationTime.count;
	return 1;
}
예제 #23
0
파일: mid.c 프로젝트: brnrc/ion-dtn
uint8_t *midcol_serialize(Lyst mids, uint32_t *size)
{
	uint8_t *result = NULL;
	Sdnv num_sdnv;
	LystElt elt;

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

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

	/* Step 1: Calculate the size. */

	/* Consider the size of the SDNV holding # MIDS.*/
	encodeSdnv(&num_sdnv, lyst_length(mids));

	*size = num_sdnv.length;

	/* Walk through each MID, make sure it is serialized, and look at size. */
    for(elt = lyst_first(mids); elt; elt = lyst_next(elt))
    {
    	mid_t *cur_mid = (mid_t *) lyst_data(elt);

    	if(cur_mid != NULL)
    	{
    		if((cur_mid->raw == NULL) || (cur_mid->raw_size == 0))
    		{
    			/* \todo check return code. */
    			mid_internal_serialize(cur_mid);
    		}
    		if((cur_mid->raw == NULL) || (cur_mid->raw_size == 0))
    		{
        		DTNMP_DEBUG_WARN("midcol_serialize","MID didn't serialize.", NULL);
    		}
    		else
    		{
    			*size += cur_mid->raw_size;
    		}
    	}
    	else
    	{
    		DTNMP_DEBUG_WARN("midcol_serialize","Found NULL MID?", NULL);
    	}
    }

    /* Step 3: Allocate the space for the serialized list. */
    if((result = (uint8_t*) MTAKE(*size)) == NULL)
    {
		DTNMP_DEBUG_ERR("midcol_serialize","Can't alloc %d bytes", *size);
		*size = 0;

		DTNMP_DEBUG_EXIT("midcol_serialize","->NULL",NULL);
		return NULL;
    }

    /* Step 4: Walk through list again copying as we go. */
    uint8_t *cursor = result;

    /* COpy over the number of MIDs in the collection. */
    memcpy(cursor, num_sdnv.text, num_sdnv.length);
    cursor += num_sdnv.length;

    for(elt = lyst_first(mids); elt; elt = lyst_next(elt))
    {
    	mid_t *cur_mid = (mid_t *) lyst_data(elt);

    	if(cur_mid != NULL)
    	{
    		if((cur_mid->raw != NULL) && (cur_mid->raw_size > 0))
    		{
    			memcpy(cursor,cur_mid->raw, cur_mid->raw_size);
    			cursor += cur_mid->raw_size;
    		}
    	}
    	else
    	{
    		DTNMP_DEBUG_WARN("midcol_serialize","Found NULL MID?", NULL);
    	}
    }

    /* Step 5: Final sanity check. */
    if((cursor - result) != *size)
    {
		DTNMP_DEBUG_ERR("midcol_serialize","Wrote %d bytes not %d bytes",
				        (cursor - result), *size);
		*size = 0;
		MRELEASE(result);
		DTNMP_DEBUG_EXIT("midcol_serialize","->NULL",NULL);
		return NULL;
    }

	DTNMP_DEBUG_EXIT("midcol_serialize","->%#llx",(unsigned long) result);
	return result;
}
예제 #24
0
파일: mid.c 프로젝트: brnrc/ion-dtn
char *midcol_to_string(Lyst mc)
{
	LystElt elt;
	char *result = NULL;
	char *cursor = NULL;
	int num_items = 0;
	int i = 0;

	char **mid_strs = NULL;
	int tot_size = 0;

	DTNMP_DEBUG_ENTRY("midcol_to_string","(%#llx)", (unsigned long) mc);

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

	/* Step 1: Grab the number of MIDs in the collection, and pre-allocate
	 *         space to store their printed information.
	 */
	num_items = (int) lyst_length(mc);

	mid_strs = (char**) MTAKE(num_items * sizeof(char*));
	if(mid_strs == NULL)
	{
		DTNMP_DEBUG_ERR("midcol_to_string","Can't alloc %d bytes.",
				        num_items * sizeof(char *));
		DTNMP_DEBUG_EXIT("midcol_to_string","->NULL",NULL);
		return NULL;
	}

	/* Step 2: Grab the pretty-print of individual MIDs. We need this anyway
	 *         and it will help us get the sizing right.
	 */
	for(elt = lyst_first(mc); (elt && (i < num_items)); elt=lyst_next(elt))
	{
		mid_t *cur_mid = (mid_t*) lyst_data(elt);
		mid_strs[i] = mid_to_string(cur_mid);
		tot_size += strlen(mid_strs[i]);
		i++;
	}

	/* Step 3: Calculate size of the MID collection print and allocate it. */
	tot_size += 5 +        /* "MC : " */
				2 +        /* trailer */
			    num_items; /* space between MIDs. */

	if((result = (char *) MTAKE(tot_size)) == NULL)
	{
		DTNMP_DEBUG_ERR("midcol_to_string","Can't alloc %d bytes.",
				        tot_size);
		for(i = 0; i < num_items; i++)
		{
			MRELEASE(mid_strs[i]);
		}
		MRELEASE(mid_strs);

		DTNMP_DEBUG_EXIT("midcol_to_string","->NULL",NULL);
		return NULL;
	}
	else
	{
		cursor = result;
	}

	/* Step 4: Fill in the MID collection string. */
	cursor += sprintf(cursor,"MC : ");
	for(i = 0; i < num_items; i++)
	{
		cursor += sprintf(cursor,"%s ",mid_strs[i]);
		MRELEASE(mid_strs[i]);
	}
	cursor += sprintf(cursor,".\n");
	MRELEASE(mid_strs);

	/* Step 5: Sanity check. */
	if((cursor - result) > tot_size)
	{
		DTNMP_DEBUG_ERR("midcol_to_string", "OVERWROTE! Alloc %d, wrote %llu.",
				tot_size, (cursor-result));
		MRELEASE(result);
		DTNMP_DEBUG_EXIT("mid_to_string","->NULL",NULL);
		return NULL;
	}

	DTNMP_DEBUG_INFO("midcol_to_string","Wrote %llu into %d string.",
					(cursor -result), tot_size);

	DTNMP_DEBUG_EXIT("midcol_to_string","->%#llx",result);

	return result;
}
예제 #25
0
int	_tcpOutductId(struct sockaddr *socketName, char *protocolName,
		char *ductName)
{
	static Lyst	tcpOutductIds = NULL;
	LystElt		elt;
	TcpOutductId	*id = NULL;
	int		idNotFound = 1;

	CHKERR(socketName);
	if (tcpOutductIds == NULL)
	{
		tcpOutductIds = lyst_create_using(getIonMemoryMgr());
		CHKERR(tcpOutductIds);
		lyst_delete_set(tcpOutductIds, deleteOutductId, NULL);
	}

	for (elt = lyst_first(tcpOutductIds); elt; elt = lyst_next(elt))
	{
		id = (TcpOutductId *) lyst_data(elt);
		idNotFound = memcmp(&(id->socketName), socketName,
				sizeof(struct sockaddr));
		if (idNotFound < 0)
		{
			continue;
		}

		/*	The result of memcmp is either 0, indicating
		 *	matching TcpOutductId was found (that is,
		 *	idNotFound is false), or greater than 0
		 *	indicating that no matching TcpOutductId was
		 *	found (that is, idNotFound is true).		*/

		break;
	}

	if (protocolName == NULL)	/*	Deleting outduct ID.	*/
	{
		if (!idNotFound)	/*	Found it.		*/
		{
			lyst_delete(elt);
		}

		return 0;
	}

	if (*protocolName == 0)		/*	Retrieving outduct ID.	*/
	{
		if (!idNotFound)	/*	Found it.		*/
		{
			istrcpy(protocolName, id->protocolName,
					MAX_CL_PROTOCOL_NAME_LEN);
			istrcpy(ductName, id->ductName, MAX_CL_DUCT_NAME_LEN);
		}

		return 0;
	}

	/*	Recording new TCP Outduct ID.				*/

	if (!idNotFound)
	{
		putErrmsg("[?] Socket address is already in TcpOutductSocket \
list.", ductName);
		return -1;
	}
예제 #26
0
static void	handle_csendpoint_start(LoadMibState *state, const char **atts)
{
	int	after = -1;
	LystElt	elt = NULL;
	int	count;
	char	*epspec = NULL;
	char	**att;
	char	*name;
	char	*value;

	if (noMibYet(state)) return;
	for (att = (char **) atts; *att; att++)
	{
		name = *att;
		att++;
		value = *att;
		if (strcmp(name, "after") == 0)
		{
			after = atoi(value);
			if (after < 0)
			{
				return noteLoadError(state, "'after' illegal");
			}

			count = after;
			for (elt = lyst_first((_mib(NULL))->csEndpoints); elt;
					elt = lyst_next(elt))
			{
				if (count == 0) break;
				count--;
			}

			if (count > 0)
			{
				return noteLoadError(state, "'after' invalid");
			}
		}
		else if (strcmp(name, "epspec") == 0)
		{
			epspec = value;
		}
		else return noteLoadError(state, "Unknown attribute.");
	}

	switch (state->currentOperation)
	{
	case LoadAdding:
		if (createCsEndpoint(epspec, elt) == NULL)
		{
			return putErrmsg("Couldn't add CS endpoint.", NULL);
		}

		break;

	case LoadChanging:
		return noteLoadError(state, "CS endpoints can only be added \
and deleted.");

	case LoadDeleting:
       		if (elt == NULL)
		{
			return putErrmsg("Couldn't delete CS endpoint.", NULL);
		}

		lyst_delete(elt);
		break;

	default:
		return noteLoadError(state, "Not in an operation.");
	}
}
예제 #27
0
void ui_print_reports(agent_t* agent)
{
	 LystElt report_elt;
	 LystElt entry_elt;
	 rpt_t *cur_report = NULL;
	 rpt_entry_t *cur_entry = NULL;

	 if(agent == NULL)
	 {
		 AMP_DEBUG_ENTRY("ui_print_reports","(NULL)", NULL);
		 AMP_DEBUG_ERR("ui_print_reports", "No agent specified", NULL);
		 AMP_DEBUG_EXIT("ui_print_reports", "->.", NULL);
		 return;

	 }
	 AMP_DEBUG_ENTRY("ui_print_reports","(%s)", agent->agent_eid.name);

	 if(lyst_length(agent->reports) == 0)
	 {
		 AMP_DEBUG_ALWAYS("ui_print_reports","[No reports received from this agent.]", NULL);
		 AMP_DEBUG_EXIT("ui_print_reports", "->.", NULL);
		 return;
	 }

	 /* Free any reports left in the reports list. */
	 for (report_elt = lyst_first(agent->reports); report_elt; report_elt = lyst_next(report_elt))
	 {
		 /* Grab the current report */
	     if((cur_report = (rpt_t*)lyst_data(report_elt)) == NULL)
	     {
	        AMP_DEBUG_ERR("ui_print_reports","Unable to get report from lyst!", NULL);
	     }
	     else
	     {
	    	 uvast mid_sizes = 0;
	    	 uvast data_sizes = 0;
	    	 int i = 1;

	    	 /* Print the Report Header */
	    	 printf("\n----------------------------------------");
	    	 printf("\n            DTNMP DATA REPORT           ");
	    	 printf("\n----------------------------------------");
	    	 printf("\nSent to   : %s", cur_report->recipient.name);
	    	 printf("\nTimestamp : %s", ctime(&(cur_report->time)));
	    	 printf("\n# Entries : %lu",
			 (unsigned long) lyst_length(cur_report->entries));
	    	 printf("\n----------------------------------------");

 	    	 /* For each MID in this report, print it. */
	    	 for(entry_elt = lyst_first(cur_report->entries); entry_elt; entry_elt = lyst_next(entry_elt))
	    	 {
	    		 printf("\nEntry %d ", i);
	    		 cur_entry = (rpt_entry_t*)lyst_data(entry_elt);
	    		 ui_print_entry(cur_entry, &mid_sizes, &data_sizes);
	    		 i++;
	    	 }

	    	 printf("\n----------------------------------------");
	    	 printf("\nSTATISTICS:");
	    	 printf("\nMIDs total "UVAST_FIELDSPEC" bytes", mid_sizes);
	    	 printf("\nData total: "UVAST_FIELDSPEC" bytes", data_sizes);
		 if ((mid_sizes + data_sizes) > 0)
		 {
	    	 	printf("\nEfficiency: %.2f%%", (double)(((double)data_sizes)/((double)mid_sizes + data_sizes)) * (double)100.0);
		 }

	    	 printf("\n----------------------------------------\n\n\n");
	     }
	 }
}
예제 #28
0
// THis is a DC of values? Generally, a typed data collection is a DC of values.
void ui_print_tdc(tdc_t *tdc, def_gen_t *cur_def)
{
	LystElt elt = NULL;
	LystElt def_elt = NULL;
	uint32_t i = 0;
	amp_type_e cur_type;
	blob_t *cur_entry = NULL;
	value_t *cur_val = NULL;

	if(tdc == NULL)
	{
		AMP_DEBUG_ERR("ui_print_tdc","Bad Args.", NULL);
		return;
	}

	if(cur_def != NULL)
	{
		if(lyst_length(cur_def->contents) != tdc->hdr.length)
		{
			AMP_DEBUG_WARN("ui_print_tdc","def and TDC length mismatch: %d != %d. Ignoring.",
					        lyst_length(cur_def->contents), tdc->hdr.length);
			cur_def = NULL;
		}
	}


	elt = lyst_first(tdc->datacol);
	if(cur_def != NULL)
	{
		def_elt = lyst_first(cur_def->contents);
	}

	for(i = 0; ((i < tdc->hdr.length) && elt); i++)
	{
		cur_type = (amp_type_e) tdc->hdr.data[i];

		printf("\n\t");
		if(cur_def != NULL)
		{
			printf("Value %d (", i);
			ui_print_mid((mid_t *) lyst_data(def_elt));
			printf(") ");
		}

		// \todo: Check return values.
		if((cur_entry = lyst_data(elt)) == NULL)
		{
			printf("NULL\n");
		}
		else
		{
			ui_print_val(cur_type, cur_entry->value, cur_entry->length);
		}


		elt = lyst_next(elt);

		if(cur_def != NULL)
		{
			def_elt = lyst_next(def_elt);
		}
	}

}
예제 #29
0
/******************************************************************************
 *
 * \par Function Name: ui_print_table
 *
 * \par Purpose: Prints a table to stdout.
 *
 * \par
 * COL HDR: Name (Type), Name (Type), Name (Type)...
 * ROW   0: Value1, Value2, Value3...
 * ROW   1: Value1, Value2, Value3...
 *
 * \param[in]  table  The table to be printed
 *
 * Modification History:
 *  MM/DD/YY  AUTHOR         DESCRIPTION
 *  --------  ------------   ---------------------------------------------
 *  06/8/16  E. Birrane     Initial implementation,
 *****************************************************************************/
void ui_print_table(table_t *table)
{
	int32_t i = 0;
	uint32_t row_num = 1;
	int8_t first = 0;

	LystElt elt;
	LystElt elt2;

	char *temp = NULL;
	blob_t *cur_blob = NULL;
	table_row_t *cur_row = NULL;

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

	printf("COL HDR: ");
	for(elt = lyst_first(table->hdr.names); elt; elt = lyst_next(elt))
	{
		cur_blob = (blob_t*) lyst_data(elt);

		if(first == 0)
		{
			first = 1;
		}
		else
		{
			printf(", ");
		}
		printf(" %s (%s)", (char *)cur_blob->value, type_to_str(table->hdr.types.value[i]));
		i++;
	}
	printf("\n");

	for(elt = lyst_first(table->rows); elt; elt = lyst_next(elt))
	{
		cur_row = (table_row_t*) lyst_data(elt);

		printf("ROW %3d: ", row_num++);

		if(cur_row == NULL)
		{
			printf("NULL");
		}
		else
		{
			first = 0;
			i = 0;

			for(elt2 = lyst_first(cur_row->cels); elt2; elt2 = lyst_next(elt2))
			{
				cur_blob = (blob_t *) lyst_data(elt2);
				value_t  val = val_from_blob(cur_blob, table->hdr.types.value[i]);

				if(first == 0)
				{
					first = 1;
				}
				else
				{
					printf(", ");
				}

				temp = val_to_string(val);
				printf("%s", temp);
				SRELEASE(temp);
				val_release(&val, 0);
				i++;
			}
			printf("\n");
		}
	}

}