ambrop7 15 лет назад
Родитель
Сommit
fda152417e
3 измененных файлов с 0 добавлено и 185 удалено
  1. 0 1
      flow/CMakeLists.txt
  2. 0 91
      flow/PacketRecvNotifier.c
  3. 0 93
      flow/PacketRecvNotifier.h

+ 0 - 1
flow/CMakeLists.txt

@@ -6,7 +6,6 @@ add_library(flow
     PacketRecvConnector.c
     StreamRecvConnector.c
     PacketRecvBlocker.c
-    PacketRecvNotifier.c
     PacketPassNotifier.c
     PacketBuffer.c
     SinglePacketBuffer.c

+ 0 - 91
flow/PacketRecvNotifier.c

@@ -1,91 +0,0 @@
-/**
- * @file PacketRecvNotifier.c
- * @author Ambroz Bizjak <ambrop7@gmail.com>
- * 
- * @section LICENSE
- * 
- * This file is part of BadVPN.
- * 
- * BadVPN is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- * 
- * BadVPN is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stddef.h>
-
-#include <flow/PacketRecvNotifier.h>
-
-static void output_handler_recv (PacketRecvNotifier *o, uint8_t *data);
-static void input_handler_done (PacketRecvNotifier *o, int data_len);
-
-void output_handler_recv (PacketRecvNotifier *o, uint8_t *data)
-{
-    DebugObject_Access(&o->d_obj);
-    
-    // schedule receive
-    o->out = data;
-    PacketRecvInterface_Receiver_Recv(o->input, o->out);
-}
-
-void input_handler_done (PacketRecvNotifier *o, int data_len)
-{
-    DebugObject_Access(&o->d_obj);
-    
-    // finish packet
-    PacketRecvInterface_Done(&o->output, data_len);
-    
-    // if we have a handler, call it
-    if (o->handler) {
-        o->handler(o->handler_user, o->out, data_len);
-        return;
-    }
-}
-
-void PacketRecvNotifier_Init (PacketRecvNotifier *o, PacketRecvInterface *input, BPendingGroup *pg)
-{
-    // set arguments
-    o->input = input;
-    
-    // init output
-    PacketRecvInterface_Init(&o->output, PacketRecvInterface_GetMTU(o->input), (PacketRecvInterface_handler_recv)output_handler_recv, o, pg);
-    
-    // init input
-    PacketRecvInterface_Receiver_Init(o->input, (PacketRecvInterface_handler_done)input_handler_done, o);
-    
-    // set no handler
-    o->handler = NULL;
-    
-    DebugObject_Init(&o->d_obj);
-}
-
-void PacketRecvNotifier_Free (PacketRecvNotifier *o)
-{
-    DebugObject_Free(&o->d_obj);
-    
-    // free output
-    PacketRecvInterface_Free(&o->output);
-}
-
-PacketRecvInterface * PacketRecvNotifier_GetOutput (PacketRecvNotifier *o)
-{
-    DebugObject_Access(&o->d_obj);
-    
-    return &o->output;
-}
-
-void PacketRecvNotifier_SetHandler (PacketRecvNotifier *o, PacketRecvNotifier_handler_notify handler, void *user)
-{
-    DebugObject_Access(&o->d_obj);
-    
-    o->handler = handler;
-    o->handler_user = user;
-}

+ 0 - 93
flow/PacketRecvNotifier.h

@@ -1,93 +0,0 @@
-/**
- * @file PacketRecvNotifier.h
- * @author Ambroz Bizjak <ambrop7@gmail.com>
- * 
- * @section LICENSE
- * 
- * This file is part of BadVPN.
- * 
- * BadVPN is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- * 
- * BadVPN is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
- * @section DESCRIPTION
- * 
- * A {@link PacketRecvInterface} layer that calls a handler function before
- * providing a packet to output.
- */
-
-#ifndef BADVPN_FLOW_PACKETRECVNOTIFIER_H
-#define BADVPN_FLOW_PACKETRECVNOTIFIER_H
-
-#include <stdint.h>
-
-#include <system/DebugObject.h>
-#include <flow/PacketRecvInterface.h>
-
-/**
- * Handler function called when input has provided a packet (i.e. by returning
- * 1 from Recv or calling Done), but before passing the packet on to output.
- * 
- * @param user value specified in {@link PacketRecvNotifier_SetHandler}
- * @param data packet provided by output (buffer provided by input)
- * @param data_len size of the packet
- */
-typedef void (*PacketRecvNotifier_handler_notify) (void *user, uint8_t *data, int data_len);
-
-/**
- * A {@link PacketRecvInterface} layer that calls a handler function before
- * providing a packet to output.
- */
-typedef struct {
-    PacketRecvInterface output;
-    PacketRecvInterface *input;
-    PacketRecvNotifier_handler_notify handler;
-    void *handler_user;
-    uint8_t *out;
-    DebugObject d_obj;
-} PacketRecvNotifier;
-
-/**
- * Initializes the object.
- *
- * @param o the object
- * @param input input interface
- * @param pg pending group
- */
-void PacketRecvNotifier_Init (PacketRecvNotifier *o, PacketRecvInterface *input, BPendingGroup *pg);
-
-/**
- * Frees the object.
- *
- * @param o the object
- */
-void PacketRecvNotifier_Free (PacketRecvNotifier *o);
-
-/**
- * Returns the output interface.
- * The MTU of the output interface will be the same as of the input interface.
- *
- * @param o the object
- * @return output interface
- */
-PacketRecvInterface * PacketRecvNotifier_GetOutput (PacketRecvNotifier *o);
-
-/**
- * Configures a handler function to invoke before passing output packets to input.
- *
- * @param o the object
- * @param handler handler function, or NULL to disable.
- * @param user value to pass to handler function. Ignored if handler is NULL.
- */
-void PacketRecvNotifier_SetHandler (PacketRecvNotifier *o, PacketRecvNotifier_handler_notify handler, void *user);
-
-#endif