Пример #1
0
void CPortC32Interface::ResetBuffers(TUint aFlags)
/**
 * Called by C32 when the client requests to reset the buffers,
 * by removing all receive and/or transmit messages according to
 * the specified flags.
 *
 * @param aFlags Indicate which buffers (receive and/or transmit) should be reset
 */
	{
	_LOG_L4C2(">>CPortC32Interface::ResetBuffers [aFlags=%d]", aFlags);
	_LOG_L4C2("[port=%d]", GetPortNumber());

	if (aFlags & KCommResetRx)
		{
		_LOG_L4C1("Removing all messages intended for the C32 client");

		RemoveWaitingAllFrames();
		}

	if (aFlags & KCommResetTx)
		{
		_LOG_L4C1("Removing all messages intended for the modem");

		GetMuxChannel()->WriteCancel();
		}

	_LOG_L4C1("<<CPortC32Interface::ResetBuffers");
	}
Пример #2
0
void GPIO_Pin::Print() {
	char port = 'A' + GetPortNumber();
  std::bitset<16> bits(Pin);
	int pin;
  for (pin = 0; pin < 16 && !bits[pin]; pin++);
	printf("P%c%d", port, pin);
}
Пример #3
0
void CPortC32Interface::SendFrameToClient(CCsyMsgBufBpFrame* aFrame)
/**
 * This method is called by a CSY Channel object when it has a single
 * frame to send to a C32 client RComm object.
 *
 * @param aFrame - Pointer to message to send to client
 */
	{
	_LOG_L4C2( "CPortC32Interface::SendFrameToClient [port=%d]", GetPortNumber());

	if (aFrame)
		{
		// check if queue is empty
		TBool trigger = iFramesWaitingToBeReadList.IsEmpty();

		iFramesWaitingToBeReadList.AddLast(*aFrame);
		if (trigger)
			{
			_LOG_L4C1("No packets already waiting");
			if (iIsReadInProgress)
				{
				_LOG_L4C1("A read is outstanding");
				ReadFromBufOrQueue();
				}
			}

		// inform client new data is available
		SetDataAvailable();
		}
	else
		{
		//MAF __ASSERT_DEBUG(EFalse, PANIC(KPanicIllegalState));
		}
	}
Пример #4
0
int gxsURL::ParseURL(const gxString &url, gxsURLInfo &u, int strict)
// Extract the specified URL in the following format:
// URL protocol://username:password@hostname:port/path/filename
// Extracts the hostname terminated with `/' or `:'.
// Extracts the port number terminated with `/', or chosen for the protocol.
// The directory name equals everything after the hostname.
// The URL information will be passed back in the "u" variable. 
// Returns false if any errors occur during the parsing
// operation.
{
  u.url = url;

  int rv = ParseProtocol(url, u.proto, u.proto_type);

  if(strict && !rv) return 0;

  gxString clean_url;
  ParseUserName(url, u.user, u.passwd, clean_url);

  if(!ParseHostName(clean_url, u.host)) return 0;

  if(!ParsePortNumber(clean_url, u.port)) GetPortNumber(clean_url, u.port);

  if(u.proto_type == gxs_ftp) ProcessFTPType(clean_url, u.ftp_type);

  ParseDirectory(clean_url, u.path, u.dir, u.file);

  ParseDynamicPage(u);  

  return 1; // No errors reported
}
Пример #5
0
TInt CPortC32Interface::QueryReceiveBuffer(TInt& aLength) const
/**
 * Called by C32 when the client queries the size of the receive buffer,
 * which returns the number of receive characters available to be read by
 * the C32 client RComm instance.
 *
 * @param aLength - Reference to client's buffer length variable
 * @return KErrNone
 */
	{
	_LOG_L4C2( "CPortC32Interface::QueryReceiveBuffer [port=%d]", GetPortNumber());

	aLength = 0;
	if (iReadBuf)
		{
		aLength = iReadBuf->iMsg.Length();
		_LOG_L4C2("iReadBuf aLength=%d", aLength);
		}
	else if (!iFramesWaitingToBeReadList.IsEmpty())
		{
		CCsyMsgBufBpFrame* frame = iFramesWaitingToBeReadList.First();
		if ((frame)&&(frame->iMsg.Length() >= (KAdvOptionHeaderSize + KChecksumSize)))
			{
#ifdef _27010ADVANCEOPTION
			aLength = frame->iMsg.Length() - (KAdvOptionHeaderSize + KChecksumSize);
#else
			aLength = frame->iMsg.Length() - (KBasicOptionHeaderSize + KChecksumSize);
#endif
			_LOG_L4C2("iFramesWaitingToBeReadList aLength=%d", aLength);
			}
		}

	return KErrNone;
	}
