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__); }
void AddShortToPacket(short byte2) { blist = AddToBufferList(blist,&byte2,2); }
void AddIntToPacket(int byte4) { blist = AddToBufferList(blist,&byte4,4); }
/* these few functions are for synched mode */ void AddByteToPacket(unsigned char byte1) { blist = AddToBufferList(blist,&byte1,1); }