Exemple #1
0
void AddStringToPacket(int int_len,const char *ptr)
{
   unsigned short len;

   len = int_len;

   blist = AddToBufferList(blist,&len,2);
   blist = AddToBufferList(blist,(void *) ptr,int_len);
}
void SendBytes(session_node *s,char *buf,int len_buf)
{
	if (s->conn.type == CONN_CONSOLE)
	{
		InterfaceSendBytes(buf,len_buf);
		return;
	}
	
	if (s->hangup)
		return;   
	
	if (WaitForSingleObject(s->muxSend,10000) != WAIT_OBJECT_0)
	{
		eprintf("SendBytes couldn't get session %i muxSend\n",s->session_id);
		return;
	}
	
	if (s->send_list == NULL)
	{
		/* if nothing in queue, try to send right now */
		
		if (send(s->conn.socket,buf,len_buf,0) == SOCKET_ERROR)
		{
			if (GetLastError() != WSAEWOULDBLOCK)
			{
				/* eprintf("SendBytes got send error %i\n",GetLastError()); */
				if (!ReleaseMutex(s->muxSend))
					eprintf("File %s line %i release of non-owned mutex\n",__FILE__,__LINE__);
				HangupSession(s);
				return;
			}
			
			s->send_list = AddToBufferList(s->send_list,buf,len_buf);
		}
		else
		{
			transmitted_bytes += len_buf;
		}
	}
	else
	{
		s->send_list = AddToBufferList(s->send_list,buf,len_buf);
	}
	
	if (!ReleaseMutex(s->muxSend))
		eprintf("File %s line %i release of non-owned mutex\n",__FILE__,__LINE__);
}
Exemple #3
0
void AddShortToPacket(short byte2)
{
   blist = AddToBufferList(blist,&byte2,2);
}
Exemple #4
0
void AddIntToPacket(int byte4)
{
   blist = AddToBufferList(blist,&byte4,4);
}
Exemple #5
0
/* these few functions are for synched mode */
void AddByteToPacket(unsigned char byte1)
{
   blist = AddToBufferList(blist,&byte1,1);
}