void CPortC32InterfaceIp::PlaceIpPacketFramesOntoReadList()
/**
 * Place all frames to do with recent IP packet onto read list
 */
	{
	_LOG_L4C2(">>CPortC32InterfaceIp::PlaceIpPacketFramesOntoReadList [port=%d]", GetPortNumber());

	CCsyMsgBufBpFrame* frame = NULL;
	iFramesReceivedForIpPacketIter.SetToFirst();
	while ((frame = iFramesReceivedForIpPacketIter++) != NULL)
		{
		iFramesReceivedForIpPacket.Remove(*frame);
		iFramesWaitingToBeReadList.AddLast(*frame);
		}
	iCurrentIpPacketLength = 0;
	iNumberOfPacketsWaiting++;
	_LOG_L4C2("iNumberOfPacketsWaiting=%d",iNumberOfPacketsWaiting);

	if (iNumberOfPacketsWaiting == KMaxPacketsOutstandingForC32Client)
		{
		_LOG_L2C1("Client appears to be slow at reading");
		_LOG_L2C3("iNumberOfPacketsWaiting %d > KMaxPacketsOutstandingForC32Client %d)",
			iNumberOfPacketsWaiting,KMaxPacketsOutstandingForC32Client);

		iMuxChannel->SetCsyToModemFlowControl(EFlowControlOn);
		}

	_LOG_L4C1("<<CPortC32InterfaceIp::PlaceIpPacketFramesOntoReadList");
	}
Пример #7
0
uint32_t GPIO_Pin::GetClock() {
  switch(GetPortNumber()) {
	  case 0: return RCC_APB2Periph_GPIOA; case 1: return RCC_APB2Periph_GPIOB;
		case 2: return RCC_APB2Periph_GPIOC; case 3: return RCC_APB2Periph_GPIOD;
		case 4: return RCC_APB2Periph_GPIOE; case 5: return RCC_APB2Periph_GPIOF;
		case 6: return RCC_APB2Periph_GPIOG;
	}
	return 0;
}
TBool CPortC32InterfaceIp::CreateIpPacketFromFrames()
/**
 * We assume that all validation has been done during SendFrameToClient so only valid
 * data exists on the iFramesWaitingToBeReadList frame list.
 *
 * @return ETrue if packet retrieved successfully
 */
	{
	_LOG_L4C2(">>CPortC32InterfaceIp::CreateIpPacketFromFrames [port=%d]", GetPortNumber());

	iIpPacket.Zero();

	TUint8	framePosition = 0;
	TInt	length = 0;
	TBool	packetRetrieved = EFalse;

	// Remove all frames to do with the same IP Packet from waiting to be read list
	CCsyMsgBufBpFrame* frame = NULL;
	iFramesWaitingToBeReadIter.SetToFirst();
	while ((frame = iFramesWaitingToBeReadIter++) != NULL)
		{
		iFramesWaitingToBeReadList.Remove(*frame);

		framePosition = frame->GetType4FrameSequence();
		_LOG_L4C2("framePosition = 0x%02x",framePosition);

		length = frame->iMsg.Length() - KAdvOptionNumOfNonDataOctets;
		_LOG_L4C2("length=%d",length);

		iIpPacket.Append(&frame->iMsg[KAdvOptionType4StartOfMessageData], length);

		iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(frame);

		if ((framePosition == KSingleFrame)||(framePosition == KEndMultiFrame))
			{
			_LOG_L4C1("retrieved packet");
			packetRetrieved = ETrue;

			if (iNumberOfPacketsWaiting == KMaxPacketsOutstandingForC32Client)
				{
				_LOG_L2C1("Client appears to be reading again");

				// Assume it is okay to set FC to Off even in low free frame
				// condition since just freed a frame.

				iMuxChannel->SetCsyToModemFlowControl(EFlowControlOff);
				}

			iNumberOfPacketsWaiting--;
			_LOG_L4C2("iNumberOfPacketsWaiting=%d",iNumberOfPacketsWaiting);
			break;
			}
		}

	_LOG_L4C2("<<CPortC32InterfaceIp::CreateIpPacketFromFrames [packetRetrieved=%d]",packetRetrieved);
	return packetRetrieved;
	}
