Beispiel #1
0
void	dtn2_findPlan(char *nodeNm, Object *planAddr, Object *eltp)
{
	Sdr	sdr = getIonsdr();
	char	nodeName[SDRSTRING_BUFSZ];
	Object	elt;

	/*	This function finds the Dtn2Plan for the specified
	 *	node, if any.						*/

	CHKVOID(ionLocked());
	CHKVOID(nodeNm && planAddr && eltp);
	*eltp = 0;
	if (filterNodeName(nodeName, nodeNm) < 0)
	{
		return;
	}

	elt = locatePlan(nodeName, NULL);
	if (elt == 0)
	{
		return;
	}

	*planAddr = sdr_list_data(sdr, elt);
	*eltp = elt;
}
Beispiel #2
0
Datei: libbp.c Projekt: 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;
			}
		}
	}
}
Beispiel #3
0
static int	loadContact(Object elt)
{
	Sdr		sdr = getIonsdr();
	Object		obj;
	IonContact	contact;
	IonCXref	cxref;

	obj = sdr_list_data(sdr, elt);
	sdr_read(sdr, (char *) &contact, obj, sizeof(IonContact));

	/*	Load contact index entry.				*/

	cxref.fromNode = contact.fromNode;
	cxref.toNode = contact.toNode;
	cxref.fromTime = contact.fromTime;
	cxref.toTime = contact.toTime;
	cxref.xmitRate = contact.xmitRate;
	cxref.prob = contact.prob;
	cxref.contactElt = elt;
	cxref.routingObject = 0;
	if (insertCXref(&cxref) == 0)
	{
		return -1;
	}

	return 0;
}
Beispiel #4
0
static int	loadRange(Object elt)
{
	Sdr		sdr = getIonsdr();
	Object		obj;
	IonRange	range;
	IonRXref	rxref;

	obj = sdr_list_data(sdr, elt);
	sdr_read(sdr, (char *) &range, obj, sizeof(IonRange));

	/*	Load range list entry.					*/

	rxref.fromNode = range.fromNode;
	rxref.toNode = range.toNode;
	rxref.fromTime = range.fromTime;
	rxref.toTime = range.toTime;
	rxref.owlt = range.owlt;
	rxref.rangeElt = elt;
	if (insertRXref(&rxref) < 0)
	{
		return -1;
	}

	return 0;
}
Beispiel #5
0
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;
}
Beispiel #6
0
Datei: cfdpadmin.c Projekt: 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);
	}
}
Beispiel #7
0
Datei: cfdpadmin.c Projekt: 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);
	}
}
Beispiel #8
0
Datei: cfdpadmin.c Projekt: 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);
	}
}
Beispiel #9
0
Datei: cfdpadmin.c Projekt: 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);
	}
}
Beispiel #10
0
Datei: cfdpadmin.c Projekt: 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);
	}
}
Beispiel #11
0
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;
}
Beispiel #12
0
Datei: cfdpadmin.c Projekt: 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);
	}
}
Beispiel #13
0
static void	printProfile(Profile *vprofile)
{
	Sdr	sdr = getIonsdr();
	char	buffer[256];
	char	sdrBuf[SDRSTRING_BUFSZ];
	
	sdr_string_read(sdr, sdrBuf, vprofile->reportToEid);
	
	isprintf(buffer, sizeof buffer, "profileID: %u maxRtx: %u lifespan: %u",
			vprofile->profileID, vprofile->maxRtx,
			vprofile->lifespan);
	printText(buffer);
	isprintf(buffer, sizeof buffer, "aggrSizeLimit: %u, aggTimeLimit: \
%u Priority: %d Custody: %d", vprofile->aggrSizeLimit, vprofile->aggrTimeLimit,
			vprofile->classOfService, vprofile->custodySwitch);
	printText(buffer);
	isprintf(buffer, sizeof buffer, "reportToEid: %s", sdrBuf);
	printText(buffer);
	isprintf(buffer, sizeof buffer, "Ordinal: %d Unreliable: %d  Critical: \
%d", vprofile->extendedCOS.ordinal, 
		vprofile->extendedCOS.flags & BP_BEST_EFFORT ? 1 : 0,
		vprofile->extendedCOS.flags & BP_MINIMUM_LATENCY ? 1 : 0);
	printText(buffer);
	isprintf(buffer, sizeof buffer, "rcvReport: %d ctReport: %d fwdReport: \
%d dlvReport: %d delReport: %d", vprofile->srrFlags & BP_RECEIVED_RPT ? 1 : 0,
		vprofile->srrFlags & BP_CUSTODY_RPT? 1 : 0,
		vprofile->srrFlags & BP_FORWARDED_RPT? 1 : 0,
		vprofile->srrFlags & BP_DELIVERED_RPT? 1 : 0,
		vprofile->srrFlags & BP_DELETED_RPT? 1 : 0);
	printText(buffer);
	return;
}
Beispiel #14
0
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);
			}

		}
	}
}
Beispiel #15
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);
}
Beispiel #16
0
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;
	}
}
Beispiel #17
0
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;
	}
}
Beispiel #18
0
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;
}
Beispiel #19
0
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;
}
Beispiel #20
0
int	ltpei_add_xmit_trailer_extension(LtpXmitSeg *segment, char tag,
		int valueLength, char *value)
{
	Sdr 			sdr = getIonsdr();
	Sdnv			sdnv;
	LtpExtensionOutbound	extension;
	Object			addr;

	CHKERR(segment);
	CHKERR(ionLocked());
	encodeSdnv(&sdnv, valueLength);
	if (segment->pdu.trailerExtensions == 0)
	{
		if ((segment->pdu.trailerExtensions = sdr_list_create(sdr))
				== 0)
		{
			return -1;	/*	No space in SDR heap.	*/
		}
	}

	extension.tag = tag;
	extension.length = valueLength;
	if (valueLength == 0)
	{
		extension.value = 0;
	}
	else
	{
		CHKERR(value);
		extension.value = sdr_insert(sdr, value, valueLength);
		if (extension.value == 0)
		{
			return -1;	/*	No space in SDR heap.	*/
		}
	}

	if ((addr = sdr_insert(sdr, (char *) &extension,
			sizeof(LtpExtensionOutbound))) == 0)
	{
		return -1;		/*	No space in SDR heap.	*/
	}

	if (sdr_list_insert_last(sdr, segment->pdu.trailerExtensions, addr)
			== 0)
	{
		return -1;		/*	No space in SDR heap.	*/
	}

	segment->pdu.trailerExtensionsCount++;
	segment->pdu.trailerLength += (1 + sdnv.length + valueLength);
	return 0;
}
Beispiel #21
0
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;
}
Beispiel #22
0
static void	executeInfo(int tokenCount, char **tokens)
{
	ImcDB	imcdb;

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

	sdr_read(getIonsdr(), (char *) &imcdb, getImcDbObject(), sizeof(ImcDB));
	printKin(strtouvast(tokens[1]), imcdb.parent);
}
Beispiel #23
0
static int	handleItem(uvast sourceEngineId, unsigned int clientId,
			Object clientServiceData)
{
	Sdr		sdr = getIonsdr();
	ZcoReader	reader;
	char		buffer[MAX_LINE_LEN + 1];

	zco_start_receiving(clientServiceData, &reader);
	memset(buffer, 0, sizeof buffer);
	zco_receive_source(sdr, &reader, MAX_LINE_LEN, buffer);
	printf("%s", buffer);
	return 0;
}
Beispiel #24
0
void destroyIonDb(char *iondbName)
{
	Sdr sdr = getIonsdr();
	IonDB iondbBuf;
	Object iondbObj;
	iondbObj = sdr_find(sdr, iondbName, NULL);
	if (iondbObj == NULL)
		return;
	sdr_read(sdr, (char *) &iondbBuf, iondbObj, sizeof(IonDB));
	sdr_list_destroy(sdr, iondbBuf.contacts, NULL, NULL);
	sdr_list_destroy(sdr, iondbBuf.ranges, NULL, NULL);
	sdr_free(sdr, iondbObj);
	//fprintf(stderr, "ionDb destroyed: %d\n", getOwnNodeNbr());
}
Beispiel #25
0
static void	executeList(int tokenCount, char **tokens)
{
	Sdr	sdr = getIonsdr();
	ImcDB	imcdb;
	Object	elt;
		OBJ_POINTER(NodeId, node);

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

	CHKVOID(sdr_begin_xn(sdr));
	sdr_read(getIonsdr(), (char *) &imcdb, getImcDbObject(), sizeof(ImcDB));
	for (elt = sdr_list_first(sdr, imcdb.kin); elt;
			elt = sdr_list_next(sdr, elt))
	{
		GET_OBJ_POINTER(sdr, NodeId, node, sdr_list_data(sdr, elt));
		printKin(node->nbr, imcdb.parent);
	}

	sdr_exit_xn(sdr);
}
Beispiel #26
0
void	dtn2_findRule(char *nodeNm, char *demux, Dtn2Plan *plan,
		Object *ruleAddr, Object *eltp)
{
	Sdr	sdr = getIonsdr();
	char	nodeName[SDRSTRING_BUFSZ];
	Object	elt;
		OBJ_POINTER(Dtn2Plan, planPtr);

	/*	This function finds the Dtn2Rule for the specified
	 *	demux token, for the specified destination node, if
	 *	any.							*/

	CHKVOID(ionLocked());
	CHKVOID(ruleAddr);
	CHKVOID(eltp);
	*eltp = 0;
	if (plan == NULL)
	{
		if (nodeNm == NULL)
		{
			return;
		}

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

		elt = locatePlan(nodeName, NULL);
		if (elt == 0)
		{
			return;
		}

		GET_OBJ_POINTER(sdr, Dtn2Plan, planPtr, sdr_list_data(sdr,
					elt));
		plan = planPtr;
	}

	elt = locateRule(plan, demux, NULL);
	if (elt == 0)
	{
		return;
	}

	*ruleAddr = sdr_list_data(sdr, elt);
	*eltp = elt;
}
Beispiel #27
0
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;
}
Beispiel #28
0
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;
}
Beispiel #29
0
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;
}
Beispiel #30
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);
}