Esempio n. 1
0
static void	terminateReceiverThread(ReceiverThreadParms *parms)
{
	int	senderSocket;

	writeErrmsgMemos();
	writeMemo("[i] brsscla receiver thread stopping.");
	pthread_mutex_lock(parms->mutex);
	if (parms->bundleSocket != -1)
	{
		closesocket(parms->bundleSocket);
		if (parms->ductNbr != (unsigned int) -1)
		{
			senderSocket = parms->ductNbr - parms->baseDuctNbr;
			if (parms->brsSockets[senderSocket] ==
					parms->bundleSocket)
			{
				/*	Stop sender thread transmission
				 *	over this socket.  Note: does
				 *	not halt the sender thread.	*/

				parms->brsSockets[senderSocket] = -1;
			}
		}

		parms->bundleSocket = -1;
	}

	lyst_delete(parms->elt);
	pthread_mutex_unlock(parms->mutex);
	MRELEASE(parms);
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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);
}
Esempio n. 4
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.");
	}
}
Esempio n. 5
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;
	}