Пример #9
0
void GPIO_Pin::ConfigInternal() {
	int portNumber = GetPortNumber();
	if (!portClockEnabled[portNumber]) {
	  RCC_APB2PeriphClockCmd(GetClock(), ENABLE);
		portClockEnabled[portNumber] = true;
	}
  GPIO_InitTypeDef GPIO_InitStructure;
  GPIO_InitStructure.GPIO_Pin = Pin;
  GPIO_InitStructure.GPIO_Mode = Mode;
  GPIO_InitStructure.GPIO_Speed = Speed;
  GPIO_Init(Port, &GPIO_InitStructure);
}
void CPortC32InterfaceIp::PlaceIpPacketFramesOntoFreeList()
/**
 * Place all frames to do with recent IP packet onto free list
 */
	{
	_LOG_L4C2(">>CPortC32InterfaceIp::PlaceIpPacketFramesOntoFreeList [port=%d]", GetPortNumber());

	CCsyMsgBufBpFrame* frame = NULL;
	iFramesReceivedForIpPacketIter.SetToFirst();
	while ((frame = iFramesReceivedForIpPacketIter++) != NULL)
		{
		iFramesReceivedForIpPacket.Remove(*frame);
		iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(frame);
		}
	iCurrentIpPacketLength = 0;

	_LOG_L4C1("<<CPortC32InterfaceIp::PlaceIpPacketFramesOntoFreeList");
	}
TInt CPortC32InterfaceIp::QueryReceiveBuffer(TInt& aLength) const
/**
 * Called by C32 when the client queries the size of the receive buffer,
 * which returns the number of receive characters available to be read by
 * the C32 client RComm instance.
 *
 * @param aLength - Reference to client's buffer length variable
 * @return KErrNone
 */
	{
	_LOG_L4C2("CPortC32InterfaceIp::QueryReceiveBuffer [port=%d]", GetPortNumber());

	aLength = 0;

	// MAF

	return KErrNone;
	}
void CPortC32InterfaceIp::ResetBuffers(TUint aFlags)
/**
 * Called by C32 when the client requests to reset the buffers,
 * by removing all receive and/or transmit messages according to
 * the specified flags.
 *
 * @param aFlags Indicate which buffers (receive and/or transmit) should be reset
 */
	{
	_LOG_L4C3(">>CPortC32InterfaceIp::ResetBuffers [aFlags=%d,port=%d]",
		aFlags,GetPortNumber());

	if (aFlags & KCommResetRx)
		{
		_LOG_L4C1("Removing all messages intended for the C32 client");

		RemoveWaitingAllFrames();

		// remove all frames to do with the most recent IP packet
		CCsyMsgBufBpFrame* ipPacketFrame = NULL;
		iFramesReceivedForIpPacketIter.SetToFirst();
		while ((ipPacketFrame = iFramesReceivedForIpPacketIter++) != NULL)
			{
			iFramesReceivedForIpPacket.Remove(*ipPacketFrame);
			delete ipPacketFrame;
			}
		}

	if (aFlags & KCommResetTx)
		{
		_LOG_L4C1("Removing all messages intended for the modem");

		GetMuxChannel()->WriteCancel();
		}

	_LOG_L4C1("<<CPortC32InterfaceIp::ResetBuffers");
	}
