/*
This file is part of GNUnet
(C) 2010 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet 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 GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file transport/plugin_transport_unix.c
* @brief Transport plugin using unix domain sockets (!)
* Clearly, can only be used locally on Unix/Linux hosts...
* ONLY INTENDED FOR TESTING!!!
* @author Christian Grothoff
* @author Nathan Evans
*/
#include "platform.h"
#include "gnunet_hello_lib.h"
#include "gnunet_connection_lib.h"
#include "gnunet_container_lib.h"
#include "gnunet_os_lib.h"
#include "gnunet_peerinfo_service.h"
#include "gnunet_protocols.h"
#include "gnunet_resolver_service.h"
#include "gnunet_server_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
#include "transport.h"
#define MAX_PROBES 20
/*
* Transport cost to peer, always 1 for UNIX (direct connection)
*/
#define UNIX_DIRECT_DISTANCE 1
#define DEFAULT_NAT_PORT 0
/**
* How long until we give up on transmitting the welcome message?
*/
#define HOSTNAME_RESOLVE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
/**
* Starting port for listening and sending, eventually a config value
*/
#define UNIX_NAT_DEFAULT_PORT 22086
GNUNET_NETWORK_STRUCT_BEGIN
/**
* UNIX Message-Packet header.
*/
struct UNIXMessage
{
/**
* Message header.
*/
struct GNUNET_MessageHeader header;
/**
* What is the identity of the sender (GNUNET_hash of public key)
*/
struct GNUNET_PeerIdentity sender;
};
struct Session
{
void *addr;
size_t addrlen;
struct GNUNET_PeerIdentity target;
/**
* Session timeout task
*/
GNUNET_SCHEDULER_TaskIdentifier timeout_task;
struct Plugin * plugin;
};
struct UNIXMessageWrapper
{
struct UNIXMessageWrapper *next;
struct UNIXMessageWrapper *prev;
struct UNIXMessage * msg;
size_t msgsize;
struct GNUNET_TIME_Relative timeout;
unsigned int priority;
struct Session *session;
GNUNET_TRANSPORT_TransmitContinuation cont;
void *cont_cls;
};
/* Forward definition */
struct Plugin;
/**
* UNIX NAT "Session"
*/
struct