ambrop7 14 年 前
コミット
fc6df95788

+ 0 - 1
CMakeLists.txt

@@ -145,7 +145,6 @@ add_subdirectory(threadwork)
 add_subdirectory(stringmap)
 add_subdirectory(udpgw_client)
 if (NOT WIN32)
-    add_subdirectory(ipc)
     add_subdirectory(process)
     add_subdirectory(inputprocess)
     add_subdirectory(udevmonitor)

+ 0 - 2
blog_channels.txt

@@ -75,8 +75,6 @@ LineBuffer 4
 BTap 4
 lwip 4
 NCDConfigParser 4
-BIPC 4
-BIPCServer 4
 nsskey 4
 addr 4
 PasswordListener 4

+ 0 - 6
examples/CMakeLists.txt

@@ -28,12 +28,6 @@ add_executable(ncd_parser_test ncd_parser_test.c)
 target_link_libraries(ncd_parser_test ncdconfig)
 
 if (NOT WIN32)
-    add_executable(ipc_server ipc_server.c)
-    target_link_libraries(ipc_server ipc)
-
-    add_executable(ipc_client ipc_client.c)
-    target_link_libraries(ipc_client ipc)
-
     add_executable(bprocess_example bprocess_example.c)
     target_link_libraries(bprocess_example system process)
 

+ 0 - 172
examples/ipc_client.c