Пример #13
0
int main(void)
{
	int sockfd,no_of_items[3],no_of_items_in_truck[3],i,num,rv;
	char cnt[50],temp[50],filename[50],buf[MAXDATASIZE],hostName[1024];
	struct addrinfo *p,hints,*servinfo;
	socklen_t addr_len;
	struct sockaddr_storage their_addr;	
	strcpy(filename,"Store-1.txt");
	ReadFileAndGetValues(no_of_items,filename);
	memset(&cnt, '\0', sizeof cnt);
	for(i=0;i<3;i++)
	{
		sprintf(temp, "%d", no_of_items[i]);
		strcat(cnt,temp);
		strcat(cnt,",");
	}
	GetHostNames(hostName);
	CreateSocket("TCPClient",&sockfd,"21891",hostName);
	printf("Phase 1: store_1 has TCP port number %d and IP address %s.\n",GetPortNumber(sockfd),GetIPAddress(hostName));
	printf("Phase 1: The outlet vector \"%s\" for store_1 has been sent to the central warehouse.\n",cnt);
	if(send(sockfd,&cnt,sizeof(cnt),0)==-1)
	{
		perror("recv");
	}
	close(sockfd);
	printf("End of phase 1 for store_1.\n");
	p=CreateSocket("UDPListener",&sockfd,"5891",hostName);
	printf("Phase 2: Store_1 has UDP port 5891 and IP Address %s.\n",GetIPAddress(hostName));
	addr_len = sizeof their_addr;
	if ((num = recvfrom(sockfd, buf, MAXDATASIZE-1 , 0,(struct sockaddr *)&their_addr, &addr_len)) == -1)
	{
		perror("recvfrom");
		exit(1);
	}
	buf[num] = '\0';
	printf("Phase 2: Store_1 received the truck vector \"%s\" from the Central Warehouse.\n", buf);
	close(sockfd);
	GetCharToInt(no_of_items_in_truck,buf);
	CreateNewTruckVector(no_of_items,no_of_items_in_truck);
	memset(&cnt, '\0', sizeof cnt);
	for(i=0;i<3;i++)
	{
		sprintf(temp, "%d", no_of_items_in_truck[i]);
		strcat(cnt,temp);
		strcat(cnt,",");
	}
	p=CreateSocket("UDPTalker",&sockfd,"6891",NULL);
	printf("Phase 2: Store_1 has UDP port 6891 and IP Address %s.\n",GetIPAddress(hostName));
	memset(&hints,0,sizeof hints);
	hints.ai_family=AF_INET;
	hints.ai_socktype=SOCK_DGRAM;
	if ((rv = getaddrinfo(hostName, "9891", &hints, &servinfo)) != 0)
	{
		fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
		return ;
	}
	if ((num = sendto(sockfd, cnt, strlen(cnt), 0, servinfo->ai_addr, servinfo->ai_addrlen)) == -1)
	{
		perror("talker: sendto");
		exit(1);
	}
	printf("Phase 2: The updated truck vector \"%s\" has been sent to Store_2.\n",cnt);
	printf("Phase 2: Store_1 updated outlet vector is : %d,%d,%d,\n",no_of_items[0],no_of_items[1],no_of_items[2]);
	close(sockfd);
	p=CreateSocket("UDPListener",&sockfd,"7891",hostName);
	printf("Phase 2: Store_1 has UDP port 7891 and IP Address %s.\n",GetIPAddress(hostName));
	addr_len = sizeof their_addr;
	if ((num = recvfrom(sockfd, buf, MAXDATASIZE-1 , 0,(struct sockaddr *)&their_addr, &addr_len)) == -1)
	{
		perror("recvfrom");
		exit(1);
	}
	buf[num] = '\0';
	printf("Phase 2: The truck vector \"%s\" has been received from Store_4.\n", buf);
	close(sockfd);
	GetCharToInt(no_of_items_in_truck,buf);
	CreateNewTruckVector(no_of_items,no_of_items_in_truck);
	memset(&cnt, '\0', sizeof cnt);
	for(i=0;i<3;i++)
	{
		sprintf(temp, "%d", no_of_items_in_truck[i]);
		strcat(cnt,temp);
		strcat(cnt,",");
	}
	p=CreateSocket("UDPTalker",&sockfd,"8891",NULL);
	printf("Phase 2: Store_1 has UDP port 8891 and IP Address %s.\n",GetIPAddress(hostName));
	memset(&hints,0,sizeof hints);
	hints.ai_family=AF_INET;
	hints.ai_socktype=SOCK_DGRAM;
	if ((rv = getaddrinfo(hostName, "11891", &hints, &servinfo)) != 0)
	{
		fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
		return ;
	}
	if ((num = sendto(sockfd, cnt, strlen(cnt), 0, servinfo->ai_addr, servinfo->ai_addrlen)) == -1)
	{
		perror("talker: sendto");
		exit(1);
	}
	printf("Phase 2: The updated truck vector \"%s\" has been sent to Store_2.\n",cnt);
	printf("Phase 2: Store_1 updated outlet vector is : %d,%d,%d,\n",no_of_items[0],no_of_items[1],no_of_items[2]);
	close(sockfd);
	printf("End of phase 2 for Store_1.\n");
	return 0;
}
Пример #14
0
TBool CPortC32Interface::ReadFromBufOrQueue()
/**
 * This method is called to read from buffer or the frame list
 * It will read as much as possible.
 *
 * @return ETrue if complete the read request
 */
	{
	_LOG_L4C2( ">>CPortC32Interface::ReadFromBufOrQueue [port=%d]",GetPortNumber());

	TBool completedTheReadRequest = EFalse;

	TInt err = KErrGeneral;
	TBool cont;
	do
		{
		cont = EFalse;
		if(iReadBuf==NULL)
			{
			//Read data from the frame list
			if (!iFramesWaitingToBeReadList.IsEmpty())
				{
				_LOG_L4C1("Set to first item");
				iReadBuf = iFramesWaitingToBeReadList.First();
				if (iReadBuf)
					{
					_LOG_L4C1("iReadBuf not null");
					// remove msg buf from client list
					iFramesWaitingToBeReadList.Remove(*iReadBuf);

					// subtract checksum field
					TInt frameLength = iReadBuf->iMsg.Length();
					_LOG_L4C2("New read buffer frameLength=%d",frameLength);

					if (frameLength >= KBasicOptionHeaderSize)
						{
						iReadBuf->iMsg.SetLength(frameLength - KChecksumSize);

						// remove leading header ints from frame
#ifdef _27010ADVANCEOPTION
						iReadBuf->iMsg.Delete(0, KAdvOptionHeaderSize);
#else
						iReadBuf->iMsg.Delete(0, KBasicOptionHeaderSize);
#endif
						}
					else
						{
						_LOG_L4C1("Incorrect frame size - freeing read buffer");
						iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(iReadBuf);
						iReadBuf = NULL;
						}
					}
				}
			}
		if (iReadBuf)
			{
			TInt length = -1;
			if (iClientLength - iPos < iReadBuf->iMsg.Length())
				{
				length = iClientLength - iPos;
				_LOG_L4C2("length = %d",length);
				}

			if (iConfig.iTerminatorCount > 0)
				{
				_LOG_L4C2("iTerminatorCount = %d",iConfig.iTerminatorCount);

				// First find terminator
				TInt terminatorLoc = -1;
				TInt loc;
				for (TInt i=0; i< iConfig.iTerminatorCount;i++)
					{
					loc = iReadBuf->iMsg.LocateF(iConfig.iTerminator[i]);
					if (loc > KErrNotFound)
						{
						if (terminatorLoc == KErrNotFound)
							{
							terminatorLoc = loc;
							}
						else
							{
							terminatorLoc = Min(loc,terminatorLoc);
							}
						}
					}
				if (terminatorLoc>KErrNotFound)
					{
					if (length > KErrNotFound)
						length = Min(terminatorLoc + 1,length);
					else
						length = terminatorLoc + 1;
					}
				_LOG_L4C2("length = %d",length);
				}

			_LOG_L4C2("Read buf length %d",iReadBuf->iMsg.Length());

			if ((iReadBuf->iMsg.Length() >= length) && (length > -1))
				{
				_LOG_L2C2("complete partial read: # %d ", length);

				iPartialReadBuf.Copy(&iReadBuf->iMsg[0], length);
				iReadBuf->iMsg.Delete(0, length);

				err = IPCWrite(iClientBuffer, iPartialReadBuf, iPos); 
				if (err)
					{
					_LOG_L1C2("** IPCWrite Error %d **",err);
					}

				CompleteReadRequest(err);
				err = KErrGeneral;

				completedTheReadRequest = ETrue;
				iPos = 0;

				if (iReadBuf->iMsg.Length()==0)
					{
					_LOG_L4C1("All data used - freeing read buffer");
					iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(iReadBuf);
					iReadBuf = NULL;
					}
				}
			else
				{
				err = IPCWrite(iClientBuffer, iReadBuf->iMsg, iPos);
				if (err)
					{
					_LOG_L1C2("** IPCWrite Error %d **",err);
					}

				_LOG_L4C3( "Read: iPos = %d, add %d bytes", iPos, iReadBuf->iMsg.Length());

				//try read next frame in the list
				cont = ETrue; 
				iPos += iReadBuf->iMsg.Length();

				_LOG_L4C1("Freeing read buffer");
				iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(iReadBuf);
				iReadBuf = NULL;
				}
			}
		}
	while (cont);

	if (iPos>0)
		{
		if (iOneOrMore)
			{
			CompleteReadRequest(err);
			iPos = 0;
			completedTheReadRequest = ETrue;
			}
		else 
			{
			//normal read and have not filled the buffer yet
			_LOG_L4C3( "Not filled buffer yet iPos = %d, iClientLength = %d", iPos, iClientLength);
			}
		}

	_LOG_L4C2( "<<CPortC32Interface::ReadFromBufOrQueue [completedTheReadRequest=%d]",completedTheReadRequest);
	return completedTheReadRequest;
	}
