예제 #1
0
파일: libdtn2fw.c 프로젝트: brnrc/ion-dtn
void	dtn2_destroyDirective(FwdDirective *directive)
{
	Sdr	sdr = getIonsdr();

	CHKVOID(directive);
	if (directive->action == fwd)
	{
		CHKVOID(sdr_begin_xn(sdr));
		sdr_free(sdr, directive->eid);
		if (sdr_end_xn(sdr) < 0)
		{
			putErrmsg("Can't destroy directive EID.", NULL);
		}

		return;
	}

	if (directive->action == xmit)
	{
		if (directive->destDuctName)
		{
			CHKVOID(sdr_begin_xn(sdr));
			sdr_free(sdr, directive->destDuctName);
			if (sdr_end_xn(sdr) < 0)
			{
				putErrmsg("Can't destroy destDuctName.", NULL);
			}

		}
	}
}
예제 #2
0
파일: ion.c 프로젝트: pantuza/pleiades-DTN
vast	ionAppendZcoExtent(Object zco, ZcoMedium source, Object location,
		vast offset, vast size, int *cancel)
{
	Sdr	sdr = getIonsdr();
	IonVdb	*vdb = _ionvdb(NULL);
	Object	length;
	int	admissionDelayed = 0;

	CHKZERO(vdb);
	if (cancel)
	{
		*cancel = 0;		/*	Initialize.		*/
	}

	CHKZERO(sdr_begin_xn(sdr));
	while (1)
	{
		length = zco_append_extent(sdr, zco, source, location, offset,
				size);
		if (sdr_end_xn(sdr) < 0 || length == ERROR)
		{
			putErrmsg("Can't create ZCO.", NULL);
			return ERROR;
		}

		if (length == 0)	/*	Not enough ZCO space.	*/
		{
			if (admissionDelayed)
			{
				ionReleaseZcoSpace(vdb);
			}

			admissionDelayed = 1;
			if (ionWaitForZcoSpace(vdb) == 1)
			{
				if (cancel && *cancel)
				{
					return 0;
				}

				CHKZERO(sdr_begin_xn(sdr));
				continue;
			}

			return ERROR;
		}

		/*	ZCO extent was appended.			*/

		if (admissionDelayed)
		{
			ionReleaseZcoSpace(vdb);
		}

		return length;
	}
}
예제 #3
0
파일: ion.c 프로젝트: pantuza/pleiades-DTN
Object	ionCreateZco(ZcoMedium source, Object location, vast offset, vast size,
		int *cancel)
{
	Sdr	sdr = getIonsdr();
	IonVdb	*vdb = _ionvdb(NULL);
	Object	zco;
	int	admissionDelayed = 0;

	CHKZERO(vdb);
	if (cancel)
	{
		*cancel = 0;		/*	Initialize.		*/
	}

	CHKZERO(sdr_begin_xn(sdr));
	while (1)
	{
		zco = zco_create(sdr, source, location, offset, size);
		if (sdr_end_xn(sdr) < 0 || zco == (Object) ERROR)
		{
			putErrmsg("Can't create ZCO.", NULL);
			return 0;
		}

		if (zco == 0)	/*	Not enough ZCO space.		*/
		{
			if (admissionDelayed)
			{
				ionReleaseZcoSpace(vdb);
			}

			admissionDelayed = 1;
			if (ionWaitForZcoSpace(vdb) == 1)
			{
				if (cancel && *cancel)
				{
					return 0;
				}

				CHKZERO(sdr_begin_xn(sdr));
				continue;
			}

			return 0;
		}

		/*	ZCO was created.				*/

		if (admissionDelayed)
		{
			ionReleaseZcoSpace(vdb);
		}

		return zco;
	}
}
예제 #4
0
파일: cfdpadmin.c 프로젝트: b/ION
static void	manageMtusize(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	Object	cfdpdbObj = getCfdpDbObject();
	CfdpDB	cfdpdb;
	int	newMtusize;

	if (tokenCount != 3)
	{
		SYNTAX_ERROR;
	}

	newMtusize = atoi(tokens[2]);
	if (newMtusize < 0)
	{
		putErrmsg("mtuSize invalid.", tokens[2]);
		return;
	}

	sdr_begin_xn(sdr);
	sdr_stage(sdr, (char *) &cfdpdb, cfdpdbObj, sizeof(CfdpDB));
	cfdpdb.mtuSize = newMtusize;
	sdr_write(sdr, cfdpdbObj, (char *) &cfdpdb, sizeof(CfdpDB));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't change mtuSize.", NULL);
	}
}
예제 #5
0
Object getOrMakeCustodianByEid(Object custodians, const char *eid)
{
    Object custodianAddr;

    /* Try to find custodian info if it exists. */
    CHKZERO(sdr_begin_xn(acsSdr));
    custodianAddr = findCustodianByEid(custodians, eid);
    if(sdr_end_xn(acsSdr) < 0)
    {
        putErrmsg("Can't search custodian database", eid);
        return 0;
    }

    /* If no custodian info, make it. */
    if(custodianAddr == 0)
    {
        custodianAddr = newSdrAcsCustodian(custodians, eid);
        if(custodianAddr == 0)
        {
            ACSLOG_WARN("Couldn't record new custodian info for %s", eid);
            return 0;
        }
    }
    return custodianAddr;
}
예제 #6
0
파일: libbp.c 프로젝트: b/ION
void	bp_release_delivery(BpDelivery *dlvBuffer, int releasePayload)
{
	Sdr	sdr = getIonsdr();

	CHKVOID(dlvBuffer);
	if (dlvBuffer->result == BpPayloadPresent)
	{
		if (dlvBuffer->bundleSourceEid)
		{
			MRELEASE(dlvBuffer->bundleSourceEid);
			dlvBuffer->bundleSourceEid = NULL;
		}

		if (releasePayload)
		{
			if (dlvBuffer->adu)
			{
				sdr_begin_xn(sdr);
				zco_destroy_reference(sdr, dlvBuffer->adu);
				if (sdr_end_xn(sdr) < 0)
				{
					putErrmsg("Failed releasing delivery.",
							NULL);
				}

				dlvBuffer->adu = 0;
			}
		}
	}
}
예제 #7
0
파일: libdtn2fw.c 프로젝트: brnrc/ion-dtn
static DtnDB	*_dtn2Constants()
{
	static DtnDB	buf;
	static DtnDB	*db = NULL;
	Sdr		sdr;
	Object		dbObject;
	
	if (db == NULL)
	{
		sdr = getIonsdr();
		CHKNULL(sdr);
		dbObject = _dtn2dbObject(NULL);
		if (dbObject)
		{
			if (sdr_heap_is_halted(sdr))
			{
				sdr_read(sdr, (char *) &buf, dbObject,
						sizeof(DtnDB));
			}
			else
			{
				CHKNULL(sdr_begin_xn(sdr));
				sdr_read(sdr, (char *) &buf, dbObject,
						sizeof(DtnDB));
				sdr_exit_xn(sdr);
			}

			db = &buf;
		}
	}
	
	return db;
}
예제 #8
0
파일: cfdpadmin.c 프로젝트: b/ION
static void	manageMaxtrnbr(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	Object	cfdpdbObj = getCfdpDbObject();
	CfdpDB	cfdpdb;
	int	newMaxtrnbr;

	if (tokenCount != 3)
	{
		SYNTAX_ERROR;
	}

	newMaxtrnbr = atoi(tokens[2]);
	if (newMaxtrnbr < 0)
	{
		putErrmsg("maxTransactionNbr invalid.", tokens[2]);
		return;
	}

	sdr_begin_xn(sdr);
	sdr_stage(sdr, (char *) &cfdpdb, cfdpdbObj, sizeof(CfdpDB));
	cfdpdb.maxTransactionNbr = newMaxtrnbr;
	sdr_write(sdr, cfdpdbObj, (char *) &cfdpdb, sizeof(CfdpDB));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't change maxTransactionNbr.", NULL);
	}
}
예제 #9
0
int acsAttach()
{
    if (acsConstants)
    {
        return 0;
    }

    if (getAcssdr() == NULL)
    {
        /* ACS can't find ACS SDR. */
        return -1;
    }

    CHKERR(sdr_begin_xn(acsSdr));
    if (acsdbObject == 0)
    {
        acsdbObject = sdr_find(acsSdr, acsDbName, NULL);
        if (acsdbObject == 0)
        {
            sdr_exit_xn(acsSdr);
            return -1;
        }
    }
    acsConstants = &acsConstantsBuf;
    sdr_read(acsSdr, (char *) acsConstants, acsdbObject, sizeof(AcsDB));
    sdr_exit_xn(acsSdr);
    return 0;
}
예제 #10
0
파일: cfdpadmin.c 프로젝트: b/ION
static void	manageFillchar(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	Object	cfdpdbObj = getCfdpDbObject();
	CfdpDB	cfdpdb;
	int	newFillchar;
	char	*trailing;

	if (tokenCount != 3)
	{
		SYNTAX_ERROR;
	}

	newFillchar = strtol(tokens[2], &trailing, 16);
	if (*trailing != '\0')
	{
		putErrmsg("fillCharacter invalid.", tokens[2]);
		return;
	}

	sdr_begin_xn(sdr);
	sdr_stage(sdr, (char *) &cfdpdb, cfdpdbObj, sizeof(CfdpDB));
	cfdpdb.fillCharacter = newFillchar;
	sdr_write(sdr, cfdpdbObj, (char *) &cfdpdb, sizeof(CfdpDB));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't change fillCharacter.", NULL);
	}
}
예제 #11
0
파일: cfdpadmin.c 프로젝트: b/ION
static void	manageMaxtimeouts(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	Object	cfdpdbObj = getCfdpDbObject();
	CfdpDB	cfdpdb;
	int	newMaxtimeouts;

	if (tokenCount != 3)
	{
		SYNTAX_ERROR;
	}

	newMaxtimeouts = atoi(tokens[2]);
	if (newMaxtimeouts < 0)
	{
		putErrmsg("checkTimeoutLimit invalid.", tokens[2]);
		return;
	}

	sdr_begin_xn(sdr);
	sdr_stage(sdr, (char *) &cfdpdb, cfdpdbObj, sizeof(CfdpDB));
	cfdpdb.checkTimeoutLimit = newMaxtimeouts;
	sdr_write(sdr, cfdpdbObj, (char *) &cfdpdb, sizeof(CfdpDB));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't change checkTimerPeriod.", NULL);
	}
}
예제 #12
0
파일: cfdpadmin.c 프로젝트: b/ION
static void	manageRequirecrc(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	Object	cfdpdbObj = getCfdpDbObject();
	CfdpDB	cfdpdb;
	int	newRequirecrc;

	if (tokenCount != 3)
	{
		SYNTAX_ERROR;
	}

	newRequirecrc = atoi(tokens[2]);
	if (newRequirecrc != 0 && newRequirecrc != 1)
	{
		putErrmsg("crcRequired switch invalid.", tokens[2]);
		return;
	}

	sdr_begin_xn(sdr);
	sdr_stage(sdr, (char *) &cfdpdb, cfdpdbObj, sizeof(CfdpDB));
	cfdpdb.crcRequired = newRequirecrc;
	sdr_write(sdr, cfdpdbObj, (char *) &cfdpdb, sizeof(CfdpDB));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't change crcRequired switch.", NULL);
	}
}
예제 #13
0
파일: cfdpadmin.c 프로젝트: b/ION
static void	manageDiscard(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	Object	cfdpdbObj = getCfdpDbObject();
	CfdpDB	cfdpdb;
	int	newDiscard;

	if (tokenCount != 3)
	{
		SYNTAX_ERROR;
	}

	newDiscard = atoi(tokens[2]);
	if (newDiscard != 0 && newDiscard != 1)
	{
		putErrmsg("discardIncompleteFile switch invalid.", tokens[2]);
		return;
	}

	sdr_begin_xn(sdr);
	sdr_stage(sdr, (char *) &cfdpdb, cfdpdbObj, sizeof(CfdpDB));
	cfdpdb.discardIncompleteFile = newDiscard;
	sdr_write(sdr, cfdpdbObj, (char *) &cfdpdb, sizeof(CfdpDB));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't change discardIncompleteFile switch.", NULL);
	}
}
예제 #14
0
파일: brsscla.c 프로젝트: brnrc/ion-dtn
static int	reforwardStrandedBundles()
{
	Sdr	sdr = getIonsdr();
	BpDB	*bpConstants = getBpConstants();
	Object	elt;
	Object	nextElt;

	CHKERR(sdr_begin_xn(sdr));
	for (elt = sdr_list_first(sdr, bpConstants->limboQueue); elt;
			elt = nextElt)
	{
		nextElt = sdr_list_next(sdr, elt);
		if (releaseFromLimbo(elt, 0) < 0)
		{
			putErrmsg("Failed releasing bundle from limbo.", NULL);
			sdr_cancel_xn(sdr);
			return -1;
		}
	}

	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("brss failed limbo release on client connect.", NULL);
		return -1;
	}

	return 0;
}
예제 #15
0
static Object newSdrAcsCustodian(Object custodians, const char *eid)
{
    Object newCustodianAddr;
    SdrAcsPendingCust newCustodian;

    memset(&newCustodian, 0, sizeof(newCustodian));
    strncpy(newCustodian.eid, eid, MAX_EID_LEN);
    newCustodian.eid[MAX_EID_LEN] = '\0';

    /* Set default ACS size and delay. */
    newCustodian.acsDelay = 2;
    newCustodian.acsSize = 300;

    CHKZERO(sdr_begin_xn(acsSdr));
    newCustodianAddr = sdr_malloc(acsSdr, sizeof(newCustodian));
    newCustodian.signals = sdr_list_create(acsSdr);
    sdr_poke(acsSdr, newCustodianAddr, newCustodian);
    sdr_list_insert_last(acsSdr, custodians, newCustodianAddr);
    if(sdr_end_xn(acsSdr) < 0)
    {
        ACSLOG_WARN("Couldn't create new custodian info for %s", eid);
        return 0;
    }
    return newCustodianAddr;
}
예제 #16
0
파일: ionadmin.c 프로젝트: michirod/cgr-jni
static void	executeList(int tokenCount, char **tokens)
{
	Sdr		sdr = getIonsdr();
	PsmPartition	ionwm = getIonwm();
	IonVdb		*vdb = getIonVdb();
	PsmAddress	elt;
	PsmAddress	addr;
	char		buffer[RFX_NOTE_LEN];

	if (tokenCount < 2)
	{
		printText("List what?");
		return;
	}

	if (strcmp(tokens[1], "contact") == 0)
	{
		CHKVOID(sdr_begin_xn(sdr));
		for (elt = sm_rbt_first(ionwm, vdb->contactIndex); elt;
				elt = sm_rbt_next(ionwm, elt))
		{
			addr = sm_rbt_data(ionwm, elt);
			rfx_print_contact(addr, buffer);
			printText(buffer);
		}

		sdr_exit_xn(sdr);
		return;
	}

	if (strcmp(tokens[1], "range") == 0)
	{
		CHKVOID(sdr_begin_xn(sdr));
		for (elt = sm_rbt_first(ionwm, vdb->rangeIndex); elt;
				elt = sm_rbt_next(ionwm, elt))
		{
			addr = sm_rbt_data(ionwm, elt);
			rfx_print_range(addr, buffer);
			printText(buffer);
		}

		sdr_exit_xn(sdr);
		return;
	}

	SYNTAX_ERROR;
}
예제 #17
0
파일: bpclock.c 프로젝트: b/ION
static void	applyRateControl(Sdr sdr)
{
	BpVdb		*vdb = getBpVdb();
	PsmPartition	ionwm = getIonwm();
	Throttle	*throttle;
	PsmAddress	elt;
	VInduct		*induct;
	VOutduct	*outduct;
	long		capacityLimit;

	sdr_begin_xn(sdr);	/*	Just to lock memory.		*/

	/*	Recalculate limit on local bundle generation.		*/

	manageProductionThrottle(vdb);

	/*	Enable some bundle acquisition.				*/

	for (elt = sm_list_first(ionwm, vdb->inducts); elt;
			elt = sm_list_next(ionwm, elt))
	{
		induct = (VInduct *) psp(ionwm, sm_list_data(ionwm, elt));
		throttle = &(induct->acqThrottle);
		capacityLimit = throttle->nominalRate << 1;
		throttle->capacity += throttle->nominalRate;
		if (throttle->capacity > capacityLimit)
		{
			throttle->capacity = capacityLimit;
		}

		if (throttle->capacity > 0)
		{
			sm_SemGive(throttle->semaphore);
		}
	}

	/*	Enable some bundle transmission.			*/

	for (elt = sm_list_first(ionwm, vdb->outducts); elt;
			elt = sm_list_next(ionwm, elt))
	{
		outduct = (VOutduct *) psp(ionwm, sm_list_data(ionwm, elt));
		throttle = &(outduct->xmitThrottle);
		capacityLimit = throttle->nominalRate << 1;
		throttle->capacity += throttle->nominalRate;
		if (throttle->capacity > capacityLimit)
		{
			throttle->capacity = capacityLimit;
		}

		if (throttle->capacity > 0)
		{
			sm_SemGive(throttle->semaphore);
		}
	}

	sdr_exit_xn(sdr);	/*	Unlock memory.			*/
}
예제 #18
0
int updateMinimumCustodyId(unsigned int minimumCustodyId)
{
    CHKERR(sdr_begin_xn(acsSdr));
    sdr_poke(acsSdr, acsConstants->id, minimumCustodyId);
    if(sdr_end_xn(acsSdr) < 0)
    {
        ACSLOG_ERROR("Couldn't update minimum custody ID to %u", minimumCustodyId);
        return -1;
    }
    return 0;
}
예제 #19
0
파일: libdtn2fw.c 프로젝트: brnrc/ion-dtn
int	dtn2_updateRule(char *nodeNm, char *demux, FwdDirective *directive)
{
	Sdr		sdr = getIonsdr();
	char		nodeName[SDRSTRING_BUFSZ];
	Object		elt;
			OBJ_POINTER(Dtn2Plan, plan);
	Object		ruleAddr;
	Dtn2Rule	ruleBuf;

	CHKERR(nodeNm && demux && directive);
	if (*demux == '\0')
	{
		writeMemo("[?] Zero-length DTN2 rule demux.");
		return 0;
	}

	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return 0;
	}

	CHKERR(sdr_begin_xn(sdr));
	elt = locatePlan(nodeName, NULL);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] No plan defined for this node", nodeNm);
		return 0;
	}

	GET_OBJ_POINTER(sdr, Dtn2Plan, plan, sdr_list_data(sdr, elt));
	dtn2_findRule(nodeName, demux, plan, &ruleAddr, &elt);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Unknown rule", demux);
		return 0;
	}

	/*	All parameters validated, okay to update the rule.	*/

	sdr_stage(sdr, (char *) &ruleBuf, ruleAddr, sizeof(Dtn2Rule));
	dtn2_destroyDirective(&ruleBuf.directive);
	memcpy((char *) &ruleBuf.directive, (char *) directive,
			sizeof(FwdDirective));
	sdr_write(sdr, ruleAddr, (char *) &ruleBuf, sizeof(Dtn2Rule));
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't update rule.", NULL);
		return -1;
	}

	return 1;
}
예제 #20
0
파일: libdtn2fw.c 프로젝트: brnrc/ion-dtn
int	dtn2_removeRule(char *nodeNm, char *demux)
{
	Sdr	sdr = getIonsdr();
	char	nodeName[SDRSTRING_BUFSZ];
	Object	elt;
		OBJ_POINTER(Dtn2Plan, plan);
	Object	ruleAddr;
		OBJ_POINTER(Dtn2Rule, rule);

	CHKERR(nodeNm && demux);
	if (*demux == '\0')
	{
		writeMemo("[?] Zero-length DTN2 rule demux.");
		return 0;
	}

	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return 0;
	}

	CHKERR(sdr_begin_xn(sdr));
	elt = locatePlan(nodeName, NULL);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] No plan defined for this node", nodeNm);
		return 0;
	}

	GET_OBJ_POINTER(sdr, Dtn2Plan, plan, sdr_list_data(sdr, elt));
	dtn2_findRule(nodeName, demux, plan, &ruleAddr, &elt);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Unknown rule", demux);
		return 0;
	}

	/*	All parameters validated, okay to remove the rule.	*/

	GET_OBJ_POINTER(sdr, Dtn2Rule, rule, ruleAddr);
	dtn2_destroyDirective(&(rule->directive));
	sdr_free(sdr, ruleAddr);
	sdr_list_delete(sdr, elt, NULL, NULL);
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't remove rule.", NULL);
		return -1;
	}

	return 1;
}
예제 #21
0
파일: libdtn2fw.c 프로젝트: brnrc/ion-dtn
int	dtn2_addPlan(char *nodeNm, FwdDirective *defaultDir)
{
	Sdr		sdr = getIonsdr();
	char		nodeName[SDRSTRING_BUFSZ];
	Object		nextPlan;
	Dtn2Plan	plan;
	Object		planObj;

	CHKERR(nodeNm && defaultDir);
	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return 0;
	}

	CHKERR(sdr_begin_xn(sdr));
	if (locatePlan(nodeName, &nextPlan) != 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Duplicate plan", nodeNm);
		return 0;
	}

	/*	Okay to add this plan to the database.			*/

	plan.nodeName = sdr_string_create(sdr, nodeName);
	memcpy((char *) &plan.defaultDirective, (char *) defaultDir,
			sizeof(FwdDirective));
	plan.rules = sdr_list_create(sdr);
	planObj = sdr_malloc(sdr, sizeof(Dtn2Plan));
	if (planObj)
	{
		if (nextPlan)
		{
			oK(sdr_list_insert_before(sdr, nextPlan, planObj));
		}
		else
		{
			oK(sdr_list_insert_last(sdr,
					(_dtn2Constants())->plans, planObj));
		}

		sdr_write(sdr, planObj, (char *) &plan, sizeof(Dtn2Plan));
	}

	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't add plan.", nodeNm);
		return -1;
	}

	return 1;
}
예제 #22
0
파일: cfdpclock.c 프로젝트: b/ION
static int	scanInFdus(Sdr sdr, time_t currentTime)
{
	CfdpDB		*cfdpConstants;
	Object		entityElt;
			OBJ_POINTER(Entity, entity);
	Object		elt;
	Object		nextElt;
	Object		fduObj;
			OBJ_POINTER(InFdu, fdu);
	CfdpHandler	handler;

	cfdpConstants = getCfdpConstants();
	sdr_begin_xn(sdr);
	for (entityElt = sdr_list_first(sdr, cfdpConstants->entities);
			entityElt; entityElt = sdr_list_next(sdr, entityElt))
	{
		GET_OBJ_POINTER(sdr, Entity, entity, sdr_list_data(sdr,
				entityElt));
		for (elt = sdr_list_first(sdr, entity->inboundFdus); elt;
				elt = nextElt)
		{
			nextElt = sdr_list_next(sdr, elt);
			fduObj = sdr_list_data(sdr, elt);
			GET_OBJ_POINTER(sdr, InFdu, fdu, fduObj);
			if (fdu->eofReceived && fdu->checkTime < currentTime)
			{
				sdr_stage(sdr, NULL, fduObj, 0);
				fdu->checkTimeouts++;
				fdu->checkTime
					+= cfdpConstants->checkTimerPeriod;
				sdr_write(sdr, fduObj, (char *) fdu,
						sizeof(InFdu));
			}

			if (fdu->checkTimeouts
				> cfdpConstants->checkTimeoutLimit)
			{
				if (handleFault(&(fdu->transactionId),
					CfdpCheckLimitReached, &handler) < 0)
				{
					sdr_cancel_xn(sdr);
					putErrmsg("Can't handle check limit \
reached.", NULL);
					return -1;
				}
			}
		}
	}
예제 #23
0
static void	executeInfo(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	ImcDB	imcdb;

	if (tokenCount != 2)
	{
		SYNTAX_ERROR;
		return;
	}

	CHKVOID(sdr_begin_xn(sdr));
	sdr_read(getIonsdr(), (char *) &imcdb, getImcDbObject(), sizeof(ImcDB));
	printKin(strtouvast(tokens[1]), imcdb.parent);
	sdr_exit_xn(sdr);
}
예제 #24
0
파일: libdtn2fw.c 프로젝트: brnrc/ion-dtn
int	dtn2Init()
{
	Sdr	sdr = getIonsdr();
	Object	dtn2dbObject;
	DtnDB	dtn2dbBuf;

	/*	Recover the DTN database, creating it if necessary.	*/

	CHKERR(sdr_begin_xn(sdr));
	dtn2dbObject = sdr_find(sdr, DTN_DBNAME, NULL);
	switch (dtn2dbObject)
	{
	case -1:		/*	SDR error.			*/
		sdr_cancel_xn(sdr);
		putErrmsg("Failed seeking DTN database in SDR.", NULL);
		return -1;

	case 0:			/*	Not found; must create new DB.	*/
		dtn2dbObject = sdr_malloc(sdr, sizeof(DtnDB));
		if (dtn2dbObject == 0)
		{
			sdr_cancel_xn(sdr);
			putErrmsg("No space for DTN database.", NULL);
			return -1;
		}

		memset((char *) &dtn2dbBuf, 0, sizeof(DtnDB));
		dtn2dbBuf.plans = sdr_list_create(sdr);
		sdr_write(sdr, dtn2dbObject, (char *) &dtn2dbBuf,
				sizeof(DtnDB));
		sdr_catlg(sdr, DTN_DBNAME, 0, dtn2dbObject);
		if (sdr_end_xn(sdr))
		{
			putErrmsg("Can't create DTN database.", NULL);
			return -1;
		}

		break;

	default:		/*	Found DB in the SDR.		*/
		sdr_exit_xn(sdr);
	}

	oK(_dtn2dbObject(&dtn2dbObject));
	oK(_dtn2Constants());
	return 0;
}
예제 #25
0
파일: libdtn2fw.c 프로젝트: brnrc/ion-dtn
int	dtn2_removePlan(char *nodeNm)
{
	Sdr	sdr = getIonsdr();
	char	nodeName[SDRSTRING_BUFSZ];
	Object	elt;
	Object	planObj;
		OBJ_POINTER(Dtn2Plan, plan);

	CHKERR(nodeNm);
	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return 0;
	}

	CHKERR(sdr_begin_xn(sdr));
	elt = locatePlan(nodeName, NULL);
	if (elt == 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Unknown plan", nodeNm);
		return 0;
	}

	planObj = sdr_list_data(sdr, elt);
	GET_OBJ_POINTER(sdr, Dtn2Plan, plan, planObj);
	if (sdr_list_length(sdr, plan->rules) > 0)
	{
		sdr_exit_xn(sdr);
		writeMemoNote("[?] Can't remove plan; still has rules", nodeNm);
		return 0;
	}

	/*	Okay to remove this plan from the database.		*/

	sdr_list_delete(sdr, elt, NULL, NULL);
	dtn2_destroyDirective(&(plan->defaultDirective));
	sdr_list_destroy(sdr, plan->rules, NULL, NULL);
	sdr_free(sdr, plan->nodeName);
	sdr_free(sdr, planObj);
	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Can't remove plan.", nodeNm);
		return -1;
	}

	return 1;
}
예제 #26
0
void    sdrnm_state_get(SdrnmState *state)
{
    Sdr		sdr = getIonsdr();
    SdrUsageSummary	usage;

    CHKVOID(state);
    CHKVOID(sdr_begin_xn(sdr));
    sdr_usage(sdr, &usage);
    state->smallPoolSize = usage.smallPoolSize;
    state->smallPoolFree = usage.smallPoolFree;
    state->smallPoolAllocated = usage.smallPoolAllocated;
    state->largePoolSize = usage.largePoolSize;
    state->largePoolFree = usage.largePoolFree;
    state->largePoolAllocated = usage.largePoolAllocated;
    state->unusedSize = usage.unusedSize;
    sdr_exit_xn(sdr);
}
예제 #27
0
int  db_forget(Object *primitiveObj, Object *descObj, Object list)
{
	Sdr sdr = getIonsdr();
	Object elt;

	if((primitiveObj == NULL) || (descObj == NULL) || (list == 0))
	{
		AMP_DEBUG_ERR("db_forget","Bad Params.",NULL);
		return -1;
	}

	CHKERR(sdr_begin_xn(sdr));

	if(*primitiveObj != 0)
	{
	  sdr_free(sdr, *primitiveObj);
	}

	if(*descObj != 0)
	{
	   elt = sdr_list_first(sdr, list);
	   while(elt)
	   {
		   if(sdr_list_data(sdr, elt) == *descObj)
		   {
			   sdr_list_delete(sdr, elt, NULL, NULL);
			   sdr_free(sdr, *descObj);
			   elt = 0;
		   }
		   else
		   {
			   elt = sdr_list_next(sdr, elt);
		   }
	   }
	}

	sdr_end_xn(sdr);

	/* Forget now invalid SDR pointers. */
	*descObj = 0;
	*primitiveObj = 0;

	return 1;
}
예제 #28
0
파일: cfdpadmin.c 프로젝트: b/ION
static void	executeInfo()
{
	Sdr	sdr = getIonsdr();
		OBJ_POINTER(CfdpDB, db);
	char	buffer[256];

	sdr_begin_xn(sdr);	/*	Just to lock memory.		*/
	GET_OBJ_POINTER(sdr, CfdpDB, db, getCfdpDbObject());
	isprintf(buffer, sizeof buffer, "xncount=%lu, maxtrnbr=%lu, \
fillchar=0x%x, discard=%hu, requirecrc=%hu, segsize=%hu, mtusize = %hu, \
inactivity=%u, ckperiod=%u, maxtimeouts=%u", db->transactionCounter,
			db->maxTransactionNbr, db->fillCharacter,
			db->discardIncompleteFile, db->crcRequired,
			db->maxFileDataLength, db->mtuSize,
			db->transactionInactivityLimit, db->checkTimerPeriod,
			db->checkTimeoutLimit);
	sdr_exit_xn(sdr);
	printText(buffer);
}
예제 #29
0
파일: libbp.c 프로젝트: b/ION
int	bp_cancel(Object bundleObj)
{
	Sdr	sdr = getIonsdr();

	sdr_begin_xn(sdr);
	if (bpDestroyBundle(bundleObj, 1) < 0)
	{
		sdr_cancel_xn(sdr);
		putErrmsg("Can't cancel bundle.", NULL);
		return -1;
	}

	if (sdr_end_xn(sdr) < 0)
	{
		putErrmsg("Failure in bundle cancellation.", NULL);
		return -1;
	}

	return 0;
}
예제 #30
0
파일: ion.c 프로젝트: b/ION
int	setDeltaFromUTC(int newDelta)
{
	Sdr	ionsdr = _ionsdr(NULL);
	Object	iondbObject = _iondbObject(NULL);
	IonDB	*ionConstants = _ionConstants();
	IonVdb	*ionvdb = _ionvdb(NULL);

	sdr_begin_xn(ionsdr);
	sdr_stage(ionsdr, (char *) ionConstants, iondbObject, sizeof(IonDB));
	ionConstants->deltaFromUTC = newDelta;
	sdr_write(ionsdr, iondbObject, (char *) ionConstants, sizeof(IonDB));
	if (sdr_end_xn(ionsdr) < 0)
	{
		putErrmsg("Can't change delta from UTC.", NULL);
		return -1;
	}

	ionvdb->deltaFromUTC = newDelta;
	return 0;
}