@@ -1,172 +0,0 @@
-/**
- * @file ipc_client.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 <misc/debug.h>
-#include <system/DebugObject.h>
-#include <system/BLog.h>
-#include <ipc/BIPC.h>
-
-#define SEND_MTU 100
-#define MAX_PACKETS 4096
-
-char *packets[MAX_PACKETS];
-int num_packets;
-int current_packet;
-int waiting;
-BReactor reactor;
-BIPC ipc;
-PacketPassInterface recv_if;
-PacketPassInterface *send_if;
-
-static void terminate (int ret);
-static void ipc_handler (void *user);
-static void send_packets (void);
-static void ipc_send_handler_done (void *user);
-static void ipc_recv_handler_send (void *user, uint8_t *data, int data_len);
-
-int main (int argc, char **argv)
-{
-    if (argc <= 0) {
-        return 1;
-    }
-    
-    int ret = 1;
-    
-    if (argc < 2) {
-        printf("Usage: %s <path> [message] ...\n", argv[0]);
-        goto fail0;
-    }
-    
-    char *path = argv[1];
-    
-    num_packets = 0;
-    for (int i = 2; i < argc; i++) {
-        if (num_packets == MAX_PACKETS) {
-            DEBUG("too many packets");
-            goto fail0;
-        }
-        packets[num_packets] = argv[i];
-        num_packets++;
-    }
-    
-    current_packet = 0;
-    
-    waiting = 0;
-    
-    BLog_InitStdout();
-    
-    if (!BReactor_Init(&reactor)) {
-        DEBUG("BReactor_Init failed");
-        goto fail1;
-    }
-    
-    PacketPassInterface_Init(&recv_if, 0, ipc_recv_handler_send, NULL, BReactor_PendingGroup(&reactor));
-    
-    if (!BIPC_InitConnect(&ipc, path, SEND_MTU, &recv_if, ipc_handler, NULL, &reactor)) {
-        DEBUG("BIPC_InitConnect failed");
-        goto fail3;
-    }
-    
-    send_if = BIPC_GetSendInterface(&ipc);
-    PacketPassInterface_Sender_Init(send_if, ipc_send_handler_done, NULL);
-    
-    send_packets();
-    
-    ret = BReactor_Exec(&reactor);
-    
-    BIPC_Free(&ipc);
-fail3:
-    PacketPassInterface_Free(&recv_if);
-fail2:
-    BReactor_Free(&reactor);
-fail1:
-    BLog_Free();
-fail0:
-    DebugObjectGlobal_Finish();
-    
-    return ret;
-}
-
-void terminate (int ret)
-{
-    BReactor_Quit(&reactor, ret);
-}
-
-void ipc_handler (void *user)
-{
-    DEBUG("IPC broken");
-    
-    terminate(1);
-}
-
-void send_packets (void)
-{
-    ASSERT(current_packet >= 0)
-    ASSERT(current_packet <= num_packets)
-    ASSERT(!waiting)
-    
-    if (current_packet < num_packets) {
-        PacketPassInterface_Sender_Send(send_if, (uint8_t *)packets[current_packet], strlen(packets[current_packet]));
-    } else {
-        terminate(0);
-    }
-}
-
-void ipc_send_handler_done (void *user)
-{
-    ASSERT(current_packet >= 0)
-    ASSERT(current_packet < num_packets)
-    ASSERT(!waiting)
-    
-    // wait for confirmation
-    waiting = 1;
-}
-
-void ipc_recv_handler_send (void *user, uint8_t *data, int data_len)
-{
-    ASSERT(current_packet >= 0)
-    ASSERT(current_packet <= num_packets)
-    ASSERT(!waiting || current_packet < num_packets)
-    
-    if (!waiting) {
-        DEBUG("not waiting!");
-        terminate(1);
-        return;
-    }
-    
-    if (data_len != 0) {
-        DEBUG("reply not empty!");
-        terminate(1);
-        return;
-    }
-    
-    current_packet++;
-    waiting = 0;
-    
-    // accept received packet
-    PacketPassInterface_Done(&recv_if);
-    
-    // send more packets
-    send_packets();
-}

+ 0 - 153
examples/ipc_server.c

@@ -1,153 +0,0 @@
-/**
- * @file ipc_server.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 <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <misc/debug.h>
-#include <misc/offset.h>
-#include <structure/LinkedList2.h>
-#include <system/DebugObject.h>
-#include <system/BLog.h>
-#include <ipc/BIPCServer.h>
-#include <ipc/BIPC.h>
-
-#define RECV_MTU 100
-
-BReactor reactor;
-BIPCServer server;
-
-struct client {
-    BIPC ipc;
-    PacketPassInterface recv_if;
-    PacketPassInterface *send_if;
-    LinkedList2Node list_node;
-};
-
-static void server_handler (void *user);
-static void remove_client (struct client *client);
-static void client_ipc_handler (struct client *client);
-static void client_recv_handler_send (struct client *client, uint8_t *data, int data_len);
-static void client_send_handler_done (struct client *client);
-
-int main (int argc, char **argv)
-{
-    if (argc <= 0) {
-        return 1;
-    }
-    
-    if (argc != 2) {
-        printf("Usage: %s <path>\n", argv[0]);
-        return 1;
-    }
-    
-    char *path = argv[1];
-    
-    BLog_InitStdout();
-    
-    if (!BReactor_Init(&reactor)) {
-        DEBUG("BReactor_Init failed");
-        goto fail1;
-    }
-    
-    if (!BIPCServer_Init(&server, path, server_handler, NULL, &reactor)) {
-        DEBUG("BIPCServer_Init failed");
-        goto fail2;
-    }
-    
-    BReactor_Exec(&reactor);
-    
-    ASSERT(0)
-    
-fail2:
-    BReactor_Free(&reactor);
-fail1:
-    BLog_Free();
-    DebugObjectGlobal_Finish();
-    
-    return 1;
-}
-
-void server_handler (void *user)
-{
-    struct client *client = malloc(sizeof(*client));
-    if (!client) {
-        DEBUG("failed to allocate client structure");
-        goto fail0;
-    }
-    
-    PacketPassInterface_Init(&client->recv_if, RECV_MTU, (PacketPassInterface_handler_send)client_recv_handler_send, client, BReactor_PendingGroup(&reactor));
-    
-    if (!BIPC_InitAccept(&client->ipc, &server, 0, &client->recv_if, (BIPC_handler)client_ipc_handler, client, &reactor)) {
-        DEBUG("BIPC_InitAccept failed");
-        goto fail1;
-    }
-    
-    client->send_if = BIPC_GetSendInterface(&client->ipc);
-    PacketPassInterface_Sender_Init(client->send_if, (PacketPassInterface_handler_done)client_send_handler_done, client);
-    
-    DEBUG("client connected");
-    
-    return;
-    
-fail1:
-    PacketPassInterface_Free(&client->recv_if);
-    free(client);
-fail0:
-    ;
-}
-
-void remove_client (struct client *client)
-{
-    DEBUG("removing client");
-    
-    BIPC_Free(&client->ipc);
-    
-    PacketPassInterface_Free(&client->recv_if);
-    
-    free(client);
-}
-
-void client_ipc_handler (struct client *client)
-{
-    remove_client(client);
-}
-
-void client_recv_handler_send (struct client *client, uint8_t *data, int data_len)
-{
-    // print message
-    uint8_t buf[data_len + 1];
-    memcpy(buf, data, data_len);
-    buf[data_len] = '\0';
-    printf("received: '%s'\n", buf);
-    
-    // send reply
-    PacketPassInterface_Sender_Send(client->send_if, NULL, 0);
-}
-
-void client_send_handler_done (struct client *client)
-{
-    // allow next message
-    PacketPassInterface_Done(&client->recv_if);
-}

+ 0 - 4
generated/blog_channel_BIPC.h

@@ -1,4 +0,0 @@
-#ifdef BLOG_CURRENT_CHANNEL
-#undef BLOG_CURRENT_CHANNEL
-#endif
-#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BIPC

+ 0 - 4
generated/blog_channel_BIPCServer.h

@@ -1,4 +0,0 @@
-#ifdef BLOG_CURRENT_CHANNEL
-#undef BLOG_CURRENT_CHANNEL
-#endif
-#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BIPCServer

+ 9 - 11
generated/blog_channels_defines.h

@@ -75,14 +75,12 @@
 #define BLOG_CHANNEL_BTap 74
 #define BLOG_CHANNEL_lwip 75
 #define BLOG_CHANNEL_NCDConfigParser 76
-#define BLOG_CHANNEL_BIPC 77
-#define BLOG_CHANNEL_BIPCServer 78
-#define BLOG_CHANNEL_nsskey 79
-#define BLOG_CHANNEL_addr 80
-#define BLOG_CHANNEL_PasswordListener 81
-#define BLOG_CHANNEL_NCDInterfaceMonitor 82
-#define BLOG_CHANNEL_NCDRfkillMonitor 83
-#define BLOG_CHANNEL_udpgw 84
-#define BLOG_CHANNEL_UdpGwClient 85
-#define BLOG_CHANNEL_SocksUdpGwClient 86
-#define BLOG_NUM_CHANNELS 87
+#define BLOG_CHANNEL_nsskey 77
+#define BLOG_CHANNEL_addr 78
+#define BLOG_CHANNEL_PasswordListener 79
+#define BLOG_CHANNEL_NCDInterfaceMonitor 80
+#define BLOG_CHANNEL_NCDRfkillMonitor 81
+#define BLOG_CHANNEL_udpgw 82
+#define BLOG_CHANNEL_UdpGwClient 83
+#define BLOG_CHANNEL_SocksUdpGwClient 84
+#define BLOG_NUM_CHANNELS 85

+ 0 - 2
generated/blog_channels_list.h

@@ -75,8 +75,6 @@
 {.name = "BTap", .loglevel = 4},
 {.name = "lwip", .loglevel = 4},
 {.name = "NCDConfigParser", .loglevel = 4},
-{.name = "BIPC", .loglevel = 4},
-{.name = "BIPCServer", .loglevel = 4},
 {.name = "nsskey", .loglevel = 4},
 {.name = "addr", .loglevel = 4},
 {.name = "PasswordListener", .loglevel = 4},

+ 0 - 176
ipc/BIPC.c

@@ -1,176 +0,0 @@
-/**
- * @file BIPC.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 <system/BLog.h>
-
-#include <ipc/BIPC.h>
-
-#include <generated/blog_channel_BIPC.h>
-
-#define COMPONENT_SOURCE 1
-#define COMPONENT_SINK 2
-#define COMPONENT_DECODER 3
-
-static void error_handler (BIPC *o, int component, int code)
-{
-    DebugObject_Access(&o->d_obj);
-    
-    DEBUGERROR(&o->d_err, o->handler(o->user))
-}
-
-static int init_io (BIPC *o, int send_mtu, PacketPassInterface *recv_if, BReactor *reactor)
-{
-    // init error domain
-    FlowErrorDomain_Init(&o->domain, (FlowErrorDomain_handler)error_handler, o);
-    
-    // init sending
-    StreamSocketSink_Init(&o->send_sink, FlowErrorReporter_Create(&o->domain, COMPONENT_SINK), &o->sock, BReactor_PendingGroup(reactor));
-    PacketStreamSender_Init(&o->send_pss, StreamSocketSink_GetInput(&o->send_sink), PACKETPROTO_ENCLEN(send_mtu), BReactor_PendingGroup(reactor));
-    PacketCopier_Init(&o->send_copier, send_mtu,  BReactor_PendingGroup(reactor));
-    PacketProtoEncoder_Init(&o->send_encoder, PacketCopier_GetOutput(&o->send_copier), BReactor_PendingGroup(reactor));
-    if (!SinglePacketBuffer_Init(&o->send_buf, PacketProtoEncoder_GetOutput(&o->send_encoder), PacketStreamSender_GetInput(&o->send_pss), BReactor_PendingGroup(reactor))) {
-        goto fail1;
-    }
-    
-    // init receiving
-    StreamSocketSource_Init(&o->recv_source, FlowErrorReporter_Create(&o->domain, COMPONENT_SOURCE), &o->sock, BReactor_PendingGroup(reactor));
-    if (!PacketProtoDecoder_Init(&o->recv_decoder, FlowErrorReporter_Create(&o->domain, COMPONENT_DECODER), StreamSocketSource_GetOutput(&o->recv_source), recv_if, BReactor_PendingGroup(reactor))) {
-        goto fail2;
-    }
-    
-    return 1;
-    
-fail2:
-    StreamSocketSource_Free(&o->recv_source);
-    SinglePacketBuffer_Free(&o->send_buf);
-fail1:
-    PacketProtoEncoder_Free(&o->send_encoder);
-    PacketCopier_Free(&o->send_copier);
-    PacketStreamSender_Free(&o->send_pss);
-    StreamSocketSink_Free(&o->send_sink);
-    return 0;
-}
-
-static void free_io (BIPC *o)
-{
-    // free receiving
-    PacketProtoDecoder_Free(&o->recv_decoder);
-    StreamSocketSource_Free(&o->recv_source);
-    
-    // free sending
-    SinglePacketBuffer_Free(&o->send_buf);
-    PacketProtoEncoder_Free(&o->send_encoder);
-    PacketCopier_Free(&o->send_copier);
-    PacketStreamSender_Free(&o->send_pss);
-    StreamSocketSink_Free(&o->send_sink);
-}
-
-int BIPC_InitConnect (BIPC *o, const char *path, int send_mtu, PacketPassInterface *recv_if, BIPC_handler handler, void *user, BReactor *reactor)
-{
-    ASSERT(send_mtu >= 0)
-    ASSERT(send_mtu <= PACKETPROTO_MAXPAYLOAD)
-    ASSERT(PacketPassInterface_GetMTU(recv_if) >= 0)
-    ASSERT(PacketPassInterface_GetMTU(recv_if) <= PACKETPROTO_MAXPAYLOAD)
-    
-    // init arguments
-    o->handler = handler;
-    o->user = user;
-    
-    // init socket
-    if (BSocket_Init(&o->sock, reactor, BADDR_TYPE_UNIX, BSOCKET_TYPE_STREAM) < 0) {
-        BLog(BLOG_ERROR, "BSocket_Init failed");
-        goto fail0;
-    }
-    
-    // connect socket
-    if (BSocket_ConnectUnix(&o->sock, path) < 0) {
-        BLog(BLOG_ERROR, "BSocket_ConnectUnix failed (%d)", BSocket_GetError(&o->sock));
-        goto fail1;
-    }
-    
-    // init I/O
-    if (!init_io(o, send_mtu, recv_if, reactor)) {
-        goto fail1;
-    }
-    
-    DebugObject_Init(&o->d_obj);
-    DebugError_Init(&o->d_err, BReactor_PendingGroup(reactor));
-    
-    return 1;
-    
-fail1:
-    BSocket_Free(&o->sock);
-fail0:
-    return 0;
-}
-
-int BIPC_InitAccept (BIPC *o, BIPCServer *server, int send_mtu, PacketPassInterface *recv_if, BIPC_handler handler, void *user, BReactor *reactor)
-{
-    ASSERT(send_mtu >= 0)
-    ASSERT(send_mtu <= PACKETPROTO_MAXPAYLOAD)
-    ASSERT(PacketPassInterface_GetMTU(recv_if) >= 0)
-    ASSERT(PacketPassInterface_GetMTU(recv_if) <= PACKETPROTO_MAXPAYLOAD)
-    
-    // init arguments
-    o->handler = handler;
-    o->user = user;
-    
-    // accept socket
-    if (!Listener_Accept(&server->listener, &o->sock, NULL)) {
-        BLog(BLOG_ERROR, "Listener_Accept failed");
-        goto fail0;
-    }
-    
-    // init I/O
-    if (!init_io(o, send_mtu, recv_if, reactor)) {
-        goto fail1;
-    }
-    
-    DebugObject_Init(&o->d_obj);
-    DebugError_Init(&o->d_err, BReactor_PendingGroup(reactor));
-    
-    return 1;
-    
-fail1:
-    BSocket_Free(&o->sock);
-fail0:
-    return 0;
-}
-
-void BIPC_Free (BIPC *o)
-{
-    DebugError_Free(&o->d_err);
-    DebugObject_Free(&o->d_obj);
-    
-    // free I/O
-    free_io(o);
-    
-    // free socket
-    BSocket_Free(&o->sock);
-}
-
-PacketPassInterface * BIPC_GetSendInterface (BIPC *o)
-{
-    DebugObject_Access(&o->d_obj);
-    
-    return PacketCopier_GetInput(&o->send_copier);
-}

+ 0 - 122
ipc/BIPC.h

@@ -1,122 +0,0 @@
-/**
- * @file BIPC.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
- * 
- * An abstraction of a reliable, sequenced, message-oriented two-way IPC.
- * Uses unix sockets on *nix systems, and named pipes on Windows.
- */
-
-#ifndef BADVPN_IPC_BIPC_H
-#define BADVPN_IPC_BIPC_H
-
-#include <protocol/packetproto.h>
-#include <misc/debug.h>
-#include <misc/debugerror.h>
-#include <system/BSocket.h>
-#include <system/DebugObject.h>
-#include <flow/StreamSocketSink.h>
-#include <flow/StreamSocketSource.h>
-#include <flow/PacketProtoEncoder.h>
-#include <flow/PacketProtoDecoder.h>
-#include <flow/SinglePacketBuffer.h>
-#include <flow/PacketCopier.h>
-#include <flow/PacketStreamSender.h>
-#include <ipc/BIPCServer.h>
-
-/**
- * Handler function called when an error occurs.
- * The object must be freed from within this handler.
- * 
- * @param user as in {@link BIPC_InitConnect}
- */
-typedef void (*BIPC_handler) (void *user);
-
-/**
- * An abstraction of a reliable, sequenced, message-oriented two-way IPC.
- */
-typedef struct {
-    BSocket sock;
-    FlowErrorDomain domain;
-    BIPC_handler handler;
-    void *user;
-    
-    // sending
-    PacketCopier send_copier;
-    PacketProtoEncoder send_encoder;
-    SinglePacketBuffer send_buf;
-    PacketStreamSender send_pss;
-    StreamSocketSink send_sink;
-    
-    // receiving
-    StreamSocketSource recv_source;
-    PacketProtoDecoder recv_decoder;
-    
-    DebugObject d_obj;
-    DebugError d_err;
-} BIPC;
-
-/**
- * Initializes the object by connecting to an IPC server.
- * 
- * @param o the object
- * @param path path of the IPC object. On *nix path of the unix socket, on Windows
- *             path of the named pipe.
- * @param send_mtu maximum packet size for sending. Must be >=0 and <=PACKETPROTO_MAXPAYLOAD.
- * @param recv_mtu maximum packet size for receiving. Must be >=0 and <=PACKETPROTO_MAXPAYLOAD.
- * @param handler handler function called when an error occurs
- * @param user value to pass to handler function
- * @param reactor reactor we live in
- * @return 1 on success, 0 on failure
- */
-int BIPC_InitConnect (BIPC *o, const char *path, int send_mtu, PacketPassInterface *recv_if, BIPC_handler handler, void *user, BReactor *reactor) WARN_UNUSED;
-
-/**
- * Initializes the object by acception a connection on an IPC server.
- * 
- * @param o the object
- * @param server IPC server to accept a connection on
- * @param send_mtu maximum packet size for sending. Must be >=0.
- * @param recv_mtu maximum packet size for receiving. Must be >=0.
- * @param handler handler function called when an error occurs
- * @param user value to pass to handler function
- * @param reactor reactor we live in
- * @return 1 on success, 0 on failure
- */
-int BIPC_InitAccept (BIPC *o, BIPCServer *server, int send_mtu, PacketPassInterface *recv_if, BIPC_handler handler, void *user, BReactor *reactor) WARN_UNUSED;
-
-/**
- * Frees the object.
- * 
- * @param o the object
- */
-void BIPC_Free (BIPC *o);
-
-/**
- * Returns the interface for sending.
- * The MTU of the interface will be as send_mtu in {@link BIPC_InitConnect}.
- * 
- * @param o the object
- * @return interface for sending
- */
-PacketPassInterface * BIPC_GetSendInterface (BIPC *o);
-
-#endif

