Explorar el Código

client: rename DataProtoDevice->DataProtoSource, DataProtoDest->DataProtoSink,
DataProtoLocalSource->DataProtoFlow

ambrop7 hace 15 años
padre
commit
123722a072
Se han modificado 6 ficheros con 102 adiciones y 102 borrados
  1. 16 16
      client/DPRelay.c
  2. 4 4
      client/DPRelay.h
  3. 29 29
      client/DataProto.c
  4. 28 28
      client/DataProto.h
  5. 22 22
      client/client.c
  6. 3 3
      client/client.h

+ 16 - 16
client/DPRelay.c

@@ -47,9 +47,9 @@ static struct DPRelay_flow * create_flow (DPRelaySource *src, DPRelaySink *sink,
     flow->src = src;
     flow->sink = sink;
     
-    // init DataProtoLocalSource
-    if (!DataProtoLocalSource_Init(&flow->dpls, &src->router->device, src->source_id, sink->dest_id, num_packets, inactivity_time, (DataProtoLocalSource_handler_inactivity)flow_inactivity_handler, flow)) {
-        BLog(BLOG_ERROR, "relay flow %d->%d: DataProtoLocalSource_Init failed", (int)src->source_id, (int)sink->dest_id);
+    // init DataProtoFlow
+    if (!DataProtoFlow_Init(&flow->dpls, &src->router->device, src->source_id, sink->dest_id, num_packets, inactivity_time, (DataProtoFlow_handler_inactivity)flow_inactivity_handler, flow)) {
+        BLog(BLOG_ERROR, "relay flow %d->%d: DataProtoFlow_Init failed", (int)src->source_id, (int)sink->dest_id);
         goto fail1;
     }
     
@@ -61,7 +61,7 @@ static struct DPRelay_flow * create_flow (DPRelaySource *src, DPRelaySink *sink,
     
     // attach flow if needed
     if (sink->dest) {
-        DataProtoLocalSource_Attach(&flow->dpls, sink->dest);
+        DataProtoFlow_Attach(&flow->dpls, sink->dest);
     }
     
     BLog(BLOG_INFO, "relay flow %d->%d: created", (int)src->source_id, (int)sink->dest_id);
@@ -78,7 +78,7 @@ static void free_flow (struct DPRelay_flow *flow)
 {
     // detach flow if needed
     if (flow->sink->dest) {
-        DataProtoLocalSource_Detach(&flow->dpls);
+        DataProtoFlow_Detach(&flow->dpls);
     }
     
     // remove posible router reference
@@ -92,8 +92,8 @@ static void free_flow (struct DPRelay_flow *flow)
     // remove from source list
     LinkedList1_Remove(&flow->src->flows_list, &flow->src_list_node);
     
-    // free DataProtoLocalSource
-    DataProtoLocalSource_Free(&flow->dpls);
+    // free DataProtoFlow
+    DataProtoFlow_Free(&flow->dpls);
     
     // free structore
     free(flow);
@@ -130,7 +130,7 @@ static void source_device_handler (DPRelayRouter *o, const uint8_t *frame, int f
     }
     
     // route frame to current flow
-    DataProtoLocalSource_Route(&o->current_flow->dpls, 0);
+    DataProtoFlow_Route(&o->current_flow->dpls, 0);
     
     // set no current flow
     o->current_flow = NULL;
@@ -147,8 +147,8 @@ int DPRelayRouter_Init (DPRelayRouter *o, int frame_mtu, BReactor *reactor)
     // init BufferWriter
     BufferWriter_Init(&o->writer, frame_mtu, BReactor_PendingGroup(reactor));
     
-    // init DataProtoDevice
-    if (!DataProtoDevice_Init(&o->device, BufferWriter_GetOutput(&o->writer), (DataProtoDevice_handler)source_device_handler, o, reactor)) {
+    // init DataProtoSource
+    if (!DataProtoSource_Init(&o->device, BufferWriter_GetOutput(&o->writer), (DataProtoSource_handler)source_device_handler, o, reactor)) {
         goto fail1;
     }
     
@@ -171,8 +171,8 @@ void DPRelayRouter_Free (DPRelayRouter *o)
     DebugCounter_Free(&o->d_ctr);
     DebugObject_Free(&o->d_obj);
     
-    // free DataProtoDevice
-    DataProtoDevice_Free(&o->device);
+    // free DataProtoSource
+    DataProtoSource_Free(&o->device);
     
     // free BufferWriter
     BufferWriter_Free(&o->writer);
@@ -251,7 +251,7 @@ void DPRelaySource_PrepareFreeDestinations (DPRelaySource *o)
     while (node) {
         struct DPRelay_flow *flow = UPPER_OBJECT(node, struct DPRelay_flow, src_list_node);
         if (flow->sink->dest) {
-            DataProtoDest_PrepareFree(flow->sink->dest);
+            DataProtoSink_PrepareFree(flow->sink->dest);
         }
         node = LinkedList1Node_Next(node);
     }
@@ -284,7 +284,7 @@ void DPRelaySink_Free (DPRelaySink *o)
     }
 }
 
-void DPRelaySink_Attach (DPRelaySink *o, DataProtoDest *dest)
+void DPRelaySink_Attach (DPRelaySink *o, DataProtoSink *dest)
 {
     ASSERT(!o->dest)
     DebugObject_Access(&o->d_obj);
@@ -296,7 +296,7 @@ void DPRelaySink_Attach (DPRelaySink *o, DataProtoDest *dest)
     LinkedList1Node *node = LinkedList1_GetFirst(&o->flows_list);
     while (node) {
         struct DPRelay_flow *flow = UPPER_OBJECT(node, struct DPRelay_flow, sink_list_node);
-        DataProtoLocalSource_Attach(&flow->dpls, o->dest);
+        DataProtoFlow_Attach(&flow->dpls, o->dest);
         node = LinkedList1Node_Next(node);
     }
 }
@@ -313,7 +313,7 @@ void DPRelaySink_Detach (DPRelaySink *o)
     LinkedList1Node *node = LinkedList1_GetFirst(&o->flows_list);
     while (node) {
         struct DPRelay_flow *flow = UPPER_OBJECT(node, struct DPRelay_flow, sink_list_node);
-        DataProtoLocalSource_Detach(&flow->dpls);
+        DataProtoFlow_Detach(&flow->dpls);
         node = LinkedList1Node_Next(node);
     }
 }

+ 4 - 4
client/DPRelay.h

@@ -39,7 +39,7 @@ struct DPRelay_flow;
 typedef struct {
     int frame_mtu;
     BufferWriter writer;
-    DataProtoDevice device;
+    DataProtoSource device;
     struct DPRelay_flow *current_flow;
     DebugObject d_obj;
     DebugCounter d_ctr;
@@ -54,7 +54,7 @@ typedef struct {
 
 typedef struct {
     peerid_t dest_id;
-    DataProtoDest *dest;
+    DataProtoSink *dest;
     LinkedList1 flows_list;
     DebugObject d_obj;
 } DPRelaySink;
@@ -62,7 +62,7 @@ typedef struct {
 struct DPRelay_flow {
     DPRelaySource *src;
     DPRelaySink *sink;
-    DataProtoLocalSource dpls;
+    DataProtoFlow dpls;
     LinkedList1Node src_list_node;
     LinkedList1Node sink_list_node;
 };
@@ -77,7 +77,7 @@ void DPRelaySource_PrepareFreeDestinations (DPRelaySource *o);
 
 void DPRelaySink_Init (DPRelaySink *o, peerid_t dest_id);
 void DPRelaySink_Free (DPRelaySink *o);
-void DPRelaySink_Attach (DPRelaySink *o, DataProtoDest *dest);
+void DPRelaySink_Attach (DPRelaySink *o, DataProtoSink *dest);
 void DPRelaySink_Detach (DPRelaySink *o);
 
 #endif

+ 29 - 29
client/DataProto.c

@@ -33,15 +33,15 @@
 
 #include <generated/blog_channel_DataProto.h>
 
-static void monitor_handler (DataProtoDest *o);
-static void send_keepalive (DataProtoDest *o);
-static void refresh_up_job (DataProtoDest *o);
-static void receive_timer_handler (DataProtoDest *o);
-static void notifier_handler (DataProtoDest *o, uint8_t *data, int data_len);
-static void keepalive_job_handler (DataProtoDest *o);
-static void up_job_handler (DataProtoDest *o);
+static void monitor_handler (DataProtoSink *o);
+static void send_keepalive (DataProtoSink *o);
+static void refresh_up_job (DataProtoSink *o);
+static void receive_timer_handler (DataProtoSink *o);
+static void notifier_handler (DataProtoSink *o, uint8_t *data, int data_len);
+static void keepalive_job_handler (DataProtoSink *o);
+static void up_job_handler (DataProtoSink *o);
 
-void monitor_handler (DataProtoDest *o)
+void monitor_handler (DataProtoSink *o)
 {
     ASSERT(!o->freeing)
     DebugObject_Access(&o->d_obj);
@@ -49,14 +49,14 @@ void monitor_handler (DataProtoDest *o)
     send_keepalive(o);
 }
 
-void send_keepalive (DataProtoDest *o)
+void send_keepalive (DataProtoSink *o)
 {
     ASSERT(!o->freeing)
     
     PacketRecvBlocker_AllowBlockedPacket(&o->ka_blocker);
 }
 
-void refresh_up_job (DataProtoDest *o)
+void refresh_up_job (DataProtoSink *o)
 {
     if (o->up != o->up_report) {
         BPending_Set(&o->up_job);
@@ -65,7 +65,7 @@ void refresh_up_job (DataProtoDest *o)
     }
 }
 
-void receive_timer_handler (DataProtoDest *o)
+void receive_timer_handler (DataProtoSink *o)
 {
     DebugObject_Access(&o->d_obj);
     
@@ -75,7 +75,7 @@ void receive_timer_handler (DataProtoDest *o)
     refresh_up_job(o);
 }
 
-void notifier_handler (DataProtoDest *o, uint8_t *data, int data_len)
+void notifier_handler (DataProtoSink *o, uint8_t *data, int data_len)
 {
     ASSERT(data_len >= sizeof(struct dataproto_header))
     DebugObject_Access(&o->d_obj);
@@ -90,7 +90,7 @@ void notifier_handler (DataProtoDest *o, uint8_t *data, int data_len)
     }
 }
 
-void keepalive_job_handler (DataProtoDest *o)
+void keepalive_job_handler (DataProtoSink *o)
 {
     ASSERT(!o->freeing)
     DebugObject_Access(&o->d_obj);
@@ -98,7 +98,7 @@ void keepalive_job_handler (DataProtoDest *o)
     send_keepalive(o);
 }
 
-void up_job_handler (DataProtoDest *o)
+void up_job_handler (DataProtoSink *o)
 {
     ASSERT(o->up != o->up_report)
     ASSERT(!o->freeing)
@@ -110,7 +110,7 @@ void up_job_handler (DataProtoDest *o)
     return;
 }
 
-static void device_router_handler (DataProtoDevice *o, uint8_t *buf, int recv_len)
+static void device_router_handler (DataProtoSource *o, uint8_t *buf, int recv_len)
 {
     ASSERT(buf)
     ASSERT(recv_len >= 0)
@@ -126,7 +126,7 @@ static void device_router_handler (DataProtoDevice *o, uint8_t *buf, int recv_le
     return;
 }
 
-int DataProtoDest_Init (DataProtoDest *o, BReactor *reactor, PacketPassInterface *output, btime_t keepalive_time, btime_t tolerance_time, DataProtoDest_handler handler, void *user)
+int DataProtoSink_Init (DataProtoSink *o, BReactor *reactor, PacketPassInterface *output, btime_t keepalive_time, btime_t tolerance_time, DataProtoSink_handler handler, void *user)
 {
     ASSERT(PacketPassInterface_HasCancel(output))
     ASSERT(PacketPassInterface_GetMTU(output) >= DATAPROTO_MAX_OVERHEAD)
@@ -197,7 +197,7 @@ fail1:
     return 0;
 }
 
-void DataProtoDest_Free (DataProtoDest *o)
+void DataProtoSink_Free (DataProtoSink *o)
 {
     DebugCounter_Free(&o->d_ctr);
     DebugObject_Free(&o->d_obj);
@@ -236,7 +236,7 @@ void DataProtoDest_Free (DataProtoDest *o)
     BPending_Free(&o->keepalive_job);
 }
 
-void DataProtoDest_PrepareFree (DataProtoDest *o)
+void DataProtoSink_PrepareFree (DataProtoSink *o)
 {
     DebugObject_Access(&o->d_obj);
     
@@ -247,7 +247,7 @@ void DataProtoDest_PrepareFree (DataProtoDest *o)
     o->freeing = 1;
 }
 
-void DataProtoDest_Received (DataProtoDest *o, int peer_receiving)
+void DataProtoSink_Received (DataProtoSink *o, int peer_receiving)
 {
     ASSERT(peer_receiving == 0 || peer_receiving == 1)
     ASSERT(!o->freeing)
@@ -269,7 +269,7 @@ void DataProtoDest_Received (DataProtoDest *o, int peer_receiving)
     refresh_up_job(o);
 }
 
-int DataProtoDevice_Init (DataProtoDevice *o, PacketRecvInterface *input, DataProtoDevice_handler handler, void *user, BReactor *reactor)
+int DataProtoSource_Init (DataProtoSource *o, PacketRecvInterface *input, DataProtoSource_handler handler, void *user, BReactor *reactor)
 {
     ASSERT(PacketRecvInterface_GetMTU(input) <= INT_MAX - DATAPROTO_MAX_OVERHEAD)
     
@@ -295,7 +295,7 @@ fail1:
     return 0;
 }
 
-void DataProtoDevice_Free (DataProtoDevice *o)
+void DataProtoSource_Free (DataProtoSource *o)
 {
     DebugCounter_Free(&o->d_ctr);
     DebugObject_Free(&o->d_obj);
@@ -304,9 +304,9 @@ void DataProtoDevice_Free (DataProtoDevice *o)
     PacketRouter_Free(&o->router);
 }
 
-int DataProtoLocalSource_Init (
-    DataProtoLocalSource *o, DataProtoDevice *device, peerid_t source_id, peerid_t dest_id, int num_packets,
-    int inactivity_time, DataProtoLocalSource_handler_inactivity handler_inactivity, void *user
+int DataProtoFlow_Init (
+    DataProtoFlow *o, DataProtoSource *device, peerid_t source_id, peerid_t dest_id, int num_packets,
+    int inactivity_time, DataProtoFlow_handler_inactivity handler_inactivity, void *user
 )
 {
     ASSERT(num_packets > 0)
@@ -350,7 +350,7 @@ fail0:
     return 0;
 }
 
-void DataProtoLocalSource_Free (DataProtoLocalSource *o)
+void DataProtoFlow_Free (DataProtoFlow *o)
 {
     ASSERT(!o->dp)
     DebugCounter_Decrement(&o->device->d_ctr);
@@ -368,7 +368,7 @@ void DataProtoLocalSource_Free (DataProtoLocalSource *o)
     PacketPassConnector_Free(&o->connector);
 }
 
-void DataProtoLocalSource_Route (DataProtoLocalSource *o, int more)
+void DataProtoFlow_Route (DataProtoFlow *o, int more)
 {
     ASSERT(more == 0 || more == 1)
     PacketRouter_AssertRoute(&o->device->router);
@@ -397,7 +397,7 @@ void DataProtoLocalSource_Route (DataProtoLocalSource *o, int more)
     o->device->current_buf = (more ? next_buf : NULL);
 }
 
-void DataProtoLocalSource_Attach (DataProtoLocalSource *o, DataProtoDest *dp)
+void DataProtoFlow_Attach (DataProtoFlow *o, DataProtoSink *dp)
 {
     ASSERT(dp)
     ASSERT(!o->dp)
@@ -418,12 +418,12 @@ void DataProtoLocalSource_Attach (DataProtoLocalSource *o, DataProtoDest *dp)
     DebugCounter_Increment(&dp->d_ctr);
 }
 
-void DataProtoLocalSource_Detach (DataProtoLocalSource *o)
+void DataProtoFlow_Detach (DataProtoFlow *o)
 {
     ASSERT(o->dp)
     DebugObject_Access(&o->d_obj);
     
-    DataProtoDest *dp = o->dp;
+    DataProtoSink *dp = o->dp;
     
     // release flow if needed
     if (!o->dp->freeing && PacketPassFairQueueFlow_IsBusy(&o->dp_qflow)) {

+ 28 - 28
client/DataProto.h

@@ -42,9 +42,9 @@
 #include <flow/PacketPassConnector.h>
 #include <flow/PacketRouter.h>
 
-typedef void (*DataProtoDest_handler) (void *user, int up);
-typedef void (*DataProtoDevice_handler) (void *user, const uint8_t *frame, int frame_len);
-typedef void (*DataProtoLocalSource_handler_inactivity) (void *user);
+typedef void (*DataProtoSink_handler) (void *user, int up);
+typedef void (*DataProtoSource_handler) (void *user, const uint8_t *frame, int frame_len);
+typedef void (*DataProtoFlow_handler_inactivity) (void *user);
 
 /**
  * Frame destination.
@@ -63,21 +63,21 @@ typedef struct {
     BTimer receive_timer;
     int up;
     int up_report;
-    DataProtoDest_handler handler;
+    DataProtoSink_handler handler;
     void *user;
     BPending keepalive_job;
     BPending up_job;
     int freeing;
     DebugObject d_obj;
     DebugCounter d_ctr;
-} DataProtoDest;
+} DataProtoSink;
 
 /**
  * Object that receives frames from a device and routes
- * them to buffers in {@link DataProtoLocalSource} objects.
+ * them to buffers in {@link DataProtoFlow} objects.
  */
 typedef struct {
-    DataProtoDevice_handler handler;
+    DataProtoSource_handler handler;
     void *user;
     BReactor *reactor;
     int frame_mtu;
@@ -86,24 +86,24 @@ typedef struct {
     int current_recv_len;
     DebugObject d_obj;
     DebugCounter d_ctr;
-} DataProtoDevice;
+} DataProtoSource;
 
 /**
  * Local frame source.
  * Buffers frames received from the TAP device, addressed to a particular peer.
  */
 typedef struct {
-    DataProtoDevice *device;
+    DataProtoSource *device;
     peerid_t source_id;
     peerid_t dest_id;
     int inactivity_time;
     RouteBuffer rbuf;
     PacketPassInactivityMonitor monitor;
     PacketPassConnector connector;
-    DataProtoDest *dp;
+    DataProtoSink *dp;
     PacketPassFairQueueFlow dp_qflow;
     DebugObject d_obj;
-} DataProtoLocalSource;
+} DataProtoFlow;
 
 /**
  * Initializes the object.
@@ -119,7 +119,7 @@ typedef struct {
  * @param user value to pass to handler
  * @return 1 on success, 0 on failure
  */
-int DataProtoDest_Init (DataProtoDest *o, BReactor *reactor, PacketPassInterface *output, btime_t keepalive_time, btime_t tolerance_time, DataProtoDest_handler handler, void *user) WARN_UNUSED;
+int DataProtoSink_Init (DataProtoSink *o, BReactor *reactor, PacketPassInterface *output, btime_t keepalive_time, btime_t tolerance_time, DataProtoSink_handler handler, void *user) WARN_UNUSED;
 
 /**
  * Frees the object.
@@ -127,7 +127,7 @@ int DataProtoDest_Init (DataProtoDest *o, BReactor *reactor, PacketPassInterface
  * 
  * @param o the object
  */
-void DataProtoDest_Free (DataProtoDest *o);
+void DataProtoSink_Free (DataProtoSink *o);
 
 /**
  * Prepares for freeing the object by allowing freeing of local sources.
@@ -137,7 +137,7 @@ void DataProtoDest_Free (DataProtoDest *o);
  * 
  * @param o the object
  */
-void DataProtoDest_PrepareFree (DataProtoDest *o);
+void DataProtoSink_PrepareFree (DataProtoSink *o);
 
 /**
  * Notifies the object that a packet was received from the peer.
@@ -147,7 +147,7 @@ void DataProtoDest_PrepareFree (DataProtoDest *o);
  * @param peer_receiving whether the DATAPROTO_FLAGS_RECEIVING_KEEPALIVES flag was set in the packet.
  *                       Must be 0 or 1.
  */
-void DataProtoDest_Received (DataProtoDest *o, int peer_receiving);
+void DataProtoSink_Received (DataProtoSink *o, int peer_receiving);
 
 /**
  * Initiazes the object.
@@ -155,20 +155,20 @@ void DataProtoDest_Received (DataProtoDest *o, int peer_receiving);
  * @param o the object
  * @param input device input. Its input MTU must be <= INT_MAX - DATAPROTO_MAX_OVERHEAD.
  * @param handler handler called when a packet arrives to allow the user to route it to
- *                appropriate {@link DataProtoLocalSource} objects.
+ *                appropriate {@link DataProtoFlow} objects.
  * @param user value passed to handler
  * @param reactor reactor we live in
  * @return 1 on success, 0 on failure
  */
-int DataProtoDevice_Init (DataProtoDevice *o, PacketRecvInterface *input, DataProtoDevice_handler handler, void *user, BReactor *reactor) WARN_UNUSED;
+int DataProtoSource_Init (DataProtoSource *o, PacketRecvInterface *input, DataProtoSource_handler handler, void *user, BReactor *reactor) WARN_UNUSED;
 
 /**
  * Frees the object.
- * There must be no {@link DataProtoLocalSource} objects referring to this device.
+ * There must be no {@link DataProtoFlow} objects referring to this device.
  * 
  * @param o the object
  */
-void DataProtoDevice_Free (DataProtoDevice *o);
+void DataProtoSource_Free (DataProtoSource *o);
 
 /**
  * Initializes the object.
@@ -183,14 +183,14 @@ void DataProtoDevice_Free (DataProtoDevice *o);
  * @param inactivity_time milliseconds of output inactivity after which to call the
  *                        inactivity handler; <0 to disable. Note that the object is considered
  *                        active as long as its buffer is non-empty, even if is not attached to
- *                        a {@link DataProtoDest}.
+ *                        a {@link DataProtoSink}.
  * @param handler_inactivity inactivity handler, if inactivity_time >=0
  * @param user value to pass to handler
  * @return 1 on success, 0 on failure
  */
-int DataProtoLocalSource_Init (
-    DataProtoLocalSource *o, DataProtoDevice *device, peerid_t source_id, peerid_t dest_id, int num_packets,
-    int inactivity_time, DataProtoLocalSource_handler_inactivity handler_inactivity, void *user
+int DataProtoFlow_Init (
+    DataProtoFlow *o, DataProtoSource *device, peerid_t source_id, peerid_t dest_id, int num_packets,
+    int inactivity_time, DataProtoFlow_handler_inactivity handler_inactivity, void *user
 ) WARN_UNUSED;
 
 /**
@@ -199,11 +199,11 @@ int DataProtoLocalSource_Init (
  * 
  * @param o the object
  */
-void DataProtoLocalSource_Free (DataProtoLocalSource *o);
+void DataProtoFlow_Free (DataProtoFlow *o);
 
 /**
  * Routes a frame from the device to this object.
- * Must be called from within the job context of the {@link DataProtoDevice_handler} handler.
+ * Must be called from within the job context of the {@link DataProtoSource_handler} handler.
  * Must not be called after this has been called with more=0 for the current frame.
  * 
  * @param o the object
@@ -211,7 +211,7 @@ void DataProtoLocalSource_Free (DataProtoLocalSource *o);
  *             objects. If 0, must not be called again until the handler is
  *             called for the next frame. Must be 0 or 1.
  */
-void DataProtoLocalSource_Route (DataProtoLocalSource *o, int more);
+void DataProtoFlow_Route (DataProtoFlow *o, int more);
 
 /**
  * Attaches the object to a destination.
@@ -221,7 +221,7 @@ void DataProtoLocalSource_Route (DataProtoLocalSource *o, int more);
  * @param dp destination to attach to. This object's frame_mtu must be <=
  *           (output MTU of dp) - DATAPROTO_MAX_OVERHEAD.
  */
-void DataProtoLocalSource_Attach (DataProtoLocalSource *o, DataProtoDest *dp);
+void DataProtoFlow_Attach (DataProtoFlow *o, DataProtoSink *dp);
 
 /**
  * Detaches the object from a destination.
@@ -229,6 +229,6 @@ void DataProtoLocalSource_Attach (DataProtoLocalSource *o, DataProtoDest *dp);
  * 
  * @param o the object
  */
-void DataProtoLocalSource_Detach (DataProtoLocalSource *o);
+void DataProtoFlow_Detach (DataProtoFlow *o);
 
 #endif

+ 22 - 22
client/client.c

@@ -324,7 +324,7 @@ static struct peer_data * find_peer_by_id (peerid_t id);
 // device error handler
 static void device_error_handler (void *unused);
 
-// DataProtoDevice handler for packets from the device
+// DataProtoSource handler for packets from the device
 static void device_input_dpd_handler (void *unused, const uint8_t *frame, int frame_len);
 
 // assign relays to clients waiting for them
@@ -516,8 +516,8 @@ int main (int argc, char *argv[])
     BLog(BLOG_INFO, "device MTU is %d", device.mtu);
     
     // init device input
-    if (!DataProtoDevice_Init(&device.input_dpd, BTap_GetOutput(&device.btap), device_input_dpd_handler, NULL, &ss)) {
-        BLog(BLOG_ERROR, "DataProtoDevice_Init failed");
+    if (!DataProtoSource_Init(&device.input_dpd, BTap_GetOutput(&device.btap), device_input_dpd_handler, NULL, &ss)) {
+        BLog(BLOG_ERROR, "DataProtoSource_Init failed");
         goto fail7;
     }
     
@@ -603,7 +603,7 @@ fail8a:
     FrameDecider_Free(&frame_decider);
 fail8:
     PacketPassFairQueue_Free(&device.output_queue);
-    DataProtoDevice_Free(&device.input_dpd);
+    DataProtoSource_Free(&device.input_dpd);
 fail7:
     BTap_Free(&device.btap);
 fail6:
@@ -1365,8 +1365,8 @@ int peer_add (peerid_t id, int flags, const uint8_t *cert, int cert_len)
     }
     
     // init local flow
-    if (!DataProtoLocalSource_Init(&peer->local_dpflow, &device.input_dpd, my_id, peer->id, options.send_buffer_size, -1, NULL, NULL)) {
-        peer_log(peer, BLOG_ERROR, "DataProtoLocalSource_Init failed");
+    if (!DataProtoFlow_Init(&peer->local_dpflow, &device.input_dpd, my_id, peer->id, options.send_buffer_size, -1, NULL, NULL)) {
+        peer_log(peer, BLOG_ERROR, "DataProtoFlow_Init failed");
         goto fail1a;
     }
     
@@ -1429,7 +1429,7 @@ fail5:
     DPRelaySink_Free(&peer->relay_sink);
     DPRelaySource_Free(&peer->relay_source);
     PacketPassFairQueueFlow_Free(&peer->local_recv_qflow);
-    DataProtoLocalSource_Free(&peer->local_dpflow);
+    DataProtoFlow_Free(&peer->local_dpflow);
 fail1a:
     if (peer->common_name) {
         PORT_Free(peer->common_name);
@@ -1514,7 +1514,7 @@ void peer_dealloc (struct peer_data *peer)
     PacketPassFairQueueFlow_Free(&peer->local_recv_qflow);
     
     // free local flow
-    DataProtoLocalSource_Free(&peer->local_dpflow);
+    DataProtoFlow_Free(&peer->local_dpflow);
     
     // free common name
     if (peer->common_name) {
@@ -1594,15 +1594,15 @@ int peer_init_link (struct peer_data *peer)
     }
     
     // init sending
-    if (!DataProtoDest_Init(&peer->send_dp, &ss, link_if, PEER_KEEPALIVE_INTERVAL, PEER_KEEPALIVE_RECEIVE_TIMER, (DataProtoDest_handler)peer_dataproto_handler, peer)) {
+    if (!DataProtoSink_Init(&peer->send_dp, &ss, link_if, PEER_KEEPALIVE_INTERVAL, PEER_KEEPALIVE_RECEIVE_TIMER, (DataProtoSink_handler)peer_dataproto_handler, peer)) {
         peer_log(peer, BLOG_ERROR, "DataProto_Init failed");
         goto fail2;
     }
     
-    // attach local flow to our DataProtoDest
-    DataProtoLocalSource_Attach(&peer->local_dpflow, &peer->send_dp);
+    // attach local flow to our DataProtoSink
+    DataProtoFlow_Attach(&peer->local_dpflow, &peer->send_dp);
     
-    // attach relay sink flows to our DataProtoDest
+    // attach relay sink flows to our DataProtoSink
     DPRelaySink_Attach(&peer->relay_sink, &peer->send_dp);
     
     peer->have_link = 1;
@@ -1629,16 +1629,16 @@ void peer_free_link (struct peer_data *peer)
     ASSERT(!peer->waiting_relay)
     
     // allow detaching DataProto flows
-    DataProtoDest_PrepareFree(&peer->send_dp);
+    DataProtoSink_PrepareFree(&peer->send_dp);
     
-    // detach relay sink flows from our DataProtoDest
+    // detach relay sink flows from our DataProtoSink
     DPRelaySink_Detach(&peer->relay_sink);
     
-    // detach local flow from our DataProtoDest
-    DataProtoLocalSource_Detach(&peer->local_dpflow);
+    // detach local flow from our DataProtoSink
+    DataProtoFlow_Detach(&peer->local_dpflow);
     
     // free sending
-    DataProtoDest_Free(&peer->send_dp);
+    DataProtoSink_Free(&peer->send_dp);
     
     // free transport-specific link objects
     if (options.transport_mode == TRANSPORT_MODE_UDP) {
@@ -1738,7 +1738,7 @@ void peer_dealloc_relay_provider (struct peer_data *peer)
     ASSERT(!peer->waiting_relay)
     
     // allow detaching DataProto flows from the relay peer
-    DataProtoDest_PrepareFree(&peer->send_dp);
+    DataProtoSink_PrepareFree(&peer->send_dp);
     
     // disconnect relay users
     LinkedList2Node *list_node;
@@ -1779,7 +1779,7 @@ void peer_install_relaying (struct peer_data *peer, struct peer_data *relay)
     LinkedList2_Append(&relay->relay_users, &peer->relaying_list_node);
     
     // attach local flow to relay
-    DataProtoLocalSource_Attach(&peer->local_dpflow, &relay->send_dp);
+    DataProtoFlow_Attach(&peer->local_dpflow, &relay->send_dp);
     
     peer->have_relaying = 1;
 }
@@ -1798,7 +1798,7 @@ void peer_free_relaying (struct peer_data *peer)
     peer_log(peer, BLOG_INFO, "uninstalling relaying through %d", (int)relay->id);
     
     // detach local flow from relay
-    DataProtoLocalSource_Detach(&peer->local_dpflow);
+    DataProtoFlow_Detach(&peer->local_dpflow);
     
     // remove from relay's users list
     LinkedList2_Remove(&relay->relay_users, &peer->relaying_list_node);
@@ -2327,7 +2327,7 @@ out:
     
     // inform DataProto of received packet
     if (dp_good) {
-        DataProtoDest_Received(&peer->send_dp, !!(flags & DATAPROTO_FLAGS_RECEIVING_KEEPALIVES));
+        DataProtoSink_Received(&peer->send_dp, !!(flags & DATAPROTO_FLAGS_RECEIVING_KEEPALIVES));
     }
 }
 
@@ -2726,7 +2726,7 @@ void device_input_dpd_handler (void *unused, const uint8_t *frame, int frame_len
     while (decider_peer) {
         FrameDeciderPeer *next = FrameDecider_NextDestination(&frame_decider);
         struct peer_data *peer = UPPER_OBJECT(decider_peer, struct peer_data, decider_peer);
-        DataProtoLocalSource_Route(&peer->local_dpflow, !!next);
+        DataProtoFlow_Route(&peer->local_dpflow, !!next);
         decider_peer = next;
     }
 }

+ 3 - 3
client/client.h

@@ -88,7 +88,7 @@ struct device_data {
     int mtu;
     
     // input
-    DataProtoDevice input_dpd;
+    DataProtoSource input_dpd;
     
     // output
     PacketPassFairQueue output_queue;
@@ -107,7 +107,7 @@ struct peer_data {
     char *common_name;
     
     // local flow
-    DataProtoLocalSource local_dpflow;
+    DataProtoFlow local_dpflow;
     
     // local receive flow
     PacketPassInterface *local_recv_if;
@@ -123,7 +123,7 @@ struct peer_data {
     int have_link;
     
     // link sending
-    DataProtoDest send_dp;
+    DataProtoSink send_dp;
     
     // link receive interface
     PacketPassInterface recv_ppi;