|
@@ -29,69 +29,66 @@
|
|
|
|
|
|
|
|
#include "SCOutmsgEncoder.h"
|
|
#include "SCOutmsgEncoder.h"
|
|
|
|
|
|
|
|
-static void output_handler_recv (SCOutmsgEncoder *enc, uint8_t *data)
|
|
|
|
|
|
|
+static void output_handler_recv (SCOutmsgEncoder *o, uint8_t *data)
|
|
|
{
|
|
{
|
|
|
- ASSERT(!enc->output_packet)
|
|
|
|
|
|
|
+ DebugObject_Access(&o->d_obj);
|
|
|
|
|
+ ASSERT(!o->output_packet)
|
|
|
ASSERT(data)
|
|
ASSERT(data)
|
|
|
- DebugObject_Access(&enc->d_obj);
|
|
|
|
|
|
|
|
|
|
// schedule receive
|
|
// schedule receive
|
|
|
- enc->output_packet = data;
|
|
|
|
|
- PacketRecvInterface_Receiver_Recv(enc->input, enc->output_packet + SCOUTMSG_OVERHEAD);
|
|
|
|
|
|
|
+ o->output_packet = data;
|
|
|
|
|
+ PacketRecvInterface_Receiver_Recv(o->input, o->output_packet + SCOUTMSG_OVERHEAD);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void input_handler_done (SCOutmsgEncoder *enc, int in_len)
|
|
|
|
|
|
|
+static void input_handler_done (SCOutmsgEncoder *o, int in_len)
|
|
|
{
|
|
{
|
|
|
- ASSERT(enc->output_packet)
|
|
|
|
|
- DebugObject_Access(&enc->d_obj);
|
|
|
|
|
|
|
+ DebugObject_Access(&o->d_obj);
|
|
|
|
|
+ ASSERT(o->output_packet)
|
|
|
|
|
|
|
|
// write SC header
|
|
// write SC header
|
|
|
- struct sc_header *header = (struct sc_header *)enc->output_packet;
|
|
|
|
|
|
|
+ struct sc_header *header = (struct sc_header *)o->output_packet;
|
|
|
header->type = htol8(SCID_OUTMSG);
|
|
header->type = htol8(SCID_OUTMSG);
|
|
|
|
|
|
|
|
// write outmsg
|
|
// write outmsg
|
|
|
struct sc_client_outmsg *outmsg = (struct sc_client_outmsg *)(header + 1);
|
|
struct sc_client_outmsg *outmsg = (struct sc_client_outmsg *)(header + 1);
|
|
|
- outmsg->clientid = htol16(enc->peer_id);
|
|
|
|
|
|
|
+ outmsg->clientid = htol16(o->peer_id);
|
|
|
|
|
|
|
|
// finish output packet
|
|
// finish output packet
|
|
|
- enc->output_packet = NULL;
|
|
|
|
|
- PacketRecvInterface_Done(&enc->output, SCOUTMSG_OVERHEAD + in_len);
|
|
|
|
|
|
|
+ o->output_packet = NULL;
|
|
|
|
|
+ PacketRecvInterface_Done(&o->output, SCOUTMSG_OVERHEAD + in_len);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void SCOutmsgEncoder_Init (SCOutmsgEncoder *enc, peerid_t peer_id, PacketRecvInterface *input, BPendingGroup *pg)
|
|
|
|
|
|
|
+void SCOutmsgEncoder_Init (SCOutmsgEncoder *o, peerid_t peer_id, PacketRecvInterface *input, BPendingGroup *pg)
|
|
|
{
|
|
{
|
|
|
ASSERT(PacketRecvInterface_GetMTU(input) <= INT_MAX - SCOUTMSG_OVERHEAD)
|
|
ASSERT(PacketRecvInterface_GetMTU(input) <= INT_MAX - SCOUTMSG_OVERHEAD)
|
|
|
|
|
|
|
|
// init arguments
|
|
// init arguments
|
|
|
- enc->peer_id = peer_id;
|
|
|
|
|
- enc->input = input;
|
|
|
|
|
|
|
+ o->peer_id = peer_id;
|
|
|
|
|
+ o->input = input;
|
|
|
|
|
|
|
|
// init input
|
|
// init input
|
|
|
- PacketRecvInterface_Receiver_Init(enc->input, (PacketRecvInterface_handler_done)input_handler_done, enc);
|
|
|
|
|
|
|
+ PacketRecvInterface_Receiver_Init(o->input, (PacketRecvInterface_handler_done)input_handler_done, o);
|
|
|
|
|
|
|
|
// init output
|
|
// init output
|
|
|
- PacketRecvInterface_Init(
|
|
|
|
|
- &enc->output, SCOUTMSG_OVERHEAD + PacketRecvInterface_GetMTU(enc->input),
|
|
|
|
|
- (PacketRecvInterface_handler_recv)output_handler_recv, enc, pg
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ PacketRecvInterface_Init(&o->output, SCOUTMSG_OVERHEAD + PacketRecvInterface_GetMTU(o->input), (PacketRecvInterface_handler_recv)output_handler_recv, o, pg);
|
|
|
|
|
|
|
|
// set no output packet
|
|
// set no output packet
|
|
|
- enc->output_packet = NULL;
|
|
|
|
|
|
|
+ o->output_packet = NULL;
|
|
|
|
|
|
|
|
- DebugObject_Init(&enc->d_obj);
|
|
|
|
|
|
|
+ DebugObject_Init(&o->d_obj);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void SCOutmsgEncoder_Free (SCOutmsgEncoder *enc)
|
|
|
|
|
|
|
+void SCOutmsgEncoder_Free (SCOutmsgEncoder *o)
|
|
|
{
|
|
{
|
|
|
- DebugObject_Free(&enc->d_obj);
|
|
|
|
|
|
|
+ DebugObject_Free(&o->d_obj);
|
|
|
|
|
|
|
|
// free input
|
|
// free input
|
|
|
- PacketRecvInterface_Free(&enc->output);
|
|
|
|
|
|
|
+ PacketRecvInterface_Free(&o->output);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-PacketRecvInterface * SCOutmsgEncoder_GetOutput (SCOutmsgEncoder *enc)
|
|
|
|
|
|
|
+PacketRecvInterface * SCOutmsgEncoder_GetOutput (SCOutmsgEncoder *o)
|
|
|
{
|
|
{
|
|
|
- DebugObject_Access(&enc->d_obj);
|
|
|
|
|
|
|
+ DebugObject_Access(&o->d_obj);
|
|
|
|
|
|
|
|
- return &enc->output;
|
|
|
|
|
|
|
+ return &o->output;
|
|
|
}
|
|
}
|