+ 0 - 83
ipc/BIPCServer.c

@@ -1,83 +0,0 @@
-/**
- * @file BIPCServer.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 <system/BLog.h>
-
-#include <ipc/BIPCServer.h>
-
-#include <generated/blog_channel_BIPCServer.h>
-
-static void listener_handler (BIPCServer *o)
-{
-    DebugObject_Access(&o->d_obj);
-    
-    o->handler(o->user);
-    return;
-}
-
-int BIPCServer_Init (BIPCServer *o, const char *path, BIPCServer_handler handler, void *user, BReactor *reactor)
-{
-    // init arguments
-    o->handler = handler;
-    o->user = user;
-    
-    // init socket
-    if (BSocket_Init(&o->sock, reactor, BADDR_TYPE_UNIX, BSOCKET_TYPE_STREAM) < 0) {
-        BLog(BLOG_ERROR, "BSocket_Init failed");
-        goto fail0;
-    }
-    
-    // bind socket
-    if (BSocket_BindUnix(&o->sock, path) < 0) {
-        BLog(BLOG_ERROR, "BSocket_BindUnix failed (%d)", BSocket_GetError(&o->sock));
-        goto fail1;
-    }
-    
-    // listen socket
-    if (BSocket_Listen(&o->sock, -1) < 0) {
-        BLog(BLOG_ERROR, "BSocket_Listen failed (%d)", BSocket_GetError(&o->sock));
-        goto fail1;
-    }
-    
-    // init listener
-    Listener_InitExisting(&o->listener, reactor, &o->sock, (Listener_handler)listener_handler, o);
-    
-    DebugObject_Init(&o->d_obj);
-    
-    return 1;
-    
-fail1:
-    BSocket_Free(&o->sock);
-fail0:
-    return 0;
-}
-
-void BIPCServer_Free (BIPCServer *o)
-{
-    DebugObject_Free(&o->d_obj);
-    
-    // free listener
-    Listener_Free(&o->listener);
-    
-    // free socket
-    BSocket_Free(&o->sock);
-}

+ 0 - 77
ipc/BIPCServer.h

@@ -1,77 +0,0 @@
-/**
- * @file BIPCServer.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
- * 
- * Server part of {@link BIPC}, an abstraction of a reliable, sequenced,
- * message-oriented two-way IPC.
- */
-
-#ifndef BADVPN_IPC_BIPCSERVER_H
-#define BADVPN_IPC_BIPCSERVER_H
-
-#include <misc/debug.h>
-#include <system/BSocket.h>
-#include <system/Listener.h>
-#include <system/DebugObject.h>
-
-/**
- * Handler function called when a client may be accepted
- * (using {@link BIPC_InitAccept}).
- * 
- * @param user as in {@link BIPCServer_Init}
- */
-typedef void (*BIPCServer_handler) (void *user);
-
-/**
- * Server part of {@link BIPC}, an abstraction of a reliable, sequenced,
- * message-oriented two-way IPC.
- */
-typedef struct {
-    BSocket sock;
-    Listener listener;
-    BIPCServer_handler handler;
-    void *user;
-    DebugObject d_obj;
-} BIPCServer;
-
-/**
- * Initializes the object.
- * 
- * @param o the object
- * @param path path of the IPC object. On *nix path of the unix socket, on Windows
- *             path of the named pipe.
- * @param handler handler function called when a client may be accepted
- *                (using {@link BIPC_InitAccept})
- * @param user value to pass to handler function
- * @param reactor reactor we live in
- * @return 1 on success, 0 on failure
- */
-int BIPCServer_Init (BIPCServer *o, const char *path, BIPCServer_handler handler, void *user, BReactor *reactor) WARN_UNUSED;
-
-/**
- * Frees the object.
- * 
- * @param o the object
- */
-void BIPCServer_Free (BIPCServer *o);
-
-#endif

+ 0 - 5
ipc/CMakeLists.txt

@@ -1,5 +0,0 @@
-add_library(ipc
-    BIPC.c
-    BIPCServer.c
-)
-target_link_libraries(ipc system flow)