28#include "gnunet_transport_plugin.h"
72 struct GNUNET_TRANSPORT_PluginFunctions *
api;
88 struct GNUNET_TRANSPORT_PluginEnvironment
env;
133 fprintf (stdout,
"Starting transport plugins `%s'\n",
135 for (pos = strtok (plugs,
" "); pos != NULL; pos = strtok (NULL,
" "))
137 fprintf (stdout,
"Loading `%s' transport plugin\n",
154 if (plug->
api == NULL)
156 fprintf (stdout,
"Failed to load transport plugin for `%s'\n",
169 const struct GNUNET_HELLO_Address *
address,
180 "short_name: %s transport_name: %s\n",
186 "short_name: %s transport_name: %s are the same\n",
189 addr = strchr (strchr (pos->
api->address_to_string (pos,
address,
address->address_length),
'.')+1,
'.') + 1;
195 "Hello address string: %s\n",
199 "Hello address uri string: %s\n",
216 const struct GNUNET_HELLO_Address *
address,
246 struct GNUNET_HELLO_Message **orig = cls;
277 struct GNUNET_HELLO_Message *orig;
278 struct GNUNET_HELLO_Message *
result;
281 ssize_t size_written;
302 _ (
"Error accessing file `%s': %s\n"),
309 fprintf (stderr,
_ (
"File `%s' is too big to be a HELLO\n"),
hello_file);
314 fprintf (stderr,
_ (
"File `%s' is too small to be a HELLO\n"),
hello_file);
323 _ (
"Error opening file `%s': %s\n"),
333 orig = (
struct GNUNET_HELLO_Message *) buf;
334 if ((fsize < GNUNET_HELLO_size (orig)) ||
338 _ (
"Did not find well-formed HELLO in file `%s'\n"),
346 fprintf (stdout,
"Processing HELLO for peer `%s'\n", pids);
359 fprintf (stdout,
"url: %s\n", url);
374 _ (
"Error opening file `%s': %s\n"),
382 if (ntohs (
msg->
size) != size_written)
385 _ (
"Error writing HELLO to file `%s': %s expected size %u size written %u\n"),
394 _ (
"Modified %u addresses, wrote %u bytes\n"),
396 (
unsigned int) ntohs (
msg->
size));
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
#define gettext_noop(String)
static int ret
Final status code.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * address
GNS address for this phone.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
int main(int argc, char *argv[])
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
static int add_to_builder(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
static ssize_t add_from_hello(void *cls, size_t max, void *buf)
Add addresses from the address list to the HELLO.
static struct TransportPlugin * plugins_head
Head of DLL of all loaded plugins.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run without the scheduler.
static int add_to_buf(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Add the given address with infinite expiration to the buffer.
static char * hello_file
The file with hello in old style which we like to replace with the new one.
static struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Our private key.
static void plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg)
static struct TransportPlugin * plugins_tail
Head of DLL of all loaded plugins.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int result
Global testing status.
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Helper library for handling HELLO URIs.
Constants for network protocols.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer's key from the file specified in the configuration.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new(const struct GNUNET_PeerIdentity *pid)
Allocate builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
char * GNUNET_HELLO_builder_to_url(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Generate GNUnet HELLO URI from a builder.
struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time)
Generate envelope with GNUnet HELLO message (including peer ID) from a builder.
#define GNUNET_log(kind,...)
char * GNUNET_CRYPTO_eddsa_public_key_to_string(const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a public key to a string.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_MessageHeader * GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env)
Obtain message contained in envelope.
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
Closure for add_to_buf().
size_t ret
Number of bytes added so far.
struct GNUNET_HELLO_Builder * builder
size_t max
Maximum number of bytes left.
Private ECC key encoded for transmission.
Handle used to access files (and pipes).
Definition of a command line option.
Context for building (or parsing) HELLO URIs.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Time for absolute times used by GNUnet, in microseconds.
Entry in doubly-linked list of all of our plugins.
char * lib_name
Name of the library (e.g.
struct GNUNET_TRANSPORT_PluginEnvironment env
Environment this transport service is using for this plugin.
struct TransportPlugin * next
This is a doubly-linked list.
char * short_name
Short name for the plugin (e.g.
struct TransportPlugin * prev
This is a doubly-linked list.
struct GNUNET_TRANSPORT_PluginFunctions * api
API of the transport as returned by the plugin's initialization function.