TBool CPortC32InterfaceIp::ReadFromBufOrQueue()
/**
 * This method is called to read from buffer or the frame list
 * It will read as much as possible.
 *
 * @return ETrue if complete the read request
 */
	{
	_LOG_L4C2(">>CPortC32InterfaceIp::ReadFromBufOrQueue [port=%d]", GetPortNumber());

	TBool completedRead = EFalse;
	TInt ret = KErrNone;

	_LOG_L4C2("iOneOrMore=%d",iOneOrMore);
	_LOG_L4C2("iClientLength=%d",iClientLength);

	while ((CreateIpPacketFromFrames())&&(!ret))
		{
		TInt ipPacketLength = iIpPacket.Length();
		TInt length = -1; 
		if (iClientLength - iPos < ipPacketLength)
			{
			length = iClientLength - iPos;
			_LOG_L4C2("length remaining = %d",length);
			}

		if ((length > -1) && (ipPacketLength >= length))
			{
			// MAF should partial reads be allowed?
			_LOG_L2C1("Partial read?");

			}
		else
			{
			_LOG_L4C3("read buf %d >= length %d ", ipPacketLength, length);

			ret = IPCWrite(iClientBuffer, iIpPacket, iPos);
			if (ret)
				{
				_LOG_L1C2("** IPCWrite Error %d **",ret);
				}

			_LOG_L4C3("Read: iPos = %d, add %d bytes", iPos, ipPacketLength);

			iPos += ipPacketLength;
			}
		}

	if (iPos>0)
		{
		if (iOneOrMore)
			{
			CompleteReadRequest(ret);

			iPos = 0;
			completedRead = ETrue;
			}
		else
			{
			//normal read? and have not filled the buffer yet
			_LOG_L4C3( "Not filled buffer yet iPos = %d, iClientLength = %d", iPos, iClientLength);
			}
		}
	
	_LOG_L4C2("<<CPortC32InterfaceIp::ReadFromBufOrQueue [completedRead=%d]", completedRead);
	return completedRead;
	}
