Exemplo n.º 1
0
// Function which adds a subscriber to the tree
void AddSubscriber(SUBSCRIBER **tree, BYTE username[MAX_USERNAME_LENGTH], LONG_MAC mac, MAC_ADDRESS mac_array, unsigned short session_id, BYTE auth_ppp_identifier, BYTE authenticator[16]) {

	// If the location of the new node is found, add new subscriber to bottom of tree
	if ((*tree) == NULL) {

		*tree = malloc (sizeof(SUBSCRIBER));
		(*tree)->right = NULL;
		(*tree)->left = NULL;
		(*tree)->creationTime = time(NULL);

		(*tree)->mac = mac;
		(*tree)->mac_array[0] = mac_array[0];
		(*tree)->mac_array[1] = mac_array[1];
		(*tree)->mac_array[2] = mac_array[2];
		memcpy((*tree)->username, username, strlen(username));
		(*tree)->session_id = session_id;
		(*tree)->echoReceived = FALSE;
		(*tree)->bytesSent = 0;
		(*tree)->bytesReceived = 0;

		(*tree)->authenticated = 0;
		memcpy((*tree)->aaaAuthenticator, authenticator, 16);
		(*tree)->auth_ppp_identifier = auth_ppp_identifier;

		//		PrintSubscribers(*tree);
	}

	// Otherwise, search the tree
	else if (mac < (*tree)->mac) AddSubscriber(&(*tree)->left, username, mac, mac_array, session_id, auth_ppp_identifier, authenticator);

	else if (mac > (*tree)->mac) AddSubscriber(&(*tree)->right, username, mac, mac_array, session_id, auth_ppp_identifier, authenticator);
}
Exemplo n.º 2
0
// register a callback for device connection status events
wmx_Status_t PIPE_HANDLER_RegisterCtrlStatusUpdatesCB(wmx_pCtrlStatusUpdateCB_t ctrlStatusUpdateCB)
{
	if (!PIPE_HANDLER_IsInitialized())
	{
		return WMX_ST_MODULE_NOT_INITIALIZED;
	}
	
	if ((ctrlStatusUpdateCB != NULL) && (eventsSubsList != NULL) && (AddSubscriber(eventsSubsList, ctrlStatusUpdateCB) != NULL))
	{
		return WMX_ST_OK;
	}
	return WMX_ST_CALLBACK_NOT_REGISTERED;
}