conn_send_data_msg.

FossilOrigin-Name: 469a0fa682e19fd904090de5636be41653de68f5f225b96e1be1ba8c90f33141
This commit is contained in:
7u83@mail.ru 2016-03-27 02:53:12 +00:00
parent fa64aca0d8
commit c8829f2c8d

View File

@ -65,7 +65,53 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
}
int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
{
int packetlen = len;
cw_dbg_msg(DBG_MSG_OUT, conn,rawmsg, packetlen,(struct sockaddr*)&conn->addr);
uint8_t * ptr = rawmsg;
int fragoffset = 0;
int hlen = cw_get_hdr_hlen(rawmsg)*4;
int mtu = conn->mtu;
while (packetlen>mtu){
cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F,1);
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,mtu,(struct sockaddr*)&conn->addr);
if (conn->write_data(conn,ptr,mtu)<0)
return -1;
// XXX Fragmentation stuff..
ptr +=mtu-hlen;
fragoffset+=(mtu-hlen)/8;
packetlen-=mtu-hlen;
}
if (fragoffset)
cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F | CW_FLAG_HDR_L,1);
else
cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F,0);
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
return conn->write_data(conn,ptr,packetlen-0);
}