void CPortC32InterfaceIp::SendFrameToClient(CCsyMsgBufBpFrame* aFrame)
/**
 * This method is called by a CSY Channel object when it has a single
 * frame to send to a C32 client RComm object.
 *
 * @param aFrame - Pointer to message to send to client
 */
	{
	_LOG_L4C2(">>CPortC32InterfaceIp::SendFrameToClient [port=%d]", GetPortNumber());

	if (aFrame)
		{
		// frame validation
		if (aFrame->iMsg.Length() <= KAdvOptionNumOfNonDataOctets)
			{
			_LOG_L1C1("** Does not appear to be a valid frame - disregarding **");

			// Place received frames on the empty list
			iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(aFrame);
			PlaceIpPacketFramesOntoFreeList();

			_LOG_L4C1("<<CPortC32InterfaceIp::SendFrameToClient - bad frame");
			return;
			}

		TUint8 framePosition = aFrame->GetType4FrameSequence();
		_LOG_L4C2("framePosition = 0x%02x",framePosition);

		// read buffer validation
		if (iFramesReceivedForIpPacket.IsEmpty())
			{
			// There is no read buffer allocated for this frame
			switch (framePosition)
				{
			case KSingleFrame:
			case KStartMultiFrame:
				{
				_LOG_L4C1("Starting new IP frame list");
				iCurrentIpPacketLength = 0;
				}
				break;
			case KEndMultiFrame:
			case KMiddleMultiFrame:
			default:
				// assumption here is that because no read buffer is allocated then
				// there cannot have been a valid start frame
				_LOG_L1C1("** Missed start of packet - disregarding **");

				// Place received frame on the empty list
				iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(aFrame);

				_LOG_L4C1("<<CPortC32InterfaceIp::SendFrameToClient - no start");
				return;
				}
			}
		else if ((framePosition == KSingleFrame)||(framePosition == KStartMultiFrame))
			{
			// There's been a comms error and an end packet has been lost
			_LOG_L1C1("** Unexpected Start/Single frame - disregarded previous frames **");

			// Place received frames on the empty list
			PlaceIpPacketFramesOntoFreeList();

			// Continue processing this frame
			_LOG_L4C1("Starting new IP frame list");
			iCurrentIpPacketLength = 0;
			}

		// If have got to here then IP frame list exists

		TInt length = aFrame->iMsg.Length() - KAdvOptionNumOfNonDataOctets;
		_LOG_L4C2("length=%d",length);

		// length validation
		if ((iCurrentIpPacketLength + length) > KMaxIpPacketSize)
			{
			// The length of the data in the new frame would exceed that available
			// in the read buffer.

			_LOG_L1C3("** iCurrentIpPacketLength + length %d exceeds max size %d **",
				(iCurrentIpPacketLength + length),KMaxIpPacketSize);

			// Place received frames on the empty list
			iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(aFrame);
			PlaceIpPacketFramesOntoFreeList();

			_LOG_L4C1("<<CPortC32InterfaceIp::SendFrameToClient - frame sized exceeded");
			return;
			}

		// If have got to here IP frame list exists and length is valid
		iCurrentIpPacketLength += length;

		TBool addReadBufferToClientList = EFalse;
		switch (framePosition)
			{
		// Single frame	
		case KSingleFrame:
			_LOG_L4C1("Only frame");
			iFramesReceivedForIpPacket.AddFirst(*aFrame);
			addReadBufferToClientList = ETrue;
			break;

		// Multiframe
		case KStartMultiFrame:
			_LOG_L4C1("Start multiframe");
			iFramesReceivedForIpPacket.AddFirst(*aFrame);
			break;

		case KMiddleMultiFrame:
			_LOG_L4C1("Middle multiframe");
			iFramesReceivedForIpPacket.AddLast(*aFrame);
			break;

		case KEndMultiFrame:
			_LOG_L4C1("Last multiframe");
			iFramesReceivedForIpPacket.AddLast(*aFrame);
			addReadBufferToClientList = ETrue;
			break;

		// Unknown
		default:
			_LOG_L1C2("** Unknown framePosition %d - ignoring **",
				framePosition);

			// Place received frame on the empty list
			iPortFactory.GetMux0710Protocol()->AddFrameFreeQ(aFrame);
			PlaceIpPacketFramesOntoFreeList();

			_LOG_L4C1("<<CPortC32InterfaceIp::SendFrameToClient - unknown frame pos");
			return;
			}

		if (addReadBufferToClientList)
			{
			// Give iFramesWaitingToBeReadList ownership of the frames making up the IP Packet
			_LOG_L4C1("Transfer frames to client msg list");

			// check if queue is empty
			TBool trigger = iFramesWaitingToBeReadList.IsEmpty();

			PlaceIpPacketFramesOntoReadList();

			if (trigger)
				{
				_LOG_L4C1("No packets already waiting");
				if (iIsReadInProgress)
					{
					_LOG_L4C1("A read is outstanding");
					ReadFromBufOrQueue();
					}
				}

			// inform client new data is available
			SetDataAvailable();
			}
		}
	else
		{
		_LOG_L1C1("** aFrame is null **");
		// MAF __ASSERT_DEBUG(EFalse, PANIC(KPanicIllegalState));
		}

	_LOG_L4C1("<<CPortC32InterfaceIp::SendFrameToClient");
	}