gettext.h   gettext.h 
/* Convenience header for conditional use of GNU <libintl.h>. /* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option) by the Free Software Foundation; either version 3, or (at your option)
any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gnunet_applications.h   gnunet_applications.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2011 Christian Grothoff (and other contributing authors) (C) 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 74 skipping to change at line 74
* Internet IPv6 gateway (any TCP/UDP/ICMP). * Internet IPv6 gateway (any TCP/UDP/ICMP).
*/ */
#define GNUNET_APPLICATION_TYPE_IPV6_GATEWAY 17 #define GNUNET_APPLICATION_TYPE_IPV6_GATEWAY 17
/** /**
* Internet exit regex prefix. Consisting of application ID, followed by ve rsion * Internet exit regex prefix. Consisting of application ID, followed by ve rsion
* and padding. * and padding.
*/ */
#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX "GNUNET-VPN-VER-0001-" #define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX "GNUNET-VPN-VER-0001-"
/**
* Consensus.
*/
#define GNUNET_APPLICATION_TYPE_CONSENSUS 18
/**
* Set. Used for two-peer set operations implemented using stream.
*/
#define GNUNET_APPLICATION_TYPE_SET 19
/**
* Vectorproduct. Used for two-peer scalarproduct operations
*/
#define GNUNET_APPLICATION_TYPE_SCALARPRODUCT 20
/**
* Conversation control data.
*/
#define GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL 21
/**
* Conversation audio data.
*/
#define GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO 22
/**
* MQTT publish-subscribe.
*/
#define GNUNET_APPLICATION_TYPE_MQTT 23
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* ifndef GNUNET_APPLICATIONS_H */ /* ifndef GNUNET_APPLICATIONS_H */
#endif #endif
/* end of gnunet_applications.h */ /* end of gnunet_applications.h */
 End of changes. 2 change blocks. 
1 lines changed or deleted 31 lines changed or added


 gnunet_arm_service.h   gnunet_arm_service.h 
skipping to change at line 38 skipping to change at line 38
#define GNUNET_ARM_SERVICE_H #define GNUNET_ARM_SERVICE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_configuration_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_os_lib.h"
#include "gnunet_time_lib.h"
/** /**
* Version of the arm API. * Version of the arm API.
*/ */
#define GNUNET_ARM_VERSION 0x00000001 #define GNUNET_ARM_VERSION 0x00000002
/** /**
* Values characterizing GNUnet process states. * Statuses of the requests that client can send to ARM.
*/ */
enum GNUNET_ARM_ProcessStatus enum GNUNET_ARM_RequestStatus
{ {
/** /**
* Service name is unknown to ARM. * Message was sent successfully.
*/ */
GNUNET_ARM_PROCESS_UNKNOWN = -1, GNUNET_ARM_REQUEST_SENT_OK = 0,
/** /**
* Service is now down (due to client request). * Misconfiguration (can't connect to the ARM service).
*/ */
GNUNET_ARM_PROCESS_DOWN = 0, GNUNET_ARM_REQUEST_CONFIGURATION_ERROR = 1,
/** /**
* Service is already running. * We disconnected from ARM, and request was not sent.
*/ */
GNUNET_ARM_PROCESS_ALREADY_RUNNING = 1, GNUNET_ARM_REQUEST_DISCONNECTED = 2,
/** /**
* Service is currently being started (due to client request). * ARM API is busy (probably trying to connect to ARM),
* and request was not sent. Try again later.
*/ */
GNUNET_ARM_PROCESS_STARTING = 2, GNUNET_ARM_REQUEST_BUSY = 3,
/** /**
* Service is already being stopped by some other client. * It was discovered that the request would be too long to fit in a messa
ge,
* and thus it was not sent.
*/ */
GNUNET_ARM_PROCESS_ALREADY_STOPPING = 3, GNUNET_ARM_REQUEST_TOO_LONG = 4,
/** /**
* Service is already down (no action taken) * Request time ran out before we had a chance to send it.
*/ */
GNUNET_ARM_PROCESS_ALREADY_DOWN = 4, GNUNET_ARM_REQUEST_TIMEOUT = 5
};
/**
* Statuses of services.
*/
enum GNUNET_ARM_ServiceStatus
{
/**
* Dummy message.
*/
GNUNET_ARM_SERVICE_MONITORING_STARTED = 0,
/**
* Service was stopped.
*/
GNUNET_ARM_SERVICE_STOPPED = 1,
/**
* Service starting was initiated
*/
GNUNET_ARM_SERVICE_STARTING = 2,
/**
* Service stopping was initiated
*/
GNUNET_ARM_SERVICE_STOPPING = 3
};
/**
* Replies to ARM requests
*/
enum GNUNET_ARM_Result
{
/**
* Service was stopped (never sent for ARM itself).
*/
GNUNET_ARM_RESULT_STOPPED = 0,
/**
* ARM stopping was initiated (there's no "stopped" for ARM itself).
*/
GNUNET_ARM_RESULT_STOPPING = 1,
/**
* Service starting was initiated
*/
GNUNET_ARM_RESULT_STARTING = 2,
/**
* Asked to start it, but it's already starting.
*/
GNUNET_ARM_RESULT_IS_STARTING_ALREADY = 3,
/**
* Asked to stop it, but it's already stopping.
*/
GNUNET_ARM_RESULT_IS_STOPPING_ALREADY = 4,
/**
* Asked to start it, but it's already started.
*/
GNUNET_ARM_RESULT_IS_STARTED_ALREADY = 5,
/** /**
* ARM is currently being shut down (no more process starts) * Asked to stop it, but it's already stopped.
*/ */
GNUNET_ARM_PROCESS_SHUTDOWN = 5, GNUNET_ARM_RESULT_IS_STOPPED_ALREADY = 6,
/** /**
* Error in communication with ARM * Asked to start or stop a service, but it's not known.
*/ */
GNUNET_ARM_PROCESS_COMMUNICATION_ERROR = 6, GNUNET_ARM_RESULT_IS_NOT_KNOWN = 7,
/** /**
* Timeout in communication with ARM * Tried to start a service, but that failed for some reason.
*/ */
GNUNET_ARM_PROCESS_COMMUNICATION_TIMEOUT = 7, GNUNET_ARM_RESULT_START_FAILED = 8,
/** /**
* Failure to perform operation * Asked to start something, but ARM is shutting down and can't comply.
*/ */
GNUNET_ARM_PROCESS_FAILURE = 8 GNUNET_ARM_RESULT_IN_SHUTDOWN = 9
}; };
/** /**
* Callback function invoked when operation is complete. * Handle for interacting with ARM.
*/
struct GNUNET_ARM_Handle;
/**
* Function called whenever we connect to or disconnect from ARM.
* *
* @param cls closure * @param cls closure
* @param result outcome of the operation * @param connected GNUNET_YES if connected, GNUNET_NO if disconnected,
* GNUNET_SYSERR if there was an error.
*/ */
typedef void (*GNUNET_ARM_Callback) (void *cls, typedef void (*GNUNET_ARM_ConnectionStatusCallback) (void *cls,
enum GNUNET_ARM_ProcessStatus result); int connected);
/** /**
* Callback function invoked when list operation is complete. * Function called in response to a start/stop request.
* Will be called when request was not sent successfully,
* or when a reply comes. If the request was not sent successfully,
* 'rs' will indicate that, and 'service' and 'result' will be undefined.
* *
* @param cls closure * @param cls closure
* @param result outcome of the operation (GNUNET_YES if successful) * @param rs status of the request
* @param count number of strings in the list * @param service service name
* @param list list of running services * @param result result of the operation
*/ */
typedef void (*GNUNET_ARM_List_Callback) (void *cls, typedef void (*GNUNET_ARM_ResultCallback) (void *cls,
int result, enum GNUNET_ARM_RequestStatus rs,
unsigned int count, const char *service,
const char *const *list); enum GNUNET_ARM_Result result);
/** /**
* Handle for interacting with ARM. * Callback function invoked when list operation is complete.
* Will be called when request was not sent successfully,
* or when a reply comes. If the request was not sent successfully,
* 'rs' will indicate that, and 'count' and 'list' will be undefined.
*
* @param cls closure
* @param rs status of the request
* @param count number of strings in the list
* @param list list of running services
*/ */
struct GNUNET_ARM_Handle; typedef void (*GNUNET_ARM_ServiceListCallback) (void *cls,
enum GNUNET_ARM_RequestStatu
s rs,
unsigned int count,
const char *const*list);
/** /**
* Setup a context for communicating with ARM. Note that this * Set up a context for communicating with ARM, then
* can be done even if the ARM service is not yet running. * start connecting to the ARM service using that context.
* *
* @param cfg configuration to use (needed to contact ARM; * @param cfg configuration to use (needed to contact ARM;
* the ARM service may internally use a different * the ARM service may internally use a different
* configuration to determine how to start the service). * configuration to determine how to start the service).
* @param service service that *this* process is implementing/providing, ca * @param conn_status will be called when connecting/disconnecting
n be NULL * @param cls closure for conn_status
* @return context to use for further ARM operations, NULL on error * @return context to use for further ARM operations, NULL on error.
*/ */
struct GNUNET_ARM_Handle * struct GNUNET_ARM_Handle *
GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *service); GNUNET_ARM_ConnectionStatusCallback conn_status,
void *cls);
/** /**
* Disconnect from the ARM service. * Disconnect from the ARM service and destroy the handle.
* *
* @param h the handle that was being used * @param h the handle that was being used
*/ */
void void
GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h); GNUNET_ARM_disconnect_and_free (struct GNUNET_ARM_Handle *h);
/** /**
* Start a service. Note that this function merely asks ARM to start * Request a list of running services.
* the service and that ARM merely confirms that it forked the
* respective process. The specified callback may thus return before
* the service has started to listen on the server socket and it may
* also be that the service has crashed in the meantime. Clients
* should repeatedly try to connect to the service at the respective
* port (with some delays in between) before assuming that the service
* actually failed to start. Note that if an error is returned to the
* callback, clients obviously should not bother with trying to
* contact the service.
* *
* @param h handle to ARM * @param h handle to ARM
* @param service_name name of the service
* @param std_inheritance flags controlling std descriptors inheritance
* @param timeout how long to wait before failing for good * @param timeout how long to wait before failing for good
* @param cb callback to invoke when service is ready * @param cont callback to invoke after request is sent or is not sent
* @param cb_cls closure for callback * @param cont_cls closure for callback
*/ */
void void
GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, const char *service_ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h,
name, struct GNUNET_TIME_Relative timeout,
enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ServiceListCallback cont, void *
struct GNUNET_TIME_Relative timeout, cont_cls);
GNUNET_ARM_Callback cb, void *cb_cls);
/** /**
* Stop a service. Note that the callback is invoked as soon * Request a service to be stopped.
* as ARM confirms that it will ask the service to terminate. * Stopping arm itself will not invalidate its handle, and
* The actual termination may still take some time. * ARM API will try to restore connection to the ARM service,
* even if ARM connection was lost because you asked for ARM to be stopped.
* Call GNUNET_ARM_disconnect_and_free () to free the handle and prevent
* further connection attempts.
* *
* @param h handle to ARM * @param h handle to ARM
* @param service_name name of the service * @param service_name name of the service
* @param timeout how long to wait before failing for good * @param timeout how long to wait before failing for good
* @param cb callback to invoke when service is ready * @param cont callback to invoke after request is sent or is not sent
* @param cb_cls closure for callback * @param cont_cls closure for callback
*/ */
void void
GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, const char *service_n GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h,
ame, const char *service_name,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_ARM_Callback cb, void *cb_cls); GNUNET_ARM_ResultCallback cont, void *cont_
cls);
/** /**
* List all running services. * Request for a service to be started.
* *
* @param h handle to ARM * @param h handle to ARM
* @param service_name name of the service
* @param std_inheritance inheritance of std streams
* @param timeout how long to wait before failing for good * @param timeout how long to wait before failing for good
* @param cb callback to invoke when service is ready * @param cont callback to invoke after request is sent or not sent
* @param cb_cls closure for callback * @param cont_cls closure for callback
*/
void
GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
const char *service_name,
enum GNUNET_OS_InheritStdioFlags std_inher
itance,
struct GNUNET_TIME_Relative timeout,
GNUNET_ARM_ResultCallback cont,
void *cont_cls);
/**
* Handle for monitoring ARM.
*/
struct GNUNET_ARM_MonitorHandle;
/**
* Function called in when a status update arrives.
*
* @param cls closure
* @param arm handle to the arm connection
* @param service service name
* @param status status of the service
*/
typedef void (*GNUNET_ARM_ServiceStatusCallback) (void *cls,
const char *service,
enum GNUNET_ARM_ServiceSta
tus status);
/**
* Setup a context for monitoring ARM, then
* start connecting to the ARM service for monitoring using that context.
*
* @param cfg configuration to use (needed to contact ARM;
* the ARM service may internally use a different
* configuration to determine how to start the service).
* @param cont callback to invoke on status updates
* @param cont_cls closure
* @return context to use for further ARM monitor operations, NULL on error
.
*/
struct GNUNET_ARM_MonitorHandle *
GNUNET_ARM_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_ARM_ServiceStatusCallback cont,
void *cont_cls);
/**
* Disconnect from the ARM service and destroy the handle.
*
* @param h the handle that was being used
*/ */
void void
GNUNET_ARM_list_running_services (struct GNUNET_ARM_Handle *h, GNUNET_ARM_monitor_disconnect_and_free (struct GNUNET_ARM_MonitorHandle *h)
struct GNUNET_TIME_Relative timeout, ;
GNUNET_ARM_List_Callback cb, void *cb_cls
);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 48 change blocks. 
84 lines changed or deleted 210 lines changed or added


 gnunet_ats_service.h   gnunet_ats_service.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2010,2011 Christian Grothoff (and other contributing authors) (C) 2010,2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_ats_service.h * @file include/gnunet_ats_service.h
* @brief automatic transport selection and outbound bandwidth determinatio n * @brief automatic transport selection and outbound bandwidth determinatio n
* @author Christian Grothoff * @author Christian Grothoff
* @author Matthias Wachs * @author Matthias Wachs
*/ */
#ifndef GNUNET_ATS_SERVICE_H #ifndef GNUNET_ATS_SERVICE_H
#define GNUNET_ATS_SERVICE_H #define GNUNET_ATS_SERVICE_H
#include "gnunet_constants.h" #include "gnunet_constants.h"
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h" #include "gnunet_hello_lib.h"
/** /**
* Number of network types supported by ATS * Number of network types supported by ATS
*/ */
#define GNUNET_ATS_NetworkTypeCount 5 #define GNUNET_ATS_NetworkTypeCount 6
/** /**
* ATS network types as array initializer * ATS network types as array initializer
*/ */
#define GNUNET_ATS_NetworkType {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_ LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN} #define GNUNET_ATS_NetworkType {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_ LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN, GNUN ET_ATS_NET_BT}
/** /**
* ATS network types as string array initializer * ATS network types as string array initializer
*/ */
#define GNUNET_ATS_NetworkTypeString {"UNSPECIFIED", "LOOPBACK", "LAN", "WA N", "WLAN"} #define GNUNET_ATS_NetworkTypeString {"UNSPECIFIED", "LOOPBACK", "LAN", "WA N", "WLAN", "BLUETOOTH"}
enum GNUNET_ATS_Network_Type enum GNUNET_ATS_Network_Type
{ {
GNUNET_ATS_NET_UNSPECIFIED = 0, GNUNET_ATS_NET_UNSPECIFIED = 0,
GNUNET_ATS_NET_LOOPBACK = 1, GNUNET_ATS_NET_LOOPBACK = 1,
GNUNET_ATS_NET_LAN = 2, GNUNET_ATS_NET_LAN = 2,
GNUNET_ATS_NET_WAN = 3, GNUNET_ATS_NET_WAN = 3,
GNUNET_ATS_NET_WLAN = 4, GNUNET_ATS_NET_WLAN = 4,
GNUNET_ATS_NET_BT = 5
}; };
/** /**
* Default bandwidth assigned to a network : 64 KB/s * Default bandwidth assigned to a network : 64 KB/s
*/ */
#define GNUNET_ATS_DefaultBandwidth 65536 #define GNUNET_ATS_DefaultBandwidth 65536
/** /**
* Undefined value for a GNUNET_ATS_Property
*/
#define GNUNET_ATS_VALUE_UNDEFINED UINT32_MAX
/**
* String representation for GNUNET_ATS_VALUE_UNDEFINED
*/
#define GNUNET_ATS_VALUE_UNDEFINED_STR "undefined"
/**
* Maximum bandwidth assigned to a network : 4095 MB/s * Maximum bandwidth assigned to a network : 4095 MB/s
*/ */
#define GNUNET_ATS_MaxBandwidth UINT32_MAX #define GNUNET_ATS_MaxBandwidth UINT32_MAX
/** /**
* Textual equivalent for GNUNET_ATS_MaxBandwidth
*/
#define GNUNET_ATS_MaxBandwidthString "unlimited"
/**
* Number of property types supported by ATS * Number of property types supported by ATS
*/ */
#define GNUNET_ATS_PropertyCount 9 #define GNUNET_ATS_PropertyCount 11
/** /**
* ATS properties types as string array initializer * ATS properties types as string array initializer
*/ */
#define GNUNET_ATS_PropertyStrings {"Terminator", "Utilization up", "Utiliz ation down", "Network type", "Delay", "Distance", "Cost WAN", "Cost LAN", " Cost WLAN"} #define GNUNET_ATS_PropertyStrings {"TERMINATOR", "UTILIZATION_UP", "UTILIZ ATION_DOWN", "UTILIZATION_PAYLOAD_UP", "UTILIZATION_PAYLOAD_DOWN", "NETWORK _TYPE", "DELAY", "DISTANCE", "COST_WAN", "COST_LAN", "COST_WLAN"}
/** /**
* Enum defining all known property types for ATS Enum values are used * Enum defining all known property types for ATS Enum values are used
* in the GNUNET_ATS_Information struct as * in the GNUNET_ATS_Information struct as
* (key,value)-pairs. * (key,value)-pairs.
* *
* Cost are always stored in uint32_t, so all units used to define costs * Cost are always stored in uint32_t, so all units used to define costs
* have to be normalized to fit in uint32_t [0 .. 4.294.967.295] * have to be normalized to fit in uint32_t [0 .. UINT32_MAX-1]
*
* UINT32_MAX is reserved for uninitialized values GNUNET_ATS_VALUE_UNDEFIN
ED
*/ */
enum GNUNET_ATS_Property enum GNUNET_ATS_Property
{ {
/** /**
* End of the array. * End of the array.
* @deprecated * @deprecated
*/ */
GNUNET_ATS_ARRAY_TERMINATOR = 0, GNUNET_ATS_ARRAY_TERMINATOR = 0,
/** /**
* Actual traffic on this connection from this peer to the other peer.
* Includes transport overhead
*
* Unit: [bytes/second]
*/
GNUNET_ATS_UTILIZATION_OUT,
/**
* Actual traffic on this connection from the other peer to this peer. * Actual traffic on this connection from the other peer to this peer.
* Includes transport overhead
* *
* Unit: [bytes/second] * Unit: [bytes/second]
*/ */
GNUNET_ATS_UTILIZATION_UP, GNUNET_ATS_UTILIZATION_IN,
/** /**
* Actual traffic on this connection from this peer to the other peer. * Actual traffic on this connection from this peer to the other peer.
* Only payload from layers > transport
*
* Unit: [bytes/second]
*/
GNUNET_ATS_UTILIZATION_PAYLOAD_OUT,
/**
* Actual traffic on this connection from the other peer to this peer.
* Only payload from layers > transport
* *
* Unit: [bytes/second] * Unit: [bytes/second]
*/ */
GNUNET_ATS_UTILIZATION_DOWN, GNUNET_ATS_UTILIZATION_PAYLOAD_IN,
/** /**
* Is this address located in WAN, LAN or a loopback address * Is this address located in WAN, LAN or a loopback address
* Value is element of GNUNET_ATS_Network_Type * Value is element of GNUNET_ATS_Network_Type
*/ */
GNUNET_ATS_NETWORK_TYPE, GNUNET_ATS_NETWORK_TYPE,
/** /**
* Delay * Delay
* Time between when the time packet is sent and the packet arrives * Time between when the time packet is sent and the packet arrives
* *
* Unit: [ms] * Unit: [microseconds]
* *
* Examples: * Examples:
* *
* LAN : 1 * LAN : 1
* WLAN : 2 * WLAN : 2
* Dialup: 500 * Dialup: 500
*/ */
GNUNET_ATS_QUALITY_NET_DELAY, GNUNET_ATS_QUALITY_NET_DELAY,
/** /**
skipping to change at line 197 skipping to change at line 233
* Interpretation: less is better * Interpretation: less is better
* *
* Examples: * Examples:
* *
* TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb] * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
* TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb] * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
* UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb] * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb]
* UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb] * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
*/ */
GNUNET_ATS_COST_WLAN GNUNET_ATS_COST_WLAN
/* Cost related values */ /* Cost related values */
/* =================== */ /* =================== */
/** /**
* Volume based cost in financial units to transmit data * Volume based cost in financial units to transmit data
* *
* Note: This value is not bound to a specific currency or unit and only * Note: This value is not bound to a specific currency or unit and only
* used locally. * used locally.
* "cent" just refers the smallest amount of money in the respective * "cent" just refers the smallest amount of money in the respective
* currency. * currency.
* *
* Unit: [cent/MB] * Unit: [cent/MB]
* *
* Interpretation: less is better * Interpretation: less is better
* *
* Examples: * Examples:
* LAN: 0 [cent/MB] * LAN: 0 [cent/MB]
* 2G : 10 [cent/MB] * 2G : 10 [cent/MB]
*/ */
// GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1, // GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1,
/** /**
* Time based cost in financial units to transmit data * Time based cost in financial units to transmit data
* *
* Note: This value is not bound to a specific currency or unit and only * Note: This value is not bound to a specific currency or unit and only
* used locally. * used locally.
* "cent" just refers the smallest amount of money in the respective * "cent" just refers the smallest amount of money in the respective
* currency. * currency.
* *
* Unit: [cent/h] * Unit: [cent/h]
* *
* Interpretation: less is better * Interpretation: less is better
* *
* Examples: * Examples:
* LAN : 0 [cent/h] * LAN : 0 [cent/h]
* Dialup: 10 [cent/h] * Dialup: 10 [cent/h]
*/ */
// GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2, // GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2,
/** /**
* Computational costs * Computational costs
* *
* Effort of preparing data to be sent with this transport * Effort of preparing data to be sent with this transport
* Includes encoding, encryption and conversion of data * Includes encoding, encryption and conversion of data
* Partial values can be summed up: c_sum = c_enc + c_enc + c_conv * Partial values can be summed up: c_sum = c_enc + c_enc + c_conv
* Resulting values depend on local system properties, e.g. CPU * Resulting values depend on local system properties, e.g. CPU
* *
* Unit: [ms/GB] * Unit: [ms/GB]
* *
* Interpretation: less is better * Interpretation: less is better
* *
* Examples: * Examples:
* *
* HTTPS with AES CBC-256: 7,382 * HTTPS with AES CBC-256: 7,382
* HTTPS with AES CBC-128: 5,279 * HTTPS with AES CBC-128: 5,279
* HTTPS with RC4-1024: 2,652 * HTTPS with RC4-1024: 2,652
*/ */
// GNUNET_ATS_COST_COMPUTATIONAL = 3, // GNUNET_ATS_COST_COMPUTATIONAL = 3,
/** /**
* Energy consumption * Energy consumption
* *
* Energy consumption using this transport when sending with a certain * Energy consumption using this transport when sending with a certain
* power at a certain bitrate. This is only an approximation based on: * power at a certain bitrate. This is only an approximation based on:
* Energy consumption E = P / D * Energy consumption E = P / D
* *
* with: * with:
* Power P in Watt (J/s) * Power P in Watt (J/s)
* Datarate D in MBit/s * Datarate D in MBit/s
* *
* Conversion between power P and dBm used by WLAN in radiotap's dBm TX p * Conversion between power P and dBm used by WLAN in radiotap's dBm TX pow
ower: er:
* *
* Lp(dbm) = 10 log10 (P/ 1mW) * Lp(dbm) = 10 log10 (P/ 1mW)
* *
* => P = 1 mW * 10^(Lp(dbm)/10) * => P = 1 mW * 10^(Lp(dbm)/10)
* *
* Unit: [mJ/MB] * Unit: [mJ/MB]
* *
* Interpretation: less is better * Interpretation: less is better
* *
* Examples: * Examples:
* *
* LAN: 0 * LAN: 0
* WLAN: 89 (600 mW @ 802.11g /w 54 MBit/s) * WLAN: 89 (600 mW @ 802.11g /w 54 MBit/s)
* Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s) * Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s)
*/ */
// GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4, // GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4,
/** /**
* Connect cost * Connect cost
* How many bytes are transmitted to initiate a new connection using * How many bytes are transmitted to initiate a new connection using
* this transport? * this transport?
* *
* Unit: [bytes] * Unit: [bytes]
* *
* Interpretation: less is better * Interpretation: less is better
* *
* Examples: * Examples:
* *
* UDP (No connection) : * UDP (No connection) :
* 0 bytes * 0 bytes
* TCP (TCP 3-Way handshake): * TCP (TCP 3-Way handshake):
* 220 bytes Ethernet, 172 bytes TCP/IP, 122 bytes TCP * 220 bytes Ethernet, 172 bytes TCP/IP, 122 bytes TCP
* HTTP (TCP + Header) : * HTTP (TCP + Header) :
* 477 bytes Ethernet, 429 bytes TCP/IP, 374 bytes TCP, 278 bytes HT * 477 bytes Ethernet, 429 bytes TCP/IP, 374 bytes TCP, 278 bytes HTTP
TP * HTTPS HTTP+TLS Handshake:
* HTTPS HTTP+TLS Handshake: * 2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HTTP
* 2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HT S
TPS *
* * */
* */ // GNUNET_ATS_COST_CONNECT = 5,
// GNUNET_ATS_COST_CONNECT = 5, /**
/** * Bandwidth cost
* Bandwidth cost *
* * How many bandwidth is available to consume?
* How many bandwidth is available to consume? * Used to calculate which impact sending data with this transport has
* Used to calculate which impact sending data with this transport has *
* * Unit: [kB/s]
* Unit: [kB/s] *
* * Interpretation: more is better
* Interpretation: more is better *
* * Examples:
* Examples: * LAN: 12,800 (100 MBit/s)
* LAN: 12,800 (100 MBit/s) * WLAN: 6,912 (54 MBit/s)
* WLAN: 6,912 (54 MBit/s) * Dial-up: 8 (64 Kbit/s)
* Dial-up: 8 (64 Kbit/s) *
* */
*/ // GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6,
// GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6, /**
/** * Network overhead
* Network overhead *
* * How many bytes are sent over the wire when 1 kilobyte (1024 bytes)
* How many bytes are sent over the wire when 1 kilobyte (1024 bytes) * of application data is transmitted?
* of application data is transmitted? * A factor used with connect cost, bandwidth cost and energy cost
* A factor used with connect cost, bandwidth cost and energy cost * to describe the overhead produced by the transport protocol
* to describe the overhead produced by the transport protocol *
* * Unit: [bytes/kb]
* Unit: [bytes/kb] *
* * Interpretation: less is better
* Interpretation: less is better *
* * Examples:
* Examples: *
* * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
* TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb] * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
* TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb] * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb]
* UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb] * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
* UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb] */
*/ // GNUNET_ATS_COST_NETWORK_OVERHEAD = 7,
// GNUNET_ATS_COST_NETWORK_OVERHEAD = 7, /* Quality related values */
/* Quality related values */ /* ====================== */
/* ====================== */ /* Physical layer quality properties */
/* Physical layer quality properties */ /**
/** * Signal strength on physical layer
* Signal strength on physical layer *
* * Unit: [dBm]
* Unit: [dBm] */
*/ // GNUNET_ATS_QUALITY_PHY_SIGNAL_STRENGTH = 1025,
// GNUNET_ATS_QUALITY_PHY_SIGNAL_STRENGTH = 1025, /**
/** * Collision rate on physical layer
* Collision rate on physical layer *
* * Unit: [B/s]
* Unit: [B/s] */
*/ // GNUNET_ATS_QUALITY_PHY_COLLISION_RATE = 1026,
// GNUNET_ATS_QUALITY_PHY_COLLISION_RATE = 1026, /**
/** * Error rate on physical layer
* Error rate on physical layer *
* * Unit: [B/s]
* Unit: [B/s] */
*/ // GNUNET_ATS_QUALITY_PHY_ERROR_RATE = 1027,
// GNUNET_ATS_QUALITY_PHY_ERROR_RATE = 1027, /**
/** * Jitter
* Jitter * Time variations of the delay
* Time variations of the delay * 1st derivative of a delay function
* 1st derivative of a delay function *
* * Unit: [ms]
* Unit: [ms] */
*/ // GNUNET_ATS_QUALITY_NET_JITTER = 1029,
// GNUNET_ATS_QUALITY_NET_JITTER = 1029, /**
/** * Error rate on network layer
* Error rate on network layer *
* * Unit: [B/s]
* Unit: [B/s] *
* * Examples:
* Examples: *
* * LAN : 0
* LAN : 0 * WLAN : 400
* WLAN : 400 * Bluetooth : 100
* Bluetooth : 100 * Note: This numbers are just assumptions as an example, not
* Note: This numbers are just assumptions as an example, not * measured or somehow determined
* measured or somehow determined */
*/ // GNUNET_ATS_QUALITY_NET_ERRORRATE = 1030,
// GNUNET_ATS_QUALITY_NET_ERRORRATE = 1030, /**
/** * Drop rate on network layer
* Drop rate on network layer * Bytes actively dismissed by a network component during transmission
* Bytes actively dismissed by a network component during transmission * Reasons for dropped data can be full queues, congestion, quota violation
* Reasons for dropped data can be full queues, congestion, quota violati s...
ons... *
* * Unit: [B/s]
* Unit: [B/s] *
* * Examples:
* Examples: *
* * LAN : 0
* LAN : 0 * WLAN : 400
* WLAN : 400 * Bluetooth : 100
* Bluetooth : 100 * Note: This numbers are just assumptions as an example, not
* Note: This numbers are just assumptions as an example, not * measured or somehow determined
* measured or somehow determined */
*/ // GNUNET_ATS_QUALITY_NET_DROPRATE = 1031,
// GNUNET_ATS_QUALITY_NET_DROPRATE = 1031, /**
/** * Loss rate on network layer
* Loss rate on network layer * Bytes lost during transmission
* Bytes lost during transmission * Reasons can be collisions, ...
* Reasons can be collisions, ... *
* * Unit: [B/s]
* Unit: [B/s] *
* * Examples:
* Examples: *
* * LAN : 0
* LAN : 0 * WLAN : 40
* WLAN : 40 * Bluetooth : 10
* Bluetooth : 10 * Note: This numbers are just assumptions as an example, not measured
* Note: This numbers are just assumptions as an example, not measured * or somehow determined
* or somehow determined */
*/ // GNUNET_ATS_QUALITY_NET_LOSSRATE = 1032,
// GNUNET_ATS_QUALITY_NET_LOSSRATE = 1032, /**
/** * Throughput on network layer
* Throughput on network layer *
* * Unit: [kB/s]
* Unit: [kB/s] *
* * Examples:
* Examples: *
* * LAN : 3400
* LAN : 3400 * WLAN : 1200
* WLAN : 1200 * Dialup: 4
* Dialup: 4 *
* */
*/ // GNUNET_ATS_QUALITY_NET_THROUGHPUT = 1033,
// GNUNET_ATS_QUALITY_NET_THROUGHPUT = 1033, /* Availability related values */
/* Availability related values */ /* =========================== */
/* =========================== */ /**
/** * Is a peer reachable?
* Is a peer reachable? */
*/ // GNUNET_ATS_AVAILABILITY_REACHABLE = 2048,
// GNUNET_ATS_AVAILABILITY_REACHABLE = 2048, /**
/** * Is there a connection established to a peer using this transport
* Is there a connection established to a peer using this transport */
*/ // GNUNET_ATS_AVAILABILITY_CONNECTED = 2049
// GNUNET_ATS_AVAILABILITY_CONNECTED = 2049
}; };
/** /**
* Number of ATS quality properties * Number of ATS quality properties
*/ */
#define GNUNET_ATS_QualityPropertiesCount 2 #define GNUNET_ATS_QualityPropertiesCount 2
/** /**
* ATS quality properties as array initializer * ATS quality properties as array initializer
*/ */
skipping to change at line 496 skipping to change at line 532
GNUNET_NETWORK_STRUCT_END GNUNET_NETWORK_STRUCT_END
/* ******************************** Scheduling API ************************ ***** */ /* ******************************** Scheduling API ************************ ***** */
/** /**
* Handle to the ATS subsystem for bandwidth/transport scheduling informati on. * Handle to the ATS subsystem for bandwidth/transport scheduling informati on.
*/ */
struct GNUNET_ATS_SchedulingHandle; struct GNUNET_ATS_SchedulingHandle;
/** /**
* Handle for address suggestion requests
*/
struct GNUNET_ATS_SuggestHandle;
/**
* Opaque session handle, defined by plugins. Contents not known to ATS. * Opaque session handle, defined by plugins. Contents not known to ATS.
*/ */
struct Session; struct Session;
/** /**
* Signature of a function called by ATS with the current bandwidth * Signature of a function called by ATS with the current bandwidth
* and address preferences as determined by ATS. * and address preferences as determined by ATS.
* *
* @param cls closure * @param cls closure
* @param address suggested address (including peer identity of the peer) * @param address suggested address (including peer identity of the peer)
* @param session session to use * @param session session to use
* @param bandwidth_out assigned outbound bandwidth for the connection * @param bandwidth_out assigned outbound bandwidth for the connection
* @param bandwidth_in assigned inbound bandwidth for the connection * @param bandwidth_in assigned inbound bandwidth for the connection
* @param ats performance data for the address (as far as known) * @param ats performance data for the address (as far as known)
* @param ats_count number of performance records in 'ats' * @param ats_count number of performance records in @a ats
*/ */
typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls, typedef void
const struct (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
GNUNET_HELLO_Address const struct GNUNET_HELLO_Address *address, struct Session *session,
* struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
address, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
struct Session * sess const struct GNUNET_ATS_Information *ats, uint32_t ats_count);
ion,
struct
GNUNET_BANDWIDTH_Valu
e32NBO
bandwidth_out,
struct
GNUNET_BANDWIDTH_Valu
e32NBO
bandwidth_in,
const struct
GNUNET_ATS_Informatio
n *
ats, uint32_t ats_cou
nt);
/** /**
* Initialize the ATS subsystem. * Initialize the ATS subsystem.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param suggest_cb notification to call whenever the suggestation changed * @param suggest_cb notification to call whenever the suggestation changed
* @param suggest_cb_cls closure for 'suggest_cb' * @param suggest_cb_cls closure for 'suggest_cb'
* @return ats context * @return ats context
*/ */
struct GNUNET_ATS_SchedulingHandle * struct GNUNET_ATS_SchedulingHandle *
GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_ATS_AddressSuggestionCallback suggest_cb GNUNET_ATS_AddressSuggestionCallback suggest_cb, void *suggest_cb_cls);
,
void *suggest_cb_cls);
/** /**
* Client is done with ATS scheduling, release resources. * Client is done with ATS scheduling, release resources.
* *
* @param sh handle to release * @param sh handle to release
*/ */
void void
GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh); GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh);
/** /**
skipping to change at line 565 skipping to change at line 597
void void
GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_PeerIdentity *peer); const struct GNUNET_PeerIdentity *peer);
/** /**
* We would like to establish a new connection with a peer. ATS * We would like to establish a new connection with a peer. ATS
* should suggest a good address to begin with. * should suggest a good address to begin with.
* *
* @param sh handle * @param sh handle
* @param peer identity of the peer we need an address for * @param peer identity of the peer we need an address for
* @return suggestion handle
*/ */
void struct GNUNET_ATS_SuggestHandle *
GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_PeerIdentity *peer); const struct GNUNET_PeerIdentity *peer);
/** /**
* We want to cancel ATS suggesting addresses for a peer. * We want to cancel ATS suggesting addresses for a peer.
* *
* @param sh handle * @param sh handle
* @param peer identity of the peer * @param peer identity of the peer
*/ */
void void
GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_PeerIdentity *peer); const struct GNUNET_PeerIdentity *peer);
/** /**
* Convert a ATS property to a string
*
* @param type the atsi type
* @return a string or NULL if invalid
*/
const char *
GNUNET_ATS_print_property_type (uint32_t type);
/**
* Convert a GNUNET_ATS_NetworkType to a string * Convert a GNUNET_ATS_NetworkType to a string
* *
* @param net the network type * @param net the network type
* @return a string or NULL if invalid * @return a string or NULL if invalid
*/ */
const char * const char *
GNUNET_ATS_print_network_type (uint32_t net); GNUNET_ATS_print_network_type (uint32_t net);
/** /**
* Returns where the address is located: LAN or WAN or ... * Returns where the address is located: LAN or WAN or ...
skipping to change at line 602 skipping to change at line 644
* @param addr address * @param addr address
* @param addrlen address length * @param addrlen address length
* @return location as GNUNET_ATS_Information * @return location as GNUNET_ATS_Information
*/ */
struct GNUNET_ATS_Information struct GNUNET_ATS_Information
GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle *sh,
const struct sockaddr * addr, const struct sockaddr * addr,
socklen_t addrlen); socklen_t addrlen);
/** /**
* Test if a address and a session is known to ATS
*
* @param sh the scheduling handle
* @param address the address
* @param session the session
* @return #GNUNET_YES or #GNUNET_NO
*/
int
GNUNET_ATS_session_known (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_HELLO_Address *address,
struct Session *session);
/**
* We have a new address ATS should know. Addresses have to be added with t his * We have a new address ATS should know. Addresses have to be added with t his
* function before they can be: updated, set in use and destroyed * function before they can be: updated, set in use and destroyed
* *
* @param sh handle * @param sh handle
* @param address the address * @param address the address
* @param session session handle (if available) * @param session session handle (if available)
* @param ats performance data for the address * @param ats performance data for the address
* @param ats_count number of performance records in 'ats' * @param ats_count number of performance records in @a ats
*/ */
int int
GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_HELLO_Address *address, const struct GNUNET_HELLO_Address *address,
struct Session *session, struct Session *session,
const struct GNUNET_ATS_Information *ats, const struct GNUNET_ATS_Information *ats,
uint32_t ats_count); uint32_t ats_count);
/** /**
* We have updated performance statistics for a given address. Note * We have updated performance statistics for a given address. Note
* that this function can be called for addresses that are currently * that this function can be called for addresses that are currently
* in use as well as addresses that are valid but not actively in use. * in use as well as addresses that are valid but not actively in use.
* Furthermore, the peer may not even be connected to us right now (in * Furthermore, the peer may not even be connected to us right now (in
* which case the call may be ignored or the information may be stored * which case the call may be ignored or the information may be stored
* for later use). Update bandwidth assignments. * for later use). Update bandwidth assignments.
* *
* @param sh handle * @param sh handle
* @param address updated address * @param address updated address
* @param session session handle (if available) * @param session session handle (if available)
* @param ats performance data for the address * @param ats performance data for the address
* @param ats_count number of performance records in 'ats' * @param ats_count number of performance records in @a ats
* @return #GNUNET_OK or #GNUNET_SYSERR
*/ */
void int
GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_HELLO_Address *address, const struct GNUNET_HELLO_Address *address,
struct Session *session, struct Session *session,
const struct GNUNET_ATS_Information *ats, const struct GNUNET_ATS_Information *ats,
uint32_t ats_count); uint32_t ats_count);
/** /**
* An address is now in use or not used any more. * An address is now in use or not used any more.
* *
* @param sh handle * @param sh handle
* @param address the address * @param address the address
* @param session session handle * @param session session handle
* @param in_use GNUNET_YES if this address is now used, GNUNET_NO * @param in_use #GNUNET_YES if this address is now used, #GNUNET_NO
* if address is not used any more * if address is not used any more
*/ */
void void
GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_HELLO_Address *address, const struct GNUNET_HELLO_Address *address,
struct Session *session, int in_use); struct Session *session,
int in_use);
/** /**
* A session got destroyed, stop including it as a valid address. * A session got destroyed, stop including it as a valid address.
* *
* @param sh handle * @param sh handle
* @param address the address * @param address the address
* @param session session handle that is no longer valid (if available) * @param session session handle that is no longer valid (if available)
*/ */
void void
GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh, GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
skipping to change at line 673 skipping to change at line 730
struct Session *session); struct Session *session);
/* ******************************** Performance API *********************** ****** */ /* ******************************** Performance API *********************** ****** */
/** /**
* ATS Handle to obtain and/or modify performance information. * ATS Handle to obtain and/or modify performance information.
*/ */
struct GNUNET_ATS_PerformanceHandle; struct GNUNET_ATS_PerformanceHandle;
/** /**
* Signature of a function that is called with QoS information about a peer . * Signature of a function that is called with QoS information about an add ress.
* *
* @param cls closure * @param cls closure
* @param address the address * @param address the address
* @param address_active is this address actively used to maintain a connec
tion
* to a peer
* @param bandwidth_out assigned outbound bandwidth for the connection * @param bandwidth_out assigned outbound bandwidth for the connection
* @param bandwidth_in assigned inbound bandwidth for the connection * @param bandwidth_in assigned inbound bandwidth for the connection
* @param ats performance data for the address (as far as known) * @param ats performance data for the address (as far as known)
* @param ats_count number of performance records in 'ats' * @param ats_count number of performance records in 'ats'
*/ */
typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls, typedef void
const struct (*GNUNET_ATS_AddressInformationCallback) (void *cls,
GNUNET_HELLO_Address * const struct GNUNET_HELLO_Address *address, int address_active,
address, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
struct struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
GNUNET_BANDWIDTH_Value3 const struct GNUNET_ATS_Information *ats, uint32_t ats_count);
2NBO
bandwidth_out,
struct
GNUNET_BANDWIDTH_Value3
2NBO
bandwidth_in,
const struct
GNUNET_ATS_Information
*
ats, uint32_t ats_count
);
/** /**
* Handle for an address listing operation * Handle for an address listing operation
*/ */
struct GNUNET_ATS_AddressListHandle; struct GNUNET_ATS_AddressListHandle;
/** /**
* Get handle to access performance API of the ATS subsystem. * Get handle to access performance API of the ATS subsystem.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param infocb function to call on performance changes, can be NULL * @param addr_info_cb callback called when performance characteristics for
* @param infocb_cls closure for infocb * an address change
* @param addr_info_cb_cls closure for infocb
* @return ats performance context * @return ats performance context
*/ */
struct GNUNET_ATS_PerformanceHandle * struct GNUNET_ATS_PerformanceHandle *
GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_ATS_PeerInformationCallback infocb, GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_
void *infocb_cls); cls);
/** /**
* Get information about addresses known to the ATS subsystem. * Get information about addresses known to the ATS subsystem.
* *
* @param handle the performance handle to use * @param handle the performance handle to use
* @param peer peer idm can be NULL for all peers * @param peer peer idm can be NULL for all peers
* @param all GNUNET_YES to get information about all addresses or GNUNET_N O to * @param all GNUNET_YES to get information about all addresses or GNUNET_N O to
* get only address currently used * get only address currently used
* @param infocb callback to call with the addresses, * @param infocb callback to call with the addresses,
* will callback with address == NULL when done * will callback with address == NULL when done
* @param infocb_cls closure for infocb * @param infocb_cls closure for infocb
* @return ats performance context * @return ats performance context
*/ */
struct GNUNET_ATS_AddressListHandle * struct GNUNET_ATS_AddressListHandle *
GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle GNUNET_ATS_performance_list_addresses (
*handle, struct GNUNET_ATS_PerformanceHandle *handle,
const struct GNUNET_PeerIdentity *pe const struct GNUNET_PeerIdentity *peer, int all,
er, GNUNET_ATS_AddressInformationCallback infocb, void *infocb_cls);
int all,
GNUNET_ATS_PeerInformationCallback i
nfocb,
void *infocb_cls);
/** /**
* Cancel a pending address listing operation * Cancel a pending address listing operation
* *
* @param handle the GNUNET_ATS_AddressListHandle handle to cancel * @param handle the GNUNET_ATS_AddressListHandle handle to cancel
*/ */
void void
GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressList GNUNET_ATS_performance_list_addresses_cancel (
Handle *handle); struct GNUNET_ATS_AddressListHandle *handle);
/** /**
* Client is done using the ATS performance subsystem, release resources. * Client is done using the ATS performance subsystem, release resources.
* *
* @param ph handle * @param ph handle
*/ */
void void
GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph); GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph);
/** /**
* Function called with reservation result. * Function called with reservation result.
* *
* @param cls closure * @param cls closure
* @param peer identifies the peer * @param peer identifies the peer
* @param amount set to the amount that was actually reserved or unreserved ; * @param amount set to the amount that was actually reserved or unreserved ;
* either the full requested amount or zero (no partial reser vations) * either the full requested amount or zero (no partial reser vations)
* @param res_delay if the reservation could not be satisfied (amount was 0 ), how * @param res_delay if the reservation could not be satisfied (amount was 0 ), how
* long should the client wait until re-trying? * long should the client wait until re-trying?
*/ */
typedef void (*GNUNET_ATS_ReservationCallback) (void *cls, typedef void
const struct GNUNET_PeerIde (*GNUNET_ATS_ReservationCallback) (void *cls,
ntity const struct GNUNET_PeerIdentity * peer, int32_t amount,
* peer, int32_t amount, struct GNUNET_TIME_Relative res_delay);
struct GNUNET_TIME_Relative
res_delay);
/** /**
* Context that can be used to cancel a peer information request. * Context that can be used to cancel a peer information request.
*/ */
struct GNUNET_ATS_ReservationContext; struct GNUNET_ATS_ReservationContext;
/** /**
* Reserve inbound bandwidth from the given peer. ATS will look at * Reserve inbound bandwidth from the given peer. ATS will look at
* the current amount of traffic we receive from the peer and ensure * the current amount of traffic we receive from the peer and ensure
* that the peer could add 'amount' of data to its stream. * that the peer could add 'amount' of data to its stream.
skipping to change at line 786 skipping to change at line 837
* @param peer identifies the peer * @param peer identifies the peer
* @param amount reserve N bytes for receiving, negative * @param amount reserve N bytes for receiving, negative
* amounts can be used to undo a (recent) reservation; * amounts can be used to undo a (recent) reservation;
* @param rcb function to call with the resulting reservation information * @param rcb function to call with the resulting reservation information
* @param rcb_cls closure for info * @param rcb_cls closure for info
* @return NULL on error * @return NULL on error
* @deprecated will be replaced soon * @deprecated will be replaced soon
*/ */
struct GNUNET_ATS_ReservationContext * struct GNUNET_ATS_ReservationContext *
GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph, GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
const struct GNUNET_PeerIdentity *peer, const struct GNUNET_PeerIdentity *peer, int32_t amount,
int32_t amount, GNUNET_ATS_ReservationCallback rcb, void *rcb_cls);
GNUNET_ATS_ReservationCallback rcb,
void *rcb_cls);
/** /**
* Cancel request for reserving bandwidth. * Cancel request for reserving bandwidth.
* *
* @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
*/ */
void void
GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext * rc); GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext * rc);
/** /**
skipping to change at line 837 skipping to change at line 886
* the goal function) to the given amount. The argument is followed * the goal function) to the given amount. The argument is followed
* by a double value giving the desired value (can be negative). * by a double value giving the desired value (can be negative).
* Preference changes are forgotten if peers disconnect. * Preference changes are forgotten if peers disconnect.
*/ */
GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_BANDWIDTH,
/** /**
* Change the peer's latency value to the given amount. The * Change the peer's latency value to the given amount. The
* argument is followed by a double value giving the desired value * argument is followed by a double value giving the desired value
* (can be negative). The absolute score in the goal function is * (can be negative). The absolute score in the goal function is
* the inverse of the latency in ms (minimum: 1 ms) multiplied by * the inverse of the latency in microseconds (minimum: 1
* the latency preferences. * microsecond) multiplied by the latency preferences.
*/ */
GNUNET_ATS_PREFERENCE_LATENCY GNUNET_ATS_PREFERENCE_LATENCY
}; };
/** /**
* Convert a GNUNET_ATS_PreferenceType to a string * Convert a GNUNET_ATS_PreferenceType to a string
* *
* @param type the preference type * @param type the preference type
* @return a string or NULL if invalid * @return a string or NULL if invalid
*/ */
skipping to change at line 861 skipping to change at line 910
/** /**
* Change preferences for the given peer. Preference changes are forgotten if peers * Change preferences for the given peer. Preference changes are forgotten if peers
* disconnect. * disconnect.
* *
* @param ph performance handle * @param ph performance handle
* @param peer identifies the peer * @param peer identifies the peer
* @param ... 0-terminated specification of the desired changes * @param ... 0-terminated specification of the desired changes
*/ */
void void
GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph, GNUNET_ATS_performance_change_preference (
const struct GNUNET_PeerIdentity *peer, ...); struct GNUNET_ATS_PerformanceHandle *ph,
const struct GNUNET_PeerIdentity *peer, ...);
/**
* Application feedback on how good preference requirements are fulfilled
* for the preferences included in the given time scope [now - scope .. now
]
*
* An application notifies ATS if (and only if) it has feedback information
* for specific properties. This values are valid until the feedback scores
are
* updated by the application.
*
* If the application has no feedback for this preference kind the applicat
ion
* will not explicitly call for this property and will not include it in th
is
* function call.
*
* @param ph performance handle
* @param scope the time interval this valid for: [now - scope .. now]
* @param peer identifies the peer
* @param ... 0-terminated specification of the desired changes
*/
void
GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *
ph,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TIME_Relative scope, ...);
#endif #endif
/* end of file gnunet-service-transport_ats.h */ /* end of file gnunet-service-transport_ats.h */
 End of changes. 42 change blocks. 
346 lines changed or deleted 409 lines changed or added


 gnunet_bandwidth_lib.h   gnunet_bandwidth_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2010 Christian Grothoff (and other contributing authors) (C) 2010 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gnunet_bio_lib.h   gnunet_bio_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_bio_lib.h * @file include/gnunet_bio_lib.h
* @brief buffered IO API * @brief buffered IO API
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup bio Buffered binary disk IO (with endianess conversion)
* @{
*/ */
#ifndef GNUNET_BIO_LIB_H #ifndef GNUNET_BIO_LIB_H
#define GNUNET_BIO_LIB_H #define GNUNET_BIO_LIB_H
#include "gnunet_container_lib.h" #include "gnunet_container_lib.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/** /**
* @ingroup bio
* Handle for buffered reading. * Handle for buffered reading.
*/ */
struct GNUNET_BIO_ReadHandle; struct GNUNET_BIO_ReadHandle;
/** /**
* Open a file for reading. * Open a file for reading.
* *
* @param fn file name to be opened * @param fn file name to be opened
* @return IO handle on success, NULL on error * @return IO handle on success, NULL on error
*/ */
struct GNUNET_BIO_ReadHandle * struct GNUNET_BIO_ReadHandle *
GNUNET_BIO_read_open (const char *fn); GNUNET_BIO_read_open (const char *fn);
/** /**
* Close an open file. Reports if any errors reading * Close an open file. Reports if any errors reading
* from the file were encountered. * from the file were encountered.
* *
* @param h file handle * @param h file handle
* @param emsg set to the error message * @param emsg set to the error message
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg);
/** /**
* Read the contents of a binary file into a buffer. * Read the contents of a binary file into a buffer.
* *
* @param h handle to an open file * @param h handle to an open file
* @param what describes what is being read (for error message creation) * @param what describes what is being read (for error message creation)
* @param result the buffer to write the result to * @param result the buffer to write the result to
* @param len the number of bytes to read * @param len the number of bytes to read
* @return GNUNET_OK on success, GNUNET_SYSERR on failure * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/ */
int int
GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what,
void *result, size_t len); void *result, size_t len);
/** /**
* Read the contents of a binary file into a buffer. * Read the contents of a binary file into a buffer.
* *
* @param h handle to an open file * @param h handle to an open file
* @param file name of the source file * @param file name of the source file
* @param line line number in the source file * @param line line number in the source file
* @param result the buffer to write the result to * @param result the buffer to write the result to
* @param len the number of bytes to read * @param len the number of bytes to read
* @return GNUNET_OK on success, GNUNET_SYSERR on failure * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/ */
int int
GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, const char *file, int GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
line, const char *file, int line,
void *result, size_t len); void *result, size_t len);
/** /**
* Read 0-terminated string from a file. * Read 0-terminated string from a file.
* *
* @param h handle to an open file * @param h handle to an open file
* @param what describes what is being read (for error message creation) * @param what describes what is being read (for error message creation)
* @param result the buffer to store a pointer to the (allocated) string to * @param result the buffer to store a pointer to the (allocated) string to
* (note that *result could be set to NULL as well) * (note that *result could be set to NULL as well)
* @param maxLen maximum allowed length for the string * @param max_length maximum allowed length for the string
* @return GNUNET_OK on success, GNUNET_SYSERR on failure * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/ */
int int
GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what,
char **result, size_t maxLen); char **result, size_t max_length);
/** /**
* Read metadata container from a file. * Read metadata container from a file.
* *
* @param h handle to an open file * @param h handle to an open file
* @param what describes what is being read (for error message creation) * @param what describes what is being read (for error message creation)
* @param result the buffer to store a pointer to the (allocated) metadata * @param result the buffer to store a pointer to the (allocated) metadata
* @return GNUNET_OK on success, GNUNET_SYSERR on failure * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/ */
int int
GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *wha t, GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *wha t,
struct GNUNET_CONTAINER_MetaData **result); struct GNUNET_CONTAINER_MetaData **result);
/** /**
* Read a float. * Read a float.
* *
* @param h hande to open file * @param h hande to open file
* @param f address of float to read * @param f address of float to read
skipping to change at line 141 skipping to change at line 145
*/ */
#define GNUNET_BIO_read_double(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LI NE__, f, sizeof(double))) #define GNUNET_BIO_read_double(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LI NE__, f, sizeof(double)))
/** /**
* Read an (u)int32_t. * Read an (u)int32_t.
* *
* @param h hande to open file * @param h hande to open file
* @param file name of the source file * @param file name of the source file
* @param line line number in the code * @param line line number in the code
* @param i address of 32-bit integer to read * @param i address of 32-bit integer to read
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file,
int line, int32_t * i); int line, int32_t * i);
/** /**
* Read an (u)int32_t. * Read an (u)int32_t.
* *
* @param h hande to open file * @param h hande to open file
* @param i address of 32-bit integer to read * @param i address of 32-bit integer to read
*/ */
#define GNUNET_BIO_read_int32(h, i) GNUNET_BIO_read_int32__ (h, __FILE__, _ _LINE__, (int32_t*) i) #define GNUNET_BIO_read_int32(h, i) GNUNET_BIO_read_int32__ (h, __FILE__, _ _LINE__, (int32_t*) i)
/** /**
* Read an (u)int64_t. * Read an (u)int64_t.
* *
* @param h hande to open file * @param h hande to open file
* @param file name of the source file * @param file name of the source file
* @param line line number in the code * @param line line number in the code
* @param i address of 64-bit integer to read * @param i address of 64-bit integer to read
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file, GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file,
int line, int64_t * i); int line, int64_t * i);
/** /**
* Read an (u)int64_t. * Read an (u)int64_t.
* *
* @param h hande to open file * @param h hande to open file
* @param i address of 64-bit integer to read * @param i address of 64-bit integer to read
skipping to change at line 205 skipping to change at line 209
*/ */
int int
GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h); GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h);
/** /**
* Write a buffer to a file. * Write a buffer to a file.
* *
* @param h handle to open file * @param h handle to open file
* @param buffer the data to write * @param buffer the data to write
* @param n number of bytes to write * @param n number of bytes to write
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer, GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer,
size_t n); size_t n);
/** /**
* Force a buffered writer to flush its buffer
*
* @param h the writer handle
* @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returne
d and
* the file is closed
*/
int
GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h);
/**
* Write a string to a file. * Write a string to a file.
* *
* @param h handle to open file * @param h handle to open file
* @param s string to write (can be NULL) * @param s string to write (can be NULL)
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s); GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s);
/** /**
* Write metadata container to a file. * Write metadata container to a file.
* *
* @param h handle to open file * @param h handle to open file
* @param m metadata to write * @param m metadata to write
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
const struct GNUNET_CONTAINER_MetaData *m); const struct GNUNET_CONTAINER_MetaData *m);
/** /**
* Write a float. * Write a float.
* *
* @param h hande to open file * @param h hande to open file
* @param f float to write (must be a variable) * @param f float to write (must be a variable)
skipping to change at line 253 skipping to change at line 267
* @param h hande to open file * @param h hande to open file
* @param f double to write (must be a variable) * @param f double to write (must be a variable)
*/ */
#define GNUNET_BIO_write_double(h, f) GNUNET_BIO_write (h, &f, sizeof(doubl e)) #define GNUNET_BIO_write_double(h, f) GNUNET_BIO_write (h, &f, sizeof(doubl e))
/** /**
* Write an (u)int32_t. * Write an (u)int32_t.
* *
* @param h hande to open file * @param h hande to open file
* @param i 32-bit integer to write * @param i 32-bit integer to write
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, int32_t i); GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, int32_t i);
/** /**
* Write an (u)int64_t. * Write an (u)int64_t.
* *
* @param h hande to open file * @param h hande to open file
* @param i 64-bit integer to write * @param i 64-bit integer to write
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i); GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group bio */
/* ifndef GNUNET_BIO_LIB_H */ /* ifndef GNUNET_BIO_LIB_H */
#endif #endif
/* end of gnunet_bio_lib.h */ /* end of gnunet_bio_lib.h */
 End of changes. 19 change blocks. 
17 lines changed or deleted 33 lines changed or added


 gnunet_block_lib.h   gnunet_block_lib.h 
skipping to change at line 43 skipping to change at line 43
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/** /**
* Blocks in the datastore and the datacache must have a unique type. * Blocks in the datastore and the datacache must have a unique type.
*/ */
enum GNUNET_BLOCK_Type enum GNUNET_BLOCK_Type
{ {
/** /**
* Any type of block, used as a wildcard when searching. Should * Any type of block, used as a wildcard when searching. Should
* never be attached to a specific block. * never be attached to a specific block.
*/ */
GNUNET_BLOCK_TYPE_ANY = 0, GNUNET_BLOCK_TYPE_ANY = 0,
/** /**
* Data block (leaf) in the CHK tree. * Data block (leaf) in the CHK tree.
*/ */
GNUNET_BLOCK_TYPE_FS_DBLOCK = 1, GNUNET_BLOCK_TYPE_FS_DBLOCK = 1,
/** /**
* Inner block in the CHK tree. * Inner block in the CHK tree.
*/ */
GNUNET_BLOCK_TYPE_FS_IBLOCK = 2, GNUNET_BLOCK_TYPE_FS_IBLOCK = 2,
/** /**
* Type of a block representing a keyword search result. Note that * Legacy type, no longer in use.
* the values for KBLOCK, SBLOCK and NBLOCK must be consecutive. */
*/
GNUNET_BLOCK_TYPE_FS_KBLOCK = 3, GNUNET_BLOCK_TYPE_FS_KBLOCK = 3,
/** /**
* Type of a block that is used to advertise content in a namespace. * Legacy type, no longer in use.
*/ */
GNUNET_BLOCK_TYPE_FS_SBLOCK = 4, GNUNET_BLOCK_TYPE_FS_SBLOCK = 4,
/** /**
* Type of a block that is used to advertise a namespace. * Legacy type, no longer in use.
*/ */
GNUNET_BLOCK_TYPE_FS_NBLOCK = 5, GNUNET_BLOCK_TYPE_FS_NBLOCK = 5,
/** /**
* Type of a block representing a block to be encoded on demand from di * Type of a block representing a block to be encoded on demand from disk
sk. .
* Should never appear on the network directly. * Should never appear on the network directly.
*/ */
GNUNET_BLOCK_TYPE_FS_ONDEMAND = 6, GNUNET_BLOCK_TYPE_FS_ONDEMAND = 6,
/** /**
* Type of a block that contains a HELLO for a peer (for * Type of a block that contains a HELLO for a peer (for
* DHT find-peer operations). * DHT find-peer operations).
*/ */
GNUNET_BLOCK_TYPE_DHT_HELLO = 7, GNUNET_BLOCK_TYPE_DHT_HELLO = 7,
/** /**
* Block for testing. * Block for testing.
*/ */
GNUNET_BLOCK_TYPE_TEST = 8, GNUNET_BLOCK_TYPE_TEST = 8,
/** /**
* Block for storing .gnunet-domains * Type of a block representing any type of search result
*/ * (universal). Implemented in the context of #2564, replaces
* SBLOCKS, KBLOCKS and NBLOCKS.
*/
GNUNET_BLOCK_TYPE_FS_UBLOCK = 9,
/**
* Block for storing DNS exit service advertisements.
*/
GNUNET_BLOCK_TYPE_DNS = 10, GNUNET_BLOCK_TYPE_DNS = 10,
/** /**
* Block for storing record data * Block for storing record data
*/ */
GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11,
/** /**
* Block for storing mesh peers * Block for storing mesh peers
*/ */
GNUNET_BLOCK_TYPE_MESH_PEER = 20, GNUNET_BLOCK_TYPE_MESH_PEER = 20,
/** /**
* Block for finding peers by type * Block to store a mesh regex state
*/ */
GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE = 21, GNUNET_BLOCK_TYPE_REGEX = 22,
/** /**
* Block to store a mesh regex state * Block to store a mesh regex accepting state
*/ */
GNUNET_BLOCK_TYPE_MESH_REGEX = 22, GNUNET_BLOCK_TYPE_REGEX_ACCEPT = 23
/**
* Block to store a mesh regex accepting state
*/
GNUNET_BLOCK_TYPE_MESH_REGEX_ACCEPT = 23
}; };
/** /**
* Possible ways for how a block may relate to a query. * Possible ways for how a block may relate to a query.
*/ */
enum GNUNET_BLOCK_EvaluationResult enum GNUNET_BLOCK_EvaluationResult
{ {
/** /**
* Valid result, and there may be more. * Valid result, and there may be more.
*/ */
GNUNET_BLOCK_EVALUATION_OK_MORE = 0, GNUNET_BLOCK_EVALUATION_OK_MORE = 0,
/** /**
* Last possible valid result. * Last possible valid result.
*/ */
GNUNET_BLOCK_EVALUATION_OK_LAST = 1, GNUNET_BLOCK_EVALUATION_OK_LAST = 1,
/** /**
* Valid result, but suppressed because it is a duplicate. * Valid result, but suppressed because it is a duplicate.
*/ */
GNUNET_BLOCK_EVALUATION_OK_DUPLICATE = 2, GNUNET_BLOCK_EVALUATION_OK_DUPLICATE = 2,
/** /**
* Block does not match query (invalid result) * Block does not match query (invalid result)
*/ */
GNUNET_BLOCK_EVALUATION_RESULT_INVALID = 3, GNUNET_BLOCK_EVALUATION_RESULT_INVALID = 3,
/** /**
* Block does not match xquery (valid result, not relevant for the requ * Block does not match xquery (valid result, not relevant for the reques
est) t)
*/ */
GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT = 4, GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT = 4,
/** /**
* Query is valid, no reply given. * Query is valid, no reply given.
*/ */
GNUNET_BLOCK_EVALUATION_REQUEST_VALID = 10, GNUNET_BLOCK_EVALUATION_REQUEST_VALID = 10,
/** /**
* Query format does not match block type (invalid query). For * Query format does not match block type (invalid query). For
* example, xquery not given or xquery_size not appropriate for * example, xquery not given or xquery_size not appropriate for
* type. * type.
*/ */
GNUNET_BLOCK_EVALUATION_REQUEST_INVALID = 11, GNUNET_BLOCK_EVALUATION_REQUEST_INVALID = 11,
/** /**
* Specified block type not supported by this plugin. * Specified block type not supported by this plugin.
*/ */
GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED = 20 GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED = 20
}; };
/** /**
* Handle to an initialized block library. * Handle to an initialized block library.
*/ */
struct GNUNET_BLOCK_Context; struct GNUNET_BLOCK_Context;
/** /**
* Mingle hash with the mingle_number to produce different bits. * Mingle hash with the mingle_number to produce different bits.
skipping to change at line 215 skipping to change at line 216
* Function called to validate a reply or a request. For * Function called to validate a reply or a request. For
* request evaluation, simply pass "NULL" for the reply_block. * request evaluation, simply pass "NULL" for the reply_block.
* Note that it is assumed that the reply has already been * Note that it is assumed that the reply has already been
* matched to the key (and signatures checked) as it would * matched to the key (and signatures checked) as it would
* be done with the "get_key" function. * be done with the "get_key" function.
* *
* @param ctx block contxt * @param ctx block contxt
* @param type block type * @param type block type
* @param query original query (hash) * @param query original query (hash)
* @param bf pointer to bloom filter associated with query; possibly update d (!) * @param bf pointer to bloom filter associated with query; possibly update d (!)
* @param bf_mutator mutation value for bf * @param bf_mutator mutation value for @a bf
* @param xquery extrended query data (can be NULL, depending on type) * @param xquery extrended query data (can be NULL, depending on type)
* @param xquery_size number of bytes in xquery * @param xquery_size number of bytes in @a xquery
* @param reply_block response to validate * @param reply_block response to validate
* @param reply_block_size number of bytes in reply block * @param reply_block_size number of bytes in @a reply_block
* @return characterization of result * @return characterization of result
*/ */
enum GNUNET_BLOCK_EvaluationResult enum GNUNET_BLOCK_EvaluationResult
GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
const struct GNUNET_HashCode * query, const struct GNUNET_HashCode * query,
struct GNUNET_CONTAINER_BloomFilter **bf, struct GNUNET_CONTAINER_BloomFilter **bf,
int32_t bf_mutator, const void *xquery, int32_t bf_mutator, const void *xquery,
size_t xquery_size, const void *reply_block, size_t xquery_size, const void *reply_block,
size_t reply_block_size); size_t reply_block_size);
/** /**
* Function called to obtain the key for a block. * Function called to obtain the key for a block.
* *
* @param ctx block context * @param ctx block context
* @param type block type * @param type block type
* @param block block to get the key for * @param block block to get the key for
* @param block_size number of bytes in block * @param block_size number of bytes in @a block
* @param key set to the key (query) for the given block * @param key set to the key (query) for the given block
* @return GNUNET_YES on success, * @return #GNUNET_YES on success,
* GNUNET_NO if the block is malformed * #GNUNET_NO if the block is malformed
* GNUNET_SYSERR if type not supported * #GNUNET_SYSERR if type not supported
* (or if extracting a key from a block of this type does not work) * (or if extracting a key from a block of this type does not work)
*/ */
int int
GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_BLOCK_Type type, const void *block, enum GNUNET_BLOCK_Type type, const void *block,
size_t block_size, struct GNUNET_HashCode * key); size_t block_size, struct GNUNET_HashCode * key);
/** /**
* Construct a bloom filter that would filter out the given * Construct a bloom filter that would filter out the given
* results. * results.
* *
* @param bf_mutator mutation value to use * @param bf_mutator mutation value to use
* @param seen_results results already seen * @param seen_results results already seen
* @param seen_results_count number of entries in 'seen_results' * @param seen_results_count number of entries in @a seen_results
* @return NULL if seen_results_count is 0, otherwise a BF * @return NULL if seen_results_count is 0, otherwise a BF
* that would match the given results. * that would match the given results.
*/ */
struct GNUNET_CONTAINER_BloomFilter * struct GNUNET_CONTAINER_BloomFilter *
GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator, GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator,
const struct GNUNET_HashCode * seen_res ults, const struct GNUNET_HashCode * seen_res ults,
unsigned int seen_results_count); unsigned int seen_results_count);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
 End of changes. 27 change blocks. 
90 lines changed or deleted 91 lines changed or added


 gnunet_block_plugin.h   gnunet_block_plugin.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2010 Christian Grothoff (and other contributing authors) (C) 2010,2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
skipping to change at line 26 skipping to change at line 26
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_block_plugin.h * @file include/gnunet_block_plugin.h
* @brief API for block plugins. Each block plugin must conform to * @brief API for block plugins. Each block plugin must conform to
* the API specified by this header. * the API specified by this header.
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup block API to be implemented by applications storing data in th
e DHT
* @{
*/ */
#ifndef PLUGIN_BLOCK_H #ifndef PLUGIN_BLOCK_H
#define PLUGIN_BLOCK_H #define PLUGIN_BLOCK_H
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_container_lib.h"
#include "gnunet_block_lib.h" #include "gnunet_block_lib.h"
/** /**
* Function called to validate a reply or a request. For * Function called to validate a reply or a request. For
* request evaluation, simply pass "NULL" for the reply_block. * request evaluation, simply pass "NULL" for the @a reply_block.
* Note that it is assumed that the reply has already been * Note that it is assumed that the reply has already been
* matched to the key (and signatures checked) as it would * matched to the key (and signatures checked) as it would
* be done with the "get_key" function. * be done with the "get_key" function.
* *
* @param cls closure * @param cls closure
* @param type block type * @param type block type
* @param query original query (hash) * @param query original query (hash)
* @param bf pointer to bloom filter associated with query; possibly update d (!) * @param bf pointer to bloom filter associated with query; possibly update d (!)
* @param bf_mutator mutation value for bf * @param bf_mutator mutation value for @a bf
* @param xquery extrended query data (can be NULL, depending on type) * @param xquery extrended query data (can be NULL, depending on type)
* @param xquery_size number of bytes in xquery * @param xquery_size number of bytes in @a xquery
* @param reply_block response to validate * @param reply_block response to validate
* @param reply_block_size number of bytes in reply block * @param reply_block_size number of bytes in @a reply_block
* @return characterization of result * @return characterization of result
*/ */
typedef enum typedef enum GNUNET_BLOCK_EvaluationResult
GNUNET_BLOCK_EvaluationResult (*GNUNET_BLOCK_EvaluationFunction) (void (*GNUNET_BLOCK_EvaluationFunction) (void *cls,
*cls, enum GNUNET_BLOCK_Type type,
enum const struct GNUNET_HashCode *query,
GNUNE struct GNUNET_CONTAINER_BloomFilter **bf
T_BLOCK_Type ,
type, int32_t bf_mutator,
const const void *xquery,
struc size_t xquery_size,
t GNUNET_HashCode const void *reply_block,
* que size_t reply_block_size);
ry,
struc
t
GNUNE
T_CONTAINER_BloomFilter
** bf
,
int32
_t
bf_mu
tator,
const
void
*xque
ry,
size_
t
xquer
y_size,
const
void
*repl
y_block,
size_
t
reply
_block_size);
/** /**
* Function called to obtain the key for a block. * Function called to obtain the key for a block.
* *
* @param cls closure * @param cls closure
* @param type block type * @param type block type
* @param block block to get the key for * @param block block to get the key for
* @param block_size number of bytes in block * @param block_size number of bytes in @a block
* @param key set to the key (query) for the given block * @param key set to the key (query) for the given block
* @return GNUNET_YES on success, * @return #GNUNET_YES on success,
* GNUNET_NO if the block is malformed * #GNUNET_NO if the block is malformed
* GNUNET_SYSERR if type not supported * #GNUNET_SYSERR if type not supported
* (or if extracting a key from a block of this type does not work) * (or if extracting a key from a block of this type does not work)
*/ */
typedef int (*GNUNET_BLOCK_GetKeyFunction) (void *cls, typedef int (*GNUNET_BLOCK_GetKeyFunction) (void *cls,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
const void *block, const void *block,
size_t block_size, size_t block_size,
struct GNUNET_HashCode * key); struct GNUNET_HashCode * key);
/** /**
* Each plugin is required to return a pointer to a struct of this * Each plugin is required to return a pointer to a struct of this
skipping to change at line 123 skipping to change at line 113
*/ */
GNUNET_BLOCK_EvaluationFunction evaluate; GNUNET_BLOCK_EvaluationFunction evaluate;
/** /**
* Obtain the key for a given block (if possible). * Obtain the key for a given block (if possible).
*/ */
GNUNET_BLOCK_GetKeyFunction get_key; GNUNET_BLOCK_GetKeyFunction get_key;
}; };
/** @} */ /* end of group block */
#endif #endif
 End of changes. 11 change blocks. 
48 lines changed or deleted 25 lines changed or added


 gnunet_client_lib.h   gnunet_client_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_client_lib.h * @file include/gnunet_client_lib.h
* @brief functions related to accessing services * @brief functions related to accessing services
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup client Generic client-side communication with services
* @{
*/ */
#ifndef GNUNET_CLIENT_LIB_H #ifndef GNUNET_CLIENT_LIB_H
#define GNUNET_CLIENT_LIB_H #define GNUNET_CLIENT_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_connection_lib.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_time_lib.h"
/** /**
* Opaque handle for a connection to a service. * Opaque handle for a connection to a service.
*/ */
struct GNUNET_CLIENT_Connection; struct GNUNET_CLIENT_Connection;
/** /**
* Get a connection with a service. * Get a connection with a service.
* *
* @param service_name name of the service * @param service_name name of the service
* @param cfg configuration to use * @param cfg configuration to use
skipping to change at line 84 skipping to change at line 80
GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *client); GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *client);
/** /**
* Type of a function to call when we receive a message * Type of a function to call when we receive a message
* from the service. * from the service.
* *
* @param cls closure * @param cls closure
* @param msg message received, NULL on timeout or fatal error * @param msg message received, NULL on timeout or fatal error
*/ */
typedef void (*GNUNET_CLIENT_MessageHandler) (void *cls, typedef void (*GNUNET_CLIENT_MessageHandler) (void *cls,
const struct GNUNET_MessageHe const struct GNUNET_MessageHe
ader ader *msg);
* msg);
/**
* Type of a function to call when we have finished shutting
* down a service, or failed.
*
* @param cls closure
* @param reason what is the result of the shutdown
* GNUNET_NO on shutdown (not running)
* GNUNET_YES on running
* GNUNET_SYSERR on failure to transmit message
*/
typedef void (*GNUNET_CLIENT_ShutdownTask) (void *cls, int reason);
/** /**
* Read from the service. * Read from the service.
* *
* @param client connection to the service * @param client connection to the service
* @param handler function to call with the message * @param handler function to call with the message
* @param handler_cls closure for handler * @param handler_cls closure for @a handler
* @param timeout how long to wait until timing out * @param timeout how long to wait until timing out
*/ */
void void
GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *client, GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *client,
GNUNET_CLIENT_MessageHandler handler, void *handler_ cls, GNUNET_CLIENT_MessageHandler handler, void *handler_ cls,
struct GNUNET_TIME_Relative timeout); struct GNUNET_TIME_Relative timeout);
/** /**
* Transmit handle for client connections. * Transmit handle for client connections.
*/ */
struct GNUNET_CLIENT_TransmitHandle; struct GNUNET_CLIENT_TransmitHandle;
/** /**
* Ask the client to call us once the specified number of bytes * Ask the client to call us once the specified number of bytes
* are free in the transmission buffer. May call the notify * are free in the transmission buffer. May call the notify
* method immediately if enough space is available. * method immediately if enough space is available.
* *
* @param client connection to the service * @param client connection to the service
* @param size number of bytes to send * @param size number of bytes to send
* @param timeout after how long should we give up (and call * @param timeout after how long should we give up (and call
* notify with buf NULL and size 0)? * @a notify with buf NULL and size 0)?
* @param auto_retry if the connection to the service dies, should we * @param auto_retry if the connection to the service dies, should we
* automatically re-connect and retry (within the timeout period) * automatically re-connect and retry (within the timeout period)
* or should we immediately fail in this case? Pass GNUNET_YES * or should we immediately fail in this case? Pass #GNUNET_YES
* if the caller does not care about temporary connection errors, * if the caller does not care about temporary connection errors,
* for example because the protocol is stateless * for example because the protocol is stateless
* @param notify function to call * @param notify function to call
* @param notify_cls closure for notify * @param notify_cls closure for @a notify
* @return NULL if someone else is already waiting to be notified * @return NULL if someone else is already waiting to be notified
* non-NULL if the notify callback was queued (can be used to cance l * non-NULL if the notify callback was queued (can be used to cance l
* using GNUNET_CONNECTION_notify_transmit_ready_cancel) * using #GNUNET_CONNECTION_notify_transmit_ready_cancel)
*/ */
struct GNUNET_CLIENT_TransmitHandle * struct GNUNET_CLIENT_TransmitHandle *
GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *clien t, GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *clien t,
size_t size, size_t size,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
int auto_retry, int auto_retry,
GNUNET_CONNECTION_TransmitReadyNotify GNUNET_CONNECTION_TransmitReadyNotify
notify, void *notify_cls); notify,
void *notify_cls);
/** /**
* Cancel a request for notification. * Cancel a request for notification.
* *
* @param th handle from the original request. * @param th handle from the original request.
*/ */
void void
GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHa ndle GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHa ndle
*th); *th);
skipping to change at line 167 skipping to change at line 150
* If either operation times out, the callback * If either operation times out, the callback
* will be called with a "NULL" response (in which * will be called with a "NULL" response (in which
* case the connection should probably be destroyed). * case the connection should probably be destroyed).
* *
* @param client connection to use * @param client connection to use
* @param hdr message to transmit * @param hdr message to transmit
* @param timeout when to give up (for both transmission * @param timeout when to give up (for both transmission
* and for waiting for a response) * and for waiting for a response)
* @param auto_retry if the connection to the service dies, should we * @param auto_retry if the connection to the service dies, should we
* automatically re-connect and retry (within the timeout period) * automatically re-connect and retry (within the timeout period)
* or should we immediately fail in this case? Pass GNUNET_YES * or should we immediately fail in this case? Pass #GNUNET_YES
* if the caller does not care about temporary connection errors, * if the caller does not care about temporary connection errors,
* for example because the protocol is stateless * for example because the protocol is stateless
* @param rn function to call with the response * @param rn function to call with the response
* @param rn_cls closure for rn * @param rn_cls closure for @a rn
* @return GNUNET_OK on success, GNUNET_SYSERR if a request * @return #GNUNET_OK on success, #GNUNET_SYSERR if a request
* is already pending * is already pending
*/ */
int int
GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *c lient, GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *c lient,
const struct GNUNET_MessageHeader *hdr, const struct GNUNET_MessageHeader *hdr,
struct GNUNET_TIME_Relative timeou t, struct GNUNET_TIME_Relative timeou t,
int auto_retry, int auto_retry,
GNUNET_CLIENT_MessageHandler rn, GNUNET_CLIENT_MessageHandler rn,
void *rn_cls); void *rn_cls);
/** /**
* Wait until the service is running. * Handle for a test to check if a service is running.
*/
struct GNUNET_CLIENT_TestHandle;
/**
* Function called with the result on the service test.
*
* @param cls closure
* @param result #GNUNET_YES if the service is running,
* #GNUNET_NO if the service is not running
* #GNUNET_SYSERR if the configuration is invalid
*/
typedef void (*GNUNET_CLIENT_TestResultCallback)(void *cls,
int result);
/**
* Test if the service is running. If we are given a UNIXPATH or a
* local address, we do this NOT by trying to connect to the service,
* but by trying to BIND to the same port. If the BIND fails, we know
* the service is running.
* *
* @param service name of the service to wait for * @param service name of the service to wait for
* @param cfg configuration to use * @param cfg configuration to use
* @param timeout how long to wait at most in ms * @param timeout how long to wait at most
* @param task task to run if service is running * @param cb function to call with the result
* (reason will be "PREREQ_DONE" (service running) * @param cb_cls closure for @a cb
* or "TIMEOUT" (service not known to be running)) * @return handle to cancel the test
* @param task_cls closure for task
*/ */
void struct GNUNET_CLIENT_TestHandle *
GNUNET_CLIENT_service_test (const char *service, GNUNET_CLIENT_service_test (const char *service,
const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_SCHEDULER_Task task, void *task_cls); GNUNET_CLIENT_TestResultCallback cb, void *cb_c
ls);
/**
* Abort testing for service.
*
* @param th test handle
*/
void
GNUNET_CLIENT_service_test_cancel (struct GNUNET_CLIENT_TestHandle *th);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group client */
/* ifndef GNUNET_CLIENT_LIB_H */ /* ifndef GNUNET_CLIENT_LIB_H */
#endif #endif
/* end of gnunet_client_lib.h */ /* end of gnunet_client_lib.h */
 End of changes. 18 change blocks. 
41 lines changed or deleted 54 lines changed or added


 gnunet_common.h   gnunet_common.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2006, 2009 Christian Grothoff (and other contributing authors) (C) 2006-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 29 skipping to change at line 29
*/ */
/** /**
* @file include/gnunet_common.h * @file include/gnunet_common.h
* @brief commonly used definitions; globals in this file * @brief commonly used definitions; globals in this file
* are exempt from the rule that the module name ("common") * are exempt from the rule that the module name ("common")
* must be part of the symbol name. * must be part of the symbol name.
* *
* @author Christian Grothoff * @author Christian Grothoff
* @author Nils Durner * @author Nils Durner
*
* @defgroup logging Logging
* @defgroup memory Memory management
*/ */
#ifndef GNUNET_COMMON_H #ifndef GNUNET_COMMON_H
#define GNUNET_COMMON_H #define GNUNET_COMMON_H
#if HAVE_SYS_SOCKET_H #if HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#if HAVE_NETINET_IN_H #if HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
skipping to change at line 60 skipping to change at line 63
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/** /**
* Version of the API (for entire gnunetutil.so library). * Version of the API (for entire gnunetutil.so library).
*/ */
#define GNUNET_UTIL_VERSION 0x00090500 #define GNUNET_UTIL_VERSION 0x000A0000
/** /**
* Named constants for return values. The following * Named constants for return values. The following invariants hold:
* invariants hold: "GNUNET_NO == 0" (to allow "if (GNUNET_NO)") * `GNUNET_NO == 0` (to allow `if (GNUNET_NO)`) `GNUNET_OK !=
* "GNUNET_OK != GNUNET_SYSERR", "GNUNET_OK != GNUNET_NO", "GNUNET_NO != GN * GNUNET_SYSERR`, `GNUNET_OK != GNUNET_NO`, `GNUNET_NO !=
UNET_SYSERR" * GNUNET_SYSERR` and finally `GNUNET_YES != GNUNET_NO`.
* and finally "GNUNET_YES != GNUNET_NO".
*/ */
#define GNUNET_OK 1 #define GNUNET_OK 1
#define GNUNET_SYSERR -1 #define GNUNET_SYSERR -1
#define GNUNET_YES 1 #define GNUNET_YES 1
#define GNUNET_NO 0 #define GNUNET_NO 0
#define GNUNET_MIN(a,b) (((a) < (b)) ? (a) : (b)) #define GNUNET_MIN(a,b) (((a) < (b)) ? (a) : (b))
#define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b)) #define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b))
skipping to change at line 107 skipping to change at line 110
#ifdef _LITTLE_ENDIAN #ifdef _LITTLE_ENDIAN
#define __LITTLE_ENDIAN _LITTLE_ENDIAN #define __LITTLE_ENDIAN _LITTLE_ENDIAN
#else #else
#ifdef LITTLE_ENDIAN #ifdef LITTLE_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN #define __LITTLE_ENDIAN LITTLE_ENDIAN
#endif #endif
#endif #endif
#endif #endif
/** /**
* @ingroup logging
* define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet sou
rce
* tree where gnunet_config.h is unavailable
*/
#ifndef GNUNET_EXTRA_LOGGING
#define GNUNET_EXTRA_LOGGING 0
#endif
/**
* Endian operations * Endian operations
*/ */
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
# define GNUNET_htobe16(x) __bswap_16 (x) # define GNUNET_htobe16(x) __bswap_16 (x)
# define GNUNET_htole16(x) (x) # define GNUNET_htole16(x) (x)
# define GNUNET_be16toh(x) __bswap_16 (x) # define GNUNET_be16toh(x) __bswap_16 (x)
# define GNUNET_le16toh(x) (x) # define GNUNET_le16toh(x) (x)
# define GNUNET_htobe32(x) __bswap_32 (x) # define GNUNET_htobe32(x) __bswap_32 (x)
skipping to change at line 236 skipping to change at line 248
*/ */
uint16_t size GNUNET_PACKED; uint16_t size GNUNET_PACKED;
/** /**
* The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian form at. * The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian form at.
*/ */
uint16_t type GNUNET_PACKED; uint16_t type GNUNET_PACKED;
}; };
/**
* @brief A SHA-512 hashcode
*/
struct GNUNET_HashCode
{
uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
};
/**
* @brief A SHA-256 hashcode
*/
struct GNUNET_CRYPTO_ShortHashCode
{
uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
};
/**
* The identity of the host (basically the SHA-512 hashcode of
* it's public key).
*/
struct GNUNET_PeerIdentity
{
struct GNUNET_HashCode hashPubKey;
};
GNUNET_NETWORK_STRUCT_END GNUNET_NETWORK_STRUCT_END
/** /**
* Function called with a filename. * Function called with a filename.
* *
* @param cls closure * @param cls closure
* @param filename complete filename (absolute path) * @param filename complete filename (absolute path)
* @return GNUNET_OK to continue to iterate, * @return #GNUNET_OK to continue to iterate,
* GNUNET_SYSERR to abort iteration with error! * #GNUNET_NO to stop iteration with no error,
* #GNUNET_SYSERR to abort iteration with error!
*/ */
typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename); typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
/* ****************************** logging ***************************** */ /* ****************************** logging ***************************** */
/** /**
* @ingroup logging
* Types of errors. * Types of errors.
*/ */
enum GNUNET_ErrorType enum GNUNET_ErrorType
{ {
GNUNET_ERROR_TYPE_UNSPECIFIED = -1, GNUNET_ERROR_TYPE_UNSPECIFIED = -1,
GNUNET_ERROR_TYPE_NONE = 0, GNUNET_ERROR_TYPE_NONE = 0,
GNUNET_ERROR_TYPE_ERROR = 1, GNUNET_ERROR_TYPE_ERROR = 1,
GNUNET_ERROR_TYPE_WARNING = 2, GNUNET_ERROR_TYPE_WARNING = 2,
GNUNET_ERROR_TYPE_INFO = 4, GNUNET_ERROR_TYPE_INFO = 4,
GNUNET_ERROR_TYPE_DEBUG = 8, GNUNET_ERROR_TYPE_DEBUG = 8,
GNUNET_ERROR_TYPE_INVALID = 16, GNUNET_ERROR_TYPE_INVALID = 16,
GNUNET_ERROR_TYPE_BULK = 32 GNUNET_ERROR_TYPE_BULK = 32
}; };
/** /**
* @ingroup logging
* User-defined handler for log messages. * User-defined handler for log messages.
* *
* @param cls closure * @param cls closure
* @param kind severeity * @param kind severeity
* @param component what component is issuing the message? * @param component what component is issuing the message?
* @param date when was the message logged? * @param date when was the message logged?
* @param message what is the message * @param message what is the message
*/ */
typedef void (*GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind, typedef void (*GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind,
const char *component, const char *date, const char *component, const char *date,
const char *message); const char *message);
/** /**
* @ingroup logging
* Get the number of log calls that are going to be skipped * Get the number of log calls that are going to be skipped
* *
* @return number of log calls to be ignored * @return number of log calls to be ignored
*/ */
int int
GNUNET_get_log_skip (); GNUNET_get_log_skip ();
#if !defined(GNUNET_CULL_LOGGING) #if !defined(GNUNET_CULL_LOGGING)
int int
GNUNET_get_log_call_status (int caller_level, const char *comp, GNUNET_get_log_call_status (int caller_level,
const char *file, const char *function, int lin const char *comp,
e); const char *file,
const char *function, int line);
#endif #endif
/** /**
* @ingroup logging
* Main log function. * Main log function.
* *
* @param kind how serious is the error? * @param kind how serious is the error?
* @param message what is the message (format string) * @param message what is the message (format string)
* @param ... arguments for format string * @param ... arguments for format string
*/ */
void void
GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...); GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...);
/* from glib */ /* from glib */
skipping to change at line 349 skipping to change at line 344
#else #else
#define GN_LIKELY(expr) (expr) #define GN_LIKELY(expr) (expr)
#define GN_UNLIKELY(expr) (expr) #define GN_UNLIKELY(expr) (expr)
#endif #endif
#if !defined(GNUNET_LOG_CALL_STATUS) #if !defined(GNUNET_LOG_CALL_STATUS)
#define GNUNET_LOG_CALL_STATUS -1 #define GNUNET_LOG_CALL_STATUS -1
#endif #endif
/** /**
* @ingroup logging
* Log function that specifies an alternative component. * Log function that specifies an alternative component.
* This function should be used by plugins. * This function should be used by plugins.
* *
* @param kind how serious is the error? * @param kind how serious is the error?
* @param comp component responsible for generating the message * @param comp component responsible for generating the message
* @param message what is the message (format string) * @param message what is the message (format string)
* @param ... arguments for format string * @param ... arguments for format string
*/ */
void void
GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp, GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
skipping to change at line 393 skipping to change at line 389
GNUNET_log_nocheck ((kind), __VA_ARGS__); \ GNUNET_log_nocheck ((kind), __VA_ARGS__); \
}\ }\
}\ }\
} while (0) } while (0)
#else #else
#define GNUNET_log(...) #define GNUNET_log(...)
#define GNUNET_log_from(...) #define GNUNET_log_from(...)
#endif #endif
/** /**
* @ingroup logging
* Log error message about missing configuration option. * Log error message about missing configuration option.
* *
* @param kind log level * @param kind log level
* @param section section with missing option * @param section section with missing option
* @param option name of missing option * @param option name of missing option
*/ */
void void
GNUNET_log_config_missing (enum GNUNET_ErrorType kind, GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
const char *section, const char *section,
const char *option); const char *option);
/** /**
* @ingroup logging
* Log error message about invalid configuration option value. * Log error message about invalid configuration option value.
* *
* @param kind log level * @param kind log level
* @param section section with invalid option * @param section section with invalid option
* @param option name of invalid option * @param option name of invalid option
* @param required what is required that is invalid about the option * @param required what is required that is invalid about the option
*/ */
void void
GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
const char *section, const char *section,
const char *option, const char *option,
const char *required); const char *required);
/** /**
* @ingroup logging
* Abort the process, generate a core dump if possible. * Abort the process, generate a core dump if possible.
*/ */
void void
GNUNET_abort (void) GNUNET_NORETURN; GNUNET_abort (void) GNUNET_NORETURN;
/** /**
* Ignore the next n calls to the log function. * @ingroup logging
* Ignore the next @a n calls to the log function.
* *
* @param n number of log calls to ignore (could be negative) * @param n number of log calls to ignore (could be negative)
* @param check_reset GNUNET_YES to assert that the log skip counter is cur rently zero * @param check_reset GNUNET_YES to assert that the log skip counter is cur rently zero
*/ */
void void
GNUNET_log_skip (int n, int check_reset); GNUNET_log_skip (int n, int check_reset);
/** /**
* @ingroup logging
* Setup logging. * Setup logging.
* *
* @param comp default component to use * @param comp default component to use
* @param loglevel what types of messages should be logged * @param loglevel what types of messages should be logged
* @param logfile change logging to logfile (use NULL to keep stderr) * @param logfile change logging to logfile (use NULL to keep stderr)
* @return GNUNET_OK on success, GNUNET_SYSERR if logfile could not be open ed * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be op ened
*/ */
int int
GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfi le); GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfi le);
/** /**
* @ingroup logging
* Add a custom logger. * Add a custom logger.
* *
* @param logger log function * @param logger log function
* @param logger_cls closure for logger * @param logger_cls closure for @a logger
*/ */
void void
GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
/** /**
* @ingroup logging
* Remove a custom logger. * Remove a custom logger.
* *
* @param logger log function * @param logger log function
* @param logger_cls closure for logger * @param logger_cls closure for logger
*/ */
void void
GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls); GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
/** /**
* Convert a short hash value to a string (for printing debug messages). * @ingroup logging
* This is one of the very few calls in the entire API that is
* NOT reentrant!
*
* @param hc the short hash code
* @return string
*/
const char *
GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc);
/**
* Convert a short hash value to a string (for printing debug messages).
* This prints all 104 characters of a hashcode!
* This is one of the very few calls in the entire API that is
* NOT reentrant!
*
* @param hc the short hash code
* @return string
*/
const char *
GNUNET_short_h2s_full (const struct GNUNET_CRYPTO_ShortHashCode * hc);
/**
* Convert a hash value to a string (for printing debug messages). * Convert a hash value to a string (for printing debug messages).
* This is one of the very few calls in the entire API that is * This is one of the very few calls in the entire API that is
* NOT reentrant! * NOT reentrant!
* *
* @param hc the hash code * @param hc the hash code
* @return string * @return string
*/ */
const char * const char *
GNUNET_h2s (const struct GNUNET_HashCode * hc); GNUNET_h2s (const struct GNUNET_HashCode * hc);
/** /**
* @ingroup logging
* Convert a hash value to a string (for printing debug messages). * Convert a hash value to a string (for printing debug messages).
* This prints all 104 characters of a hashcode! * This prints all 104 characters of a hashcode!
* This is one of the very few calls in the entire API that is * This is one of the very few calls in the entire API that is
* NOT reentrant! * NOT reentrant!
* *
* @param hc the hash code * @param hc the hash code
* @return string * @return string
*/ */
const char * const char *
GNUNET_h2s_full (const struct GNUNET_HashCode * hc); GNUNET_h2s_full (const struct GNUNET_HashCode * hc);
/** /**
* @ingroup logging
* Convert a peer identity to a string (for printing debug messages). * Convert a peer identity to a string (for printing debug messages).
* This is one of the very few calls in the entire API that is * This is one of the very few calls in the entire API that is
* NOT reentrant! * NOT reentrant!
* *
* @param pid the peer identity * @param pid the peer identity
* @return string form of the pid; will be overwritten by next * @return string form of the pid; will be overwritten by next
* call to GNUNET_i2s. * call to #GNUNET_i2s.
*/ */
const char * const char *
GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
/** /**
* @ingroup logging
* Convert a peer identity to a string (for printing debug messages). * Convert a peer identity to a string (for printing debug messages).
* This is one of the very few calls in the entire API that is * This is one of the very few calls in the entire API that is
* NOT reentrant! * NOT reentrant!
* *
* @param pid the peer identity * @param pid the peer identity
* @return string form of the pid; will be overwritten by next * @return string form of the pid; will be overwritten by next
* call to GNUNET_i2s. * call to #GNUNET_i2s.
*/ */
const char * const char *
GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid);
/** /**
* @ingroup logging
* Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string * Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string
* (for printing debug messages). This is one of the very few calls * (for printing debug messages). This is one of the very few calls
* in the entire API that is NOT reentrant! * in the entire API that is NOT reentrant!
* *
* @param addr the address * @param addr the address
* @param addrlen the length of the address * @param addrlen the length of the address
* @return nicely formatted string for the address * @return nicely formatted string for the address
* will be overwritten by next call to GNUNET_a2s. * will be overwritten by next call to GNUNET_a2s.
*/ */
const char * const char *
GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
/** /**
* @ingroup logging
* Convert error type to string. * Convert error type to string.
* *
* @param kind type to convert * @param kind type to convert
* @return string corresponding to the type * @return string corresponding to the type
*/ */
const char * const char *
GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
/** /**
* @ingroup logging
* Use this for fatal errors that cannot be handled * Use this for fatal errors that cannot be handled
*/ */
#define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TY PE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); GNUNET_ab ort(); } } while(0) #define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TY PE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); GNUNET_ab ort(); } } while(0)
/** /**
* @ingroup logging
* Use this for fatal errors that cannot be handled * Use this for fatal errors that cannot be handled
*/ */
#define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET _ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); GNUNET_abort() ; } } while(0) #define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET _ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); GNUNET_abort() ; } } while(0)
/** /**
* @ingroup logging
* Use this for internal assertion violations that are * Use this for internal assertion violations that are
* not fatal (can be handled) but should not occur. * not fatal (can be handled) but should not occur.
*/ */
#define GNUNET_break(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TY PE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); } } while (0) #define GNUNET_break(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TY PE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); } } while (0)
/** /**
* @ingroup logging
* Use this for assertion violations caused by other * Use this for assertion violations caused by other
* peers (i.e. protocol violations). We do not want to * peers (i.e. protocol violations). We do not want to
* confuse end-users (say, some other peer runs an * confuse end-users (say, some other peer runs an
* older, broken or incompatible GNUnet version), but * older, broken or incompatible GNUnet version), but
* we still want to see these problems during * we still want to see these problems during
* development and testing. "OP == other peer". * development and testing. "OP == other peer".
*/ */
#define GNUNET_break_op(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR _TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("External protocol violation dete cted at %s:%d.\n"), __FILE__, __LINE__); } } while(0) #define GNUNET_break_op(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR _TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("External protocol violation dete cted at %s:%d.\n"), __FILE__, __LINE__); } } while(0)
/** /**
* @ingroup logging
* Log an error message at log-level 'level' that indicates * Log an error message at log-level 'level' that indicates
* a failure of the command 'cmd' with the message given * a failure of the command 'cmd' with the message given
* by strerror(errno). * by strerror(errno).
*/ */
#define GNUNET_log_strerror(level, cmd) do { GNUNET_log(level, _("`%s' fail ed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0) #define GNUNET_log_strerror(level, cmd) do { GNUNET_log(level, _("`%s' fail ed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0)
/** /**
* @ingroup logging
* Log an error message at log-level 'level' that indicates * Log an error message at log-level 'level' that indicates
* a failure of the command 'cmd' with the message given * a failure of the command 'cmd' with the message given
* by strerror(errno). * by strerror(errno).
*/ */
#define GNUNET_log_from_strerror(level, component, cmd) do { GNUNET_log_fro m (level, component, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FIL E__, __LINE__, STRERROR(errno)); } while(0) #define GNUNET_log_from_strerror(level, component, cmd) do { GNUNET_log_fro m (level, component, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FIL E__, __LINE__, STRERROR(errno)); } while(0)
/** /**
* @ingroup logging
* Log an error message at log-level 'level' that indicates * Log an error message at log-level 'level' that indicates
* a failure of the command 'cmd' with the message given * a failure of the command 'cmd' with the message given
* by strerror(errno). * by strerror(errno).
*/ */
#define GNUNET_log_strerror_file(level, cmd, filename) do { GNUNET_log(leve l, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename,_ _FILE__, __LINE__, STRERROR(errno)); } while(0) #define GNUNET_log_strerror_file(level, cmd, filename) do { GNUNET_log(leve l, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename,_ _FILE__, __LINE__, STRERROR(errno)); } while(0)
/** /**
* @ingroup logging
* Log an error message at log-level 'level' that indicates * Log an error message at log-level 'level' that indicates
* a failure of the command 'cmd' with the message given * a failure of the command 'cmd' with the message given
* by strerror(errno). * by strerror(errno).
*/ */
#define GNUNET_log_from_strerror_file(level, component, cmd, filename) do { GNUNET_log_from (level, component, _("`%s' failed on file `%s' at %s:%d wi th error: %s\n"), cmd, filename,__FILE__, __LINE__, STRERROR(errno)); } whi le(0) #define GNUNET_log_from_strerror_file(level, component, cmd, filename) do { GNUNET_log_from (level, component, _("`%s' failed on file `%s' at %s:%d wi th error: %s\n"), cmd, filename,__FILE__, __LINE__, STRERROR(errno)); } whi le(0)
/* ************************* endianess conversion ****************** */ /* ************************* endianess conversion ****************** */
/** /**
* Convert unsigned 64-bit integer to host-byte-order. * Convert unsigned 64-bit integer to host-byte-order.
skipping to change at line 645 skipping to change at line 639
* Convert double to host-byte-order * Convert double to host-byte-order
* @param d the value in network byte order * @param d the value in network byte order
* @return the same value in host byte order * @return the same value in host byte order
*/ */
double double
GNUNET_ntoh_double (double d); GNUNET_ntoh_double (double d);
/* ************************* allocation functions ****************** */ /* ************************* allocation functions ****************** */
/** /**
* @ingroup memory
* Maximum allocation with GNUNET_malloc macro. * Maximum allocation with GNUNET_malloc macro.
*/ */
#define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40) #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40)
/** /**
* @ingroup memory
* Allocate a struct or union of the given @a type.
* Wrapper around #GNUNET_malloc that returns a pointer
* to the newly created object of the correct type.
*
* @param type name of the struct or union, i.e. pass 'struct Foo'.
*/
#define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type))
/**
* @ingroup memory
* Wrapper around malloc. Allocates size bytes of memory. * Wrapper around malloc. Allocates size bytes of memory.
* The memory will be zero'ed out. * The memory will be zero'ed out.
* *
* @param size the number of bytes to allocate, must be * @param size the number of bytes to allocate, must be
* smaller than 40 MB. * smaller than 40 MB.
* @return pointer to size bytes of memory, never NULL (!) * @return pointer to size bytes of memory, never NULL (!)
*/ */
#define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__) #define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__)
/** /**
* @ingroup memory
* Allocate and initialize a block of memory. * Allocate and initialize a block of memory.
* *
* @param buf data to initalize the block with * @param buf data to initalize the block with
* @param size the number of bytes in buf (and size of the allocation) * @param size the number of bytes in buf (and size of the allocation)
* @return pointer to size bytes of memory, never NULL (!) * @return pointer to size bytes of memory, never NULL (!)
*/ */
#define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE __) #define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE __)
/** /**
* @ingroup memory
* Wrapper around malloc. Allocates size bytes of memory. * Wrapper around malloc. Allocates size bytes of memory.
* The memory will be zero'ed out. * The memory will be zero'ed out.
* *
* @param size the number of bytes to allocate * @param size the number of bytes to allocate
* @return pointer to size bytes of memory, NULL if we do not have enough m emory * @return pointer to size bytes of memory, NULL if we do not have enough m emory
*/ */
#define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__) #define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__)
/** /**
* @ingroup memory
* Wrapper around realloc. Rellocates size bytes of memory. * Wrapper around realloc. Rellocates size bytes of memory.
* *
* @param ptr the pointer to reallocate * @param ptr the pointer to reallocate
* @param size the number of bytes to reallocate * @param size the number of bytes to reallocate
* @return pointer to size bytes of memory * @return pointer to size bytes of memory
*/ */
#define GNUNET_realloc(ptr, size) GNUNET_xrealloc_(ptr, size, __FILE__, __L INE__) #define GNUNET_realloc(ptr, size) GNUNET_xrealloc_(ptr, size, __FILE__, __L INE__)
/** /**
* @ingroup memory
* Wrapper around free. Frees the memory referred to by ptr. * Wrapper around free. Frees the memory referred to by ptr.
* Note that is is generally better to free memory that was * Note that is is generally better to free memory that was
* allocated with GNUNET_array_grow using GNUNET_array_grow(mem, size, 0) i nstead of GNUNET_free. * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free.
* *
* @param ptr location where to free the memory. ptr must have * @param ptr location where to free the memory. ptr must have
* been returned by GNUNET_strdup, GNUNET_strndup, GNUNET_malloc or GNU NET_array_grow earlier. * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier.
*/ */
#define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) #define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__)
/** /**
* @ingroup memory
* Free the memory pointed to by ptr if ptr is not NULL. * Free the memory pointed to by ptr if ptr is not NULL.
* Equivalent to if (ptr!=null)GNUNET_free(ptr). * Equivalent to `if (NULL != ptr) GNUNET_free(ptr)`.
* *
* @param ptr the location in memory to free * @param ptr the location in memory to free
*/ */
#define GNUNET_free_non_null(ptr) do { void * __x__ = ptr; if (__x__ != NUL L) { GNUNET_free(__x__); } } while(0) #define GNUNET_free_non_null(ptr) do { void * __x__ = ptr; if (__x__ != NUL L) { GNUNET_free(__x__); } } while(0)
/** /**
* Wrapper around GNUNET_strdup. Makes a copy of the zero-terminated strin * @ingroup memory
g * Wrapper around #GNUNET_xstrdup_. Makes a copy of the zero-terminated st
ring
* pointed to by a. * pointed to by a.
* *
* @param a pointer to a zero-terminated string * @param a pointer to a zero-terminated string
* @return a copy of the string including zero-termination * @return a copy of the string including zero-termination
*/ */
#define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__) #define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__)
/** /**
* Wrapper around GNUNET_strndup. Makes a partial copy of the string * @ingroup memory
* Wrapper around #GNUNET_xstrndup_. Makes a partial copy of the string
* pointed to by a. * pointed to by a.
* *
* @param a pointer to a string * @param a pointer to a string
* @param length of the string to duplicate * @param length of the string to duplicate
* @return a partial copy of the string including zero-termination * @return a partial copy of the string including zero-termination
*/ */
#define GNUNET_strndup(a,length) GNUNET_xstrndup_(a,length,__FILE__,__LINE_ _) #define GNUNET_strndup(a,length) GNUNET_xstrndup_(a,length,__FILE__,__LINE_ _)
/** /**
* @ingroup memory
* Grow a well-typed (!) array. This is a convenience * Grow a well-typed (!) array. This is a convenience
* method to grow a vector <tt>arr</tt> of size <tt>size</tt> * method to grow a vector @a arr of size @a size
* to the new (target) size <tt>tsize</tt>. * to the new (target) size @a tsize.
* <p> * <p>
* *
* Example (simple, well-typed stack): * Example (simple, well-typed stack):
* *
* <pre> * <pre>
* static struct foo * myVector = NULL; * static struct foo * myVector = NULL;
* static int myVecLen = 0; * static int myVecLen = 0;
* *
* static void push(struct foo * elem) { * static void push(struct foo * elem) {
* GNUNET_array_grow(myVector, myVecLen, myVecLen+1); * GNUNET_array_grow(myVector, myVecLen, myVecLen+1);
skipping to change at line 759 skipping to change at line 773
* arr is important since size is the number of elements and * arr is important since size is the number of elements and
* not the size in bytes * not the size in bytes
* @param size the number of elements in the existing vector (number * @param size the number of elements in the existing vector (number
* of elements to copy over) * of elements to copy over)
* @param tsize the target size for the resulting vector, use 0 to * @param tsize the target size for the resulting vector, use 0 to
* free the vector (then, arr will be NULL afterwards). * free the vector (then, arr will be NULL afterwards).
*/ */
#define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&arr, sizeo f(arr[0]), &size, tsize, __FILE__, __LINE__) #define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&arr, sizeo f(arr[0]), &size, tsize, __FILE__, __LINE__)
/** /**
* @ingroup memory
* Append an element to a list (growing the * Append an element to a list (growing the
* list by one). * list by one).
*/ */
#define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,si ze,size+1); arr[size-1] = element; } while(0) #define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,si ze,size+1); arr[size-1] = element; } while(0)
/** /**
* @ingroup memory
* Like snprintf, just aborts if the buffer is of insufficient size. * Like snprintf, just aborts if the buffer is of insufficient size.
* *
* @param buf pointer to buffer that is written to * @param buf pointer to buffer that is written to
* @param size number of bytes in buf * @param size number of bytes in @a buf
* @param format format strings * @param format format strings
* @param ... data for format string * @param ... data for format string
* @return number of bytes written to buf or negative value on error * @return number of bytes written to buf or negative value on error
*/ */
int int
GNUNET_snprintf (char *buf, size_t size, const char *format, ...); GNUNET_snprintf (char *buf, size_t size, const char *format, ...);
/** /**
* @ingroup memory
* Like asprintf, just portable. * Like asprintf, just portable.
* *
* @param buf set to a buffer of sufficient size (allocated, caller must fr ee) * @param buf set to a buffer of sufficient size (allocated, caller must fr ee)
* @param format format string (see printf, fprintf, etc.) * @param format format string (see printf, fprintf, etc.)
* @param ... data for format string * @param ... data for format string
* @return number of bytes in "*buf" excluding 0-termination * @return number of bytes in "*buf" excluding 0-termination
*/ */
int int
GNUNET_asprintf (char **buf, const char *format, ...); GNUNET_asprintf (char **buf, const char *format, ...);
/* ************** internal implementations, use macros above! ************* * */ /* ************** internal implementations, use macros above! ************* * */
/** /**
* Allocate memory. Checks the return value, aborts if no more * Allocate memory. Checks the return value, aborts if no more
* memory is available. Don't use GNUNET_xmalloc_ directly. Use the * memory is available. Don't use GNUNET_xmalloc_ directly. Use the
* GNUNET_malloc macro. * #GNUNET_malloc macro.
* The memory will be zero'ed out. * The memory will be zero'ed out.
* *
* @param size number of bytes to allocate * @param size number of bytes to allocate
* @param filename where is this call being made (for debugging) * @param filename where is this call being made (for debugging)
* @param linenumber line where this call is being made (for debugging) * @param linenumber line where this call is being made (for debugging)
* @return allocated memory, never NULL * @return allocated memory, never NULL
*/ */
void * void *
GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
/** /**
* Allocate and initialize memory. Checks the return value, aborts if no mo re * Allocate and initialize memory. Checks the return value, aborts if no mo re
* memory is available. Don't use GNUNET_xmemdup_ directly. Use the * memory is available. Don't use GNUNET_xmemdup_ directly. Use the
* GNUNET_memdup macro. * #GNUNET_memdup macro.
* *
* @param buf buffer to initialize from (must contain size bytes) * @param buf buffer to initialize from (must contain size bytes)
* @param size number of bytes to allocate * @param size number of bytes to allocate
* @param filename where is this call being made (for debugging) * @param filename where is this call being made (for debugging)
* @param linenumber line where this call is being made (for debugging) * @param linenumber line where this call is being made (for debugging)
* @return allocated memory, never NULL * @return allocated memory, never NULL
*/ */
void * void *
GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename, GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
int linenumber); int linenumber);
/** /**
* Allocate memory. This function does not check if the allocation * Allocate memory. This function does not check if the allocation
* request is within reasonable bounds, allowing allocations larger * request is within reasonable bounds, allowing allocations larger
* than 40 MB. If you don't expect the possibility of very large * than 40 MB. If you don't expect the possibility of very large
* allocations, use GNUNET_malloc instead. The memory will be zero'ed * allocations, use #GNUNET_malloc instead. The memory will be zero'ed
* out. * out.
* *
* @param size number of bytes to allocate * @param size number of bytes to allocate
* @param filename where is this call being made (for debugging) * @param filename where is this call being made (for debugging)
* @param linenumber line where this call is being made (for debugging) * @param linenumber line where this call is being made (for debugging)
* @return pointer to size bytes of memory, NULL if we do not have enough m emory * @return pointer to size bytes of memory, NULL if we do not have enough m emory
*/ */
void * void *
GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumbe r); GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumbe r);
/** /**
* Reallocate memory. Checks the return value, aborts if no more * Reallocate memory. Checks the return value, aborts if no more
* memory is available. * memory is available.
*/ */
void * void *
GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber ); GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber );
/** /**
* Free memory. Merely a wrapper for the case that we * Free memory. Merely a wrapper for the case that we
* want to keep track of allocations. Don't use GNUNET_xfree_ * want to keep track of allocations. Don't use GNUNET_xfree_
* directly. Use the GNUNET_free macro. * directly. Use the #GNUNET_free macro.
* *
* @param ptr pointer to memory to free * @param ptr pointer to memory to free
* @param filename where is this call being made (for debugging) * @param filename where is this call being made (for debugging)
* @param linenumber line where this call is being made (for debugging) * @param linenumber line where this call is being made (for debugging)
*/ */
void void
GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); GNUNET_xfree_ (void *ptr, const char *filename, int linenumber);
/** /**
* Dup a string. Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup macro. * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the #GNUNET_strdu p macro.
* @param str string to duplicate * @param str string to duplicate
* @param filename where is this call being made (for debugging) * @param filename where is this call being made (for debugging)
* @param linenumber line where this call is being made (for debugging) * @param linenumber line where this call is being made (for debugging)
* @return the duplicated string * @return the duplicated string
*/ */
char * char *
GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
/** /**
* Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the GN UNET_strndup macro. * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #G NUNET_strndup macro.
* *
* @param str string to duplicate * @param str string to duplicate
* @param len length of the string to duplicate * @param len length of the string to duplicate
* @param filename where is this call being made (for debugging) * @param filename where is this call being made (for debugging)
* @param linenumber line where this call is being made (for debugging) * @param linenumber line where this call is being made (for debugging)
* @return the duplicated string * @return the duplicated string
*/ */
char * char *
GNUNET_xstrndup_ (const char *str, size_t len, const char *filename, GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
int linenumber); int linenumber);
/** /**
* Grow an array, the new elements are zeroed out. * Grow an array, the new elements are zeroed out.
* Grows old by (*oldCount-newCount)*elementSize * Grows old by (*oldCount-newCount)*elementSize
* bytes and sets *oldCount to newCount. * bytes and sets *oldCount to newCount.
* *
* Don't call GNUNET_xgrow_ directly. Use the GNUNET_array_grow macro. * Don't call GNUNET_xgrow_ directly. Use the #GNUNET_array_grow macro.
* *
* @param old address of the pointer to the array * @param old address of the pointer to the array
* *old may be NULL * *old may be NULL
* @param elementSize the size of the elements of the array * @param elementSize the size of the elements of the array
* @param oldCount address of the number of elements in the *old array * @param oldCount address of the number of elements in the *old array
* @param newCount number of elements in the new array, may be 0 (then *old will be NULL afterwards) * @param newCount number of elements in the new array, may be 0 (then *old will be NULL afterwards)
* @param filename where is this call being made (for debugging) * @param filename where is this call being made (for debugging)
* @param linenumber line where this call is being made (for debugging) * @param linenumber line where this call is being made (for debugging)
*/ */
void void
GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
unsigned int newCount, const char *filename, int linenumber) ; unsigned int newCount, const char *filename, int linenumber) ;
/** /**
* @ingroup memory
* Create a copy of the given message. * Create a copy of the given message.
* *
* @param msg message to copy * @param msg message to copy
* @return duplicate of the message * @return duplicate of the message
*/ */
struct GNUNET_MessageHeader * struct GNUNET_MessageHeader *
GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); GNUNET_copy_message (const struct GNUNET_MessageHeader *msg);
#if __STDC_VERSION__ < 199901L #if __STDC_VERSION__ < 199901L
#if __GNUC__ >= 2 #if __GNUC__ >= 2
 End of changes. 65 change blocks. 
81 lines changed or deleted 98 lines changed or added


 gnunet_config.h   gnunet_config.h 
skipping to change at line 22 skipping to change at line 22
/* This is an Apple Darwin system */ /* This is an Apple Darwin system */
/* #undef DARWIN */ /* #undef DARWIN */
/* enable expensive heap statistics */ /* enable expensive heap statistics */
#define ENABLE_HEAP_STATISTICS 0 #define ENABLE_HEAP_STATISTICS 0
/* Define to 1 if translation of program messages to the user's native /* Define to 1 if translation of program messages to the user's native
language is requested. */ language is requested. */
#define ENABLE_NLS 1 #define ENABLE_NLS 1
/* have NSE send timestamp information to testbed logger */
#define ENABLE_NSE_HISTOGRAM 0
/* 1 if freed memory should be poisoned, 0 otherwise */ /* 1 if freed memory should be poisoned, 0 otherwise */
#define ENABLE_POISONING 0 #define ENABLE_POISONING 0
/* Build with support for SuperMUC */
#define ENABLE_SUPERMUC 0
/* enable workarounds used on Windows (only useful for test cases) */ /* enable workarounds used on Windows (only useful for test cases) */
#define ENABLE_WINDOWS_WORKAROUNDS 0 #define ENABLE_WINDOWS_WORKAROUNDS 0
/* Build a Mac OS X Framework */ /* Build a Mac OS X Framework */
/* #undef FRAMEWORK_BUILD */ /* #undef FRAMEWORK_BUILD */
/* This is a FreeBSD system */ /* This is a FreeBSD system */
/* #undef FREEBSD */ /* #undef FREEBSD */
/* This is a GNU system */ /* This is a GNU system */
skipping to change at line 48 skipping to change at line 54
/* #undef GNUNET_CULL_LOGGING */ /* #undef GNUNET_CULL_LOGGING */
/* This should be the default choice for the name of the first network /* This should be the default choice for the name of the first network
interface */ interface */
#define GNUNET_DEFAULT_INTERFACE "eth0" #define GNUNET_DEFAULT_INTERFACE "eth0"
/* 1 if extra logging is enabled, 2 for very verbose extra logging, 0 /* 1 if extra logging is enabled, 2 for very verbose extra logging, 0
otherwise */ otherwise */
#define GNUNET_EXTRA_LOGGING GNUNET_NO #define GNUNET_EXTRA_LOGGING GNUNET_NO
/* Define to 1 if you have the `argz_add' function. */
#define HAVE_ARGZ_ADD 1
/* Define to 1 if you have the `argz_append' function. */
#define HAVE_ARGZ_APPEND 1
/* Define to 1 if you have the `argz_count' function. */
#define HAVE_ARGZ_COUNT 1
/* Define to 1 if you have the `argz_create_sep' function. */
#define HAVE_ARGZ_CREATE_SEP 1
/* Define to 1 if you have the <argz.h> header file. */ /* Define to 1 if you have the <argz.h> header file. */
#define HAVE_ARGZ_H 1 #define HAVE_ARGZ_H 1
/* Define to 1 if you have the `argz_insert' function. */
#define HAVE_ARGZ_INSERT 1
/* Define to 1 if you have the `argz_next' function. */
#define HAVE_ARGZ_NEXT 1
/* Define to 1 if you have the `argz_stringify' function. */
#define HAVE_ARGZ_STRINGIFY 1
/* Define to 1 if you have the <arpa/inet.h> header file. */ /* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1 #define HAVE_ARPA_INET_H 1
/* Define to 1 if you have the `atoll' function. */ /* Define to 1 if you have the `atoll' function. */
#define HAVE_ATOLL 1 #define HAVE_ATOLL 1
/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the /* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
CoreFoundation framework. */ CoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYCURRENT */ /* #undef HAVE_CFLOCALECOPYCURRENT */
/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue i n /* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue i n
the CoreFoundation framework. */ the CoreFoundation framework. */
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ /* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
/* Define to 1 if your system has a working `chown' function. */ /* Define to 1 if your system has a working `chown' function. */
#define HAVE_CHOWN 1 #define HAVE_CHOWN 1
/* Define to 1 if you have the `closedir' function. */
#define HAVE_CLOSEDIR 1
/* Define to 1 if you have the <ctype.h> header file. */ /* Define to 1 if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1 #define HAVE_CTYPE_H 1
/* Define if the GNU dcgettext() function is already present or preinstalle d. /* Define if the GNU dcgettext() function is already present or preinstalle d.
*/ */
#define HAVE_DCGETTEXT 1 #define HAVE_DCGETTEXT 1
/* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 /* Define to 1 if you have the declaration of `gcry_mpi_set_opaque_copy', a
if nd
you don't. */ to 0 if you don't. */
/* #undef HAVE_DECL_CYGWIN_CONV_PATH */ #define HAVE_DECL_GCRY_MPI_SET_OPAQUE_COPY 1
/* Define to 1 if you have the declaration of `gcry_mpi_lshift', and to 0 i /* Define to 1 if you have the declaration of `_stati64', and to 0 if you
f don't. */
you don't. */ #define HAVE_DECL__STATI64 0
#define HAVE_DECL_GCRY_MPI_LSHIFT 1
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR' . /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR' .
*/ */
#define HAVE_DIRENT_H 1 #define HAVE_DIRENT_H 1
/* Define if you have the GNU dld library. */
/* #undef HAVE_DLD */
/* Define to 1 if you have the <dld.h> header file. */
/* #undef HAVE_DLD_H */
/* Define to 1 if you have the `dlerror' function. */
#define HAVE_DLERROR 1
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1 #define HAVE_DLFCN_H 1
/* Define to 1 if you have the <dl.h> header file. */
/* #undef HAVE_DL_H */
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */ /* #undef HAVE_DOPRNT */
/* Define if you have the _dyld_func_lookup function. */
/* #undef HAVE_DYLD */
/* Define to 1 if you have the <endian.h> header file. */ /* Define to 1 if you have the <endian.h> header file. */
#define HAVE_ENDIAN_H 1 #define HAVE_ENDIAN_H 1
/* Define to 1 if you have the <errno.h> header file. */ /* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1 #define HAVE_ERRNO_H 1
/* Define to 1 if the system has the type `error_t'. */
#define HAVE_ERROR_T 1
/* Define to 1 if you have the <execinfo.h> header file. */ /* Define to 1 if you have the <execinfo.h> header file. */
#define HAVE_EXECINFO_H 1 #define HAVE_EXECINFO_H 1
/* Define to 1 if you have the <extractor.h> header file. */ /* Define to 1 if you have the <extractor.h> header file. */
#define HAVE_EXTRACTOR_H 1 #define HAVE_EXTRACTOR_H 1
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1 #define HAVE_FCNTL_H 1
/* Define to 1 if you have the `fork' function. */ /* Define to 1 if you have the `fork' function. */
skipping to change at line 192 skipping to change at line 156
/* Define to 1 if you have the `getpeereid' function. */ /* Define to 1 if you have the `getpeereid' function. */
/* #undef HAVE_GETPEEREID */ /* #undef HAVE_GETPEEREID */
/* Define to 1 if you have the `getpeerucred' function. */ /* Define to 1 if you have the `getpeerucred' function. */
/* #undef HAVE_GETPEERUCRED */ /* #undef HAVE_GETPEERUCRED */
/* Define to 1 if you have the `getresgid' function. */ /* Define to 1 if you have the `getresgid' function. */
#define HAVE_GETRESGID 1 #define HAVE_GETRESGID 1
/* Define to 1 if you have the `getrlimit' function. */
#define HAVE_GETRLIMIT 1
/* Define to 1 if you have the `getrusage' function. */ /* Define to 1 if you have the `getrusage' function. */
#define HAVE_GETRUSAGE 1 #define HAVE_GETRUSAGE 1
/* Define if the GNU gettext() function is already present or preinstalled. */ /* Define if the GNU gettext() function is already present or preinstalled. */
#define HAVE_GETTEXT 1 #define HAVE_GETTEXT 1
/* Have glib2 */
#define HAVE_GLIB2 1
/* Define to 1 if you have the <glpk.h> header file. */ /* Define to 1 if you have the <glpk.h> header file. */
#define HAVE_GLPK_H 1 #define HAVE_GLPK_H 1
/* Define to 1 if `presolve' is a member of `glp_iocp'. */ /* Define to 1 if `presolve' is a member of `glp_iocp'. */
#define HAVE_GLP_IOCP_PRESOLVE 1 #define HAVE_GLP_IOCP_PRESOLVE 1
/* We have gnutls */ /* We have GnuTLS */
#define HAVE_GNUTLS true #define HAVE_GNUTLS true
/* Define to 1 if you have the <gnutls/abstract.h> header file. */ /* Define to 1 if you have the <gnutls/abstract.h> header file. */
#define HAVE_GNUTLS_ABSTRACT_H 1 #define HAVE_GNUTLS_ABSTRACT_H 1
/* We have GnuTLS with DANE support */
#define HAVE_GNUTLS_DANE 0
/* Define to 1 if you have the <gnutls/dane.h> header file. */
/* #undef HAVE_GNUTLS_DANE_H */
/* Define if you have the iconv() function. */ /* Define if you have the iconv() function. */
#define HAVE_ICONV 1 #define HAVE_ICONV 1
/* Define to 1 if you have the <ifaddrs.h> header file. */ /* Define to 1 if you have the <ifaddrs.h> header file. */
#define HAVE_IFADDRS_H 1 #define HAVE_IFADDRS_H 1
/* Define this if inet_ntoa() is available */ /* Define this if inet_ntoa() is available */
/* #undef HAVE_INET_NTOA */ /* #undef HAVE_INET_NTOA */
/* Define to 1 if you have the `initgroups' function. */ /* Define to 1 if you have the `initgroups' function. */
skipping to change at line 237 skipping to change at line 207
/* Define to 1 if you have the <kstat.h> header file. */ /* Define to 1 if you have the <kstat.h> header file. */
/* #undef HAVE_KSTAT_H */ /* #undef HAVE_KSTAT_H */
/* Define to 1 if you have the <kvm.h> header file. */ /* Define to 1 if you have the <kvm.h> header file. */
/* #undef HAVE_KVM_H */ /* #undef HAVE_KVM_H */
/* Define to 1 if you have the <langinfo.h> header file. */ /* Define to 1 if you have the <langinfo.h> header file. */
#define HAVE_LANGINFO_H 1 #define HAVE_LANGINFO_H 1
/* Have libcurl */ /* Have bluetooth library */
#define HAVE_LIBCURL 1 #define HAVE_LIBBLUETOOTH 1
/* Define if you have the libdl library or equivalent. */
#define HAVE_LIBDL 1
/* Define if libdlloader will be built on this platform */
#define HAVE_LIBDLLOADER 1
/* Have GLPK */ /* Have GLPK */
#define HAVE_LIBGLPK 1 #define HAVE_LIBGLPK 1
/* Have libgtop */ /* Have libgnurl */
#define HAVE_LIBGTOP 1 /* #undef HAVE_LIBGNURL */
/* Define to 1 if you have the `intl' library (-lintl). */ /* Define to 1 if you have the `intl' library (-lintl). */
/* #undef HAVE_LIBINTL */ /* #undef HAVE_LIBINTL */
/* Define to 1 if you have the <libintl.h> header file. */ /* Define to 1 if you have the <libintl.h> header file. */
#define HAVE_LIBINTL_H 1 #define HAVE_LIBINTL_H 1
/* Define to 1 if you have the `kstat' library (-lkstat). */ /* Define to 1 if you have the `kstat' library (-lkstat). */
/* #undef HAVE_LIBKSTAT */ /* #undef HAVE_LIBKSTAT */
skipping to change at line 279 skipping to change at line 243
/* Define to 1 if you have the `rt' library (-lrt). */ /* Define to 1 if you have the `rt' library (-lrt). */
/* #undef HAVE_LIBRT */ /* #undef HAVE_LIBRT */
/* Define to 1 if you have the `socket' library (-lsocket). */ /* Define to 1 if you have the `socket' library (-lsocket). */
/* #undef HAVE_LIBSOCKET */ /* #undef HAVE_LIBSOCKET */
/* Define if you have the unistring library. */ /* Define if you have the unistring library. */
#define HAVE_LIBUNISTRING 1 #define HAVE_LIBUNISTRING 1
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if you have the <limits.h> header file. */ /* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1 #define HAVE_LIMITS_H 1
/* Define to 1 if you have the <llapi.h> header file. */
/* #undef HAVE_LLAPI_H */
/* Define to 1 if you have the <locale.h> header file. */ /* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1 #define HAVE_LOCALE_H 1
/* Define this if a modern libltdl is already installed */ /* Define to 1 if you have the <ltdl.h> header file. */
#define HAVE_LTDL 1 #define HAVE_LTDL_H 1
/* Define to 1 if you have the <mach/mach.h> header file. */ /* Define to 1 if you have the <mach/mach.h> header file. */
/* #undef HAVE_MACH_MACH_H */ /* #undef HAVE_MACH_MACH_H */
/* Define to 1 if you have the <mach-o/dyld.h> header file. */
/* #undef HAVE_MACH_O_DYLD_H */
/* Define to 1 if you have the `mallinfo' function. */ /* Define to 1 if you have the `mallinfo' function. */
#define HAVE_MALLINFO 1 #define HAVE_MALLINFO 1
/* Define to 1 if you have the <malloc.h> header file. */ /* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1 #define HAVE_MALLOC_H 1
/* Define to 1 if you have the <malloc/malloc.h> header file. */ /* Define to 1 if you have the <malloc/malloc.h> header file. */
/* #undef HAVE_MALLOC_MALLOC_H */ /* #undef HAVE_MALLOC_MALLOC_H */
/* Define to 1 if you have the `malloc_size' function. */ /* Define to 1 if you have the `malloc_size' function. */
skipping to change at line 322 skipping to change at line 277
/* Define to 1 if you have the `malloc_usable_size' function. */ /* Define to 1 if you have the `malloc_usable_size' function. */
#define HAVE_MALLOC_USABLE_SIZE 1 #define HAVE_MALLOC_USABLE_SIZE 1
/* Define to 1 if you have the <math.h> header file. */ /* Define to 1 if you have the <math.h> header file. */
#define HAVE_MATH_H 1 #define HAVE_MATH_H 1
/* Define to 1 if you have the <memory.h> header file. */ /* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1 #define HAVE_MEMORY_H 1
/* We have libmicrohttpd */ /* We have libmicrohttpd */
#define HAVE_MHD 1 #define HAVE_MHD 0
/* Define to 1 if you have the <microhttpd.h> header file. */ /* Define to 1 if you have the <microhttpd.h> header file. */
#define HAVE_MICROHTTPD_H 1 #define HAVE_MICROHTTPD_H 1
/* Define to 1 if you have the `mremap' function. */ /* Define to 1 if you have the `mremap' function. */
#define HAVE_MREMAP 1 #define HAVE_MREMAP 1
/* Define to 1 if you have the <mysql/mysql.h> header file. */ /* Define to 1 if you have the <mysql/mysql.h> header file. */
#define HAVE_MYSQL_MYSQL_H 1 #define HAVE_MYSQL_MYSQL_H 1
skipping to change at line 345 skipping to change at line 300
/* Define to 1 if you have the <netdb.h> header file. */ /* Define to 1 if you have the <netdb.h> header file. */
#define HAVE_NETDB_H 1 #define HAVE_NETDB_H 1
/* Define to 1 if you have the <netinet/in.h> header file. */ /* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1 #define HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <netinet/in_systm.h> header file. */ /* Define to 1 if you have the <netinet/in_systm.h> header file. */
#define HAVE_NETINET_IN_SYSTM_H 1 #define HAVE_NETINET_IN_SYSTM_H 1
/* Define to 1 if you have the <netinet/ip.h> header file. */
#define HAVE_NETINET_IP_H 1
/* Define to 1 if you have the <nss.h> header file. */ /* Define to 1 if you have the <nss.h> header file. */
#define HAVE_NSS_H 1 #define HAVE_NSS_H 1
/* Define to 1 if the system has the type `off_t'. */ /* Define to 1 if the system has the type `off_t'. */
#define HAVE_OFF_T 1 #define HAVE_OFF_T 1
/* Define to 1 if you have the `opendir' function. */ /* Have libopus library */
#define HAVE_OPENDIR 1 #define HAVE_OPUS 1
/* Define to 1 if you have the <postgresql/libpq-fe.h> header file. */ /* Define to 1 if you have the <postgresql/libpq-fe.h> header file. */
/* #undef HAVE_POSTGRESQL_LIBPQ_FE_H */ /* #undef HAVE_POSTGRESQL_LIBPQ_FE_H */
/* Define if libtool can extract symbol lists from object files. */ /* Have libpulse(audio) library */
#define HAVE_PRELOADED_SYMBOLS 1 #define HAVE_PULSE 1
/* Define to 1 if you have the `readdir' function. */ /* Define to 1 if you have the `random' function. */
#define HAVE_READDIR 1 #define HAVE_RANDOM 1
/* Define this if select() is available */ /* Define this if select() is available */
/* #undef HAVE_SELECT */ /* #undef HAVE_SELECT */
/* Define to 1 if you have the `setresuid' function. */ /* Define to 1 if you have the `setresuid' function. */
#define HAVE_SETRESUID 1 #define HAVE_SETRESUID 1
/* Define to 1 if you have the `setrlimit' function. */ /* Define to 1 if you have the `setrlimit' function. */
#define HAVE_SETRLIMIT 1 #define HAVE_SETRLIMIT 1
/* Define if you have the shl_load function. */
/* #undef HAVE_SHL_LOAD */
/* Define to 1 if you have the <signal.h> header file. */ /* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
/* Define to 1 if the system has the type `sigset_t'. */ /* Define to 1 if the system has the type `sigset_t'. */
#define HAVE_SIGSET_T 1 #define HAVE_SIGSET_T 1
/* Define to 1 if the system has the type `size_t'. */ /* Define to 1 if the system has the type `size_t'. */
#define HAVE_SIZE_T 1 #define HAVE_SIZE_T 1
/* Do we have sockaddr_in.sin_len? */ /* Do we have sockaddr_in.sin_len? */
skipping to change at line 396 skipping to change at line 351
/* Define this if socket() is available */ /* Define this if socket() is available */
/* #undef HAVE_SOCKET */ /* #undef HAVE_SOCKET */
/* Define to 1 if you have the <sockLib.h> header file. */ /* Define to 1 if you have the <sockLib.h> header file. */
/* #undef HAVE_SOCKLIB_H */ /* #undef HAVE_SOCKLIB_H */
/* Define to 1 if you have the <sqlite3.h> header file. */ /* Define to 1 if you have the <sqlite3.h> header file. */
#define HAVE_SQLITE3_H 1 #define HAVE_SQLITE3_H 1
/* Define to 1 if you have the `srandom' function. */
#define HAVE_SRANDOM 1
/* Define to 1 if you have the `stat' function. */
#define HAVE_STAT 1
/* Define to 1 if you have the `stat64' function. */ /* Define to 1 if you have the `stat64' function. */
#define HAVE_STAT64 1 #define HAVE_STAT64 1
/* Define to 1 if you have the `statfs' function. */
#define HAVE_STATFS 1
/* Define to 1 if you have the `statvfs' function. */
#define HAVE_STATVFS 1
/* Define to 1 if `stat' has the bug that it succeeds when given the /* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */ zero-length file name argument. */
/* #undef HAVE_STAT_EMPTY_STRING_BUG */ /* #undef HAVE_STAT_EMPTY_STRING_BUG */
/* Define to 1 if you have the <stdarg.h> header file. */ /* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1 #define HAVE_STDARG_H 1
/* Define to 1 if stdbool.h conforms to C99. */ /* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1 #define HAVE_STDBOOL_H 1
skipping to change at line 430 skipping to change at line 397
/* Define to 1 if you have the `strftime' function. */ /* Define to 1 if you have the `strftime' function. */
#define HAVE_STRFTIME 1 #define HAVE_STRFTIME 1
/* Define to 1 if you have the <strings.h> header file. */ /* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1 #define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */ /* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
/* Define to 1 if you have the `strlcat' function. */
/* #undef HAVE_STRLCAT */
/* Define to 1 if you have the `strlcpy' function. */
/* #undef HAVE_STRLCPY */
/* Define to 1 if you have the `strndup' function. */ /* Define to 1 if you have the `strndup' function. */
#define HAVE_STRNDUP 1 #define HAVE_STRNDUP 1
/* Define to 1 if you have the `strnlen' function. */ /* Define to 1 if you have the `strnlen' function. */
#define HAVE_STRNLEN 1 #define HAVE_STRNLEN 1
/* Define to 1 if you have the `sysconf' function. */ /* Define to 1 if you have the `sysconf' function. */
#define HAVE_SYSCONF 1 #define HAVE_SYSCONF 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR '. /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR '.
*/ */
/* #undef HAVE_SYS_DIR_H */ /* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/dl.h> header file. */
/* #undef HAVE_SYS_DL_H */
/* Define to 1 if you have the <sys/endian.h> header file. */ /* Define to 1 if you have the <sys/endian.h> header file. */
/* #undef HAVE_SYS_ENDIAN_H */ /* #undef HAVE_SYS_ENDIAN_H */
/* Define to 1 if you have the <sys/file.h> header file. */ /* Define to 1 if you have the <sys/file.h> header file. */
#define HAVE_SYS_FILE_H 1 #define HAVE_SYS_FILE_H 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */ /* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1 #define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/mman.h> header file. */ /* Define to 1 if you have the <sys/mman.h> header file. */
skipping to change at line 513 skipping to change at line 471
/* Define to 1 if you have the <sys/vfs.h> header file. */ /* Define to 1 if you have the <sys/vfs.h> header file. */
#define HAVE_SYS_VFS_H 1 #define HAVE_SYS_VFS_H 1
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H 1 #define HAVE_SYS_WAIT_H 1
/* Define to 1 if you have the <terminos.h> header file. */ /* Define to 1 if you have the <terminos.h> header file. */
/* #undef HAVE_TERMINOS_H */ /* #undef HAVE_TERMINOS_H */
/* Define if struct tm has the tm_gmtoff member. */
#define HAVE_TM_GMTOFF 1
/* Define to 1 if you have the <ucred.h> header file. */ /* Define to 1 if you have the <ucred.h> header file. */
/* #undef HAVE_UCRED_H */ /* #undef HAVE_UCRED_H */
/* We can access-64 bit values that are only 32-bit aligned */ /* We can access-64 bit values that are only 32-bit aligned */
#define HAVE_UNALIGNED_64_ACCESS 0 #define HAVE_UNALIGNED_64_ACCESS 0
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1 #define HAVE_UNISTD_H 1
/* Define to 1 if you have the `vfork' function. */ /* Define to 1 if you have the `vfork' function. */
#define HAVE_VFORK 1 #define HAVE_VFORK 1
/* Define to 1 if you have the <vfork.h> header file. */ /* Define to 1 if you have the <vfork.h> header file. */
/* #undef HAVE_VFORK_H */ /* #undef HAVE_VFORK_H */
/* Define to 1 if you have the `vprintf' function. */ /* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1 #define HAVE_VPRINTF 1
/* This value is set to 1 to indicate that the system argz facility works *
/
#define HAVE_WORKING_ARGZ 1
/* Define to 1 if `fork' works. */ /* Define to 1 if `fork' works. */
#define HAVE_WORKING_FORK 1 #define HAVE_WORKING_FORK 1
/* Define to 1 if `vfork' works. */ /* Define to 1 if `vfork' works. */
#define HAVE_WORKING_VFORK 1 #define HAVE_WORKING_VFORK 1
/* Have compression library */
#define HAVE_ZLIB /**/
/* Define to 1 if the system has the type `_Bool'. */ /* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1 #define HAVE__BOOL 1
/* Define as const if the declaration of iconv() needs const. */ /* Define as const if the declaration of iconv() needs const. */
#define ICONV_CONST #define ICONV_CONST
/* Defined if libcurl supports AsynchDNS */ /* Defined if libgnurl supports AsynchDNS */
/* #undef LIBCURL_FEATURE_ASYNCHDNS */ /* #undef LIBGNURL_FEATURE_ASYNCHDNS */
/* Defined if libcurl supports IDN */
#define LIBCURL_FEATURE_IDN 1
/* Defined if libcurl supports IPv6 */ /* Defined if libgnurl supports IDN */
#define LIBCURL_FEATURE_IPV6 1 /* #undef LIBGNURL_FEATURE_IDN */
/* Defined if libcurl supports KRB4 */ /* Defined if libgnurl supports IPv6 */
/* #undef LIBCURL_FEATURE_KRB4 */ /* #undef LIBGNURL_FEATURE_IPV6 */
/* Defined if libcurl supports libz */ /* Defined if libgnurl supports KRB4 */
#define LIBCURL_FEATURE_LIBZ 1 /* #undef LIBGNURL_FEATURE_KRB4 */
/* Defined if libcurl supports NTLM */ /* Defined if libgnurl supports libz */
#define LIBCURL_FEATURE_NTLM 1 /* #undef LIBGNURL_FEATURE_LIBZ */
/* Defined if libcurl supports SSL */ /* Defined if libgnurl supports NTLM */
#define LIBCURL_FEATURE_SSL 1 /* #undef LIBGNURL_FEATURE_NTLM */
/* Defined if libcurl supports SSPI */ /* Defined if libgnurl supports SSL */
/* #undef LIBCURL_FEATURE_SSPI */ /* #undef LIBGNURL_FEATURE_SSL */
/* Defined if libcurl supports DICT */ /* Defined if libgnurl supports SSPI */
#define LIBCURL_PROTOCOL_DICT 1 /* #undef LIBGNURL_FEATURE_SSPI */
/* Defined if libcurl supports FILE */ /* Defined if libgnurl supports DICT */
#define LIBCURL_PROTOCOL_FILE 1 /* #undef LIBGNURL_PROTOCOL_DICT */
/* Defined if libcurl supports FTP */ /* Defined if libgnurl supports FILE */
#define LIBCURL_PROTOCOL_FTP 1 /* #undef LIBGNURL_PROTOCOL_FILE */
/* Defined if libcurl supports FTPS */ /* Defined if libgnurl supports FTP */
#define LIBCURL_PROTOCOL_FTPS 1 /* #undef LIBGNURL_PROTOCOL_FTP */
/* Defined if libcurl supports HTTP */ /* Defined if libgnurl supports FTPS */
#define LIBCURL_PROTOCOL_HTTP 1 /* #undef LIBGNURL_PROTOCOL_FTPS */
/* Defined if libcurl supports HTTPS */ /* Defined if libgnurl supports HTTP */
#define LIBCURL_PROTOCOL_HTTPS 1 /* #undef LIBGNURL_PROTOCOL_HTTP */
/* Defined if libcurl supports IMAP */ /* Defined if libgnurl supports HTTPS */
#define LIBCURL_PROTOCOL_IMAP 1 /* #undef LIBGNURL_PROTOCOL_HTTPS */
/* Defined if libcurl supports LDAP */ /* Defined if libgnurl supports IMAP */
#define LIBCURL_PROTOCOL_LDAP 1 /* #undef LIBGNURL_PROTOCOL_IMAP */
/* Defined if libcurl supports POP3 */ /* Defined if libgnurl supports LDAP */
#define LIBCURL_PROTOCOL_POP3 1 /* #undef LIBGNURL_PROTOCOL_LDAP */
/* Defined if libcurl supports RTSP */ /* Defined if libgnurl supports POP3 */
#define LIBCURL_PROTOCOL_RTSP 1 /* #undef LIBGNURL_PROTOCOL_POP3 */
/* Defined if libcurl supports SMTP */ /* Defined if libgnurl supports RTSP */
#define LIBCURL_PROTOCOL_SMTP 1 /* #undef LIBGNURL_PROTOCOL_RTSP */
/* Defined if libcurl supports TELNET */ /* Defined if libgnurl supports SMTP */
#define LIBCURL_PROTOCOL_TELNET 1 /* #undef LIBGNURL_PROTOCOL_SMTP */
/* Defined if libcurl supports TFTP */ /* Defined if libgnurl supports TELNET */
#define LIBCURL_PROTOCOL_TFTP 1 /* #undef LIBGNURL_PROTOCOL_TELNET */
/* Define to 1 if you want IDN support. */ /* Defined if libgnurl supports TFTP */
#define LIBIDN 1 /* #undef LIBGNURL_PROTOCOL_TFTP */
/* This is a Linux kernel */ /* This is a Linux kernel */
#define LINUX 1 #define LINUX 1
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing /* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */ slash. */
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
/* Define if the OS needs help to load dependent libraries for dlopen(). */
/* #undef LTDL_DLOPEN_DEPLIBS */
/* Define to the system default library search path. */
#define LT_DLSEARCH_PATH "/lib:/usr/lib:/usr/lib/atlas-sse:/usr/lib/atlas-s
se3:/usr/lib/atlas:/usr/lib/paraview-mpi"
/* The archive extension */
#define LT_LIBEXT "a"
/* The archive prefix */
#define LT_LIBPREFIX "lib"
/* Define to the extension used for runtime loadable modules, say, ".so". *
/
#define LT_MODULE_EXT ".so"
/* Define to the name of the environment variable that determines the run-t
ime
module search path. */
#define LT_MODULE_PATH_VAR "LD_LIBRARY_PATH"
/* Define to the sub-directory in which libtool stores uninstalled librarie s. /* Define to the sub-directory in which libtool stores uninstalled librarie s.
*/ */
#define LT_OBJDIR ".libs/" #define LT_OBJDIR ".libs/"
/* Define to the shared library suffix, say, ".dylib". */
/* #undef LT_SHARED_EXT */
/* This is a MinGW system */ /* This is a MinGW system */
/* #undef MINGW */ /* #undef MINGW */
/* required libgcrypt version */ /* required libgcrypt version */
#define NEED_LIBGCRYPT_VERSION "1.4.2" #define NEED_LIBGCRYPT_VERSION "1.6.0"
/* Define if dlsym() requires a leading underscore in symbol names. */
/* #undef NEED_USCORE */
/* This is a NetBSD system */ /* This is a NetBSD system */
/* #undef NETBSD */ /* #undef NETBSD */
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* This is an OpenBSD system */ /* This is an OpenBSD system */
/* #undef OPENBSD */ /* #undef OPENBSD */
/* Some strange OS */ /* Some strange OS */
/* #undef OTHEROS */ /* #undef OTHEROS */
/* Name of package */ /* Name of package */
#define PACKAGE "gnunet" #define PACKAGE "gnunet"
/* Define to the address where bug reports for this package should be sent. */ /* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-gnunet@gnu.org" #define PACKAGE_BUGREPORT "bug-gnunet@gnu.org"
/* Define to the full name of this package. */ /* Define to the full name of this package. */
#define PACKAGE_NAME "gnunet" #define PACKAGE_NAME "gnunet"
/* Define to the full name and version of this package. */ /* Define to the full name and version of this package. */
#define PACKAGE_STRING "gnunet 0.9.5" #define PACKAGE_STRING "gnunet 0.10.0"
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "gnunet" #define PACKAGE_TARNAME "gnunet"
/* Define to the home page for this package. */ /* Define to the home page for this package. */
#define PACKAGE_URL "" #define PACKAGE_URL ""
/* Define to the version of this package. */ /* Define to the version of this package. */
#define PACKAGE_VERSION "0.9.5" #define PACKAGE_VERSION "0.10.0"
/* Define as the return type of signal handlers (`int' or `void'). */ /* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void #define RETSIGTYPE void
/* Define to the type of arg 1 for `select'. */ /* Define to the type of arg 1 for `select'. */
#define SELECT_TYPE_ARG1 int #define SELECT_TYPE_ARG1 int
/* Define to the type of args 2, 3 and 4 for `select'. */ /* Define to the type of args 2, 3 and 4 for `select'. */
#define SELECT_TYPE_ARG234 (fd_set *) #define SELECT_TYPE_ARG234 (fd_set *)
skipping to change at line 717 skipping to change at line 647
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1 #define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1 #define TIME_WITH_SYS_TIME 1
/* Define to 1 if your <sys/time.h> declares `struct tm'. */ /* Define to 1 if your <sys/time.h> declares `struct tm'. */
/* #undef TM_IN_SYS_TIME */ /* #undef TM_IN_SYS_TIME */
/* repository svn version */ /* VCS revision/hash or tarball version */
#define VCS_VERSION "svn-" #define VCS_VERSION "release"
/* Version number of package */ /* Version number of package */
#define VERSION "0.9.5" #define VERSION "0.10.0"
/* This is a Windows system */ /* This is a Windows system */
/* #undef WINDOWS */ /* #undef WINDOWS */
/* Do we have to use IBM LoadLeveler */
#define WITH_LL 0
/* Define to 1 if the X Window System is missing or not being used. */ /* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */ /* #undef X_DISPLAY_MISSING */
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */ /* Number of bits in a file offset, on hosts where this is settable. */
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
/* #undef _LARGEFILE_SOURCE */ /* #undef _LARGEFILE_SOURCE */
/* Define for large files, on AIX-style hosts. */ /* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */ /* #undef _LARGE_FILES */
/* Need with solaris or errno doesnt work */ /* Need with solaris or errno doesnt work */
/* #undef _REENTRANT */ /* #undef _REENTRANT */
/* This is a Windows system */ /* This is a Windows system */
/* #undef _WIN32 */ /* #undef _WIN32 */
/* Define so that glibc/gnulib argp.h does not typedef error_t. */ /* Define curl_free() as free() if our version of gnurl lacks curl_free. */
/* #undef __error_t_defined */
/* Define curl_free() as free() if our version of curl lacks curl_free. */
/* #undef curl_free */ /* #undef curl_free */
/* Define to a type to use for `error_t' if it is not otherwise available.
*/
/* #undef error_t */
/* Define to `int' if <sys/types.h> doesn't define. */ /* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */ /* #undef gid_t */
/* Define to `int' if <sys/types.h> does not define. */ /* Define to `int' if <sys/types.h> does not define. */
/* #undef mode_t */ /* #undef mode_t */
/* Define to `long int' if <sys/types.h> does not define. */ /* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */ /* #undef off_t */
/* Define to `int' if <sys/types.h> does not define. */ /* Define to `int' if <sys/types.h> does not define. */
 End of changes. 66 change blocks. 
197 lines changed or deleted 107 lines changed or added


 gnunet_configuration_lib.h   gnunet_configuration_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2006, 2008, 2009 Christian Grothoff (and other contributing author s) (C) 2006, 2008, 2009 Christian Grothoff (and other contributing author s)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_configuration_lib.h * @file include/gnunet_configuration_lib.h
* @brief configuration API * @brief configuration API
*
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup configuration Configuration management
* @{
*/ */
#ifndef GNUNET_CONFIGURATION_LIB_H #ifndef GNUNET_CONFIGURATION_LIB_H
#define GNUNET_CONFIGURATION_LIB_H #define GNUNET_CONFIGURATION_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h"
#include "gnunet_time_lib.h"
/** /**
* A configuration object. * A configuration object.
*/ */
struct GNUNET_CONFIGURATION_Handle; struct GNUNET_CONFIGURATION_Handle;
/** /**
* Create a new configuration object. * Create a new configuration object.
* @return fresh configuration object * @return fresh configuration object
*/ */
struct GNUNET_CONFIGURATION_Handle * struct GNUNET_CONFIGURATION_Handle *
skipping to change at line 78 skipping to change at line 75
void void
GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg); GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg);
/** /**
* Load configuration. This function will first parse the * Load configuration. This function will first parse the
* defaults and then parse the specific configuration file * defaults and then parse the specific configuration file
* to overwrite the defaults. * to overwrite the defaults.
* *
* @param cfg configuration to update * @param cfg configuration to update
* @param filename name of the configuration file, NULL to load defaults * @param filename name of the configuration file, NULL to load defaults
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
const char *filename); const char *filename);
/** /**
* Load default configuration. This function will parse the * Load default configuration. This function will parse the
* defaults from the given defaults_d directory. * defaults from the given defaults_d directory.
* *
* @param cfg configuration to update * @param cfg configuration to update
* @param defaults_d directory with the defaults * @param defaults_d directory with the defaults
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg,
const char *defaults_d); const char *defaults_d);
/** /**
* Parse a configuration file, add all of the options in the * Parse a configuration file, add all of the options in the
* file to the configuration environment. * file to the configuration environment.
* *
* @param cfg configuration to update * @param cfg configuration to update
* @param filename name of the configuration file * @param filename name of the configuration file
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
const char *filename); const char *filename);
/** /**
* Serializes the given configuration. * Serializes the given configuration.
* *
* @param cfg configuration to serialize * @param cfg configuration to serialize
* @param size will be set to the size of the serialized memory block * @param size will be set to the size of the serialized memory block
skipping to change at line 126 skipping to change at line 123
char * char *
GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *c fg, GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *c fg,
size_t *size); size_t *size);
/** /**
* De-serializes configuration * De-serializes configuration
* *
* @param cfg configuration to update * @param cfg configuration to update
* @param mem the memory block of serialized configuration * @param mem the memory block of serialized configuration
* @param size the size of the memory block * @param size the size of the memory block
* @param allow_inline set to GNUNET_YES if we recursively load configurati * @param allow_inline set to #GNUNET_YES if we recursively load configurat
on ion
* from inlined configurations; GNUNET_NO if not and raise warning * from inlined configurations; #GNUNET_NO if not and raise warnin
s gs
* when we come across them * when we come across them
* @return GNUNET_OK on success, GNUNET_ERROR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
const char *mem, const char *mem,
const size_t size, const size_t size,
int allow_inline); int allow_inline);
/** /**
* Write configuration file. * Write configuration file.
* *
* @param cfg configuration to write * @param cfg configuration to write
* @param filename where to write the configuration * @param filename where to write the configuration
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
const char *filename); const char *filename);
/** /**
* Write only configuration entries that have been changed to configuration file * Write only configuration entries that have been changed to configuration file
* @param cfgDefault default configuration * @param cfg_default default configuration
* @param cfgNew new configuration * @param cfg_new new configuration
* @param filename where to write the configuration diff between default an d new * @param filename where to write the configuration diff between default an d new
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle
*cfgDefault, *cfg_default,
const struct GNUNET_CONFIGURATION_Handle const struct GNUNET_CONFIGURATION_Handle
*cfgNew, const char *filename); *cfg_new, const char *filename);
/** /**
* Compute configuration with only entries that have been changed * Compute configuration with only entries that have been changed
* *
* @param cfgDefault original configuration * @param cfg_default original configuration
* @param cfgNew new configuration * @param cfg_new new configuration
* @return configuration with only the differences, never NULL * @return configuration with only the differences, never NULL
*/ */
struct GNUNET_CONFIGURATION_Handle * struct GNUNET_CONFIGURATION_Handle *
GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle
*cfgDefault, *cfg_default,
const struct GNUNET_CONFIGURATION_Handle const struct GNUNET_CONFIGURATION_Handle
*cfgNew); *cfg_new);
/** /**
* Test if there are configuration options that were * Test if there are configuration options that were
* changed since the last save. * changed since the last save.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @return GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed) * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on err or (i.e. last save failed)
*/ */
int int
GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cf g); GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cf g);
/** /**
* Function to iterate over options. * Function to iterate over options.
* *
* @param cls closure * @param cls closure
* @param section name of the section * @param section name of the section
* @param option name of the option * @param option name of the option
skipping to change at line 247 skipping to change at line 244
GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cf g, GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cf g,
const char *section); const char *section);
/** /**
* Get a configuration value that should be a number. * Get a configuration value that should be a number.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param number where to store the numeric value of the option * @param number where to store the numeric value of the option
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Ha ndle GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Ha ndle
*cfg, const char *section, *cfg, const char *section,
const char *option, const char *option,
unsigned long long *number); unsigned long long *number);
/** /**
* Get a configuration value that should be a relative time. * Get a configuration value that should be a relative time.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param time set to the time value stored in the configuration * @param time set to the time value stored in the configuration
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Hand le GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Hand le
*cfg, const char *section, *cfg, const char *section,
const char *option, const char *option,
struct GNUNET_TIME_Relative *time); struct GNUNET_TIME_Relative *time);
/** /**
* Get a configuration value that should be a size in bytes. * Get a configuration value that should be a size in bytes.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param size set to the size in bytes as stored in the configuration * @param size set to the size in bytes as stored in the configuration
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Hand le GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Hand le
*cfg, const char *section, *cfg, const char *section,
const char *option, const char *option,
unsigned long long *size); unsigned long long *size);
/** /**
* Test if we have a value for a particular option * Test if we have a value for a particular option
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @return GNUNET_YES if so, GNUNET_NO if not. * @return #GNUNET_YES if so, #GNUNET_NO if not.
*/ */
int int
GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle * cfg, GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle * cfg,
const char *section, const char *option); const char *section, const char *option);
/** /**
* Get a configuration value that should be a string. * Get a configuration value that should be a string.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param value will be set to a freshly allocated configuration * @param value will be set to a freshly allocated configuration
* value, or NULL if option is not specified * value, or NULL if option is not specified
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Ha GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Ha
ndle ndle *cfg,
*cfg, const char *section, const char *section,
const char *option, char **value); const char *option,
char **value);
/** /**
* Get a configuration value that should be the name of a file * Get a configuration value that should be the name of a file
* or directory. * or directory.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param value will be set to a freshly allocated configuration * @param value will be set to a freshly allocated configuration
* value, or NULL if option is not specified * value, or NULL if option is not specified
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_
GNUNET_CONFIGURATION_Handle *cfg, Handle *cfg,
const char *section, const char *section,
const char *option, char **value); const char *option, char **value);
/** /**
* Iterate over the set of filenames stored in a configuration value. * Iterate over the set of filenames stored in a configuration value.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param cb function to call on each filename * @param cb function to call on each filename
* @param cb_cls closure for cb * @param cb_cls closure for @a cb
* @return number of filenames iterated over, -1 on error * @return number of filenames iterated over, -1 on error
*/ */
int int
GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_iterate_value_filenames (const struct
GNUNET_CONFIGURATION_Handle * cfg, GNUNET_CONFIGURATION_Handle * cfg,
const char *section, const char *section,
const char *option, const char *option,
GNUNET_FileNameCallback cb, GNUNET_FileNameCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Iterate over values of a section in the configuration. * Iterate over values of a section in the configuration.
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section the section * @param section the section
* @param iter function to call on each option * @param iter function to call on each option
* @param iter_cls closure for iter * @param iter_cls closure for @a iter
*/ */
void void
GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_iterate_section_values (const struct
GNUNET_CONFIGURATION_Handle *c fg, GNUNET_CONFIGURATION_Handle *c fg,
const char *section, const char *section,
GNUNET_CONFIGURATION_Iterator iter, GNUNET_CONFIGURATION_Iterator iter,
void *iter_cls); void *iter_cls);
/** /**
* Get a configuration value that should be in a set of * Get a configuration value that should be in a set of
* predefined strings * predefined strings
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param choices NULL-terminated list of legal values * @param choices NULL-terminated list of legal values
* @param value will be set to an entry in the legal list, * @param value will be set to an entry in the legal list,
* or NULL if option is not specified and no default given * or NULL if option is not specified and no default given
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Ha ndle GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Ha ndle
*cfg, const char *section, *cfg, const char *section,
const char *option, const char **cho ices, const char *option, const char *cons t *choices,
const char **value); const char **value);
/** /**
* Get a configuration value that should be in a set of * Get a configuration value that should be in a set of
* "YES" or "NO". * "YES" or "NO".
* *
* @param cfg configuration to inspect * @param cfg configuration to inspect
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @return GNUNET_YES, GNUNET_NO or if option has no valid value, GNUNET_SY SERR * @return #GNUNET_YES, #GNUNET_NO or if option has no valid value, #GNUNET _SYSERR
*/ */
int int
GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Han dle GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Han dle
*cfg, const char *section, *cfg, const char *section,
const char *option); const char *option);
/** /**
* Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
* where either in the "PATHS" section or the environtment * where either in the "PATHS" section or the environtment "FOO" is
* "FOO" is set to "DIRECTORY". * set to "DIRECTORY". We also support default expansion,
* i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is
* set in PATHS or the environment, and otherwise to "default". Note
* that "default" itself can also be a $-expression, thus
* "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined
* to VAR2.
* *
* @param cfg configuration to use for path expansion * @param cfg configuration to use for path expansion
* @param orig string to $-expand (will be freed!) * @param orig string to $-expand (will be freed!) Note that multiple
* $-expressions can be present in this string. They will all be
* $-expanded.
* @return $-expanded string * @return $-expanded string
*/ */
char * char *
GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handl e GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handl e
*cfg, char *orig); *cfg, char *orig);
/** /**
* Set a configuration value that should be a number. * Set a configuration value that should be a number.
* *
* @param cfg configuration to update * @param cfg configuration to update
skipping to change at line 441 skipping to change at line 445
const char *value); const char *value);
/** /**
* Remove a filename from a configuration value that * Remove a filename from a configuration value that
* represents a list of filenames * represents a list of filenames
* *
* @param cfg configuration to update * @param cfg configuration to update
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param value filename to remove * @param value filename to remove
* @return GNUNET_OK on success, * @return #GNUNET_OK on success,
* GNUNET_SYSERR if the filename is not in the list * #GNUNET_SYSERR if the filename is not in the list
*/ */
int int
GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Han dle GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Han dle
*cfg, const char *section, *cfg, const char *section,
const char *option, const char *option,
const char *value); const char *value);
/** /**
* Append a filename to a configuration value that * Append a filename to a configuration value that
* represents a list of filenames * represents a list of filenames
* *
* @param cfg configuration to update * @param cfg configuration to update
* @param section section of interest * @param section section of interest
* @param option option of interest * @param option option of interest
* @param value filename to append * @param value filename to append
* @return GNUNET_OK on success, * @return #GNUNET_OK on success,
* GNUNET_SYSERR if the filename already in the list * #GNUNET_SYSERR if the filename already in the list
*/ */
int int
GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Han dle GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Han dle
*cfg, const char *section, *cfg, const char *section,
const char *option, const char *option,
const char *value); const char *value);
/** @} */ /* end of group configuration */
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 37 change blocks. 
49 lines changed or deleted 56 lines changed or added


 gnunet_connection_lib.h   gnunet_connection_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gnunet_constants.h   gnunet_constants.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 38 skipping to change at line 38
#define GNUNET_CONSTANTS_H #define GNUNET_CONSTANTS_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_bandwidth_lib.h" /**
* Last resort choice for configuration file name.
*/
#define GNUNET_DEFAULT_USER_CONFIG_FILE "~/.config/gnunet.conf"
/** /**
* Bandwidth (in/out) to assume initially (before either peer has * Bandwidth (in/out) to assume initially (before either peer has
* communicated any particular preference). Should be rather low; set * communicated any particular preference). Should be rather low; set
* so that at least one maximum-size message can be send roughly once * so that at least one maximum-size message can be send roughly once
* per minute. * per minute.
*/ */
#define GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT GNUNET_BANDWIDTH_value_init (102 4) #define GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT GNUNET_BANDWIDTH_value_init (102 4)
/** /**
skipping to change at line 95 skipping to change at line 98
#define GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S 5 #define GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S 5
/** /**
* After how long do we expire an address in a HELLO that we just * After how long do we expire an address in a HELLO that we just
* validated? This value is also used for our own addresses when we * validated? This value is also used for our own addresses when we
* create a HELLO. * create a HELLO.
*/ */
#define GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION GNUNET_TIME_relative_mult iply (GNUNET_TIME_UNIT_HOURS, 12) #define GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION GNUNET_TIME_relative_mult iply (GNUNET_TIME_UNIT_HOURS, 12)
/** /**
* After how long do we expire an address in a HELLO that we just
* validated? This value is also used for our own addresses when we
* create a HELLO.
*/
#define GNUNET_CONSTANTS_DHT_MAX_EXPIRATION GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_HOURS, 24)
/**
* Size of the 'struct EncryptedMessage' of the core (which * Size of the 'struct EncryptedMessage' of the core (which
* is the per-message overhead of the core). * is the per-message overhead of the core).
*/ */
#define GNUNET_CONSTANTS_CORE_SIZE_ENCRYPTED_MESSAGE (24 + sizeof (struct G NUNET_HashCode)) #define GNUNET_CONSTANTS_CORE_SIZE_ENCRYPTED_MESSAGE (24 + sizeof (struct G NUNET_HashCode))
/** /**
* What is the maximum size for encrypted messages? Note that this * What is the maximum size for encrypted messages? Note that this
* number imposes a clear limit on the maximum size of any message. * number imposes a clear limit on the maximum size of any message.
* Set to a value close to 64k but not so close that transports will * Set to a value close to 64k but not so close that transports will
* have trouble with their headers. * have trouble with their headers.
* *
* Could theoretically be 64k minus (GNUNET_CONSTANTS_CORE_SIZE_ENCRYPTED_M ESSAGE + * Could theoretically be 64k minus (GNUNET_CONSTANTS_CORE_SIZE_ENCRYPTED_M ESSAGE +
* GNUNET_CONSTANTS_TRANSPORT_SIZE_OUTBOUND_MESSAGE), but we're going * GNUNET_CONSTANTS_TRANSPORT_SIZE_OUTBOUND_MESSAGE), but we're going
* to be more conservative for now. * to be more conservative for now.
*/ */
#define GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE (63 * 1024) #define GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE (63 * 1024)
/** /**
* Largest block that can be stored in the DHT.
*/
#define GNUNET_CONSTANTS_MAX_BLOCK_SIZE (62 * 1024)
/**
* K-value that must be used for the bloom filters in 'GET' * K-value that must be used for the bloom filters in 'GET'
* queries. * queries.
*/ */
#define GNUNET_CONSTANTS_BLOOMFILTER_K 16 #define GNUNET_CONSTANTS_BLOOMFILTER_K 16
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
 End of changes. 4 change blocks. 
2 lines changed or deleted 18 lines changed or added


 gnunet_container_lib.h   gnunet_container_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Christian Gro thoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_container_lib.h * @file include/gnunet_container_lib.h
* @brief container classes for GNUnet * @brief container classes for GNUnet
*
* @author Christian Grothoff * @author Christian Grothoff
* @author Nils Durner * @author Nils Durner
* @defgroup hashmap multi hash-map
* @defgroup heap min- or max-heap with arbitrary element removal
* @defgroup bloomfilter Bloom filter (probabilistic set tests)
* @defgroup dll Doubly-linked list
* @defgroup metadata Meta data (GNU libextractor key-value pairs)
*/ */
#ifndef GNUNET_CONTAINER_LIB_H #ifndef GNUNET_CONTAINER_LIB_H
#define GNUNET_CONTAINER_LIB_H #define GNUNET_CONTAINER_LIB_H
/* add error and config prototypes */ /* add error and config prototypes */
#include "gnunet_crypto_lib.h" #include "gnunet_crypto_lib.h"
#include <extractor.h> #include <extractor.h>
#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME #ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
skipping to change at line 53 skipping to change at line 57
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/* ******************* bloomfilter ***************** */ /* ******************* bloomfilter ***************** */
/** /**
* @brief bloomfilter representation (opaque) * @brief bloomfilter representation (opaque)
* @ingroup bloomfilter
*/ */
struct GNUNET_CONTAINER_BloomFilter; struct GNUNET_CONTAINER_BloomFilter;
/** /**
* Iterator over HashCodes. * @ingroup bloomfilter
* Iterator over struct GNUNET_HashCodes.
* *
* @param cls closure * @param cls closure
* @param next set to the next hash code * @param next set to the next hash code
* @return GNUNET_YES if next was updated * @return #GNUNET_YES if next was updated
* GNUNET_NO if there are no more entries * #GNUNET_NO if there are no more entries
*/ */
typedef int (*GNUNET_HashCodeIterator) (void *cls, struct GNUNET_HashCode * typedef int (*GNUNET_HashCodeIterator) (void *cls,
next); struct GNUNET_HashCode *next);
/** /**
* Load a bloom-filter from a file. * @ingroup bloomfilter
* Load a Bloom filter from a file.
* *
* @param filename the name of the file (or the prefix) * @param filename the name of the file (or the prefix)
* @param size the size of the bloom-filter (number of * @param size the size of the bloom-filter (number of
* bytes of storage space to use); will be rounded up * bytes of storage space to use); will be rounded up
* to next power of 2 * to next power of 2
* @param k the number of GNUNET_CRYPTO_hash-functions to apply per * @param k the number of #GNUNET_CRYPTO_hash-functions to apply per
* element (number of bits set per element in the set) * element (number of bits set per element in the set)
* @return the bloomfilter * @return the bloomfilter
*/ */
struct GNUNET_CONTAINER_BloomFilter * struct GNUNET_CONTAINER_BloomFilter *
GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size, GNUNET_CONTAINER_bloomfilter_load (const char *filename,
size_t size,
unsigned int k); unsigned int k);
/** /**
* Create a bloom filter from raw bits. * @ingroup bloomfilter
* Create a Bloom filter from raw bits.
* *
* @param data the raw bits in memory (maybe NULL, * @param data the raw bits in memory (maybe NULL,
* in which case all bits should be considered * in which case all bits should be considered
* to be zero). * to be zero).
* @param size the size of the bloom-filter (number of * @param size the size of the bloom-filter (number of
* bytes of storage space to use); also size of data * bytes of storage space to use); also size of @a data
* -- unless data is NULL. Must be a power of 2. * -- unless data is NULL. Must be a power of 2.
* @param k the number of GNUNET_CRYPTO_hash-functions to apply per * @param k the number of #GNUNET_CRYPTO_hash-functions to apply per
* element (number of bits set per element in the set) * element (number of bits set per element in the set)
* @return the bloomfilter * @return the bloomfilter
*/ */
struct GNUNET_CONTAINER_BloomFilter * struct GNUNET_CONTAINER_BloomFilter *
GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size, GNUNET_CONTAINER_bloomfilter_init (const char *data,
size_t size,
unsigned int k); unsigned int k);
/** /**
* Copy the raw data of this bloomfilter into * @ingroup bloomfilter
* Copy the raw data of this Bloom filter into
* the given data array. * the given data array.
* *
* @param data where to write the data * @param data where to write the data
* @param size the size of the given data array * @param size the size of the given @a data array
* @return GNUNET_SYSERR if the data array of the wrong size * @return #GNUNET_SYSERR if the data array of the wrong size
*/ */
int int
GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct GNUNET_CONTAINER_Bl
GNUNET_CONTAINER_BloomFilter *bf oomFilter *bf,
,
char *data, size_t size); char *data, size_t size);
/** /**
* @ingroup bloomfilter
* Test if an element is in the filter. * Test if an element is in the filter.
*
* @param e the element * @param e the element
* @param bf the filter * @param bf the filter
* @return GNUNET_YES if the element is in the filter, GNUNET_NO if not * @return #GNUNET_YES if the element is in the filter, #GNUNET_NO if not
*/ */
int int
GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilte GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilte
r r *bf,
*bf, const struct GNUNET_HashCode * e); const struct GNUNET_HashCode *e);
/** /**
* Add an element to the filter * @ingroup bloomfilter
* Add an element to the filter.
*
* @param bf the filter * @param bf the filter
* @param e the element * @param e the element
*/ */
void void
GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf,
const struct GNUNET_HashCode * e); const struct GNUNET_HashCode *e);
/** /**
* @ingroup bloomfilter
* Remove an element from the filter. * Remove an element from the filter.
*
* @param bf the filter * @param bf the filter
* @param e the element to remove * @param e the element to remove
*/ */
void void
GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *b f, GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *b f,
const struct GNUNET_HashCode * e); const struct GNUNET_HashCode *e);
/** /**
* @ingroup bloomfilter
* Create a copy of a bloomfilter. * Create a copy of a bloomfilter.
* *
* @param bf the filter * @param bf the filter
* @return copy of bf * @return copy of bf
*/ */
struct GNUNET_CONTAINER_BloomFilter * struct GNUNET_CONTAINER_BloomFilter *
GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilte GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilte
r r *bf);
*bf);
/** /**
* @ingroup bloomfilter
* Free the space associcated with a filter * Free the space associcated with a filter
* in memory, flush to drive if needed (do not * in memory, flush to drive if needed (do not
* free the space on the drive) * free the space on the drive).
*
* @param bf the filter * @param bf the filter
*/ */
void void
GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf) ; GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf) ;
/** /**
* Get the number of the addresses set per element in the bloom filter.
*
* @param bf the filter
* @return addresses set per element in the bf
*/
size_t
GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CON
TAINER_BloomFilter *bf);
/**
* @ingroup bloomfilter
* Get size of the bloom filter. * Get size of the bloom filter.
* *
* @param bf the filter * @param bf the filter
* @return number of bytes used for the data of the bloom filter * @return number of bytes used for the data of the bloom filter
*/ */
size_t size_t
GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomF GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomF
ilter ilter *bf);
*bf);
/** /**
* Reset a bloom filter to empty. * @ingroup bloomfilter
* Reset a Bloom filter to empty.
*
* @param bf the filter * @param bf the filter
*/ */
void void
GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf ); GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf );
/** /**
* Or the entries of the given raw data array with the * @ingroup bloomfilter
* data of the given bloom filter. Assumes that * "or" the entries of the given raw data array with the
* the size of the data array and the current filter * data of the given Bloom filter. Assumes that
* the @a size of the @a data array and the current filter
* match. * match.
* *
* @param bf the filter * @param bf the filter
* @param data data to OR-in * @param data data to OR-in
* @param size size of data * @param size size of @a data
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
const char *data, size_t size); const char *data, size_t size);
/** /**
* Or the entries of the given raw data array with the * @ingroup bloomfilter
* data of the given bloom filter. Assumes that * "or" the entries of the given raw data array with the
* the size of the data array and the current filter * data of the given Bloom filter. Assumes that
* match. * the size of the two filters matches.
* *
* @param bf the filter * @param bf the filter
* @param to_or the bloomfilter to or-in * @param to_or the bloomfilter to or-in
* @param size number of bytes in data * @return #GNUNET_OK on success
*/ */
int int
GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf,
const struct GNUNET_CONTAINER_BloomFilter const struct GNUNET_CONTAINER_BloomFilter
*to_or, size_t size); *to_or);
/** /**
* @ingroup bloomfilter
* Resize a bloom filter. Note that this operation * Resize a bloom filter. Note that this operation
* is pretty costly. Essentially, the bloom filter * is pretty costly. Essentially, the Bloom filter
* needs to be completely re-build. * needs to be completely re-build.
* *
* @param bf the filter * @param bf the filter
* @param iterator an iterator over all elements stored in the BF * @param iterator an iterator over all elements stored in the BF
* @param iterator_cls closure for iterator * @param iterator_cls closure for @a iterator
* @param size the new size for the filter * @param size the new size for the filter
* @param k the new number of GNUNET_CRYPTO_hash-function to apply per elem ent * @param k the new number of #GNUNET_CRYPTO_hash-function to apply per ele ment
*/ */
void void
GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *b f, GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *b f,
GNUNET_HashCodeIterator iterator, GNUNET_HashCodeIterator iterator,
void *iterator_cls, size_t size, void *iterator_cls, size_t size,
unsigned int k); unsigned int k);
/* ****************** metadata ******************* */ /* ****************** metadata ******************* */
/** /**
* @ingroup metadata
* Meta data to associate with a file, directory or namespace. * Meta data to associate with a file, directory or namespace.
*/ */
struct GNUNET_CONTAINER_MetaData; struct GNUNET_CONTAINER_MetaData;
/** /**
* Create a fresh MetaData token. * @ingroup metadata
* Create a fresh meta data container.
* *
* @return empty meta-data container * @return empty meta-data container
*/ */
struct GNUNET_CONTAINER_MetaData * struct GNUNET_CONTAINER_MetaData *
GNUNET_CONTAINER_meta_data_create (void); GNUNET_CONTAINER_meta_data_create (void);
/** /**
* @ingroup metadata
* Duplicate a MetaData token. * Duplicate a MetaData token.
* *
* @param md what to duplicate * @param md what to duplicate
* @return duplicate meta-data container * @return duplicate meta-data container
*/ */
struct GNUNET_CONTAINER_MetaData * struct GNUNET_CONTAINER_MetaData *
GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaDat a GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaDat a
*md); *md);
/** /**
* @ingroup metadata
* Free meta data. * Free meta data.
* *
* @param md what to free * @param md what to free
*/ */
void void
GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md); GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
/** /**
* @ingroup metadata
* Test if two MDs are equal. We consider them equal if * Test if two MDs are equal. We consider them equal if
* the meta types, formats and content match (we do not * the meta types, formats and content match (we do not
* include the mime types and plugins names in this * include the mime types and plugins names in this
* consideration). * consideration).
* *
* @param md1 first value to check * @param md1 first value to check
* @param md2 other value to check * @param md2 other value to check
* @return GNUNET_YES if they are equal * @return #GNUNET_YES if they are equal
*/ */
int int
GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaDa GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaDa
ta ta *md1,
*md1, const struct GNUNET_CONTAINER_MetaDa
const struct GNUNET_CONTAINER_MetaDa ta *md2);
ta
*md2);
/** /**
* @ingroup metadata
* Extend metadata. * Extend metadata.
* *
* @param md metadata to extend * @param md metadata to extend
* @param plugin_name name of the plugin that produced this value; * @param plugin_name name of the plugin that produced this value;
* special values can be used (i.e. '&lt;zlib&gt;' for zlib being * special values can be used (i.e. '&lt;zlib&gt;' for zlib being
* used in the main libextractor library and yielding * used in the main libextractor library and yielding
* meta data). * meta data).
* @param type libextractor-type describing the meta data * @param type libextractor-type describing the meta data
* @param format basic format information about data * @param format basic format information about data
* @param data_mime_type mime-type of data (not of the original file); * @param data_mime_type mime-type of data (not of the original file);
* can be NULL (if mime-type is not known) * can be NULL (if mime-type is not known)
* @param data actual meta-data found * @param data actual meta-data found
* @param data_size number of bytes in data * @param data_size number of bytes in data
* @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exis ts
* data_mime_type and plugin_name are not considered for "exists" c hecks * data_mime_type and plugin_name are not considered for "exists" c hecks
*/ */
int int
GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
const char *plugin_name, const char *plugin_name,
enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaType type,
enum EXTRACTOR_MetaFormat format, enum EXTRACTOR_MetaFormat format,
const char *data_mime_type, const char * data, const char *data_mime_type, const char * data,
size_t data_size); size_t data_size);
/** /**
* @ingroup metadata
* Extend metadata. Merges the meta data from the second argument * Extend metadata. Merges the meta data from the second argument
* into the first, discarding duplicate key-value pairs. * into the first, discarding duplicate key-value pairs.
* *
* @param md metadata to extend * @param md metadata to extend
* @param in metadata to merge * @param in metadata to merge
*/ */
void void
GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
const struct GNUNET_CONTAINER_MetaData *i n); const struct GNUNET_CONTAINER_MetaData *i n);
/** /**
* @ingroup metadata
* Remove an item. * Remove an item.
* *
* @param md metadata to manipulate * @param md metadata to manipulate
* @param type type of the item to remove * @param type type of the item to remove
* @param data specific value to remove, NULL to remove all * @param data specific value to remove, NULL to remove all
* entries of the given type * entries of the given type
* @param data_size number of bytes in data * @param data_size number of bytes in data
* @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist i n md * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md
*/ */
int int
GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaType type,
const char *data, size_t data_size); const char *data, size_t data_size);
/** /**
* @ingroup metadata
* Remove all items in the container. * Remove all items in the container.
* *
* @param md metadata to manipulate * @param md metadata to manipulate
*/ */
void void
GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md); GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md);
/** /**
* @ingroup metadata
* Add the current time as the publication date * Add the current time as the publication date
* to the meta-data. * to the meta-data.
* *
* @param md metadata to modify * @param md metadata to modify
*/ */
void void
GNUNET_CONTAINER_meta_data_add_publication_date (struct GNUNET_CONTAINER_meta_data_add_publication_date (struct
GNUNET_CONTAINER_MetaData *md); GNUNET_CONTAINER_MetaData *md);
/** /**
* @ingroup metadata
* Iterate over MD entries. * Iterate over MD entries.
* *
* @param md metadata to inspect * @param md metadata to inspect
* @param iter function to call on each entry * @param iter function to call on each entry, return 0 to continue to iter
* @param iter_cls closure for iterator ate
* and 1 to abort iteration in this function (GNU libextractor
API!)
* @param iter_cls closure for @a iter
* @return number of entries * @return number of entries
*/ */
int int
GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
EXTRACTOR_MetaDataProcessor iter, EXTRACTOR_MetaDataProcessor iter,
void *iter_cls); void *iter_cls);
/** /**
* @ingroup metadata
* Get the first MD entry of the given type. Caller * Get the first MD entry of the given type. Caller
* is responsible for freeing the return value. * is responsible for freeing the return value.
* Also, only meta data items that are strings (0-terminated) * Also, only meta data items that are strings (0-terminated)
* are returned by this function. * are returned by this function.
* *
* @param md metadata to inspect * @param md metadata to inspect
* @param type type to look for * @param type type to look for
* @return NULL if no entry was found * @return NULL if no entry was found
*/ */
char * char *
GNUNET_CONTAINER_meta_data_get_by_type (const struct GNUNET_CONTAINER_MetaD ata GNUNET_CONTAINER_meta_data_get_by_type (const struct GNUNET_CONTAINER_MetaD ata
*md, enum EXTRACTOR_MetaType type); *md, enum EXTRACTOR_MetaType type);
/** /**
* @ingroup metadata
* Get the first matching MD entry of the given types. Caller is * Get the first matching MD entry of the given types. Caller is
* responsible for freeing the return value. Also, only meta data * responsible for freeing the return value. Also, only meta data
* items that are strings (0-terminated) are returned by this * items that are strings (0-terminated) are returned by this
* function. * function.
* *
* @param md metadata to inspect * @param md metadata to inspect
* @param ... -1-terminated list of types * @param ... -1-terminated list of types
* @return NULL if we do not have any such entry, * @return NULL if we do not have any such entry,
* otherwise client is responsible for freeing the value! * otherwise client is responsible for freeing the value!
*/ */
char * char *
GNUNET_CONTAINER_meta_data_get_first_by_types (const struct GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
GNUNET_CONTAINER_MetaData *m d, GNUNET_CONTAINER_MetaData *m d,
...); ...);
/** /**
* @ingroup metadata
* Get a thumbnail from the meta-data (if present). Only matches meta * Get a thumbnail from the meta-data (if present). Only matches meta
* data with mime type "image" and binary format. * data with mime type "image" and binary format.
* *
* @param md metadata to inspect * @param md metadata to inspect
* @param thumb will be set to the thumbnail data. Must be * @param thumb will be set to the thumbnail data. Must be
* freed by the caller! * freed by the caller!
* @return number of bytes in thumbnail, 0 if not available * @return number of bytes in thumbnail, 0 if not available
*/ */
size_t size_t
GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_Met aData GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_Met aData
*md, unsigned char **thumb); *md, unsigned char **thumb);
/** /**
* @ingroup metadata
* Options for metadata serialization. * Options for metadata serialization.
*/ */
enum GNUNET_CONTAINER_MetaDataSerializationOptions enum GNUNET_CONTAINER_MetaDataSerializationOptions
{ {
/** /**
* @ingroup metadata
* Serialize all of the data. * Serialize all of the data.
*/ */
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0, GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0,
/** /**
* @ingroup metadata
* If not enough space is available, it is acceptable * If not enough space is available, it is acceptable
* to only serialize some of the metadata. * to only serialize some of the metadata.
*/ */
GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1, GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1,
/** /**
* @ingroup metadata
* Speed is of the essence, do not allow compression. * Speed is of the essence, do not allow compression.
*/ */
GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2 GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2
}; };
/** /**
* @ingroup metadata
* Serialize meta-data to target. * Serialize meta-data to target.
* *
* @param md metadata to serialize * @param md metadata to serialize
* @param target where to write the serialized metadata; * @param target where to write the serialized metadata;
* *target can be NULL, in which case memory is allocated * *target can be NULL, in which case memory is allocated
* @param max maximum number of bytes available * @param max maximum number of bytes available
* @param opt is it ok to just write SOME of the * @param opt is it ok to just write SOME of the
* meta-data to match the size constraint, * meta-data to match the size constraint,
* possibly discarding some data? * possibly discarding some data?
* @return number of bytes written on success, * @return number of bytes written on success,
skipping to change at line 440 skipping to change at line 489
* space) * space)
*/ */
ssize_t ssize_t
GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaDat a GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaDat a
*md, char **target, size_t max, *md, char **target, size_t max,
enum enum
GNUNET_CONTAINER_MetaDataSerializatio nOptions GNUNET_CONTAINER_MetaDataSerializatio nOptions
opt); opt);
/** /**
* @ingroup metadata
* Get the size of the full meta-data in serialized form. * Get the size of the full meta-data in serialized form.
* *
* @param md metadata to inspect * @param md metadata to inspect
* @return number of bytes needed for serialization, -1 on error * @return number of bytes needed for serialization, -1 on error
*/ */
ssize_t ssize_t
GNUNET_CONTAINER_meta_data_get_serialized_size (const struct GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
GNUNET_CONTAINER_MetaData * md); GNUNET_CONTAINER_MetaData * md);
/** /**
* @ingroup metadata
* Deserialize meta-data. Initializes md. * Deserialize meta-data. Initializes md.
* *
* @param input serialized meta-data. * @param input serialized meta-data.
* @param size number of bytes available * @param size number of bytes available
* @return MD on success, NULL on error (i.e. * @return MD on success, NULL on error (i.e.
* bad format) * bad format)
*/ */
struct GNUNET_CONTAINER_MetaData * struct GNUNET_CONTAINER_MetaData *
GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size); GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size);
/* ******************************* HashMap **************************** */ /* ******************************* HashMap **************************** */
/** /**
* @ingroup hashmap
* Opaque handle for a HashMap. * Opaque handle for a HashMap.
*/ */
struct GNUNET_CONTAINER_MultiHashMap; struct GNUNET_CONTAINER_MultiHashMap;
/** /**
* @ingroup hashmap
* Opaque handle to an iterator over
* a multihashmap.
*/
struct GNUNET_CONTAINER_MultiHashMapIterator;
/**
* @ingroup hashmap
* Options for storing values in the HashMap. * Options for storing values in the HashMap.
*/ */
enum GNUNET_CONTAINER_MultiHashMapOption enum GNUNET_CONTAINER_MultiHashMapOption
{ {
/** /**
* @ingroup hashmap
* If a value with the given key exists, replace it. Note that the * If a value with the given key exists, replace it. Note that the
* old value would NOT be freed by replace (the application has to * old value would NOT be freed by replace (the application has to
* make sure that this happens if required). * make sure that this happens if required).
*/ */
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE,
/** /**
* @ingroup hashmap
* Allow multiple values with the same key. * Allow multiple values with the same key.
*/ */
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE,
/** /**
* @ingroup hashmap
* There must only be one value per key; storing a value should fail * There must only be one value per key; storing a value should fail
* if a value under the same key already exists. * if a value under the same key already exists.
*/ */
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY,
/** /**
* There must only be one value per key, but don't bother checking * @ingroup hashmap There must only be one value per key, but don't
* if a value already exists (faster than UNIQUE_ONLY; implemented * bother checking if a value already exists (faster than
* just like MULTIPLE but this option documents better what is * #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY; implemented
* intended if UNIQUE is what is desired). * just like #GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE but this
* option documents better what is intended if
* #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY is what is
* desired).
*/ */
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
}; };
/** /**
* @ingroup hashmap
* Iterator over hash map entries. * Iterator over hash map entries.
* *
* @param cls closure * @param cls closure
* @param key current key code * @param key current key code
* @param value value in the hash map * @param value value in the hash map
* @return GNUNET_YES if we should continue to * @return #GNUNET_YES if we should continue to
* iterate, * iterate,
* GNUNET_NO if not. * #GNUNET_NO if not.
*/ */
typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls, typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls,
const struct GNUNET_HashCo de * key, const struct GNUNET_HashCo de *key,
void *value); void *value);
/** /**
* @ingroup hashmap
* Create a multi hash map. * Create a multi hash map.
* *
* @param len initial size (map will grow as needed) * @param len initial size (map will grow as needed)
* @param do_not_copy_keys GNUNET_NO is always safe and should be used by d * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by
efault; default;
* GNUNET_YES means that on 'put', the 'key' does n * #GNUNET_YES means that on 'put', the 'key' does
ot have not have
* to be copied as the destination of the pointer i s * to be copied as the destination of the pointer i s
* guaranteed to be life as long as the value is st ored in * guaranteed to be life as long as the value is st ored in
* the hashmap. This can significantly reduce memo ry * the hashmap. This can significantly reduce memo ry
* consumption, but of course is also a recipie for * consumption, but of course is also a recipie for
* heap corruption if the assumption is not true. Only * heap corruption if the assumption is not true. Only
* use this if (1) memory use is important in this case and * use this if (1) memory use is important in this case and
* (2) you have triple-checked that the invariant h olds * (2) you have triple-checked that the invariant h olds
* @return NULL on error * @return NULL on error
*/ */
struct GNUNET_CONTAINER_MultiHashMap * struct GNUNET_CONTAINER_MultiHashMap *
GNUNET_CONTAINER_multihashmap_create (unsigned int len, GNUNET_CONTAINER_multihashmap_create (unsigned int len,
int do_not_copy_keys); int do_not_copy_keys);
/** /**
* @ingroup hashmap
* Destroy a hash map. Will not free any values * Destroy a hash map. Will not free any values
* stored in the hash map! * stored in the hash map!
* *
* @param map the map * @param map the map
*/ */
void void
GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap
*map); *map);
/** /**
* @ingroup hashmap
* Given a key find a value in the map matching the key. * Given a key find a value in the map matching the key.
* *
* @param map the map * @param map the map
* @param key what to look for * @param key what to look for
* @return NULL if no value was found; note that * @return NULL if no value was found; note that
* this is indistinguishable from values that just * this is indistinguishable from values that just
* happen to be NULL; use "contains" to test for * happen to be NULL; use "contains" to test for
* key-value pairs with value NULL * key-value pairs with value NULL
*/ */
void * void *
GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashM GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashM
ap ap *map,
*map, const struct GNUNET_HashCode * key const struct GNUNET_HashCode *key);
);
/** /**
* @ingroup hashmap
* Remove the given key-value pair from the map. Note that if the * Remove the given key-value pair from the map. Note that if the
* key-value pair is in the map multiple times, only one of the pairs * key-value pair is in the map multiple times, only one of the pairs
* will be removed. * will be removed.
* *
* @param map the map * @param map the map
* @param key key of the key-value pair * @param key key of the key-value pair
* @param value value of the key-value pair * @param value value of the key-value pair
* @return GNUNET_YES on success, GNUNET_NO if the key-value pair * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
* is not in the map * is not in the map
*/ */
int int
GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
const struct GNUNET_HashCode * key, v const struct GNUNET_HashCode *key,
oid *value); const void *value);
/** /**
* @ingroup hashmap
* Remove all entries for the given key from the map. * Remove all entries for the given key from the map.
* Note that the values would not be "freed". * Note that the values would not be "freed".
* *
* @param map the map * @param map the map
* @param key identifies values to be removed * @param key identifies values to be removed
* @return number of values removed * @return number of values removed
*/ */
int int
GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHash GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHash
Map Map *map,
*map, const struct GNUNET_HashCod const struct GNUNET_HashCode *key
e * key); );
/** /**
* @ingroup hashmap
* Check if the map contains any value under the given * Check if the map contains any value under the given
* key (including values that are NULL). * key (including values that are NULL).
* *
* @param map the map * @param map the map
* @param key the key to test if a value exists for it * @param key the key to test if a value exists for it
* @return GNUNET_YES if such a value exists, * @return #GNUNET_YES if such a value exists,
* GNUNET_NO if not * #GNUNET_NO if not
*/ */
int int
GNUNET_CONTAINER_multihashmap_contains (const struct GNUNET_CONTAINER_multihashmap_contains (const struct GNUNET_CONTAINER_Multi
GNUNET_CONTAINER_MultiHashMap *map, HashMap *map,
const struct GNUNET_HashCode * key) ; const struct GNUNET_HashCode * key) ;
/** /**
* @ingroup hashmap
* Check if the map contains the given value under the given * Check if the map contains the given value under the given
* key. * key.
* *
* @param map the map * @param map the map
* @param key the key to test if a value exists for it * @param key the key to test if a value exists for it
* @param value value to test for * @param value value to test for
* @return GNUNET_YES if such a value exists, * @return #GNUNET_YES if such a value exists,
* GNUNET_NO if not * #GNUNET_NO if not
*/ */
int int
GNUNET_CONTAINER_multihashmap_contains_value (const struct GNUNET_CONTAINER_multihashmap_contains_value (const struct GNUNET_CONTAINER
GNUNET_CONTAINER_MultiHashMap _MultiHashMap *map,
*map, const struct GNUNET_Has const struct GNUNET_HashCode
hCode * key, *key,
const void *value); const void *value);
/** /**
* @ingroup hashmap
* Store a key-value pair in the map. * Store a key-value pair in the map.
* *
* @param map the map * @param map the map
* @param key key to use * @param key key to use
* @param value value to use * @param value value to use
* @param opt options for put * @param opt options for put
* @return GNUNET_OK on success, * @return #GNUNET_OK on success,
* GNUNET_NO if a value was replaced (with REPLACE) * #GNUNET_NO if a value was replaced (with REPLACE)
* GNUNET_SYSERR if UNIQUE_ONLY was the option and the * #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ON
LY was the option and the
* value already exists * value already exists
*/ */
int int
GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *ma p, GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *ma p,
const struct GNUNET_HashCode * key, void const struct GNUNET_HashCode *key,
*value, void *value,
enum GNUNET_CONTAINER_MultiHashMapOption enum GNUNET_CONTAINER_MultiHashMapOption
opt); opt);
/** /**
* @ingroup hashmap
* Get the number of key-value pairs in the map. * Get the number of key-value pairs in the map.
* *
* @param map the map * @param map the map
* @return the number of key value pairs * @return the number of key value pairs
*/ */
unsigned int unsigned int
GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHash Map GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHash Map
*map); *map);
/** /**
* @ingroup hashmap
* Iterate over all entries in the map. * Iterate over all entries in the map.
* *
* @param map the map * @param map the map
* @param it function to call on each entry * @param it function to call on each entry
* @param it_cls extra argument to it * @param it_cls extra argument to @a it
* @return the number of key value pairs processed, * @return the number of key value pairs processed,
* GNUNET_SYSERR if it aborted iteration * #GNUNET_SYSERR if it aborted iteration
*/ */
int int
GNUNET_CONTAINER_multihashmap_iterate (const struct GNUNET_CONTAINER_multihashmap_iterate (const struct
GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMap *map,
GNUNET_CONTAINER_HashMapIterator it, GNUNET_CONTAINER_HashMapIterator it,
void *it_cls); void *it_cls);
/** /**
* @ingroup hashmap
* Create an iterator for a multihashmap.
* The iterator can be used to retrieve all the elements in the multihashma
p
* one by one, without having to handle all elements at once (in contrast t
o
* #GNUNET_CONTAINER_multihashmap_iterate). Note that the iterator can not
be
* used anymore if elements have been removed from 'map' after the creation
of
* the iterator, or 'map' has been destroyed. Adding elements to 'map' may
* result in skipped or repeated elements.
*
* @param map the map to create an iterator for
* @return an iterator over the given multihashmap @a map
*/
struct GNUNET_CONTAINER_MultiHashMapIterator *
GNUNET_CONTAINER_multihashmap_iterator_create (const struct GNUNET_CONTAINE
R_MultiHashMap *map);
/**
* @ingroup hashmap
* Retrieve the next element from the hash map at the iterator's
* position. If there are no elements left, #GNUNET_NO is returned,
* and @a key and @a value are not modified. This operation is only
* allowed if no elements have been removed from the multihashmap
* since the creation of @a iter, and the map has not been destroyed.
* Adding elements may result in repeating or skipping elements.
*
* @param iter the iterator to get the next element from
* @param key pointer to store the key in, can be NULL
* @param value pointer to store the value in, can be NULL
* @return #GNUNET_YES we returned an element,
* #GNUNET_NO if we are out of elements
*/
int
GNUNET_CONTAINER_multihashmap_iterator_next (struct GNUNET_CONTAINER_MultiH
ashMapIterator *iter,
struct GNUNET_HashCode *key,
const void **value);
/**
* @ingroup hashmap
* Destroy a multihashmap iterator.
*
* @param iter the iterator to destroy
*/
void
GNUNET_CONTAINER_multihashmap_iterator_destroy (struct GNUNET_CONTAINER_Mul
tiHashMapIterator *iter);
/**
* @ingroup hashmap
* Iterate over all entries in the map that match a particular key. * Iterate over all entries in the map that match a particular key.
* *
* @param map the map * @param map the map
* @param key key that the entries must correspond to * @param key key that the entries must correspond to
* @param it function to call on each entry * @param it function to call on each entry
* @param it_cls extra argument to it * @param it_cls extra argument to @a it
* @return the number of key value pairs processed, * @return the number of key value pairs processed,
* GNUNET_SYSERR if it aborted iteration * #GNUNET_SYSERR if it aborted iteration
*/ */
int int
GNUNET_CONTAINER_multihashmap_get_multiple (const struct GNUNET_CONTAINER_multihashmap_get_multiple (const struct
GNUNET_CONTAINER_MultiHashMap * map, GNUNET_CONTAINER_MultiHashMap * map,
const struct GNUNET_HashCode * key, const struct GNUNET_HashCode * key,
GNUNET_CONTAINER_HashMapIterato r it, GNUNET_CONTAINER_HashMapIterato r it,
void *it_cls); void *it_cls);
/* ***************** Version of Multihashmap for peer identities **********
******** */
/**
* @ingroup hashmap
* Iterator over hash map entries.
*
* @param cls closure
* @param key current public key
* @param value value in the hash map
* @return #GNUNET_YES if we should continue to
* iterate,
* #GNUNET_NO if not.
*/
typedef int (*GNUNET_CONTAINER_PeerMapIterator) (void *cls,
const struct GNUNET_PeerId
entity *key,
void *value);
/**
* @ingroup hashmap
* Create a multi peer map (hash map for public keys of peers).
*
* @param len initial size (map will grow as needed)
* @param do_not_copy_keys #GNUNET_NO is always safe and should be used by
default;
* #GNUNET_YES means that on 'put', the 'key' does
not have
* to be copied as the destination of the pointer i
s
* guaranteed to be life as long as the value is st
ored in
* the hashmap. This can significantly reduce memo
ry
* consumption, but of course is also a recipie for
* heap corruption if the assumption is not true.
Only
* use this if (1) memory use is important in this
case and
* (2) you have triple-checked that the invariant h
olds
* @return NULL on error
*/
struct GNUNET_CONTAINER_MultiPeerMap *
GNUNET_CONTAINER_multipeermap_create (unsigned int len,
int do_not_copy_keys);
/**
* @ingroup hashmap
* Destroy a hash map. Will not free any values
* stored in the hash map!
*
* @param map the map
*/
void
GNUNET_CONTAINER_multipeermap_destroy (struct GNUNET_CONTAINER_MultiPeerMap
*map);
/**
* @ingroup hashmap
* Given a key find a value in the map matching the key.
*
* @param map the map
* @param key what to look for
* @return NULL if no value was found; note that
* this is indistinguishable from values that just
* happen to be NULL; use "contains" to test for
* key-value pairs with value NULL
*/
void *
GNUNET_CONTAINER_multipeermap_get (const struct GNUNET_CONTAINER_MultiPeerM
ap *map,
const struct GNUNET_PeerIdentity *key);
/**
* @ingroup hashmap
* Remove the given key-value pair from the map. Note that if the
* key-value pair is in the map multiple times, only one of the pairs
* will be removed.
*
* @param map the map
* @param key key of the key-value pair
* @param value value of the key-value pair
* @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
* is not in the map
*/
int
GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap
*map,
const struct GNUNET_PeerIdentity * ke
y,
const void *value);
/**
* @ingroup hashmap
* Remove all entries for the given key from the map.
* Note that the values would not be "freed".
*
* @param map the map
* @param key identifies values to be removed
* @return number of values removed
*/
int
GNUNET_CONTAINER_multipeermap_remove_all (struct GNUNET_CONTAINER_MultiPeer
Map *map,
const struct GNUNET_PeerIdentity
*key);
/**
* @ingroup hashmap
* Check if the map contains any value under the given
* key (including values that are NULL).
*
* @param map the map
* @param key the key to test if a value exists for it
* @return #GNUNET_YES if such a value exists,
* #GNUNET_NO if not
*/
int
GNUNET_CONTAINER_multipeermap_contains (const struct GNUNET_CONTAINER_Multi
PeerMap *map,
const struct GNUNET_PeerIdentity *k
ey);
/**
* @ingroup hashmap
* Check if the map contains the given value under the given
* key.
*
* @param map the map
* @param key the key to test if a value exists for it
* @param value value to test for
* @return #GNUNET_YES if such a value exists,
* #GNUNET_NO if not
*/
int
GNUNET_CONTAINER_multipeermap_contains_value (const struct GNUNET_CONTAINER
_MultiPeerMap *map,
const struct GNUNET_PeerIdent
ity * key,
const void *value);
/**
* @ingroup hashmap
* Store a key-value pair in the map.
*
* @param map the map
* @param key key to use
* @param value value to use
* @param opt options for put
* @return #GNUNET_OK on success,
* #GNUNET_NO if a value was replaced (with REPLACE)
* #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ON
LY was the option and the
* value already exists
*/
int
GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *ma
p,
const struct GNUNET_PeerIdentity *key,
void *value,
enum GNUNET_CONTAINER_MultiHashMapOption
opt);
/**
* @ingroup hashmap
* Get the number of key-value pairs in the map.
*
* @param map the map
* @return the number of key value pairs
*/
unsigned int
GNUNET_CONTAINER_multipeermap_size (const struct GNUNET_CONTAINER_MultiPeer
Map *map);
/**
* @ingroup hashmap
* Iterate over all entries in the map.
*
* @param map the map
* @param it function to call on each entry
* @param it_cls extra argument to @a it
* @return the number of key value pairs processed,
* #GNUNET_SYSERR if it aborted iteration
*/
int
GNUNET_CONTAINER_multipeermap_iterate (const struct GNUNET_CONTAINER_MultiP
eerMap *map,
GNUNET_CONTAINER_PeerMapIterator it,
void *it_cls);
/**
* @ingroup hashmap
* Create an iterator for a multihashmap.
* The iterator can be used to retrieve all the elements in the multihashma
p
* one by one, without having to handle all elements at once (in contrast t
o
* #GNUNET_CONTAINER_multipeermap_iterate). Note that the iterator can not
be
* used anymore if elements have been removed from @a map after the creatio
n of
* the iterator, or 'map' has been destroyed. Adding elements to @a map ma
y
* result in skipped or repeated elements.
*
* @param map the map to create an iterator for
* @return an iterator over the given multihashmap @a map
*/
struct GNUNET_CONTAINER_MultiPeerMapIterator *
GNUNET_CONTAINER_multipeermap_iterator_create (const struct GNUNET_CONTAINE
R_MultiPeerMap *map);
/**
* @ingroup hashmap
* Retrieve the next element from the hash map at the iterator's
* position. If there are no elements left, #GNUNET_NO is returned,
* and @a key and @a value are not modified. This operation is only
* allowed if no elements have been removed from the multihashmap
* since the creation of @a iter, and the map has not been destroyed.
* Adding elements may result in repeating or skipping elements.
*
* @param iter the iterator to get the next element from
* @param key pointer to store the key in, can be NULL
* @param value pointer to store the value in, can be NULL
* @return #GNUNET_YES we returned an element,
* #GNUNET_NO if we are out of elements
*/
int
GNUNET_CONTAINER_multipeermap_iterator_next (struct GNUNET_CONTAINER_MultiP
eerMapIterator *iter,
struct GNUNET_PeerIdentity *ke
y,
const void **value);
/**
* @ingroup hashmap
* Destroy a multipeermap iterator.
*
* @param iter the iterator to destroy
*/
void
GNUNET_CONTAINER_multipeermap_iterator_destroy (struct GNUNET_CONTAINER_Mul
tiPeerMapIterator *iter);
/**
* @ingroup hashmap
* Iterate over all entries in the map that match a particular key.
*
* @param map the map
* @param key public key that the entries must correspond to
* @param it function to call on each entry
* @param it_cls extra argument to @a it
* @return the number of key value pairs processed,
* #GNUNET_SYSERR if it aborted iteration
*/
int
GNUNET_CONTAINER_multipeermap_get_multiple (const struct GNUNET_CONTAINER_M
ultiPeerMap *map,
const struct GNUNET_PeerIdentit
y *key,
GNUNET_CONTAINER_PeerMapIterato
r it,
void *it_cls);
/* Version of multihashmap with 32 bit keys */
/**
* @ingroup hashmap
* Opaque handle for the 32-bit key HashMap.
*/
struct GNUNET_CONTAINER_MultiHashMap32;
/**
* @ingroup hashmap
* Opaque handle to an iterator over
* a 32-bit key multihashmap.
*/
struct GNUNET_CONTAINER_MultiHashMap32Iterator;
/**
* @ingroup hashmap
* Iterator over hash map entries.
*
* @param cls closure
* @param key current key code
* @param value value in the hash map
* @return #GNUNET_YES if we should continue to
* iterate,
* #GNUNET_NO if not.
*/
typedef int (*GNUNET_CONTAINER_HashMapIterator32) (void *cls,
uint32_t key,
void *value);
/**
* @ingroup hashmap
* Create a 32-bit key multi hash map.
*
* @param len initial size (map will grow as needed)
* @return NULL on error
*/
struct GNUNET_CONTAINER_MultiHashMap32 *
GNUNET_CONTAINER_multihashmap32_create (unsigned int len);
/**
* @ingroup hashmap
* Destroy a 32-bit key hash map. Will not free any values
* stored in the hash map!
*
* @param map the map
*/
void
GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashM
ap32
*map);
/**
* @ingroup hashmap
* Get the number of key-value pairs in the map.
*
* @param map the map
* @return the number of key value pairs
*/
unsigned int
GNUNET_CONTAINER_multihashmap32_size (const struct
GNUNET_CONTAINER_MultiHashMap32 *map)
;
/**
* @ingroup hashmap
* Given a key find a value in the map matching the key.
*
* @param map the map
* @param key what to look for
* @return NULL if no value was found; note that
* this is indistinguishable from values that just
* happen to be NULL; use "contains" to test for
* key-value pairs with value NULL
*/
void *
GNUNET_CONTAINER_multihashmap32_get (const struct
GNUNET_CONTAINER_MultiHashMap32 *map,
uint32_t key);
/**
* @ingroup hashmap
* Iterate over all entries in the map.
*
* @param map the map
* @param it function to call on each entry
* @param it_cls extra argument to @a it
* @return the number of key value pairs processed,
* #GNUNET_SYSERR if it aborted iteration
*/
int
GNUNET_CONTAINER_multihashmap32_iterate (const struct
GNUNET_CONTAINER_MultiHashMap32 *m
ap,
GNUNET_CONTAINER_HashMapIterator32
it,
void *it_cls);
/**
* @ingroup hashmap
* Remove the given key-value pair from the map. Note that if the
* key-value pair is in the map multiple times, only one of the pairs
* will be removed.
*
* @param map the map
* @param key key of the key-value pair
* @param value value of the key-value pair
* @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
* is not in the map
*/
int
GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMa
p32 *map,
uint32_t key,
const void *value);
/**
* @ingroup hashmap
* Remove all entries for the given key from the map.
* Note that the values would not be "freed".
*
* @param map the map
* @param key identifies values to be removed
* @return number of values removed
*/
int
GNUNET_CONTAINER_multihashmap32_remove_all (struct GNUNET_CONTAINER_MultiHa
shMap32 *map,
uint32_t key);
/**
* @ingroup hashmap
* Check if the map contains any value under the given
* key (including values that are NULL).
*
* @param map the map
* @param key the key to test if a value exists for it
* @return #GNUNET_YES if such a value exists,
* #GNUNET_NO if not
*/
int
GNUNET_CONTAINER_multihashmap32_contains (const struct GNUNET_CONTAINER_Mul
tiHashMap32 *map,
uint32_t key);
/**
* @ingroup hashmap
* Check if the map contains the given value under the given
* key.
*
* @param map the map
* @param key the key to test if a value exists for it
* @param value value to test for
* @return #GNUNET_YES if such a value exists,
* #GNUNET_NO if not
*/
int
GNUNET_CONTAINER_multihashmap32_contains_value (const struct GNUNET_CONTAIN
ER_MultiHashMap32 *map,
uint32_t key,
const void *value);
/**
* @ingroup hashmap
* Store a key-value pair in the map.
*
* @param map the map
* @param key key to use
* @param value value to use
* @param opt options for put
* @return #GNUNET_OK on success,
* #GNUNET_NO if a value was replaced (with REPLACE)
* #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ON
LY was the option and the
* value already exists
*/
int
GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32
*map,
uint32_t key,
void *value,
enum GNUNET_CONTAINER_MultiHashMapOpti
on opt);
/**
* @ingroup hashmap
* Iterate over all entries in the map that match a particular key.
*
* @param map the map
* @param key key that the entries must correspond to
* @param it function to call on each entry
* @param it_cls extra argument to @a it
* @return the number of key value pairs processed,
* #GNUNET_SYSERR if it aborted iteration
*/
int
GNUNET_CONTAINER_multihashmap32_get_multiple (const struct GNUNET_CONTAINER
_MultiHashMap32 *map,
uint32_t key,
GNUNET_CONTAINER_HashMapItera
tor32 it,
void *it_cls);
/**
* Create an iterator for a 32-bit multihashmap.
* The iterator can be used to retrieve all the elements in the multihashma
p
* one by one, without having to handle all elements at once (in contrast t
o
* #GNUNET_CONTAINER_multihashmap32_iterate). Note that the iterator can n
ot be
* used anymore if elements have been removed from 'map' after the creation
of
* the iterator, or 'map' has been destroyed. Adding elements to 'map' may
* result in skipped or repeated elements.
*
* @param map the map to create an iterator for
* @return an iterator over the given multihashmap map
*/
struct GNUNET_CONTAINER_MultiHashMap32Iterator *
GNUNET_CONTAINER_multihashmap32_iterator_create (const struct GNUNET_CONTAI
NER_MultiHashMap32 *map);
/**
* Retrieve the next element from the hash map at the iterator's position.
* If there are no elements left, GNUNET_NO is returned, and 'key' and 'val
ue'
* are not modified.
* This operation is only allowed if no elements have been removed from the
* multihashmap since the creation of 'iter', and the map has not been dest
royed.
* Adding elements may result in repeating or skipping elements.
*
* @param iter the iterator to get the next element from
* @param key pointer to store the key in, can be NULL
* @param value pointer to store the value in, can be NULL
* @return #GNUNET_YES we returned an element,
* #GNUNET_NO if we are out of elements
*/
int
GNUNET_CONTAINER_multihashmap32_iterator_next (struct GNUNET_CONTAINER_Mult
iHashMap32Iterator *iter,
uint32_t *key,
const void **value);
/**
* Destroy a 32-bit multihashmap iterator.
*
* @param iter the iterator to destroy
*/
void
GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_M
ultiHashMapIterator *iter);
/* ******************** doubly-linked list *************** */ /* ******************** doubly-linked list *************** */
/* To avoid mistakes: head->prev == tail->next == NULL */ /* To avoid mistakes: head->prev == tail->next == NULL */
/** /**
* @ingroup dll
* Insert an element at the head of a DLL. Assumes that head, tail and * Insert an element at the head of a DLL. Assumes that head, tail and
* element are structs with prev and next fields. * element are structs with prev and next fields.
* *
* @param head pointer to the head of the DLL * @param head pointer to the head of the DLL
* @param tail pointer to the tail of the DLL * @param tail pointer to the tail of the DLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_DLL_insert(head,tail,element) do { \ #define GNUNET_CONTAINER_DLL_insert(head,tail,element) do { \
GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \ GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
(element)->next = (head); \ (element)->next = (head); \
(element)->prev = NULL; \ (element)->prev = NULL; \
if ((tail) == NULL) \ if ((tail) == NULL) \
(tail) = element; \ (tail) = element; \
else \ else \
(head)->prev = element; \ (head)->prev = element; \
(head) = (element); } while (0) (head) = (element); } while (0)
/** /**
* @ingroup dll
* Insert an element at the tail of a DLL. Assumes that head, tail and * Insert an element at the tail of a DLL. Assumes that head, tail and
* element are structs with prev and next fields. * element are structs with prev and next fields.
* *
* @param head pointer to the head of the DLL * @param head pointer to the head of the DLL
* @param tail pointer to the tail of the DLL * @param tail pointer to the tail of the DLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_DLL_insert_tail(head,tail,element) do { \ #define GNUNET_CONTAINER_DLL_insert_tail(head,tail,element) do { \
GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \ GNUNET_assert ( ( (element)->next == NULL) && ((tail) != (element))); \
(element)->prev = (tail); \ (element)->prev = (tail); \
(element)->next = NULL; \ (element)->next = NULL; \
if ((head) == NULL) \ if ((head) == NULL) \
(head) = element; \ (head) = element; \
else \ else \
(tail)->next = element; \ (tail)->next = element; \
(tail) = (element); } while (0) (tail) = (element); } while (0)
/** /**
* @ingroup dll
* Insert an element into a DLL after the given other element. Insert * Insert an element into a DLL after the given other element. Insert
* at the head if the other element is NULL. * at the head if the other element is NULL.
* *
* @param head pointer to the head of the DLL * @param head pointer to the head of the DLL
* @param tail pointer to the tail of the DLL * @param tail pointer to the tail of the DLL
* @param other prior element, NULL for insertion at head of DLL * @param other prior element, NULL for insertion at head of DLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) do { \ #define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) do { \
GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
skipping to change at line 744 skipping to change at line 1329
{ \ { \
(element)->next = (other)->next; \ (element)->next = (other)->next; \
(other)->next = (element); \ (other)->next = (element); \
} \ } \
if (NULL == (element)->next) \ if (NULL == (element)->next) \
(tail) = (element); \ (tail) = (element); \
else \ else \
(element)->next->prev = (element); } while (0) (element)->next->prev = (element); } while (0)
/** /**
* @ingroup dll
* Insert an element into a DLL before the given other element. Insert * Insert an element into a DLL before the given other element. Insert
* at the tail if the other element is NULL. * at the tail if the other element is NULL.
* *
* @param head pointer to the head of the DLL * @param head pointer to the head of the DLL
* @param tail pointer to the tail of the DLL * @param tail pointer to the tail of the DLL
* @param other prior element, NULL for insertion at head of DLL * @param other prior element, NULL for insertion at head of DLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_DLL_insert_before(head,tail,other,element) do { \ #define GNUNET_CONTAINER_DLL_insert_before(head,tail,other,element) do { \
GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \ GNUNET_assert ( ( (element)->prev == NULL) && ((head) != (element))); \
skipping to change at line 772 skipping to change at line 1358
{ \ { \
(element)->prev = (other)->prev; \ (element)->prev = (other)->prev; \
(other)->prev = (element); \ (other)->prev = (element); \
} \ } \
if (NULL == (element)->prev) \ if (NULL == (element)->prev) \
(head) = (element); \ (head) = (element); \
else \ else \
(element)->prev->next = (element); } while (0) (element)->prev->next = (element); } while (0)
/** /**
* Remove an element from a DLL. Assumes * @ingroup dll
* that head, tail and element are structs * Remove an element from a DLL. Assumes that head, tail and
* with prev and next fields. * element point to structs with prev and next fields.
*
* Using the head or tail pointer as the element
* argument does NOT work with this macro.
* Make sure to store head/tail in another pointer
* and use it to remove the head or tail of the list.
* *
* @param head pointer to the head of the DLL * @param head pointer to the head of the DLL
* @param tail pointer to the tail of the DLL * @param tail pointer to the tail of the DLL
* @param element element to remove * @param element element to remove
*/ */
#define GNUNET_CONTAINER_DLL_remove(head,tail,element) do { \ #define GNUNET_CONTAINER_DLL_remove(head,tail,element) do { \
GNUNET_assert ( ( (element)->prev != NULL) || ((head) == (element))); \ GNUNET_assert ( ( (element)->prev != NULL) || ((head) == (element))); \
GNUNET_assert ( ( (element)->next != NULL) || ((tail) == (element))); \ GNUNET_assert ( ( (element)->next != NULL) || ((tail) == (element))); \
if ((element)->prev == NULL) \ if ((element)->prev == NULL) \
(head) = (element)->next; \ (head) = (element)->next; \
skipping to change at line 798 skipping to change at line 1389
(tail) = (element)->prev; \ (tail) = (element)->prev; \
else \ else \
(element)->next->prev = (element)->prev; \ (element)->next->prev = (element)->prev; \
(element)->next = NULL; \ (element)->next = NULL; \
(element)->prev = NULL; } while (0) (element)->prev = NULL; } while (0)
/* ************ Multi-DLL interface, allows DLL elements to be /* ************ Multi-DLL interface, allows DLL elements to be
in multiple lists at the same time *********************** */ in multiple lists at the same time *********************** */
/** /**
* @ingroup dll
* Insert an element at the head of a MDLL. Assumes that head, tail and * Insert an element at the head of a MDLL. Assumes that head, tail and
* element are structs with prev and next fields. * element are structs with prev and next fields.
* *
* @param mdll suffix name for the next and prev pointers in the element * @param mdll suffix name for the next and prev pointers in the element
* @param head pointer to the head of the MDLL * @param head pointer to the head of the MDLL
* @param tail pointer to the tail of the MDLL * @param tail pointer to the tail of the MDLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_MDLL_insert(mdll,head,tail,element) do { \ #define GNUNET_CONTAINER_MDLL_insert(mdll,head,tail,element) do { \
GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element) )); \ GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element) )); \
GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element) )); \ GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element) )); \
(element)->next_##mdll = (head); \ (element)->next_##mdll = (head); \
(element)->prev_##mdll = NULL; \ (element)->prev_##mdll = NULL; \
if ((tail) == NULL) \ if ((tail) == NULL) \
(tail) = element; \ (tail) = element; \
else \ else \
(head)->prev_##mdll = element; \ (head)->prev_##mdll = element; \
(head) = (element); } while (0) (head) = (element); } while (0)
/** /**
* @ingroup dll
* Insert an element at the tail of a MDLL. Assumes that head, tail and * Insert an element at the tail of a MDLL. Assumes that head, tail and
* element are structs with prev and next fields. * element are structs with prev and next fields.
* *
* @param mdll suffix name for the next and prev pointers in the element * @param mdll suffix name for the next and prev pointers in the element
* @param head pointer to the head of the MDLL * @param head pointer to the head of the MDLL
* @param tail pointer to the tail of the MDLL * @param tail pointer to the tail of the MDLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_MDLL_insert_tail(mdll,head,tail,element) do { \ #define GNUNET_CONTAINER_MDLL_insert_tail(mdll,head,tail,element) do { \
GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element) )); \ GNUNET_assert ( ( (element)->prev_##mdll == NULL) && ((head) != (element) )); \
GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element) )); \ GNUNET_assert ( ( (element)->next_##mdll == NULL) && ((tail) != (element) )); \
(element)->prev_##mdll = (tail); \ (element)->prev_##mdll = (tail); \
(element)->next_##mdll = NULL; \ (element)->next_##mdll = NULL; \
if ((head) == NULL) \ if ((head) == NULL) \
(head) = element; \ (head) = element; \
else \ else \
(tail)->next_##mdll = element; \ (tail)->next_##mdll = element; \
(tail) = (element); } while (0) (tail) = (element); } while (0)
/** /**
* @ingroup dll
* Insert an element into a MDLL after the given other element. Insert * Insert an element into a MDLL after the given other element. Insert
* at the head if the other element is NULL. * at the head if the other element is NULL.
* *
* @param mdll suffix name for the next and prev pointers in the element * @param mdll suffix name for the next and prev pointers in the element
* @param head pointer to the head of the MDLL * @param head pointer to the head of the MDLL
* @param tail pointer to the tail of the MDLL * @param tail pointer to the tail of the MDLL
* @param other prior element, NULL for insertion at head of MDLL * @param other prior element, NULL for insertion at head of MDLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_MDLL_insert_after(mdll,head,tail,other,element) do { \ #define GNUNET_CONTAINER_MDLL_insert_after(mdll,head,tail,other,element) do { \
skipping to change at line 867 skipping to change at line 1461
{ \ { \
(element)->next_##mdll = (other)->next_##mdll; \ (element)->next_##mdll = (other)->next_##mdll; \
(other)->next_##mdll = (element); \ (other)->next_##mdll = (element); \
} \ } \
if (NULL == (element)->next_##mdll) \ if (NULL == (element)->next_##mdll) \
(tail) = (element); \ (tail) = (element); \
else \ else \
(element)->next->prev_##mdll = (element); } while (0) (element)->next->prev_##mdll = (element); } while (0)
/** /**
* @ingroup dll
* Insert an element into a MDLL before the given other element. Insert * Insert an element into a MDLL before the given other element. Insert
* at the tail if the other element is NULL. * at the tail if the other element is NULL.
* *
* @param mdll suffix name for the next and prev pointers in the element * @param mdll suffix name for the next and prev pointers in the element
* @param head pointer to the head of the MDLL * @param head pointer to the head of the MDLL
* @param tail pointer to the tail of the MDLL * @param tail pointer to the tail of the MDLL
* @param other prior element, NULL for insertion at head of MDLL * @param other prior element, NULL for insertion at head of MDLL
* @param element element to insert * @param element element to insert
*/ */
#define GNUNET_CONTAINER_MDLL_insert_before(mdll,head,tail,other,element) d o { \ #define GNUNET_CONTAINER_MDLL_insert_before(mdll,head,tail,other,element) d o { \
skipping to change at line 896 skipping to change at line 1491
{ \ { \
(element)->prev_##mdll = (other)->prev_##mdll; \ (element)->prev_##mdll = (other)->prev_##mdll; \
(other)->prev_##mdll = (element); \ (other)->prev_##mdll = (element); \
} \ } \
if (NULL == (element)->prev_##mdll) \ if (NULL == (element)->prev_##mdll) \
(head) = (element); \ (head) = (element); \
else \ else \
(element)->prev_##mdll->next_##mdll = (element); } while (0) (element)->prev_##mdll->next_##mdll = (element); } while (0)
/** /**
* @ingroup dll
* Remove an element from a MDLL. Assumes * Remove an element from a MDLL. Assumes
* that head, tail and element are structs * that head, tail and element are structs
* with prev and next fields. * with prev and next fields.
* *
* @param mdll suffix name for the next and prev pointers in the element * @param mdll suffix name for the next and prev pointers in the element
* @param head pointer to the head of the MDLL * @param head pointer to the head of the MDLL
* @param tail pointer to the tail of the MDLL * @param tail pointer to the tail of the MDLL
* @param element element to remove * @param element element to remove
*/ */
#define GNUNET_CONTAINER_MDLL_remove(mdll,head,tail,element) do { \ #define GNUNET_CONTAINER_MDLL_remove(mdll,head,tail,element) do { \
skipping to change at line 922 skipping to change at line 1518
if ((element)->next_##mdll == NULL) \ if ((element)->next_##mdll == NULL) \
(tail) = (element)->prev_##mdll; \ (tail) = (element)->prev_##mdll; \
else \ else \
(element)->next_##mdll->prev_##mdll = (element)->prev_##mdll; \ (element)->next_##mdll->prev_##mdll = (element)->prev_##mdll; \
(element)->next_##mdll = NULL; \ (element)->next_##mdll = NULL; \
(element)->prev_##mdll = NULL; } while (0) (element)->prev_##mdll = NULL; } while (0)
/* ******************** Heap *************** */ /* ******************** Heap *************** */
/** /**
* @ingroup heap
* Cost by which elements in a heap can be ordered. * Cost by which elements in a heap can be ordered.
*/ */
typedef uint64_t GNUNET_CONTAINER_HeapCostType; typedef uint64_t GNUNET_CONTAINER_HeapCostType;
/* /**
* Heap type, either max or min. Hopefully makes the * @ingroup heap
* implementation more useful. * Heap type, either max or min.
*/ */
enum GNUNET_CONTAINER_HeapOrder enum GNUNET_CONTAINER_HeapOrder
{ {
/** /**
* @ingroup heap
* Heap with the maximum cost at the root. * Heap with the maximum cost at the root.
*/ */
GNUNET_CONTAINER_HEAP_ORDER_MAX, GNUNET_CONTAINER_HEAP_ORDER_MAX,
/** /**
* @ingroup heap
* Heap with the minimum cost at the root. * Heap with the minimum cost at the root.
*/ */
GNUNET_CONTAINER_HEAP_ORDER_MIN GNUNET_CONTAINER_HEAP_ORDER_MIN
}; };
/** /**
* @ingroup heap
* Handle to a Heap. * Handle to a Heap.
*/ */
struct GNUNET_CONTAINER_Heap; struct GNUNET_CONTAINER_Heap;
/** /**
* @ingroup heap
* Handle to a node in a heap. * Handle to a node in a heap.
*/ */
struct GNUNET_CONTAINER_HeapNode; struct GNUNET_CONTAINER_HeapNode;
/** /**
* @ingroup heap
* Create a new heap. * Create a new heap.
* *
* @param order how should the heap be sorted? * @param order how should the heap be sorted?
* @return handle to the heap * @return handle to the heap
*/ */
struct GNUNET_CONTAINER_Heap * struct GNUNET_CONTAINER_Heap *
GNUNET_CONTAINER_heap_create (enum GNUNET_CONTAINER_HeapOrder order); GNUNET_CONTAINER_heap_create (enum GNUNET_CONTAINER_HeapOrder order);
/** /**
* @ingroup heap
* Destroys the heap. Only call on a heap that * Destroys the heap. Only call on a heap that
* is already empty. * is already empty.
* *
* @param heap heap to destroy * @param heap heap to destroy
*/ */
void void
GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *heap); GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *heap);
/** /**
* @ingroup heap
* Get element stored at root of heap. * Get element stored at root of heap.
* *
* @param heap heap to inspect * @param heap heap to inspect
* @return NULL if heap is empty * @return NULL if heap is empty
*/ */
void * void *
GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap); GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap);
/** /**
* @ingroup heap
* Get the current size of the heap * Get the current size of the heap
* *
* @param heap the heap to get the size of * @param heap the heap to get the size of
* @return number of elements stored * @return number of elements stored
*/ */
unsigned int unsigned int
GNUNET_CONTAINER_heap_get_size (const struct GNUNET_CONTAINER_Heap *heap); GNUNET_CONTAINER_heap_get_size (const struct GNUNET_CONTAINER_Heap *heap);
/** /**
* @ingroup heap
* Get the current cost of the node * Get the current cost of the node
* *
* @param node the node to get the cost of * @param node the node to get the cost of
* @return cost of the node * @return cost of the node
*/ */
GNUNET_CONTAINER_HeapCostType GNUNET_CONTAINER_HeapCostType
GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode
*node); *node);
/** /**
* @ingroup heap
* Iterator for heap * Iterator for heap
* *
* @param cls closure * @param cls closure
* @param node internal node of the heap * @param node internal node of the heap
* @param element value stored at the node * @param element value stored at the node
* @param cost cost associated with the node * @param cost cost associated with the node
* @return GNUNET_YES if we should continue to iterate, * @return #GNUNET_YES if we should continue to iterate,
* GNUNET_NO if not. * #GNUNET_NO if not.
*/ */
typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls, typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls,
struct GNUNET_CONTAINER_HeapN ode * struct GNUNET_CONTAINER_HeapN ode *
node, void *element, node, void *element,
GNUNET_CONTAINER_HeapCostType GNUNET_CONTAINER_HeapCostType
cost); cost);
/** /**
* @ingroup heap
* Iterate over all entries in the heap. * Iterate over all entries in the heap.
* *
* @param heap the heap * @param heap the heap
* @param iterator function to call on each entry * @param iterator function to call on each entry
* @param iterator_cls closure for iterator * @param iterator_cls closure for @a iterator
*/ */
void void
GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap, GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap,
GNUNET_CONTAINER_HeapIterator iterator, GNUNET_CONTAINER_HeapIterator iterator,
void *iterator_cls); void *iterator_cls);
/** /**
* @ingroup heap
* Perform a random walk of the tree. The walk is biased * Perform a random walk of the tree. The walk is biased
* towards elements closer to the root of the tree (since * towards elements closer to the root of the tree (since
* each walk starts at the root and ends at a random leaf). * each walk starts at the root and ends at a random leaf).
* The heap internally tracks the current position of the * The heap internally tracks the current position of the
* walk. * walk.
* *
* @param heap heap to walk * @param heap heap to walk
* @return data stored at the next random node in the walk; * @return data stored at the next random node in the walk;
* NULL if the tree is empty. * NULL if the tree is empty.
*/ */
void * void *
GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap); GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap);
/** /**
* @ingroup heap
* Inserts a new element into the heap. * Inserts a new element into the heap.
* *
* @param heap heap to modify * @param heap heap to modify
* @param element element to insert * @param element element to insert
* @param cost cost for the element * @param cost cost for the element
* @return node for the new element * @return node for the new element
*/ */
struct GNUNET_CONTAINER_HeapNode * struct GNUNET_CONTAINER_HeapNode *
GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, void *ele ment, GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, void *ele ment,
GNUNET_CONTAINER_HeapCostType cost); GNUNET_CONTAINER_HeapCostType cost);
/** /**
* @ingroup heap
* Remove root of the heap. * Remove root of the heap.
* *
* @param heap heap to modify * @param heap heap to modify
* @return element data stored at the root node * @return element data stored at the root node
*/ */
void * void *
GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap); GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap);
/** /**
* @ingroup heap
* Removes a node from the heap. * Removes a node from the heap.
* *
* @param node node to remove * @param node node to remove
* @return element data stored at the node, NULL if heap is empty * @return element data stored at the node, NULL if heap is empty
*/ */
void * void *
GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node); GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node);
/** /**
* @ingroup heap
* Updates the cost of any node in the tree * Updates the cost of any node in the tree
* *
* @param heap heap to modify * @param heap heap to modify
* @param node node for which the cost is to be changed * @param node node for which the cost is to be changed
* @param new_cost new cost for the node * @param new_cost new cost for the node
*/ */
void void
GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
struct GNUNET_CONTAINER_HeapNode *node, struct GNUNET_CONTAINER_HeapNode *node,
GNUNET_CONTAINER_HeapCostType new_cost); GNUNET_CONTAINER_HeapCostType new_cost);
/* ******************** Singly linked list *************** */ /* ******************** Singly linked list *************** */
/** /**
* Possible ways for how data stored in the linked list * Possible ways for how data stored in the linked list
* might be allocated. * might be allocated.
* @deprecated use DLL macros
*/ */
enum GNUNET_CONTAINER_SListDisposition enum GNUNET_CONTAINER_SListDisposition
{ {
/** /**
* Single-linked list must copy the buffer. * Single-linked list must copy the buffer.
*/ * @deprecated use DLL macros
*/
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0, GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0,
/** /**
* Data is static, no need to copy or free. * Data is static, no need to copy or free.
*/ * @deprecated use DLL macros
*/
GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2, GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2,
/** /**
* Data is dynamic, do not copy but free when done. * Data is dynamic, do not copy but free when done.
*/ * @deprecated use DLL macros
*/
GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4 GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4
}; };
/** /**
* Handle to a singly linked list * Handle to a singly linked list
* @deprecated use DLL macros
*/ */
struct GNUNET_CONTAINER_SList; struct GNUNET_CONTAINER_SList;
/** /**
* Handle to a singly linked list iterator * Handle to a singly linked list iterator
* @deprecated use DLL macros
*/ */
struct GNUNET_CONTAINER_SList_Iterator struct GNUNET_CONTAINER_SList_Iterator
{ {
/** /**
* Linked list that we are iterating over. * Linked list that we are iterating over.
*/ */
struct GNUNET_CONTAINER_SList *list; struct GNUNET_CONTAINER_SList *list;
/** /**
* Last element accessed. * Last element accessed.
skipping to change at line 1139 skipping to change at line 1758
*/ */
struct GNUNET_CONTAINER_SList_Elem *elem; struct GNUNET_CONTAINER_SList_Elem *elem;
}; };
/** /**
* Add a new element to the list * Add a new element to the list
* @param l list * @param l list
* @param disp memory disposition * @param disp memory disposition
* @param buf payload buffer * @param buf payload buffer
* @param len length of the buffer * @param len length of the buffer
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l, GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l,
enum GNUNET_CONTAINER_SListDisposition disp, enum GNUNET_CONTAINER_SListDisposition disp,
const void *buf, size_t len); const void *buf, size_t len);
/** /**
* Add a new element to the end of the list * Add a new element to the end of the list
* @param l list * @param l list
* @param disp memory disposition * @param disp memory disposition
* @param buf payload buffer * @param buf payload buffer
* @param len length of the buffer * @param len length of the buffer
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l, GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l,
enum GNUNET_CONTAINER_SListDisposition disp , enum GNUNET_CONTAINER_SListDisposition disp ,
const void *buf, size_t len); const void *buf, size_t len);
/** /**
* Append a singly linked list to another * Append a singly linked list to another
* @param dst list to append to * @param dst list to append to
* @param src source * @param src source
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst, GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst,
struct GNUNET_CONTAINER_SList *src); struct GNUNET_CONTAINER_SList *src);
/** /**
* Create a new singly linked list * Create a new singly linked list
* @return the new list * @return the new list
* @deprecated use DLL macros
*/ */
struct GNUNET_CONTAINER_SList * struct GNUNET_CONTAINER_SList *
GNUNET_CONTAINER_slist_create (void); GNUNET_CONTAINER_slist_create (void);
/** /**
* Destroy a singly linked list * Destroy a singly linked list
* @param l the list to be destroyed * @param l the list to be destroyed
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l); GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l);
/** /**
* Return the beginning of a list * Return the beginning of a list
* *
* @param l list * @param l list
* @return iterator pointing to the beginning (by value! Either allocate th e * @return iterator pointing to the beginning (by value! Either allocate th e
* structure on the stack, or use GNUNET_malloc() yourself! All other * structure on the stack, or use GNUNET_malloc() yourself! All other
* functions do take pointer to this struct though) * functions do take pointer to this struct though)
* @deprecated use DLL macros
*/ */
struct GNUNET_CONTAINER_SList_Iterator struct GNUNET_CONTAINER_SList_Iterator
GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l); GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l);
/** /**
* Clear a list * Clear a list
* *
* @param l list * @param l list
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l); GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l);
/** /**
* Check if a list contains a certain element * Check if a list contains a certain element
* @param l list * @param l list
* @param buf payload buffer to find * @param buf payload buffer to find
* @param len length of the payload (number of bytes in buf) * @param len length of the payload (number of bytes in buf)
*
* @return GNUNET_YES if found, GNUNET_NO otherwise * @return GNUNET_YES if found, GNUNET_NO otherwise
* @deprecated use DLL macros
*/ */
int int
GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l, GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l,
const void *buf, size_t len); const void *buf, size_t len);
/** /**
* Check if a list contains a certain element using 'compare' function * Check if a list contains a certain element using 'compare' function
* *
* @param l list * @param l list
* @param buf payload buffer to find * @param buf payload buffer to find
* @param len length of the payload (number of bytes in buf) * @param len length of the payload (number of bytes in buf)
* @param compare comparison function * @param compare comparison function
* *
* @return NULL if the 'buf' could not be found, pointer to the * @return NULL if the 'buf' could not be found, pointer to the
* list element, if found * list element, if found
* @deprecated use DLL macros
*/ */
void * void *
GNUNET_CONTAINER_slist_contains2 (const struct GNUNET_CONTAINER_SList *l, GNUNET_CONTAINER_slist_contains2 (const struct GNUNET_CONTAINER_SList *l,
const void *buf, size_t len, const void *buf, size_t len,
int (*compare)(const void *, const size_t , const void *, const size_t)); int (*compare)(const void *, const size_t , const void *, const size_t));
/** /**
* Count the elements of a list * Count the elements of a list
* @param l list * @param l list
* @return number of elements in the list * @return number of elements in the list
* @deprecated use DLL macros
*/ */
int int
GNUNET_CONTAINER_slist_count (const struct GNUNET_CONTAINER_SList *l); GNUNET_CONTAINER_slist_count (const struct GNUNET_CONTAINER_SList *l);
/** /**
* Remove an element from the list * Remove an element from the list
* @param i iterator that points to the element to be removed * @param i iterator that points to the element to be removed
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i); GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i);
/** /**
* Insert an element into a list at a specific position * Insert an element into a list at a specific position
* @param before where to insert the new element * @param before where to insert the new element
* @param disp memory disposition * @param disp memory disposition
* @param buf payload buffer * @param buf payload buffer
* @param len length of the payload * @param len length of the payload
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *befo re, GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *befo re,
enum GNUNET_CONTAINER_SListDisposition disp, enum GNUNET_CONTAINER_SListDisposition disp,
const void *buf, size_t len); const void *buf, size_t len);
/** /**
* Advance an iterator to the next element * Advance an iterator to the next element
* @param i iterator * @param i iterator
* @return GNUNET_YES on success, GNUNET_NO if the end has been reached * @return GNUNET_YES on success, GNUNET_NO if the end has been reached
* @deprecated use DLL macros
*/ */
int int
GNUNET_CONTAINER_slist_next (struct GNUNET_CONTAINER_SList_Iterator *i); GNUNET_CONTAINER_slist_next (struct GNUNET_CONTAINER_SList_Iterator *i);
/** /**
* Check if an iterator points beyond the end of a list * Check if an iterator points beyond the end of a list
* @param i iterator * @param i iterator
* @return GNUNET_YES if the end has been reached, GNUNET_NO if the iterato r * @return GNUNET_YES if the end has been reached, GNUNET_NO if the iterato r
* points to a valid element * points to a valid element
* @deprecated use DLL macros
*/ */
int int
GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i); GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i);
/** /**
* Retrieve the element at a specific position in a list * Retrieve the element at a specific position in a list
* *
* @param i iterator * @param i iterator
* @param len set to the payload length * @param len set to the payload length
* @return payload * @return payload
* @deprecated use DLL macros
*/ */
void * void *
GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i , GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i ,
size_t * len); size_t *len);
/** /**
* Release an iterator * Release an iterator
* @param i iterator * @param i iterator
* @deprecated use DLL macros
*/ */
void void
GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator *i); GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator *i);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
 End of changes. 161 change blocks. 
126 lines changed or deleted 830 lines changed or added


 gnunet_core_service.h   gnunet_core_service.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009, 2010 Christian Grothoff (and other contributing authors) (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
skipping to change at line 26 skipping to change at line 26
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_core_service.h * @file include/gnunet_core_service.h
* @brief core service; this is the main API for encrypted P2P * @brief core service; this is the main API for encrypted P2P
* communications * communications
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup core encrypted direct communication between peers
* @{
*/ */
#ifndef GNUNET_CORE_SERVICE_H #ifndef GNUNET_CORE_SERVICE_H
#define GNUNET_CORE_SERVICE_H #define GNUNET_CORE_SERVICE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
skipping to change at line 57 skipping to change at line 59
/** /**
* Opaque handle to the service. * Opaque handle to the service.
*/ */
struct GNUNET_CORE_Handle; struct GNUNET_CORE_Handle;
/** /**
* Method called whenever a given peer connects. * Method called whenever a given peer connects.
* *
* @param cls closure * @param cls closure
* @param peer peer identity this notification is about * @param peer peer identity this notification is about
* @param atsi performance data for the connection
* @param atsi_count number of records in 'atsi'
*/ */
typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls, typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls,
const struct const struct GNUNET_PeerId
GNUNET_PeerIdentity * peer entity *peer);
,
const struct
GNUNET_ATS_Information * a
tsi,
unsigned int atsi_count);
/** /**
* Method called whenever a peer disconnects. * Method called whenever a peer disconnects.
* *
* @param cls closure * @param cls closure
* @param peer peer identity this notification is about * @param peer peer identity this notification is about
*/ */
typedef void (*GNUNET_CORE_DisconnectEventHandler) (void *cls, typedef void (*GNUNET_CORE_DisconnectEventHandler) (void *cls,
const struct const struct GNUNET_Pee
GNUNET_PeerIdentity * p rIdentity *peer);
eer);
/** /**
* Functions with this signature are called whenever a message is * Functions with this signature are called whenever a message is
* received or transmitted. * received or transmitted.
* *
* @param cls closure (set from GNUNET_CORE_connect) * @param cls closure (set from #GNUNET_CORE_connect)
* @param peer the other peer involved (sender or receiver, NULL * @param peer the other peer involved (sender or receiver, NULL
* for loopback messages where we are both sender and receiver) * for loopback messages where we are both sender and receiver)
* @param message the actual message * @param message the actual message
* @param atsi performance data for the connection * @return #GNUNET_OK to keep the connection open,
* @param atsi_count number of records in 'atsi' * #GNUNET_SYSERR to close connection to the peer (signal serious e
* @return GNUNET_OK to keep the connection open, rror)
* GNUNET_SYSERR to close it (signal serious error)
*/ */
typedef int (*GNUNET_CORE_MessageCallback) (void *cls, typedef int (*GNUNET_CORE_MessageCallback) (void *cls,
const struct GNUNET_PeerIdentit y * const struct GNUNET_PeerIdentit y *
other, other,
const struct GNUNET_MessageHead er * const struct GNUNET_MessageHead er *
message, message);
const struct GNUNET_ATS_Informa
tion
* atsi, unsigned int atsi_count
);
/** /**
* Message handler. Each struct specifies how to handle on particular * Message handler. Each struct specifies how to handle on particular
* type of message received. * type of message received.
*/ */
struct GNUNET_CORE_MessageHandler struct GNUNET_CORE_MessageHandler
{ {
/** /**
* Function to call for messages of "type". * Function to call for messages of "type".
*/ */
skipping to change at line 124 skipping to change at line 115
/** /**
* Expected size of messages of this type. Use 0 for variable-size. * Expected size of messages of this type. Use 0 for variable-size.
* If non-zero, messages of the given type will be discarded if they * If non-zero, messages of the given type will be discarded if they
* do not have the right size. * do not have the right size.
*/ */
uint16_t expected_size; uint16_t expected_size;
}; };
/** /**
* Function called after GNUNET_CORE_connect has succeeded (or failed * Function called after #GNUNET_CORE_connect has succeeded (or failed
* for good). Note that the private key of the peer is intentionally * for good). Note that the private key of the peer is intentionally
* not exposed here; if you need it, your process should try to read * not exposed here; if you need it, your process should try to read
* the private key file directly (which should work if you are * the private key file directly (which should work if you are
* authorized...). Implementations of this function must not call * authorized...). Implementations of this function must not call
* GNUNET_CORE_disconnect (other than by scheduling a new task to * #GNUNET_CORE_disconnect (other than by scheduling a new task to
* do this later). * do this later).
* *
* @param cls closure * @param cls closure
* @param server handle to the server, NULL if we failed
* @param my_identity ID of this peer, NULL if we failed * @param my_identity ID of this peer, NULL if we failed
*/ */
typedef void (*GNUNET_CORE_StartupCallback) (void *cls, typedef void (*GNUNET_CORE_StartupCallback) (void *cls,
struct GNUNET_CORE_Handle * se const struct GNUNET_PeerIdenti
rver, ty *my_identity);
const struct GNUNET_PeerIdenti
ty *
my_identity);
/** /**
* Connect to the core service. Note that the connection may complete * Connect to the core service. Note that the connection may complete
* (or fail) asynchronously. This function primarily causes the given * (or fail) asynchronously. This function primarily causes the given
* callback notification functions to be invoked whenever the * callback notification functions to be invoked whenever the
* specified event happens. The maximum number of queued * specified event happens. The maximum number of queued
* notifications (queue length) is per client; the queue is shared * notifications (queue length) is per client; the queue is shared
* across all types of notifications. So a slow client that registers * across all types of notifications. So a slow client that registers
* for 'outbound_notify' also risks missing 'inbound_notify' messages. * for @a outbound_notify also risks missing @a inbound_notify messages.
* Certain events (such as connect/disconnect notifications) are not * Certain events (such as connect/disconnect notifications) are not
* subject to queue size limitations. * subject to queue size limitations.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param cls closure for the various callbacks that follow (including hand lers in the handlers array) * @param cls closure for the various callbacks that follow (including hand lers in the handlers array)
* @param init callback to call once we have successfully * @param init callback to call once we have successfully
* connected to the core service * connected to the core service
* @param connects function to call on peer connect, can be NULL * @param connects function to call on peer connect, can be NULL
* @param disconnects function to call on peer disconnect / timeout, can be NULL * @param disconnects function to call on peer disconnect / timeout, can be NULL
* @param inbound_notify function to call for all inbound messages, can be NULL * @param inbound_notify function to call for all inbound messages, can be NULL
* note that the core is allowed to drop notifications about inbound * note that the core is allowed to drop notifications about inbound
* messages if the client does not process them fast enough (for this * messages if the client does not process them fast enough (for this
* notification type, a bounded queue is used) * notification type, a bounded queue is used)
* @param inbound_hdr_only set to GNUNET_YES if inbound_notify will only re * @param inbound_hdr_only set to #GNUNET_YES if @a inbound_notify will onl
ad the y read the
* GNUNET_MessageHeader and hence we do not need to give it * `struct GNUNET_MessageHeader` and hence we do not need to
the full message; give it the full message;
* can be used to improve efficiency, ignored if inbound_not ify is NULL * can be used to improve efficiency, ignored if inbound_not ify is NULL
* note that the core is allowed to drop notifications about inbound * note that the core is allowed to drop notifications about inbound
* messages if the client does not process them fast enough (for this * messages if the client does not process them fast enough (for this
* notification type, a bounded queue is used) * notification type, a bounded queue is used)
* @param outbound_notify function to call for all outbound messages, can b e NULL; * @param outbound_notify function to call for all outbound messages, can b e NULL;
* note that the core is allowed to drop notifications about outbound * note that the core is allowed to drop notifications about outbound
* messages if the client does not process them fast enough (for this * messages if the client does not process them fast enough (for this
* notification type, a bounded queue is used) * notification type, a bounded queue is used)
* @param outbound_hdr_only set to GNUNET_YES if outbound_notify will only * @param outbound_hdr_only set to #GNUNET_YES if @a outbound_notify will o
read the nly read the
* GNUNET_MessageHeader and hence we do not need to give it * `struct GNUNET_MessageHeader` and hence we do not need to
the full message give it the full message
* can be used to improve efficiency, ignored if outbound_no tify is NULL * can be used to improve efficiency, ignored if outbound_no tify is NULL
* note that the core is allowed to drop notifications about outbound * note that the core is allowed to drop notifications about outbound
* messages if the client does not process them fast enough (for this * messages if the client does not process them fast enough (for this
* notification type, a bounded queue is used) * notification type, a bounded queue is used)
* @param handlers callbacks for messages we care about, NULL-terminated * @param handlers callbacks for messages we care about, NULL-terminated
* note that the core is allowed to drop notifications about inbound * note that the core is allowed to drop notifications about inbound
* messages if the client does not process them fast enough (for this * messages if the client does not process them fast enough (for this
* notification type, a bounded queue is used) * notification type, a bounded queue is used)
* @return handle to the core service (only useful for disconnect until 'in it' is called), * @return handle to the core service (only useful for disconnect until @a init is called),
* NULL on error (in this case, init is never called) * NULL on error (in this case, init is never called)
*/ */
struct GNUNET_CORE_Handle * struct GNUNET_CORE_Handle *
GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
void *cls, void *cls,
GNUNET_CORE_StartupCallback init, GNUNET_CORE_StartupCallback init,
GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_ConnectEventHandler connects,
GNUNET_CORE_DisconnectEventHandler disconnects, GNUNET_CORE_DisconnectEventHandler disconnects,
GNUNET_CORE_MessageCallback inbound_notify, GNUNET_CORE_MessageCallback inbound_notify,
int inbound_hdr_only, int inbound_hdr_only,
GNUNET_CORE_MessageCallback outbound_notify, GNUNET_CORE_MessageCallback outbound_notify,
int outbound_hdr_only, int outbound_hdr_only,
const struct GNUNET_CORE_MessageHandler *handlers); const struct GNUNET_CORE_MessageHandler *handlers);
/** /**
* Disconnect from the core service. This function can only * Disconnect from the core service. This function can only
* be called *after* all pending 'GNUNET_CORE_notify_transmit_ready' * be called *after* all pending #GNUNET_CORE_notify_transmit_ready
* requests have been explicitly cancelled. * requests have been explicitly cancelled.
* *
* @param handle connection to core to disconnect * @param handle connection to core to disconnect
*/ */
void void
GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle); GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle);
/** /**
* Handle for a transmission request. * Handle for a transmission request.
*/ */
struct GNUNET_CORE_TransmitHandle; struct GNUNET_CORE_TransmitHandle;
/** /**
* Ask the core to call "notify" once it is ready to transmit the * Ask the core to call @a notify once it is ready to transmit the
* given number of bytes to the specified "target". Must only be * given number of bytes to the specified @a target. Must only be
* called after a connection to the respective peer has been * called after a connection to the respective peer has been
* established (and the client has been informed about this). You may * established (and the client has been informed about this). You may
* have one request of this type pending for each connected peer at * have one request of this type pending for each connected peer at
* any time. If a peer disconnects, the application MUST call * any time. If a peer disconnects, the application MUST call
* "GNUNET_CORE_notify_transmit_ready_cancel" on the respective * #GNUNET_CORE_notify_transmit_ready_cancel on the respective
* transmission request, if one such request is pending. * transmission request, if one such request is pending.
* *
* @param handle connection to core service * @param handle connection to core service
* @param cork is corking allowed for this transmission? * @param cork is corking allowed for this transmission?
* @param priority how important is the message? * @param priority how important is the message?
* @param maxdelay how long can the message wait? * @param maxdelay how long can the message wait?
* @param target who should receive the message, never NULL (can be this pe er's identity for loopback) * @param target who should receive the message, never NULL (can be this pe er's identity for loopback)
* @param notify_size how many bytes of buffer space does notify want? * @param notify_size how many bytes of buffer space does notify want?
* @param notify function to call when buffer space is available; * @param notify function to call when buffer space is available;
* will be called with NULL on timeout; clients MUST cancel * will be called with NULL on timeout; clients MUST cancel
* all pending transmission requests DURING the disconnect * all pending transmission requests DURING the disconnect
* handler * handler
* @param notify_cls closure for notify * @param notify_cls closure for @a notify
* @return non-NULL if the notify callback was queued, * @return non-NULL if the notify callback was queued,
* NULL if we can not even queue the request (request already pendi ng); * NULL if we can not even queue the request (request already pendi ng);
* if NULL is returned, "notify" will NOT be called. * if NULL is returned, "notify" will NOT be called.
*/ */
struct GNUNET_CORE_TransmitHandle * struct GNUNET_CORE_TransmitHandle *
GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int c ork, GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int c ork,
uint32_t priority, uint32_t priority,
struct GNUNET_TIME_Relative maxdelay, struct GNUNET_TIME_Relative maxdelay,
const struct GNUNET_PeerIdentity *target , const struct GNUNET_PeerIdentity *target ,
size_t notify_size, size_t notify_size,
skipping to change at line 256 skipping to change at line 244
/** /**
* Cancel the specified transmission-ready notification. * Cancel the specified transmission-ready notification.
* *
* @param th handle that was returned by "notify_transmit_ready". * @param th handle that was returned by "notify_transmit_ready".
*/ */
void void
GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle
*th); *th);
/** /**
* Iterate over all connected peers. Calls peer_cb with each * Iterate over all connected peers. Calls @a peer_cb with each
* connected peer, and then once with NULL to indicate that all peers * connected peer, and then once with NULL to indicate that all peers
* have been handled. Normal users of the CORE API are not expected * have been handled. Normal users of the CORE API are not expected
* to use this function. It is different in that it truly lists * to use this function. It is different in that it truly lists
* all connections, not just those relevant to the application. This * all connections, not just those relevant to the application. This
* function is used by special applications for diagnostics. This * function is used by special applications for diagnostics. This
* function is NOT part of the 'versioned', 'official' API. * function is NOT part of the 'versioned', 'official' API.
* *
* FIXME: we should probably make it possible to 'cancel' the * FIXME: we should probably make it possible to 'cancel' the
* operation... * operation...
* *
* @param cfg configuration handle * @param cfg configuration handle
* @param peer_cb function to call with the peer information * @param peer_cb function to call with the peer information
* @param cb_cls closure for peer_cb * @param cb_cls closure for @a peer_cb
* @return GNUNET_OK on success, GNUNET_SYSERR on errors * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
*/ */
int int
GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_CORE_ConnectEventHandler peer_cb, GNUNET_CORE_ConnectEventHandler peer_cb,
void *cb_cls); void *cb_cls);
/** /**
* Handle to cancel 'is_peer_connected' test. * Check if the given peer is currently connected. This function is for spe
cial
* cirumstances (GNUNET_TESTBED uses it), normal users of the CORE API are
* expected to track which peers are connected based on the connect/disconn
ect
* callbacks from #GNUNET_CORE_connect. This function is NOT part of the
* 'versioned', 'official' API. This function returns
* synchronously after looking in the CORE API cache.
*
* @param h the core handle
* @param pid the identity of the peer to check if it has been connected to
us
* @return #GNUNET_YES if the peer is connected to us; #GNUNET_NO if not
*/ */
struct GNUNET_CORE_ConnectTestHandle; int
GNUNET_CORE_is_peer_connected_sync (const struct GNUNET_CORE_Handle *h,
/** const struct GNUNET_PeerIdentity *pid);
* Check if the given peer is currently connected and return information
* about the session if so. This function is for special cirumstances
* (GNUNET_TESTING uses it), normal users of the CORE API are
* expected to track which peers are connected based on the
* connect/disconnect callbacks from GNUNET_CORE_connect. This
* function is NOT part of the 'versioned', 'official' API.
*
* @param cfg configuration to use
* @param peer the specific peer to check for
* @param peer_cb function to call with the peer information
* @param cb_cls closure for peer_cb
* @return handle to cancel the operation
*/
struct GNUNET_CORE_ConnectTestHandle *
GNUNET_CORE_is_peer_connected (const struct GNUNET_CONFIGURATION_Handle *cf
g,
const struct GNUNET_PeerIdentity *peer,
GNUNET_CORE_ConnectEventHandler peer_cb,
void *cb_cls);
/** /**
* Abort 'is_connected' test operation. * Create a message queue for sending messages to a peer with CORE.
* * Messages may only be queued with #GNUNET_MQ_send once the init callback
* @param cth handle for operation to cancel has
*/ * been called for the given handle.
void * There must only be one queue per peer for each core handle.
GNUNET_CORE_is_peer_connected_cancel (struct GNUNET_CORE_ConnectTestHandle * The message queue can only be used to transmit messages,
*cth); * not to receive them.
*
* @param h the core handle
* @param target the target peer for this queue, may not be NULL
* @return a message queue for sending messages over the core handle
* to the target peer
*/
struct GNUNET_MQ_Handle *
GNUNET_CORE_mq_create (struct GNUNET_CORE_Handle *h,
const struct GNUNET_PeerIdentity *target);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group core */
/* ifndef GNUNET_CORE_SERVICE_H */ /* ifndef GNUNET_CORE_SERVICE_H */
#endif #endif
/* end of gnunet_core_service.h */ /* end of gnunet_core_service.h */
 End of changes. 26 change blocks. 
79 lines changed or deleted 68 lines changed or added


 gnunet_crypto_lib.h   gnunet_crypto_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 Christian Grothoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 30 skipping to change at line 30
/** /**
* @file include/gnunet_crypto_lib.h * @file include/gnunet_crypto_lib.h
* @brief cryptographic primitives for GNUnet * @brief cryptographic primitives for GNUnet
* *
* @author Christian Grothoff * @author Christian Grothoff
* @author Krista Bennett * @author Krista Bennett
* @author Gerd Knorr <kraxel@bytesex.org> * @author Gerd Knorr <kraxel@bytesex.org>
* @author Ioana Patrascu * @author Ioana Patrascu
* @author Tzvetan Horozov * @author Tzvetan Horozov
*
* @defgroup crypto Cryptographic operations
* @defgroup hash Hashing and operations on hashes
*/ */
#ifndef GNUNET_CRYPTO_LIB_H #ifndef GNUNET_CRYPTO_LIB_H
#define GNUNET_CRYPTO_LIB_H #define GNUNET_CRYPTO_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/**
* @brief A 512-bit hashcode
*/
struct GNUNET_HashCode;
/**
* The identity of the host (wraps the signing key of the peer).
*/
struct GNUNET_PeerIdentity;
#include "gnunet_common.h" #include "gnunet_common.h"
#include "gnunet_scheduler_lib.h" #include "gnunet_scheduler_lib.h"
/** /**
* Desired quality level for cryptographic operations. * @brief A 512-bit hashcode
*/
struct GNUNET_HashCode
{
uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
};
/**
* Maximum length of an ECC signature.
* Note: round up to multiple of 8 minus 2 for alignment.
*/
#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
/**
* Desired quality level for random numbers.
* @ingroup crypto
*/ */
enum GNUNET_CRYPTO_Quality enum GNUNET_CRYPTO_Quality
{ {
/** /**
* No good quality of the operation is needed (i.e., * No good quality of the operation is needed (i.e.,
* random numbers can be pseudo-random). * random numbers can be pseudo-random).
* @ingroup crypto
*/ */
GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_QUALITY_WEAK,
/** /**
* High-quality operations are desired. * High-quality operations are desired.
* @ingroup crypto
*/ */
GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_QUALITY_STRONG,
/** /**
* Randomness for IVs etc. is required. * Randomness for IVs etc. is required.
* @ingroup crypto
*/ */
GNUNET_CRYPTO_QUALITY_NONCE GNUNET_CRYPTO_QUALITY_NONCE
}; };
/** /**
* @brief length of the sessionkey in bytes (256 BIT sessionkey) * @brief length of the sessionkey in bytes (256 BIT sessionkey)
*/ */
#define GNUNET_CRYPTO_AES_KEY_LENGTH (256/8) #define GNUNET_CRYPTO_AES_KEY_LENGTH (256/8)
/** /**
* @brief Length of RSA encrypted data (2048 bit)
*
* We currently do not handle encryption of data
* that can not be done in a single call to the
* RSA methods (read: large chunks of data).
* We should never need that, as we can use
* the GNUNET_CRYPTO_hash for larger pieces of data for signing,
* and for encryption, we only need to encode sessionkeys!
*/
#define GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH 256
/**
* Length of an RSA KEY (n,e,len), 2048 bit (=256 octests) key n, 2 byte e
*/
#define GNUNET_CRYPTO_RSA_KEY_LENGTH 258
/**
* Length of a hash value * Length of a hash value
*/ */
#define GNUNET_CRYPTO_HASH_LENGTH (512/8) #define GNUNET_CRYPTO_HASH_LENGTH (512/8)
/** /**
* Maximum length of an ECC signature. * How many characters (without 0-terminator) are our ASCII-encoded
* Note: round up to multiple of 8 minus 2 for alignment. * public keys (ECDSA/EDDSA/ECDHE).
*/
#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 190
/**
* Maximum length of the public key (q-point, Q = dP) when encoded.
*/
#define GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH 140
/**
* The private information of an RSA key pair.
*/
struct GNUNET_CRYPTO_RsaPrivateKey;
/**
* The private information of an ECC private key.
*/ */
struct GNUNET_CRYPTO_EccPrivateKey; #define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
GNUNET_NETWORK_STRUCT_BEGIN
/**
* GNUnet mandates a certain format for the encoding
* of private RSA key information that is provided
* by the RSA implementations. This format is used
* to serialize a private RSA key (typically when
* writing it to disk).
*/
struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded
{
/**
* Total size of the structure, in bytes, in big-endian!
*/
uint16_t len GNUNET_PACKED;
uint16_t sizen GNUNET_PACKED; /* in big-endian! */
uint16_t sizee GNUNET_PACKED; /* in big-endian! */
uint16_t sized GNUNET_PACKED; /* in big-endian! */
uint16_t sizep GNUNET_PACKED; /* in big-endian! */
uint16_t sizeq GNUNET_PACKED; /* in big-endian! */
uint16_t sizedmp1 GNUNET_PACKED; /* in big-endian! */
uint16_t sizedmq1 GNUNET_PACKED; /* in big-endian! */
/* followed by the actual values */
};
GNUNET_NETWORK_STRUCT_END
/** /**
* @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode. * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode.
*/ */
struct GNUNET_CRYPTO_HashAsciiEncoded struct GNUNET_CRYPTO_HashAsciiEncoded
{ {
unsigned char encoding[104]; unsigned char encoding[104];
}; };
/**
* @brief 0-terminated ASCII encoding of a 'struct GNUNET_ShortHashCode'.
*/
struct GNUNET_CRYPTO_ShortHashAsciiEncoded
{
unsigned char short_encoding[53];
};
/**
* @brief an RSA signature
*/
struct GNUNET_CRYPTO_RsaSignature
{
unsigned char sig[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH];
};
GNUNET_NETWORK_STRUCT_BEGIN GNUNET_NETWORK_STRUCT_BEGIN
/** /**
* @brief header of what an RSA signature signs * @brief header of what an ECC signature signs
* this must be followed by "size - 8" bytes of * this must be followed by "size - 8" bytes of
* the actual signed data * the actual signed data
*/ */
struct GNUNET_CRYPTO_RsaSignaturePurpose struct GNUNET_CRYPTO_EccSignaturePurpose
{ {
/** /**
* How many bytes does this signature sign? * How many bytes does this signature sign?
* (including this purpose header); in network * (including this purpose header); in network
* byte order (!). * byte order (!).
*/ */
uint32_t size GNUNET_PACKED; uint32_t size GNUNET_PACKED;
/** /**
* What does this signature vouch for? This * What does this signature vouch for? This
* must contain a GNUNET_SIGNATURE_PURPOSE_XXX * must contain a GNUNET_SIGNATURE_PURPOSE_XXX
* constant (from gnunet_signatures.h). In * constant (from gnunet_signatures.h). In
* network byte order! * network byte order!
*/ */
uint32_t purpose GNUNET_PACKED; uint32_t purpose GNUNET_PACKED;
}; };
/** /**
* @brief A public key. * @brief an ECC signature using EdDSA.
* See https://gnunet.org/ed25519
*/ */
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded struct GNUNET_CRYPTO_EddsaSignature
{ {
/** /**
* In big-endian, must be GNUNET_CRYPTO_RSA_KEY_LENGTH+4 * R value.
*/ */
uint16_t len GNUNET_PACKED; unsigned char r[256 / 8];
/** /**
* Size of n in key; in big-endian! * S value.
*/ */
uint16_t sizen GNUNET_PACKED; unsigned char s[256 / 8];
};
/**
* @brief an ECC signature using ECDSA
*/
struct GNUNET_CRYPTO_EcdsaSignature
{
/** /**
* The key itself, contains n followed by e. * R value.
*/ */
unsigned char key[GNUNET_CRYPTO_RSA_KEY_LENGTH]; unsigned char r[256 / 8];
/** /**
* Padding (must be 0) * S value.
*/ */
uint16_t padding GNUNET_PACKED; unsigned char s[256 / 8];
}; };
/** /**
* RSA Encrypted data. * Public ECC key (always for Curve25519) encoded in a format suitable
* for network transmission and EdDSA signatures.
*/ */
struct GNUNET_CRYPTO_RsaEncryptedData struct GNUNET_CRYPTO_EddsaPublicKey
{ {
unsigned char encoding[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH]; /**
* Q consists of an x- and a y-value, each mod p (256 bits), given
* here in affine coordinates and Ed25519 standard compact format.
*/
unsigned char q_y[256 / 8];
}; };
/** /**
* @brief header of what an ECC signature signs * Public ECC key (always for Curve25519) encoded in a format suitable
* this must be followed by "size - 8" bytes of * for network transmission and ECDSA signatures.
* the actual signed data
*/ */
struct GNUNET_CRYPTO_EccSignaturePurpose struct GNUNET_CRYPTO_EcdsaPublicKey
{ {
/** /**
* How many bytes does this signature sign? * Q consists of an x- and a y-value, each mod p (256 bits), given
* (including this purpose header); in network * here in affine coordinates and Ed25519 standard compact format.
* byte order (!).
*/
uint32_t size GNUNET_PACKED;
/**
* What does this signature vouch for? This
* must contain a GNUNET_SIGNATURE_PURPOSE_XXX
* constant (from gnunet_signatures.h). In
* network byte order!
*/ */
uint32_t purpose GNUNET_PACKED; unsigned char q_y[256 / 8];
}; };
/** /**
* @brief an ECC signature * The identity of the host (wraps the signing key of the peer).
*/ */
struct GNUNET_CRYPTO_EccSignature struct GNUNET_PeerIdentity
{ {
/** struct GNUNET_CRYPTO_EddsaPublicKey public_key;
* Overall size of the signature data. };
*/
uint16_t size;
/**
* Public ECC key (always for Curve25519) encoded in a format suitable
* for network transmission and encryption (ECDH),
* See http://cr.yp.to/ecdh.html
*/
struct GNUNET_CRYPTO_EcdhePublicKey
{
/** /**
* S-expression, padded with zeros. * Q consists of an x- and a y-value, each mod p (256 bits), given
* here in affine coordinates and Ed25519 standard compact format.
*/ */
char sexpr[GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH]; unsigned char q_y[256 / 8];
}; };
/** /**
* Public ECC key (always for NIST P-521) encoded in a format suitable * Private ECC key encoded for transmission. To be used only for ECDH
* for network transmission as created using 'gcry_sexp_sprint'. * key exchange (ECDHE to be precise).
*/ */
struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded struct GNUNET_CRYPTO_EcdhePrivateKey
{ {
/** /**
* Size of the encoding, in network byte order. * d is a value mod n, where n has at most 256 bits.
*/ */
uint16_t size; unsigned char d[256 / 8];
/** };
* Actual length of the q-point binary encoding.
*/
uint16_t len;
/**
* Private ECC key encoded for transmission. To be used only for ECDSA
* signatures.
*/
struct GNUNET_CRYPTO_EcdsaPrivateKey
{
/** /**
* 0-padded q-point in binary encoding (GCRYPT_MPI_FMT_USG). * d is a value mod n, where n has at most 256 bits.
*/ */
unsigned char key[GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH]; unsigned char d[256 / 8];
}; };
struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded /**
* Private ECC key encoded for transmission. To be used only for EdDSA
* signatures.
*/
struct GNUNET_CRYPTO_EddsaPrivateKey
{ {
/** /**
* Overall size of the private key. * d is a value mod n, where n has at most 256 bits.
*/ */
uint16_t size; unsigned char d[256 / 8];
/* followd by S-expression, opaque to applications */
/* FIXME: consider defining padding to make this a fixed-size struct */
}; };
/** /**
* @brief type for session keys * @brief type for session keys
*/ */
struct GNUNET_CRYPTO_AesSessionKey struct GNUNET_CRYPTO_SymmetricSessionKey
{ {
/** /**
* Actual key. * Actual key for AES.
*/ */
unsigned char key[GNUNET_CRYPTO_AES_KEY_LENGTH]; unsigned char aes_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
/** /**
* checksum! * Actual key for TwoFish.
*/ */
uint32_t crc32 GNUNET_PACKED; unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
}; };
GNUNET_NETWORK_STRUCT_END GNUNET_NETWORK_STRUCT_END
/** /**
* @brief IV for sym cipher * @brief IV for sym cipher
* *
* NOTE: must be smaller (!) in size than the * NOTE: must be smaller (!) in size than the
* struct GNUNET_HashCode. * `struct GNUNET_HashCode`.
*/ */
struct GNUNET_CRYPTO_AesInitializationVector struct GNUNET_CRYPTO_SymmetricInitializationVector
{ {
unsigned char iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
}; };
/** /**
* @brief type for (message) authentication keys * @brief type for (message) authentication keys
*/ */
struct GNUNET_CRYPTO_AuthKey struct GNUNET_CRYPTO_AuthKey
{ {
unsigned char key[GNUNET_CRYPTO_HASH_LENGTH]; unsigned char key[GNUNET_CRYPTO_HASH_LENGTH];
}; };
/* **************** Functions and Macros ************* */ /* **************** Functions and Macros ************* */
/** /**
* Seed a weak random generator. Only GNUNET_CRYPTO_QUALITY_WEAK-mode gener * @ingroup crypto
ator * Seed a weak random generator. Only #GNUNET_CRYPTO_QUALITY_WEAK-mode gene
rator
* can be seeded. * can be seeded.
* *
* @param seed the seed to use * @param seed the seed to use
*/ */
void void
GNUNET_CRYPTO_seed_weak_random (int32_t seed); GNUNET_CRYPTO_seed_weak_random (int32_t seed);
/** /**
* Perform an incremental step in a CRC16 (for TCP/IP) calculation. * Perform an incremental step in a CRC16 (for TCP/IP) calculation.
* *
* @param sum current sum, initially 0 * @param sum current sum, initially 0
* @param buf buffer to calculate CRC over (must be 16-bit aligned) * @param buf buffer to calculate CRC over (must be 16-bit aligned)
* @param len number of bytes in hdr, must be multiple of 2 * @param len number of bytes in @a buf, must be multiple of 2
* @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finis
to get actual crc16) h to get actual crc16)
*/ */
uint32_t uint32_t
GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
/** /**
* Convert results from GNUNET_CRYPTO_crc16_step to final crc16. * Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
* *
* @param sum cummulative sum * @param sum cummulative sum
* @return crc16 value * @return crc16 value
*/ */
uint16_t uint16_t
GNUNET_CRYPTO_crc16_finish (uint32_t sum); GNUNET_CRYPTO_crc16_finish (uint32_t sum);
/** /**
* @ingroup hash
* Calculate the checksum of a buffer in one step. * Calculate the checksum of a buffer in one step.
* *
* @param buf buffer to calculate CRC over (must be 16-bit aligned) * @param buf buffer to calculate CRC over (must be 16-bit aligned)
* @param len number of bytes in hdr, must be multiple of 2 * @param len number of bytes in @a buf, must be multiple of 2
* @return crc16 value * @return crc16 value
*/ */
uint16_t uint16_t
GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
/** /**
* @ingroup hash
* Compute the CRC32 checksum for the first len * Compute the CRC32 checksum for the first len
* bytes of the buffer. * bytes of the buffer.
* *
* @param buf the data over which we're taking the CRC * @param buf the data over which we're taking the CRC
* @param len the length of the buffer in bytes * @param len the length of the buffer @a buf in bytes
* @return the resulting CRC32 checksum * @return the resulting CRC32 checksum
*/ */
int32_t int32_t
GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
/** /**
* @ingroup crypto
* Fill block with a random values.
*
* @param mode desired quality of the random number
* @param buffer the buffer to fill
* @param length buffer length
*/
void
GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, void *buffer,
size_t length);
/**
* @ingroup crypto
* Produce a random value. * Produce a random value.
* *
* @param mode desired quality of the random number * @param mode desired quality of the random number
* @param i the upper limit (exclusive) for the random number * @param i the upper limit (exclusive) for the random number
* @return a random value in the interval [0,i) (exclusive). * @return a random value in the interval [0,@a i) (exclusive).
*/ */
uint32_t uint32_t
GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i);
/** /**
* @ingroup crypto
* Random on unsigned 64-bit values. * Random on unsigned 64-bit values.
* *
* @param mode desired quality of the random number * @param mode desired quality of the random number
* @param max value returned will be in range [0,max) (exclusive) * @param max value returned will be in range [0,@a max) (exclusive)
* @return random 64-bit number * @return random 64-bit number
*/ */
uint64_t uint64_t
GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max);
/** /**
* @ingroup crypto
* Get an array with a random permutation of the * Get an array with a random permutation of the
* numbers 0...n-1. * numbers 0...n-1.
* @param mode GNUNET_CRYPTO_QUALITY_STRONG if the strong (but expensive) P * @param mode #GNUNET_CRYPTO_QUALITY_STRONG if the strong (but expensive)
RNG should be used, GNUNET_CRYPTO_QUALITY_WEAK otherwise PRNG should be used,
* #GNUNET_CRYPTO_QUALITY_WEAK or #GNUNET_CRYPTO_QUALITY_NONCE
otherwise
* @param n the size of the array * @param n the size of the array
* @return the permutation array (allocated from heap) * @return the permutation array (allocated from heap)
*/ */
unsigned int * unsigned int *
GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n);
/** /**
* Create a new Session key. * @ingroup crypto
* Create a new random session key.
* *
* @param key key to initialize * @param key key to initialize
*/ */
void void
GNUNET_CRYPTO_aes_create_session_key (struct GNUNET_CRYPTO_AesSessionKey *k GNUNET_CRYPTO_symmetric_create_session_key (struct GNUNET_CRYPTO_SymmetricS
ey); essionKey *key);
/**
* Check that a new session key is well-formed.
*
* @param key key to check
* @return GNUNET_OK if the key is valid
*/
int
GNUNET_CRYPTO_aes_check_session_key (const struct GNUNET_CRYPTO_AesSessionK
ey
*key);
/** /**
* Encrypt a block with the public key of another * @ingroup crypto
* host that uses the same cyper. * Encrypt a block using a symmetric sessionkey.
* *
* @param block the block to encrypt * @param block the block to encrypt
* @param len the size of the block * @param size the size of the @a block
* @param sessionkey the key used to encrypt * @param sessionkey the key used to encrypt
* @param iv the initialization vector to use, use INITVALUE * @param iv the initialization vector to use, use INITVALUE
* for streams. * for streams.
* @return the size of the encrypted block, -1 for errors * @return the size of the encrypted block, -1 for errors
*/ */
ssize_t ssize_t
GNUNET_CRYPTO_aes_encrypt (const void *block, size_t len, GNUNET_CRYPTO_symmetric_encrypt (const void *block, size_t size,
const struct GNUNET_CRYPTO_AesSessionKey *sessio const struct GNUNET_CRYPTO_SymmetricSessio
nkey, nKey *sessionkey,
const struct GNUNET_CRYPTO_AesInitializationVect const struct GNUNET_CRYPTO_SymmetricInitia
or lizationVector *iv,
*iv, void *result); void *result);
/** /**
* Decrypt a given block with the sessionkey. * @ingroup crypto
* Decrypt a given block using a symmetric sessionkey.
* *
* @param block the data to decrypt, encoded as returned by encrypt * @param block the data to decrypt, encoded as returned by encrypt
* @param size how big is the block? * @param size how big is the block?
* @param sessionkey the key used to decrypt * @param sessionkey the key used to decrypt
* @param iv the initialization vector to use * @param iv the initialization vector to use
* @param result address to store the result at * @param result address to store the result at
* @return -1 on failure, size of decrypted block on success * @return -1 on failure, size of decrypted block on success
*/ */
ssize_t ssize_t
GNUNET_CRYPTO_aes_decrypt (const void *block, size_t size, GNUNET_CRYPTO_symmetric_decrypt (const void *block, size_t size,
const struct GNUNET_CRYPTO_AesSessionKey *sessio const struct GNUNET_CRYPTO_SymmetricSessio
nkey, nKey *sessionkey,
const struct GNUNET_CRYPTO_AesInitializationVect const struct GNUNET_CRYPTO_SymmetricInitia
or lizationVector *iv,
*iv, void *result); void *result);
/** /**
* @ingroup crypto
* @brief Derive an IV * @brief Derive an IV
* @param iv initialization vector * @param iv initialization vector
* @param skey session key * @param skey session key
* @param salt salt for the derivation * @param salt salt for the derivation
* @param salt_len size of the salt * @param salt_len size of the @a salt
* @param ... pairs of void * & size_t for context chunks, terminated by NU LL * @param ... pairs of void * & size_t for context chunks, terminated by NU LL
*/ */
void void
GNUNET_CRYPTO_aes_derive_iv (struct GNUNET_CRYPTO_AesInitializationVector * GNUNET_CRYPTO_symmetric_derive_iv (struct GNUNET_CRYPTO_SymmetricInitializa
iv, tionVector *iv,
const struct GNUNET_CRYPTO_AesSessionKey *skey const struct GNUNET_CRYPTO_SymmetricSess
, ionKey *skey,
const void *salt, size_t salt_len, ...); const void *salt,
size_t salt_len, ...);
/** /**
* @brief Derive an IV * @brief Derive an IV
* @param iv initialization vector * @param iv initialization vector
* @param skey session key * @param skey session key
* @param salt salt for the derivation * @param salt salt for the derivation
* @param salt_len size of the salt * @param salt_len size of the @a salt
* @param argp pairs of void * & size_t for context chunks, terminated by N ULL * @param argp pairs of void * & size_t for context chunks, terminated by N ULL
*/ */
void void
GNUNET_CRYPTO_aes_derive_iv_v (struct GNUNET_CRYPTO_AesInitializationVector GNUNET_CRYPTO_symmetric_derive_iv_v (struct GNUNET_CRYPTO_SymmetricInitiali
*iv, zationVector *iv,
const struct GNUNET_CRYPTO_AesSessionKey *sk const struct GNUNET_CRYPTO_SymmetricSe
ey, ssionKey *skey,
const void *salt, size_t salt_len, va_list a const void *salt,
rgp); size_t salt_len,
va_list argp);
/** /**
* @ingroup hash
* Convert hash to ASCII encoding. * Convert hash to ASCII encoding.
* @param block the hash code * @param block the hash code
* @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsci iEncoded can be * @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsci iEncoded can be
* safely cast to char*, a '\\0' termination is set). * safely cast to char*, a '\\0' termination is set).
*/ */
void void
GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode * block, GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode * block,
struct GNUNET_CRYPTO_HashAsciiEncoded *result); struct GNUNET_CRYPTO_HashAsciiEncoded *result);
/** /**
* Convert short hash to ASCII encoding. * @ingroup hash
*
* @param block the hash code
* @param result where to store the encoding (struct GNUNET_CRYPTO_ShortHas
hAsciiEncoded can be
* safely cast to char*, a '\\0' termination is set).
*/
void
GNUNET_CRYPTO_short_hash_to_enc (const struct GNUNET_CRYPTO_ShortHashCode *
block,
struct GNUNET_CRYPTO_ShortHashAsciiEncoded
*result);
/**
* Convert ASCII encoding back to a 'struct GNUNET_HashCode' * Convert ASCII encoding back to a 'struct GNUNET_HashCode'
* *
* @param enc the encoding * @param enc the encoding
* @param enclen number of characters in 'enc' (without 0-terminator, which * @param enclen number of characters in @a enc (without 0-terminator, whic
can be missing) h can be missing)
* @param result where to store the GNUNET_CRYPTO_hash code * @param result where to store the hash code
* @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong enco * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong en
ding coding
*/ */
int int
GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen, GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen,
struct GNUNET_HashCode * result); struct GNUNET_HashCode *result);
/**
* Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash'
*
* @param enc the encoding
* @param enclen number of characters in 'enc' (without 0-terminator, which
can be missing)
* @param result where to store the GNUNET_CRYPTO_hash code
* @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong enco
ding
*/
int
GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
struct GNUNET_CRYPTO_ShortHashCode *
result);
/** /**
* Convert ASCII encoding back to struct GNUNET_HashCode * @ingroup hash
* Convert ASCII encoding back to `struct GNUNET_HashCode`
* *
* @param enc the encoding * @param enc the encoding
* @param result where to store the hash code * @param result where to store the hash code
* @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong enco ding * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong en coding
*/ */
#define GNUNET_CRYPTO_hash_from_string(enc, result) \ #define GNUNET_CRYPTO_hash_from_string(enc, result) \
GNUNET_CRYPTO_hash_from_string2 (enc, strlen(enc), result) GNUNET_CRYPTO_hash_from_string2 (enc, strlen(enc), result)
/** /**
* Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash' * @ingroup hash
* *
* @param enc the encoding * Compute the distance between 2 hashcodes. The
* @param result where to store the GNUNET_CRYPTO_ShortHash * computation must be fast, not involve @a a[0] or @a a[4] (they're used
* @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong enco * elsewhere), and be somewhat consistent. And of course, the result
ding * should be a positive number.
*/
#define GNUNET_CRYPTO_short_hash_from_string(enc, result) \
GNUNET_CRYPTO_short_hash_from_string2 (enc, strlen(enc), result)
/**
* Compare function for ShortHashCodes, producing a total ordering
* of all hashcodes.
*
* @param h1 some hash code
* @param h2 some hash code
* @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
*/
int
GNUNET_CRYPTO_short_hash_cmp (const struct GNUNET_CRYPTO_ShortHashCode * h1
,
const struct GNUNET_CRYPTO_ShortHashCode * h2
);
/**
* Compute the distance between 2 hashcodes.
* The computation must be fast, not involve
* a.a or a.e (they're used elsewhere), and
* be somewhat consistent. And of course, the
* result should be a positive number.
* *
* @param a some hash code * @param a some hash code
* @param b some hash code * @param b some hash code
* @return number between 0 and UINT32_MAX * @return number between 0 and UINT32_MAX
*/ */
uint32_t uint32_t
GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode * a, GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode *a,
const struct GNUNET_HashCode * b); const struct GNUNET_HashCode *b);
/** /**
* @ingroup hash
* Compute hash of a given block. * Compute hash of a given block.
* *
* @param block the data to hash * @param block the data to hash
* @param size size of the block * @param size size of the @a block
* @param ret pointer to where to write the hashcode * @param ret pointer to where to write the hashcode
*/ */
void void
GNUNET_CRYPTO_hash (const void *block, size_t size, struct GNUNET_HashCode * ret); GNUNET_CRYPTO_hash (const void *block, size_t size, struct GNUNET_HashCode * ret);
/** /**
* Compute short (256-bit) hash of a given block. * @ingroup hash
*
* @param block the data to hash
* @param size size of the block
* @param ret pointer to where to write the hashcode
*/
void
GNUNET_CRYPTO_short_hash (const void *block, size_t size,
struct GNUNET_CRYPTO_ShortHashCode * ret);
/**
* Double short (256-bit) hash to create a long hash.
*
* @param sh short hash to double
* @param dh where to store the (doubled) long hash (not really a hash)
*/
void
GNUNET_CRYPTO_short_hash_double (const struct GNUNET_CRYPTO_ShortHashCode *
sh,
struct GNUNET_HashCode *dh);
/**
* Truncate doubled short hash back to a short hash.
*
* @param dh doubled short hash to reduce again
* @param sh where to store the short hash
* @return GNUNET_OK on success, GNUNET_SYSERR if this was not a
* doubled short hash
*/
int
GNUNET_CRYPTO_short_hash_from_truncation (const struct GNUNET_HashCode *dh,
struct GNUNET_CRYPTO_ShortHashCode
*sh);
/**
* Calculate HMAC of a message (RFC 2104) * Calculate HMAC of a message (RFC 2104)
* *
* @param key secret key * @param key secret key
* @param plaintext input plaintext * @param plaintext input plaintext
* @param plaintext_len length of plaintext * @param plaintext_len length of @a plaintext
* @param hmac where to store the hmac * @param hmac where to store the hmac
*/ */
void void
GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key,
const void *plaintext, size_t plaintext_len, const void *plaintext, size_t plaintext_len,
struct GNUNET_HashCode * hmac); struct GNUNET_HashCode * hmac);
/** /**
* Function called once the hash computation over the * Function called once the hash computation over the
* specified file has completed. * specified file has completed.
* *
* @param cls closure * @param cls closure
* @param res resulting hash, NULL on error * @param res resulting hash, NULL on error
*/ */
typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls, typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls,
const struct GNUNET_Ha const struct GNUNET_Ha
shCode * shCode *res);
res);
/** /**
* Handle to file hashing operation. * Handle to file hashing operation.
*/ */
struct GNUNET_CRYPTO_FileHashContext; struct GNUNET_CRYPTO_FileHashContext;
/** /**
* @ingroup hash
* Compute the hash of an entire file. * Compute the hash of an entire file.
* *
* @param priority scheduling priority to use * @param priority scheduling priority to use
* @param filename name of file to hash * @param filename name of file to hash
* @param blocksize number of bytes to process in one task * @param blocksize number of bytes to process in one task
* @param callback function to call upon completion * @param callback function to call upon completion
* @param callback_cls closure for callback * @param callback_cls closure for @a callback
* @return NULL on (immediate) errror * @return NULL on (immediate) errror
*/ */
struct GNUNET_CRYPTO_FileHashContext * struct GNUNET_CRYPTO_FileHashContext *
GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
const char *filename, size_t blocksize, const char *filename, size_t blocksize,
GNUNET_CRYPTO_HashCompletedCallback callback, GNUNET_CRYPTO_HashCompletedCallback callback,
void *callback_cls); void *callback_cls);
/** /**
* Cancel a file hashing operation. * Cancel a file hashing operation.
* *
* @param fhc operation to cancel (callback must not yet have been invoked) * @param fhc operation to cancel (callback must not yet have been invoked)
*/ */
void void
GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc); GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc);
/** /**
* @ingroup hash
* Create a random hash code. * Create a random hash code.
* *
* @param mode desired quality level * @param mode desired quality level
* @param result hash code that is randomized * @param result hash code that is randomized
*/ */
void void
GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode,
struct GNUNET_HashCode * result); struct GNUNET_HashCode *result);
/** /**
* compute result(delta) = b - a * @ingroup hash
* compute @a result = @a b - @a a
* *
* @param a some hash code * @param a some hash code
* @param b some hash code * @param b some hash code
* @param result set to b - a * @param result set to @a b - @a a
*/ */
void void
GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode * a, GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode *a,
const struct GNUNET_HashCode * b, const struct GNUNET_HashCode *b,
struct GNUNET_HashCode * result); struct GNUNET_HashCode *result);
/** /**
* compute result(b) = a + delta * @ingroup hash
* compute @a result = @a a + @a delta
* *
* @param a some hash code * @param a some hash code
* @param delta some hash code * @param delta some hash code
* @param result set to a + delta * @param result set to @a a + @a delta
*/ */
void void
GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode * a, GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
const struct GNUNET_HashCode * delta, const struct GNUNET_HashCode *delta,
struct GNUNET_HashCode * result); struct GNUNET_HashCode *result);
/** /**
* @ingroup hash
* compute result = a ^ b * compute result = a ^ b
* *
* @param a some hash code * @param a some hash code
* @param b some hash code * @param b some hash code
* @param result set to a ^ b * @param result set to @a a ^ @a b
*/ */
void void
GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode * a, const struct GNUN ET_HashCode * b, GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode * a, const struct GNUN ET_HashCode * b,
struct GNUNET_HashCode * result); struct GNUNET_HashCode * result);
/** /**
* @ingroup hash
* Convert a hashcode into a key. * Convert a hashcode into a key.
* *
* @param hc hash code that serves to generate the key * @param hc hash code that serves to generate the key
* @param skey set to a valid session key * @param skey set to a valid session key
* @param iv set to a valid initialization vector * @param iv set to a valid initialization vector
*/ */
void void
GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode * hc, GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode * hc,
struct GNUNET_CRYPTO_AesSessionKey *skey, struct GNUNET_CRYPTO_SymmetricSessionKey *sk
struct GNUNET_CRYPTO_AesInitializationVector ey,
*iv); struct GNUNET_CRYPTO_SymmetricInitialization
Vector *iv);
/** /**
* @ingroup hash
* Obtain a bit from a hashcode. * Obtain a bit from a hashcode.
* *
* @param code the GNUNET_CRYPTO_hash to index bit-wise * @param code the `struct GNUNET_HashCode` to index bit-wise
* @param bit index into the hashcode, [0...159] * @param bit index into the hashcode, [0...159]
* @return Bit \a bit from hashcode \a code, -1 for invalid index * @return Bit \a bit from hashcode \a code, -1 for invalid index
*/ */
int int
GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode * code, unsigned i GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code,
nt bit); unsigned int bit);
/** /**
* @ingroup hash
* Determine how many low order bits match in two * Determine how many low order bits match in two
* struct GNUNET_HashCodes. i.e. - 010011 and 011111 share * `struct GNUNET_HashCodes`. i.e. - 010011 and 011111 share
* the first two lowest order bits, and therefore the * the first two lowest order bits, and therefore the
* return value is two (NOT XOR distance, nor how many * return value is two (NOT XOR distance, nor how many
* bits match absolutely!). * bits match absolutely!).
* *
* @param first the first hashcode * @param first the first hashcode
* @param second the hashcode to compare first to * @param second the hashcode to compare first to
*
* @return the number of bits that match * @return the number of bits that match
*/ */
unsigned int unsigned int
GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode * first, GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode *first,
const struct GNUNET_HashCode * second); const struct GNUNET_HashCode *second);
/** /**
* @ingroup hash
* Compare function for HashCodes, producing a total ordering * Compare function for HashCodes, producing a total ordering
* of all hashcodes. * of all hashcodes.
* *
* @param h1 some hash code * @param h1 some hash code
* @param h2 some hash code * @param h2 some hash code
* @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2. * @return 1 if @a h1 > @a h2, -1 if @a h1 < @a h2 and 0 if @a h1 == @a h2.
*/ */
int int
GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode * h1, const struct GNU GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
NET_HashCode * h2); const struct GNUNET_HashCode *h2);
/** /**
* @ingroup hash
* Find out which of the two GNUNET_CRYPTO_hash codes is closer to target * Find out which of the two GNUNET_CRYPTO_hash codes is closer to target
* in the XOR metric (Kademlia). * in the XOR metric (Kademlia).
* *
* @param h1 some hash code * @param h1 some hash code
* @param h2 some hash code * @param h2 some hash code
* @param target some hash code * @param target some hash code
* @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2. * @return -1 if @a h1 is closer, 1 if @a h2 is closer and 0 if @a h1== @a h2.
*/ */
int int
GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode * h1, GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1,
const struct GNUNET_HashCode * h2, const struct GNUNET_HashCode *h2,
const struct GNUNET_HashCode * target); const struct GNUNET_HashCode *target);
/** /**
* @ingroup hash
* @brief Derive an authentication key * @brief Derive an authentication key
* @param key authentication key * @param key authentication key
* @param rkey root key * @param rkey root key
* @param salt salt * @param salt salt
* @param salt_len size of the salt * @param salt_len size of the salt
* @param argp pair of void * & size_t for context chunks, terminated by NU LL * @param argp pair of void * & size_t for context chunks, terminated by NU LL
*/ */
void void
GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
const struct GNUNET_CRYPTO_AesSessionKey * rkey, const struct GNUNET_CRYPTO_SymmetricSessio nKey *rkey,
const void *salt, size_t salt_len, const void *salt, size_t salt_len,
va_list argp); va_list argp);
/** /**
* @ingroup hash
* @brief Derive an authentication key * @brief Derive an authentication key
* @param key authentication key * @param key authentication key
* @param rkey root key * @param rkey root key
* @param salt salt * @param salt salt
* @param salt_len size of the salt * @param salt_len size of the salt
* @param ... pair of void * & size_t for context chunks, terminated by NUL L * @param ... pair of void * & size_t for context chunks, terminated by NUL L
*/ */
void void
GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
const struct GNUNET_CRYPTO_AesSessionKey *rk ey, const struct GNUNET_CRYPTO_SymmetricSessionK ey *rkey,
const void *salt, size_t salt_len, ...); const void *salt, size_t salt_len, ...);
/** /**
* @ingroup hash
* @brief Derive key * @brief Derive key
* @param result buffer for the derived key, allocated by caller * @param result buffer for the derived key, allocated by caller
* @param out_len desired length of the derived key * @param out_len desired length of the derived key
* @param xtr_algo hash algorithm for the extraction phase, GCRY_MD_... * @param xtr_algo hash algorithm for the extraction phase, GCRY_MD_...
* @param prf_algo hash algorithm for the expansion phase, GCRY_MD_... * @param prf_algo hash algorithm for the expansion phase, GCRY_MD_...
* @param xts salt * @param xts salt
* @param xts_len length of xts * @param xts_len length of @a xts
* @param skm source key material * @param skm source key material
* @param skm_len length of skm * @param skm_len length of @a skm
* @return GNUNET_YES on success * @param ... pair of void * & size_t for context chunks, terminated by NUL
L
* @return #GNUNET_YES on success
*/ */
int int
GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_alg o, GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_alg o,
const void *xts, size_t xts_len, const void *skm, const void *xts, size_t xts_len, const void *skm,
size_t skm_len, ...); size_t skm_len, ...);
/** /**
* @ingroup hash
* @brief Derive key * @brief Derive key
* @param result buffer for the derived key, allocated by caller * @param result buffer for the derived key, allocated by caller
* @param out_len desired length of the derived key * @param out_len desired length of the derived key
* @param xtr_algo hash algorithm for the extraction phase, GCRY_MD_... * @param xtr_algo hash algorithm for the extraction phase, GCRY_MD_...
* @param prf_algo hash algorithm for the expansion phase, GCRY_MD_... * @param prf_algo hash algorithm for the expansion phase, GCRY_MD_...
* @param xts salt * @param xts salt
* @param xts_len length of xts * @param xts_len length of @a xts
* @param skm source key material * @param skm source key material
* @param skm_len length of skm * @param skm_len length of @a skm
* @param argp va_list of void * & size_t pairs for context chunks * @param argp va_list of void * & size_t pairs for context chunks
* @return GNUNET_YES on success * @return #GNUNET_YES on success
*/ */
int int
GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_a lgo, GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_a lgo,
const void *xts, size_t xts_len, const void *skm, const void *xts, size_t xts_len, const void *skm,
size_t skm_len, va_list argp); size_t skm_len, va_list argp);
/** /**
* @brief Derive key * @brief Derive key
* @param result buffer for the derived key, allocated by caller * @param result buffer for the derived key, allocated by caller
* @param out_len desired length of the derived key * @param out_len desired length of the derived key
* @param xts salt * @param xts salt
* @param xts_len length of xts * @param xts_len length of @a xts
* @param skm source key material * @param skm source key material
* @param skm_len length of skm * @param skm_len length of @a skm
* @param argp va_list of void * & size_t pairs for context chunks * @param argp va_list of void * & size_t pairs for context chunks
* @return GNUNET_YES on success * @return #GNUNET_YES on success
*/ */
int int
GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts, GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts,
size_t xts_len, const void *skm, size_t skm_len, size_t xts_len, const void *skm, size_t skm_len,
va_list argp); va_list argp);
/** /**
* @ingroup hash
* @brief Derive key * @brief Derive key
* @param result buffer for the derived key, allocated by caller * @param result buffer for the derived key, allocated by caller
* @param out_len desired length of the derived key * @param out_len desired length of the derived key
* @param xts salt * @param xts salt
* @param xts_len length of xts * @param xts_len length of @a xts
* @param skm source key material * @param skm source key material
* @param skm_len length of skm * @param skm_len length of @a skm
* @param ... void * & size_t pairs for context chunks * @param ... void * & size_t pairs for context chunks
* @return GNUNET_YES on success * @return #GNUNET_YES on success
*/ */
int int
GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts, GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts,
size_t xts_len, const void *skm, size_t skm_len, ...); size_t xts_len, const void *skm, size_t skm_len, ...);
/** /**
* @ingroup crypto
* Extract the public key for the given private key.
*
* @param priv the private key
* @param pub where to write the public key
*/
void
GNUNET_CRYPTO_ecdsa_key_get_public (const struct GNUNET_CRYPTO_EcdsaPrivate
Key *priv,
struct GNUNET_CRYPTO_EcdsaPublicKey *pu
b);
/**
* @ingroup crypto
* Extract the public key for the given private key.
*
* @param priv the private key
* @param pub where to write the public key
*/
void
GNUNET_CRYPTO_eddsa_key_get_public (const struct GNUNET_CRYPTO_EddsaPrivate
Key *priv,
struct GNUNET_CRYPTO_EddsaPublicKey *pu
b);
/**
* @ingroup crypto
* Extract the public key for the given private key.
*
* @param priv the private key
* @param pub where to write the public key
*/
void
GNUNET_CRYPTO_ecdhe_key_get_public (const struct GNUNET_CRYPTO_EcdhePrivate
Key *priv,
struct GNUNET_CRYPTO_EcdhePublicKey *pu
b);
/**
* Convert a public key to a string. * Convert a public key to a string.
* *
* @param pub key to convert * @param pub key to convert
* @return string representing 'pub' * @return string representing @a pub
*/ */
char * char *
GNUNET_CRYPTO_rsa_public_key_to_string (const struct GNUNET_CRYPTO_RsaPubli GNUNET_CRYPTO_ecdsa_public_key_to_string (const struct GNUNET_CRYPTO_EcdsaP
cKeyBinaryEncoded *pub); ublicKey *pub);
/**
* Convert a public key to a string.
*
* @param pub key to convert
* @return string representing @a pub
*/
char *
GNUNET_CRYPTO_eddsa_public_key_to_string (const struct GNUNET_CRYPTO_EddsaP
ublicKey *pub);
/** /**
* Convert a string representing a public key to a public key. * Convert a string representing a public key to a public key.
* *
* @param enc encoded public key * @param enc encoded public key
* @param enclen number of bytes in enc (without 0-terminator) * @param enclen number of bytes in @a enc (without 0-terminator)
* @param pub where to store the public key * @param pub where to store the public key
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_CRYPTO_rsa_public_key_from_string (const char *enc, GNUNET_CRYPTO_ecdsa_public_key_from_string (const char *enc,
size_t enclen, size_t enclen,
struct GNUNET_CRYPTO_RsaPublicKeyB struct GNUNET_CRYPTO_EcdsaPubli
inaryEncoded *pub); cKey *pub);
/**
* Encode the private key in a format suitable for
* storing it into a file.
* @return encoding of the private key
*/
struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *
GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hos
tkey);
/** /**
* Decode the private key from the data-format back * Convert a string representing a public key to a public key.
* to the "normal", internal format.
* *
* @param buf the buffer where the private key data is stored * @param enc encoded public key
* @param len the length of the data in 'buffer' * @param enclen number of bytes in @a enc (without 0-terminator)
* @return NULL on error * @param pub where to store the public key
* @return #GNUNET_OK on success
*/ */
struct GNUNET_CRYPTO_RsaPrivateKey * int
GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len); GNUNET_CRYPTO_eddsa_public_key_from_string (const char *enc,
size_t enclen,
struct GNUNET_CRYPTO_EddsaPubli
cKey *pub);
/** /**
* @ingroup crypto
* Create a new private key by reading it from a file. If the * Create a new private key by reading it from a file. If the
* files does not exist, create a new key and write it to the * files does not exist, create a new key and write it to the
* file. Caller must free return value. Note that this function * file. Caller must free return value. Note that this function
* can not guarantee that another process might not be trying * can not guarantee that another process might not be trying
* the same operation on the same file at the same time. * the same operation on the same file at the same time.
* If the contents of the file * If the contents of the file
* are invalid the old file is deleted and a fresh key is * are invalid the old file is deleted and a fresh key is
* created. * created.
* *
* @param filename name of file to use for storage * @param filename name of file to use to store the key
* @return new private key, NULL on error (for example, * @return new private key, NULL on error (for example,
* permission denied) * permission denied); free using #GNUNET_free
* @deprecated use 'GNUNET_CRYPTO_rsa_key_create_start' instead
*/ */
struct GNUNET_CRYPTO_RsaPrivateKey * struct GNUNET_CRYPTO_EcdsaPrivateKey *
GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename); GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename);
/** /**
* Handle to cancel private key generation. * @ingroup crypto
*/ * Create a new private key by reading it from a file. If the
struct GNUNET_CRYPTO_RsaKeyGenerationContext; * files does not exist, create a new key and write it to the
* file. Caller must free return value. Note that this function
/** * can not guarantee that another process might not be trying
* Function called upon completion of 'GNUNET_CRYPTO_rsa_key_create_async'. * the same operation on the same file at the same time.
* If the contents of the file
* are invalid the old file is deleted and a fresh key is
* created.
* *
* @param cls closure * @param filename name of file to use to store the key
* @param pk NULL on error, otherwise the private key (which must be free'd * @return new private key, NULL on error (for example,
by the callee) * permission denied); free using #GNUNET_free
* @param emsg NULL on success, otherwise an error message
*/ */
typedef void (*GNUNET_CRYPTO_RsaKeyCallback)(void *cls, struct GNUNET_CRYPTO_EddsaPrivateKey *
struct GNUNET_CRYPTO_RsaPrivate GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename);
Key *pk,
const char *emsg);
/** /**
* Create a new private key by reading it from a file. If the files * @ingroup crypto
* does not exist, create a new key and write it to the file. If the * Create a new private key by reading our peer's key from
* contents of the file are invalid the old file is deleted and a * the file specified in the configuration.
* fresh key is created.
* *
* @param filename name of file to use for storage * @param cfg the configuration to use
* @param cont function to call when done (or on errors) * @return new private key, NULL on error (for example,
* @param cont_cls closure for 'cont' * permission denied); free using #GNUNET_free
* @return handle to abort operation, NULL on fatal errors (cont will not b
e called if NULL is returned)
*/ */
struct GNUNET_CRYPTO_RsaKeyGenerationContext * struct GNUNET_CRYPTO_EddsaPrivateKey *
GNUNET_CRYPTO_rsa_key_create_start (const char *filename, GNUNET_CRYPTO_eddsa_key_create_from_configuration (const struct GNUNET_CONF
GNUNET_CRYPTO_RsaKeyCallback cont, IGURATION_Handle *cfg);
void *cont_cls);
/** /**
* Abort RSA key generation. * @ingroup crypto
* Create a new private key. Caller must free return value.
* *
* @param gc key generation context to abort * @return fresh private key; free using #GNUNET_free
*/ */
void struct GNUNET_CRYPTO_EcdsaPrivateKey *
GNUNET_CRYPTO_rsa_key_create_stop (struct GNUNET_CRYPTO_RsaKeyGenerationCon GNUNET_CRYPTO_ecdsa_key_create (void);
text *gc);
/** /**
* Setup a hostkey file for a peer given the name of the * @ingroup crypto
* configuration file (!). This function is used so that * Create a new private key. Caller must free return value.
* at a later point code can be certain that reading a
* hostkey is fast (for example in time-dependent testcases).
* *
* @param cfg_name name of the configuration file to use * @return fresh private key; free using #GNUNET_free
*/ */
void struct GNUNET_CRYPTO_EddsaPrivateKey *
GNUNET_CRYPTO_rsa_setup_hostkey (const char *cfg_name); GNUNET_CRYPTO_eddsa_key_create (void);
/** /**
* Deterministically (!) create a private key using only the * @ingroup crypto
* given HashCode as input to the PRNG. * Create a new private key. Caller must free return value.
* *
* @param hc "random" input to PRNG * @return fresh private key; free using #GNUNET_free
* @return some private key purely dependent on input
*/ */
struct GNUNET_CRYPTO_RsaPrivateKey * struct GNUNET_CRYPTO_EcdhePrivateKey *
GNUNET_CRYPTO_rsa_key_create_from_hash (const struct GNUNET_HashCode *hc); GNUNET_CRYPTO_ecdhe_key_create (void);
/** /**
* Free memory occupied by the private key. * @ingroup crypto
* Clear memory that was used to store a private key.
* *
* @param key pointer to the memory to free * @param pk location of the key
*/ */
void void
GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key); GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk);
/** /**
* Extract the public key of the host. * @ingroup crypto
* Clear memory that was used to store a private key.
* *
* @param priv the private key * @param pk location of the key
* @param pub where to write the public key
*/ */
void void
GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk);
*priv,
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEn
coded
*pub);
/** /**
* Encrypt a block with the public key of another host that uses the * @ingroup crypto
* same cyper. * Clear memory that was used to store a private key.
* *
* @param block the block to encrypt * @param pk location of the key
* @param size the size of block
* @param publicKey the encoded public key used to encrypt
* @param target where to store the encrypted block
* @return GNUNET_SYSERR on error, GNUNET_OK if ok
*/
int
GNUNET_CRYPTO_rsa_encrypt (const void *block, size_t size,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEnc
oded
*publicKey,
struct GNUNET_CRYPTO_RsaEncryptedData *target);
/**
* Decrypt a given block with the hostkey.
*
* @param key the key to use
* @param block the data to decrypt, encoded as returned by encrypt, not co
nsumed
* @param result pointer to a location where the result can be stored
* @param max how many bytes of a result are expected? Must be exact.
* @return the size of the decrypted block (that is, size) or -1 on error
*/
ssize_t
GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
const struct GNUNET_CRYPTO_RsaEncryptedData *blo
ck,
void *result, size_t max);
/**
* Sign a given block.
*
* @param key private key to use for the signing
* @param purpose what to sign (size, purpose)
* @param sig where to write the signature
* @return GNUNET_SYSERR on error, GNUNET_OK on success
*/
int
GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
const struct GNUNET_CRYPTO_RsaSignaturePurpose *pur
pose,
struct GNUNET_CRYPTO_RsaSignature *sig);
/**
* Verify signature. Note that the caller MUST have already
* checked that "validate->size" bytes are actually available.
*
* @param purpose what is the purpose that validate should have?
* @param validate block to validate (size, purpose, data)
* @param sig signature that is being validated
* @param publicKey public key of the signer
* @return GNUNET_OK if ok, GNUNET_SYSERR if invalid
*/
int
GNUNET_CRYPTO_rsa_verify (uint32_t purpose,
const struct GNUNET_CRYPTO_RsaSignaturePurpose
*validate,
const struct GNUNET_CRYPTO_RsaSignature *sig,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEnco
ded
*publicKey);
/**
* Function called upon completion of 'GNUNET_CRYPTO_ecc_key_create_async'.
*
* @param cls closure
* @param pk NULL on error, otherwise the private key (which must be free'd
by the callee)
* @param emsg NULL on success, otherwise an error message
*/
typedef void (*GNUNET_CRYPTO_EccKeyCallback)(void *cls,
struct GNUNET_CRYPTO_EccPrivate
Key *pk,
const char *emsg);
/**
* Free memory occupied by ECC key
*
* @param privatekey pointer to the memory to free
*/ */
void void
GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *privatekey) ; GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk);
/** /**
* Extract the public key for the given private key. * @ingroup crypto
* Get the shared private key we use for anonymous users.
* *
* @param priv the private key * @return "anonymous" private key; do not free
* @param pub where to write the public key
*/ */
void const struct GNUNET_CRYPTO_EcdsaPrivateKey *
GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey GNUNET_CRYPTO_ecdsa_key_get_anonymous (void);
*priv,
struct GNUNET_CRYPTO_EccPublicKeyBinaryEn
coded *pub);
/** /**
* Convert a public key to a string. * @ingroup crypto
* * Setup a hostkey file for a peer given the name of the
* @param pub key to convert * configuration file (!). This function is used so that
* @return string representing 'pub' * at a later point code can be certain that reading a
* hostkey is fast (for example in time-dependent testcases).
*
* @param cfg_name name of the configuration file to use
*/ */
char * void
GNUNET_CRYPTO_ecc_public_key_to_string (struct GNUNET_CRYPTO_EccPublicKeyBi GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
naryEncoded *pub);
/** /**
* Convert a string representing a public key to a public key. * @ingroup crypto
* Retrieve the identity of the host's peer.
* *
* @param enc encoded public key * @param cfg configuration to use
* @param enclen number of bytes in enc (without 0-terminator) * @param dst pointer to where to write the peer identity
* @param pub where to store the public key * @return #GNUNET_OK on success, #GNUNET_SYSERR if the identity
* @return GNUNET_OK on success * could not be retrieved
*/ */
int int
GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc, GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *
size_t enclen, cfg,
struct GNUNET_CRYPTO_EccPublicKeyB struct GNUNET_PeerIdentity *dst);
inaryEncoded *pub);
/**
* Encode the private key in a format suitable for
* storing it into a file.
*
* @param key key to encode
* @return encoding of the private key.
* The first 4 bytes give the size of the array, as usual.
*/
struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *
GNUNET_CRYPTO_ecc_encode_key (const struct GNUNET_CRYPTO_EccPrivateKey *key
);
/** /**
* Decode the private key from the file-format back * Compare two Peer Identities.
* to the "normal", internal format.
* *
* @param buf the buffer where the private key data is stored * @param first first peer identity
* @param len the length of the data in 'buffer' * @param second second peer identity
* @return NULL on error * @return bigger than 0 if first > second,
* 0 if they are the same
* smaller than 0 if second > first
*/ */
struct GNUNET_CRYPTO_EccPrivateKey * int
GNUNET_CRYPTO_ecc_decode_key (const char *buf, GNUNET_CRYPTO_cmp_peer_identity (const struct GNUNET_PeerIdentity *first,
size_t len); const struct GNUNET_PeerIdentity *second);
/**
* Create a new private key by reading it from a file. If the
* files does not exist, create a new key and write it to the
* file. Caller must free return value. Note that this function
* can not guarantee that another process might not be trying
* the same operation on the same file at the same time.
* If the contents of the file
* are invalid the old file is deleted and a fresh key is
* created.
*
* @return new private key, NULL on error (for example,
* permission denied)
*/
struct GNUNET_CRYPTO_EccPrivateKey *
GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename);
/**
* Handle to cancel private key generation and state for the
* key generation operation.
*/
struct GNUNET_CRYPTO_EccKeyGenerationContext;
/**
* Create a new private key by reading it from a file. If the files
* does not exist, create a new key and write it to the file. If the
* contents of the file are invalid the old file is deleted and a
* fresh key is created.
*
* @param filename name of file to use for storage
* @param cont function to call when done (or on errors)
* @param cont_cls closure for 'cont'
* @return handle to abort operation, NULL on fatal errors (cont will not b
e called if NULL is returned)
*/
struct GNUNET_CRYPTO_EccKeyGenerationContext *
GNUNET_CRYPTO_ecc_key_create_start (const char *filename,
GNUNET_CRYPTO_EccKeyCallback cont,
void *cont_cls);
/** /**
* Abort ECC key generation. * @ingroup crypto
* Derive key material from a public and a private ECC key.
* *
* @param gc key generation context to abort * @param priv private key to use for the ECDH (x)
* @param pub public key to use for the ECDH (yG)
* @param key_material where to write the key material (xyG)
* @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/ */
void int
GNUNET_CRYPTO_ecc_key_create_stop (struct GNUNET_CRYPTO_EccKeyGenerationCon GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
text *gc); const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
struct GNUNET_HashCode *key_material);
/** /**
* Setup a hostkey file for a peer given the name of the * @ingroup crypto
* configuration file (!). This function is used so that * EdDSA sign a given block.
* at a later point code can be certain that reading a
* hostkey is fast (for example in time-dependent testcases).
* *
* @param cfg_name name of the configuration file to use * @param priv private key to use for the signing
* @param purpose what to sign (size, purpose)
* @param sig where to write the signature
* @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/ */
void int
GNUNET_CRYPTO_ecc_setup_hostkey (const char *cfg_name); GNUNET_CRYPTO_eddsa_sign (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
const struct GNUNET_CRYPTO_EccSignaturePurpose *p
urpose,
struct GNUNET_CRYPTO_EddsaSignature *sig);
/** /**
* Sign a given block. * @ingroup crypto
* ECDSA Sign a given block.
* *
* @param key private key to use for the signing * @param priv private key to use for the signing
* @param purpose what to sign (size, purpose) * @param purpose what to sign (size, purpose)
* @param sig where to write the signature * @param sig where to write the signature
* @return GNUNET_SYSERR on error, GNUNET_OK on success * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/ */
int int
GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *key, GNUNET_CRYPTO_ecdsa_sign (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
const struct GNUNET_CRYPTO_EccSignaturePurpose *pur const struct GNUNET_CRYPTO_EccSignaturePurpose *p
pose, urpose,
struct GNUNET_CRYPTO_EccSignature *sig); struct GNUNET_CRYPTO_EcdsaSignature *sig);
/** /**
* Verify signature. * @ingroup crypto
* Verify EdDSA signature.
* *
* @param purpose what is the purpose that the signature should have? * @param purpose what is the purpose that the signature should have?
* @param validate block to validate (size, purpose, data) * @param validate block to validate (size, purpose, data)
* @param sig signature that is being validated * @param sig signature that is being validated
* @param publicKey public key of the signer * @param pub public key of the signer
* @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
*/ */
int int
GNUNET_CRYPTO_ecc_verify (uint32_t purpose, GNUNET_CRYPTO_eddsa_verify (uint32_t purpose,
const struct GNUNET_CRYPTO_EccSignaturePurpose const struct GNUNET_CRYPTO_EccSignaturePurpose
*validate, *validate,
const struct GNUNET_CRYPTO_EccSignature *sig, const struct GNUNET_CRYPTO_EddsaSignature *sig,
const struct GNUNET_CRYPTO_EccPublicKeyBinaryEnco const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
ded ;
*publicKey);
/** /**
* This function should only be called in testcases * @ingroup crypto
* where strong entropy gathering is not desired * Verify ECDSA signature.
* (for example, for hostkey generation).
*/
void
GNUNET_CRYPTO_random_disable_entropy_gathering (void);
/**
* Check if we are using weak random number generation.
* *
* @return GNUNET_YES if weak number generation is on * @param purpose what is the purpose that the signature should have?
* (thus will return YES if 'GNUNET_CRYPTO_random_disable_entropy_g * @param validate block to validate (size, purpose, data)
athering' * @param sig signature that is being validated
* was called previously). * @param pub public key of the signer
* @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
*/ */
int int
GNUNET_CRYPTO_random_is_weak (void); GNUNET_CRYPTO_ecdsa_verify (uint32_t purpose,
const struct GNUNET_CRYPTO_EccSignaturePurpose
*validate,
const struct GNUNET_CRYPTO_EcdsaSignature *sig,
const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
;
/**
* @ingroup crypto
* Derive a private key from a given private key and a label.
* Essentially calculates a private key 'h = H(l,P) * d mod n'
* where n is the size of the ECC group and P is the public
* key associated with the private key 'd'.
*
* @param priv original private key
* @param label label to use for key deriviation
* @param context additional context to use for HKDF of 'h';
* typically the name of the subsystem/application
* @return derived private key
*/
struct GNUNET_CRYPTO_EcdsaPrivateKey *
GNUNET_CRYPTO_ecdsa_private_key_derive (const struct GNUNET_CRYPTO_EcdsaPri
vateKey *priv,
const char *label,
const char *context);
/**
* @ingroup crypto
* Derive a public key from a given public key and a label.
* Essentially calculates a public key 'V = H(l,P) * P'.
*
* @param pub original public key
* @param label label to use for key deriviation
* @param context additional context to use for HKDF of 'h'.
* typically the name of the subsystem/application
* @param result where to write the derived public key
*/
void
GNUNET_CRYPTO_ecdsa_public_key_derive (const struct GNUNET_CRYPTO_EcdsaPubl
icKey *pub,
const char *label,
const char *context,
struct GNUNET_CRYPTO_EcdsaPublicKey
*result);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* ifndef GNUNET_CRYPTO_LIB_H */ /* ifndef GNUNET_CRYPTO_LIB_H */
#endif #endif
 End of changes. 206 change blocks. 
647 lines changed or deleted 523 lines changed or added


 gnunet_datacache_lib.h   gnunet_datacache_lib.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2006, 2009 Christian Grothoff (and other contributing authors) (C) 2006, 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gnunet_datacache_plugin.h   gnunet_datacache_plugin.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2006, 2009 Christian Grothoff (and other contributing authors) (C) 2006, 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gnunet_datastore_plugin.h   gnunet_datastore_plugin.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2009, 2011 Christian Grothoff (and other contributing authors) (C) 2009, 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 87 skipping to change at line 87
* *
* @param cls closure * @param cls closure
* @param key key for the content * @param key key for the content
* @param size number of bytes in data * @param size number of bytes in data
* @param data content stored * @param data content stored
* @param type type of the content * @param type type of the content
* @param priority priority of the content * @param priority priority of the content
* @param anonymity anonymity-level for the content * @param anonymity anonymity-level for the content
* @param expiration expiration time for the content * @param expiration expiration time for the content
* @param uid unique identifier for the datum * @param uid unique identifier for the datum
* * @return #GNUNET_OK to keep the item
* @return GNUNET_OK to keep the item * #GNUNET_NO to delete the item
* GNUNET_NO to delete the item
*/ */
typedef int (*PluginDatumProcessor) (void *cls, const struct GNUNET_HashCod e * key, typedef int (*PluginDatumProcessor) (void *cls, const struct GNUNET_HashCod e * key,
uint32_t size, const void *data, uint32_t size, const void *data,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
uint32_t priority, uint32_t anonymity, uint32_t priority, uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration , struct GNUNET_TIME_Absolute expiration ,
uint64_t uid); uint64_t uid);
/** /**
* Get an estimate of how much space the database is * Get an estimate of how much space the database is
skipping to change at line 114 skipping to change at line 113
*/ */
typedef unsigned long long (*PluginEstimateSize) (void *cls); typedef unsigned long long (*PluginEstimateSize) (void *cls);
/** /**
* Store an item in the datastore. If the item is already present, * Store an item in the datastore. If the item is already present,
* the priorities and replication levels are summed up and the higher * the priorities and replication levels are summed up and the higher
* expiration time and lower anonymity level is used. * expiration time and lower anonymity level is used.
* *
* @param cls closure * @param cls closure
* @param key key for the item * @param key key for the item
* @param size number of bytes in data * @param size number of bytes in @a data
* @param data content stored * @param data content stored
* @param type type of the content * @param type type of the content
* @param priority priority of the content * @param priority priority of the content
* @param anonymity anonymity-level for the content * @param anonymity anonymity-level for the content
* @param replication replication-level for the content * @param replication replication-level for the content
* @param expiration expiration time for the content * @param expiration expiration time for the content
* @param msg set to an error message (on failure) * @param msg set to an error message (on failure)
* @return GNUNET_OK on success, * @return #GNUNET_OK on success,
* GNUNET_SYSERR on failure * #GNUNET_SYSERR on failure
*/ */
typedef int (*PluginPut) (void *cls, const struct GNUNET_HashCode * key, ui nt32_t size, typedef int (*PluginPut) (void *cls, const struct GNUNET_HashCode * key, ui nt32_t size,
const void *data, enum GNUNET_BLOCK_Type type, const void *data, enum GNUNET_BLOCK_Type type,
uint32_t priority, uint32_t anonymity, uint32_t priority, uint32_t anonymity,
uint32_t replication, uint32_t replication,
struct GNUNET_TIME_Absolute expiration, char **ms g); struct GNUNET_TIME_Absolute expiration, char **ms g);
/** /**
* An processor over a set of keys stored in the datastore. * An processor over a set of keys stored in the datastore.
* *
* @param cls closure * @param cls closure
* @param key key in the data store * @param key key in the data store
* @param count how many values are stored under this key in the datastore * @param count how many values are stored under this key in the datastore
*/ */
typedef void (*PluginKeyProcessor) (void *cls, typedef void (*PluginKeyProcessor) (void *cls,
const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *key,
unsigned int count); unsigned int count);
/** /**
* Get all of the keys in the datastore. * Get all of the keys in the datastore.
* *
* @param cls closure * @param cls closure
* @param proc function to call on each key * @param proc function to call on each key
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
*/ */
typedef void (*PluginGetKeys) (void *cls, typedef void (*PluginGetKeys) (void *cls,
PluginKeyProcessor proc, void *proc_cls); PluginKeyProcessor proc, void *proc_cls);
/** /**
* Get one of the results for a particular key in the datastore. * Get one of the results for a particular key in the datastore.
* *
* @param cls closure * @param cls closure
* @param offset offset of the result (modulo num-results); * @param offset offset of the result (modulo num-results);
* specific ordering does not matter for the offset * specific ordering does not matter for the offset
skipping to change at line 170 skipping to change at line 169
* match all values that have the right key). * match all values that have the right key).
* Note that for DBlocks there is no difference * Note that for DBlocks there is no difference
* betwen key and vhash, but for other blocks * betwen key and vhash, but for other blocks
* there may be! * there may be!
* @param type entries of which type are relevant? * @param type entries of which type are relevant?
* Use 0 for any type. * Use 0 for any type.
* @param min find the smallest key that is larger than the given min, * @param min find the smallest key that is larger than the given min,
* NULL for no minimum (return smallest key) * NULL for no minimum (return smallest key)
* @param proc function to call on the matching value; * @param proc function to call on the matching value;
* proc should be called with NULL if there is no result * proc should be called with NULL if there is no result
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
*/ */
typedef void (*PluginGetKey) (void *cls, uint64_t offset, typedef void (*PluginGetKey) (void *cls, uint64_t offset,
const struct GNUNET_HashCode * key, const struct GNUNET_HashCode * key,
const struct GNUNET_HashCode * vhash, const struct GNUNET_HashCode * vhash,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
PluginDatumProcessor proc, void *proc_cls); PluginDatumProcessor proc, void *proc_cls);
/** /**
* Get a random item (additional constraints may apply depending on * Get a random item (additional constraints may apply depending on
* the specific implementation). Calls 'proc' with all values ZERO or * the specific implementation). Calls @a proc with all values ZERO or
* NULL if no item applies, otherwise 'proc' is called once and only * NULL if no item applies, otherwise @a proc is called once and only
* once with an item. * once with an item.
* *
* @param cls closure * @param cls closure
* @param proc function to call the value (once only). * @param proc function to call the value (once only).
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
*/ */
typedef void (*PluginGetRandom) (void *cls, PluginDatumProcessor proc, typedef void (*PluginGetRandom) (void *cls, PluginDatumProcessor proc,
void *proc_cls); void *proc_cls);
/** /**
* Update the priority for a particular key in the datastore. If * Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in * the expiration time in value is different than the time found in
* the datastore, the higher value should be kept. For the * the datastore, the higher value should be kept. For the
* anonymity level, the lower value is to be used. The specified * anonymity level, the lower value is to be used. The specified
* priority should be added to the existing priority, ignoring the * priority should be added to the existing priority, ignoring the
skipping to change at line 209 skipping to change at line 208
* @param cls closure * @param cls closure
* @param uid unique identifier of the datum * @param uid unique identifier of the datum
* @param delta by how much should the priority * @param delta by how much should the priority
* change? If priority + delta < 0 the * change? If priority + delta < 0 the
* priority should be set to 0 (never go * priority should be set to 0 (never go
* negative). * negative).
* @param expire new expiration time should be the * @param expire new expiration time should be the
* MAX of any existing expiration time and * MAX of any existing expiration time and
* this value * this value
* @param msg set to an error message (on error) * @param msg set to an error message (on error)
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
typedef int (*PluginUpdate) (void *cls, uint64_t uid, int delta, typedef int (*PluginUpdate) (void *cls, uint64_t uid, int delta,
struct GNUNET_TIME_Absolute expire, char **msg ); struct GNUNET_TIME_Absolute expire, char **msg );
/** /**
* Select a single item from the datastore at the specified offset * Select a single item from the datastore at the specified offset
* (among those applicable). * (among those applicable).
* *
* @param cls closure * @param cls closure
* @param offset offset of the result (modulo num-results); * @param offset offset of the result (modulo num-results);
* specific ordering does not matter for the offset * specific ordering does not matter for the offset
* @param type entries of which type should be considered? * @param type entries of which type should be considered?
* Must not be zero (ANY). * Must not be zero (ANY).
* @param proc function to call on the matching value * @param proc function to call on the matching value
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
*/ */
typedef void (*PluginGetType) (void *cls, uint64_t offset, typedef void (*PluginGetType) (void *cls, uint64_t offset,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
PluginDatumProcessor proc, void *proc_cls); PluginDatumProcessor proc, void *proc_cls);
/** /**
* Drop database. * Drop database.
* *
* @param cls closure * @param cls closure
*/ */
 End of changes. 11 change blocks. 
16 lines changed or deleted 15 lines changed or added


 gnunet_datastore_service.h   gnunet_datastore_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Christian Grothoff (and o ther contributing authors) (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Christian Grothoff (and o ther contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 84 skipping to change at line 84
* @param drop set to GNUNET_YES to delete all data in datastore (!) * @param drop set to GNUNET_YES to delete all data in datastore (!)
*/ */
void void
GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop); GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop);
/** /**
* Continuation called to notify client about result of the * Continuation called to notify client about result of the
* operation. * operation.
* *
* @param cls closure * @param cls closure
* @param success GNUNET_SYSERR on failure (including timeout/queue drop) * @param success #GNUNET_SYSERR on failure (including timeout/queue drop)
* GNUNET_NO if content was already there * #GNUNET_NO if content was already there
* GNUNET_YES (or other positive value) on success * #GNUNET_YES (or other positive value) on success
* @param min_expiration minimum expiration time required for 0-priority co ntent to be stored * @param min_expiration minimum expiration time required for 0-priority co ntent to be stored
* by the datacache at this time, zero for unknown, forever if we have no * by the datacache at this time, zero for unknown, forever if we have no
* space for 0-priority content * space for 0-priority content
* @param msg NULL on success, otherwise an error message * @param msg NULL on success, otherwise an error message
*/ */
typedef void (*GNUNET_DATASTORE_ContinuationWithStatus) (void *cls, typedef void (*GNUNET_DATASTORE_ContinuationWithStatus) (void *cls,
int32_t success, int32_t success,
struct GNUNET_TIME_ Absolute min_expiration, struct GNUNET_TIME_ Absolute min_expiration,
const char *msg); const char *msg);
skipping to change at line 145 skipping to change at line 145
* @param type type of the content * @param type type of the content
* @param priority priority of the content * @param priority priority of the content
* @param anonymity anonymity-level for the content * @param anonymity anonymity-level for the content
* @param replication how often should the content be replicated to other p eers? * @param replication how often should the content be replicated to other p eers?
* @param expiration expiration time for the content * @param expiration expiration time for the content
* @param queue_priority ranking of this request in the priority queue * @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped * @param max_queue_size at what queue size should this request be dropped
* (if other requests of higher priority are in the queue) * (if other requests of higher priority are in the queue)
* @param timeout timeout for the operation * @param timeout timeout for the operation
* @param cont continuation to call when done * @param cont continuation to call when done
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return NULL if the entry was not queued, otherwise a handle that can be used to * @return NULL if the entry was not queued, otherwise a handle that can be used to
* cancel; note that even if NULL is returned, the callback will be invoked * cancel; note that even if NULL is returned, the callback will be invoked
* (or rather, will already have been invoked) * (or rather, will already have been invoked)
*/ */
struct GNUNET_DATASTORE_QueueEntry * struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid, GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid,
const struct GNUNET_HashCode * key, size_t size, const struct GNUNET_HashCode *key, size_t size,
const void *data, enum GNUNET_BLOCK_Type type, const void *data, enum GNUNET_BLOCK_Type type,
uint32_t priority, uint32_t anonymity, uint32_t priority, uint32_t anonymity,
uint32_t replication, uint32_t replication,
struct GNUNET_TIME_Absolute expiration, struct GNUNET_TIME_Absolute expiration,
unsigned int queue_priority, unsigned int max_queue_s ize, unsigned int queue_priority, unsigned int max_queue_s ize,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_DATASTORE_ContinuationWithStatus cont, GNUNET_DATASTORE_ContinuationWithStatus cont,
void *cont_cls); void *cont_cls);
/** /**
skipping to change at line 178 skipping to change at line 178
* @param rid reservation ID (value of "success" in original continuation * @param rid reservation ID (value of "success" in original continuation
* from the "reserve" function). * from the "reserve" function).
* @param queue_priority ranking of this request in the priority queue * @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped * @param max_queue_size at what queue size should this request be dropped
* (if other requests of higher priority are in the queue) * (if other requests of higher priority are in the queue)
* @param queue_priority ranking of this request in the priority queue * @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped * @param max_queue_size at what queue size should this request be dropped
* (if other requests of higher priority are in the queue) * (if other requests of higher priority are in the queue)
* @param timeout how long to wait at most for a response * @param timeout how long to wait at most for a response
* @param cont continuation to call when done * @param cont continuation to call when done
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return NULL if the entry was not queued, otherwise a handle that can be used to * @return NULL if the entry was not queued, otherwise a handle that can be used to
* cancel; note that even if NULL is returned, the callback will be invoked * cancel; note that even if NULL is returned, the callback will be invoked
* (or rather, will already have been invoked) * (or rather, will already have been invoked)
*/ */
struct GNUNET_DATASTORE_QueueEntry * struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h,
uint32_t rid, unsigned int queue_priority , uint32_t rid, unsigned int queue_priority ,
unsigned int max_queue_size, unsigned int max_queue_size,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_DATASTORE_ContinuationWithStatus c ont, GNUNET_DATASTORE_ContinuationWithStatus c ont,
skipping to change at line 203 skipping to change at line 203
* *
* @param h handle to the datastore * @param h handle to the datastore
* @param uid identifier for the value * @param uid identifier for the value
* @param priority how much to increase the priority of the value * @param priority how much to increase the priority of the value
* @param expiration new expiration value should be MAX of existing and thi s argument * @param expiration new expiration value should be MAX of existing and thi s argument
* @param queue_priority ranking of this request in the priority queue * @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped * @param max_queue_size at what queue size should this request be dropped
* (if other requests of higher priority are in the queue) * (if other requests of higher priority are in the queue)
* @param timeout how long to wait at most for a response * @param timeout how long to wait at most for a response
* @param cont continuation to call when done * @param cont continuation to call when done
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return NULL if the entry was not queued, otherwise a handle that can be used to * @return NULL if the entry was not queued, otherwise a handle that can be used to
* cancel; note that even if NULL is returned, the callback will be invoked * cancel; note that even if NULL is returned, the callback will be invoked
* (or rather, will already have been invoked) * (or rather, will already have been invoked)
*/ */
struct GNUNET_DATASTORE_QueueEntry * struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid, GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid,
uint32_t priority, uint32_t priority,
struct GNUNET_TIME_Absolute expiration, struct GNUNET_TIME_Absolute expiration,
unsigned int queue_priority, unsigned int queue_priority,
unsigned int max_queue_size, unsigned int max_queue_size,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_DATASTORE_ContinuationWithStatus cont, GNUNET_DATASTORE_ContinuationWithStatus cont,
void *cont_cls); void *cont_cls);
/** /**
* Explicitly remove some content from the database. * Explicitly remove some content from the database. @a cont will be
* The "cont"inuation will be called with status * called with status #GNUNET_OK if content was removed, #GNUNET_NO if
* "GNUNET_OK" if content was removed, "GNUNET_NO" * no matching entry was found and #GNUNET_SYSERR on all other types
* if no matching entry was found and "GNUNET_SYSERR" * of errors.
* on all other types of errors.
* *
* @param h handle to the datastore * @param h handle to the datastore
* @param key key for the value * @param key key for the value
* @param size number of bytes in data * @param size number of bytes in @a data
* @param data content stored * @param data content stored
* @param queue_priority ranking of this request in the priority queue * @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped * @param max_queue_size at what queue size should this request be dropped
* (if other requests of higher priority are in the queue) * (if other requests of higher priority are in the queue)
* @param timeout how long to wait at most for a response * @param timeout how long to wait at most for a response
* @param cont continuation to call when done * @param cont continuation to call when done
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return NULL if the entry was not queued, otherwise a handle that can be used to * @return NULL if the entry was not queued, otherwise a handle that can be used to
* cancel; note that even if NULL is returned, the callback will be invoked * cancel; note that even if NULL is returned, the callback will be invoked
* (or rather, will already have been invoked) * (or rather, will already have been invoked)
*/ */
struct GNUNET_DATASTORE_QueueEntry * struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
const struct GNUNET_HashCode * key, size_t size, const struct GNUNET_HashCode * key, size_t size,
const void *data, unsigned int queue_priority, const void *data, unsigned int queue_priority,
unsigned int max_queue_size, unsigned int max_queue_size,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
skipping to change at line 263 skipping to change at line 262
* @param size number of bytes in data * @param size number of bytes in data
* @param data content stored * @param data content stored
* @param type type of the content * @param type type of the content
* @param priority priority of the content * @param priority priority of the content
* @param anonymity anonymity-level for the content * @param anonymity anonymity-level for the content
* @param expiration expiration time for the content * @param expiration expiration time for the content
* @param uid unique identifier for the datum; * @param uid unique identifier for the datum;
* maybe 0 if no unique identifier is available * maybe 0 if no unique identifier is available
*/ */
typedef void (*GNUNET_DATASTORE_DatumProcessor) (void *cls, typedef void (*GNUNET_DATASTORE_DatumProcessor) (void *cls,
const struct GNUNET_HashCo de * key, const struct GNUNET_HashCo de *key,
size_t size, const void *d ata, size_t size, const void *d ata,
enum GNUNET_BLOCK_Type typ e, enum GNUNET_BLOCK_Type typ e,
uint32_t priority, uint32_t priority,
uint32_t anonymity, uint32_t anonymity,
struct GNUNET_TIME_Absolut struct GNUNET_TIME_Absolut
e e expiration,
expiration, uint64_t uid); uint64_t uid);
/** /**
* Get a result for a particular key from the datastore. The processor * Get a result for a particular key from the datastore. The processor
* will only be called once. * will only be called once.
* *
* @param h handle to the datastore * @param h handle to the datastore
* @param offset offset of the result (modulo num-results); set to * @param offset offset of the result (modulo num-results); set to
* a random 64-bit value initially; then increment by * a random 64-bit value initially; then increment by
* one each time; detect that all results have been found by uid * one each time; detect that all results have been found by uid
* being again the first uid ever returned. * being again the first uid ever returned.
* @param key maybe NULL (to match all entries) * @param key maybe NULL (to match all entries)
* @param type desired type, 0 for any * @param type desired type, 0 for any
* @param queue_priority ranking of this request in the priority queue * @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped * @param max_queue_size at what queue size should this request be dropped
* (if other requests of higher priority are in the queue) * (if other requests of higher priority are in the queue)
* @param timeout how long to wait at most for a response * @param timeout how long to wait at most for a response
* @param proc function to call on a matching value; * @param proc function to call on a matching value;
* or with a NULL value if no datum matches * or with a NULL value if no datum matches
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
* @return NULL if the entry was not queued, otherwise a handle that can be used to * @return NULL if the entry was not queued, otherwise a handle that can be used to
* cancel * cancel
*/ */
struct GNUNET_DATASTORE_QueueEntry * struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, uint64_t offse t, GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, uint64_t offse t,
const struct GNUNET_HashCode * key, const struct GNUNET_HashCode *key,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
unsigned int queue_priority, unsigned int queue_priority,
unsigned int max_queue_size, unsigned int max_queue_size,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_DATASTORE_DatumProcessor proc, void *proc_ cls); GNUNET_DATASTORE_DatumProcessor proc, void *proc_ cls);
/** /**
* Get a single zero-anonymity value from the datastore. * Get a single zero-anonymity value from the datastore.
* Note that some implementations can ignore the 'offset' and * Note that some implementations can ignore the 'offset' and
* instead return a random zero-anonymity value. In that case, * instead return a random zero-anonymity value. In that case,
 End of changes. 13 change blocks. 
21 lines changed or deleted 20 lines changed or added


 gnunet_dht_service.h   gnunet_dht_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2004, 2005, 2006, 2008, 2009, 2011 Christian Grothoff (and other contributing authors) (C) 2004-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
skipping to change at line 25 skipping to change at line 25
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_dht_service.h * @file include/gnunet_dht_service.h
* @brief API to the DHT service * @brief API to the DHT service
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup dht Distributed Hash Table
* @{
*/ */
#ifndef GNUNET_DHT_SERVICE_H #ifndef GNUNET_DHT_SERVICE_H
#define GNUNET_DHT_SERVICE_H #define GNUNET_DHT_SERVICE_H
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_block_lib.h" #include "gnunet_block_lib.h"
#include "gnunet_hello_lib.h" #include "gnunet_hello_lib.h"
#ifdef __cplusplus #ifdef __cplusplus
skipping to change at line 67 skipping to change at line 69
/** /**
* Handle to control a find peer operation. * Handle to control a find peer operation.
*/ */
struct GNUNET_DHT_FindPeerHandle; struct GNUNET_DHT_FindPeerHandle;
/** /**
* Options for routing. * Options for routing.
*/ */
enum GNUNET_DHT_RouteOption enum GNUNET_DHT_RouteOption
{ {
/** /**
* Default. Do nothing special. * Default. Do nothing special.
*/ */
GNUNET_DHT_RO_NONE = 0, GNUNET_DHT_RO_NONE = 0,
/** /**
* Each peer along the way should look at 'enc' (otherwise * Each peer along the way should look at 'enc' (otherwise
* only the k-peers closest to the key should look at it). * only the k-peers closest to the key should look at it).
*/ */
GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1, GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1,
/** /**
* We should keep track of the route that the message * We should keep track of the route that the message
* took in the P2P network. * took in the P2P network.
*/ */
GNUNET_DHT_RO_RECORD_ROUTE = 2, GNUNET_DHT_RO_RECORD_ROUTE = 2,
/** /**
* This is a 'FIND-PEER' request, so approximate results are fine. * This is a 'FIND-PEER' request, so approximate results are fine.
*/ */
GNUNET_DHT_RO_FIND_PEER = 4, GNUNET_DHT_RO_FIND_PEER = 4,
/** /**
* Possible message option for query key randomization. * Possible message option for query key randomization.
*/ */
GNUNET_DHT_RO_BART = 8 GNUNET_DHT_RO_BART = 8
}; };
/** /**
* Initialize the connection with the DHT service. * Initialize the connection with the DHT service.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param ht_len size of the internal hash table to use for * @param ht_len size of the internal hash table to use for
* processing multiple GET/FIND requests in parallel * processing multiple GET/FIND requests in parallel
* @return NULL on error * @return NULL on error
skipping to change at line 124 skipping to change at line 126
/* *************** Standard API: get and put ******************* */ /* *************** Standard API: get and put ******************* */
/** /**
* Opaque handle to cancel a PUT operation. * Opaque handle to cancel a PUT operation.
*/ */
struct GNUNET_DHT_PutHandle; struct GNUNET_DHT_PutHandle;
/** /**
* Type of a PUT continuation. You must not call * Type of a PUT continuation. You must not call
* "GNUNET_DHT_disconnect" in this continuation. * #GNUNET_DHT_disconnect in this continuation.
* *
* @param cls closure * @param cls closure
* @param success GNUNET_OK if the PUT was transmitted, * @param success #GNUNET_OK if the PUT was transmitted,
* GNUNET_NO on timeout, * #GNUNET_NO on timeout,
* GNUNET_SYSERR on disconnect from service * #GNUNET_SYSERR on disconnect from service
* after the PUT message was transmitted * after the PUT message was transmitted
* (so we don't know if it was received or not) * (so we don't know if it was received or not)
*/ */
typedef void (*GNUNET_DHT_PutContinuation)(void *cls, typedef void (*GNUNET_DHT_PutContinuation)(void *cls,
int success); int success);
/** /**
* Perform a PUT operation storing data in the DHT. * Perform a PUT operation storing data in the DHT.
* *
* @param handle handle to DHT service * @param handle handle to DHT service
* @param key the key to store under * @param key the key to store under
* @param desired_replication_level estimate of how many * @param desired_replication_level estimate of how many
* nearest peers this request should reach * nearest peers this request should reach
* @param options routing options for this message * @param options routing options for this message
* @param type type of the value * @param type type of the value
* @param size number of bytes in data; must be less than 64k * @param size number of bytes in @a data; must be less than 64k
* @param data the data to store * @param data the data to store
* @param exp desired expiration time for the value * @param exp desired expiration time for the value
* @param timeout how long to wait for transmission of this request * @param timeout how long to wait for transmission of this request
* @param cont continuation to call when done (transmitting request to serv ice) * @param cont continuation to call when done (transmitting request to serv ice)
* You must not call "GNUNET_DHT_disconnect" in this continuation * You must not call #GNUNET_DHT_disconnect in this continuation
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return handle to cancel the "PUT" operation, NULL on error * @return handle to cancel the "PUT" operation, NULL on error
* (size too big) * (size too big)
*/ */
struct GNUNET_DHT_PutHandle * struct GNUNET_DHT_PutHandle *
GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
const struct GNUNET_HashCode * key, const struct GNUNET_HashCode *key,
uint32_t desired_replication_level, uint32_t desired_replication_level,
enum GNUNET_DHT_RouteOption options, enum GNUNET_DHT_RouteOption options,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
size_t size, const void *data, size_t size, const void *data,
struct GNUNET_TIME_Absolute exp, struct GNUNET_TIME_Absolute exp,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_DHT_PutContinuation cont, GNUNET_DHT_PutContinuation cont,
void *cont_cls); void *cont_cls);
/** /**
* Cancels a DHT PUT operation. Note that the PUT request may still * Cancels a DHT PUT operation. Note that the PUT request may still
* go out over the network (we can't stop that); However, if the PUT * go out over the network (we can't stop that); However, if the PUT
* has not yet been sent to the service, cancelling the PUT will stop * has not yet been sent to the service, cancelling the PUT will stop
* this from happening (but there is no way for the user of this API * this from happening (but there is no way for the user of this API
* to tell if that is the case). The only use for this API is to * to tell if that is the case). The only use for this API is to
* prevent a later call to 'cont' from "GNUNET_DHT_put" (i.e. because * prevent a later call to 'cont' from #GNUNET_DHT_put (i.e. because
* the system is shutting down). * the system is shutting down).
* *
* @param ph put operation to cancel ('cont' will no longer be called) * @param ph put operation to cancel ('cont' will no longer be called)
*/ */
void void
GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph); GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph);
/** /**
* Iterator called on each result obtained for a DHT * Iterator called on each result obtained for a DHT
* operation that expects a reply * operation that expects a reply
* *
* @param cls closure * @param cls closure
* @param exp when will this value expire * @param exp when will this value expire
* @param key key of the result * @param key key of the result
* @param get_path peers on reply path (or NULL if not recorded) * @param get_path peers on reply path (or NULL if not recorded)
* @param get_path_length number of entries in get_path * [0] = datastore's first neighbor, [length - 1] = local p
eer
* @param get_path_length number of entries in @a get_path
* @param put_path peers on the PUT path (or NULL if not recorded) * @param put_path peers on the PUT path (or NULL if not recorded)
* @param put_path_length number of entries in get_path * [0] = origin, [length - 1] = datastore
* @param put_path_length number of entries in @a put_path
* @param type type of the result * @param type type of the result
* @param size number of bytes in data * @param size number of bytes in @a data
* @param data pointer to the result data * @param data pointer to the result data
*/ */
typedef void (*GNUNET_DHT_GetIterator) (void *cls, typedef void (*GNUNET_DHT_GetIterator) (void *cls,
struct GNUNET_TIME_Absolute exp, struct GNUNET_TIME_Absolute exp,
const struct GNUNET_HashCode * key, const struct GNUNET_HashCode *key,
const struct GNUNET_PeerIdentity * const struct GNUNET_PeerIdentity *g
get_path, unsigned int get_path_len et_path,
gth, unsigned int get_path_length,
const struct GNUNET_PeerIdentity * const struct GNUNET_PeerIdentity *p
put_path, unsigned int put_path_len ut_path,
gth, unsigned int put_path_length,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
size_t size, const void *data); size_t size, const void *data);
/** /**
* Perform an asynchronous GET operation on the DHT identified. See * Perform an asynchronous GET operation on the DHT identified. See
* also "GNUNET_BLOCK_evaluate". * also #GNUNET_BLOCK_evaluate.
* *
* @param handle handle to the DHT service * @param handle handle to the DHT service
* @param type expected type of the response object * @param type expected type of the response object
* @param key the key to look up * @param key the key to look up
* @param desired_replication_level estimate of how many * @param desired_replication_level estimate of how many
nearest peers this request should reach nearest peers this request should reach
* @param options routing options for this message * @param options routing options for this message
* @param xquery extended query data (can be NULL, depending on type) * @param xquery extended query data (can be NULL, depending on type)
* @param xquery_size number of bytes in xquery * @param xquery_size number of bytes in @a xquery
* @param iter function to call on each result * @param iter function to call on each result
* @param iter_cls closure for iter * @param iter_cls closure for @a iter
* *
* @return handle to stop the async get * @return handle to stop the async get
*/ */
struct GNUNET_DHT_GetHandle * struct GNUNET_DHT_GetHandle *
GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *key,
uint32_t desired_replication_level, uint32_t desired_replication_level,
enum GNUNET_DHT_RouteOption options, enum GNUNET_DHT_RouteOption options,
const void *xquery, size_t xquery_size, const void *xquery, size_t xquery_size,
GNUNET_DHT_GetIterator iter, void *iter_cls); GNUNET_DHT_GetIterator iter, void *iter_cls);
/** /**
* Tell the DHT not to return any of the following known results * Tell the DHT not to return any of the following known results
* to this client. * to this client.
* *
* @param get_handle get operation for which results should be filtered * @param get_handle get operation for which results should be filtered
* @param num_results number of results to be blocked that are * @param num_results number of results to be blocked that are
* provided in this call (size of the 'results' array) * provided in this call (size of the @a results array)
* @param results array of hash codes over the 'data' of the results * @param results array of hash codes over the 'data' of the results
* to be blocked * to be blocked
*/ */
void void
GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handl e, GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handl e,
unsigned int num_results, unsigned int num_results,
const struct GNUNET_HashCode *results); const struct GNUNET_HashCode *results);
/** /**
* Stop async DHT-get. Frees associated resources. * Stop async DHT-get. Frees associated resources.
skipping to change at line 272 skipping to change at line 276
*/ */
struct GNUNET_DHT_MonitorHandle; struct GNUNET_DHT_MonitorHandle;
/** /**
* Callback called on each GET request going through the DHT. * Callback called on each GET request going through the DHT.
* *
* @param cls Closure. * @param cls Closure.
* @param options Options, for instance RecordRoute, DemultiplexEverywhere. * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
* @param type The type of data in the request. * @param type The type of data in the request.
* @param hop_count Hop count so far. * @param hop_count Hop count so far.
* @param path_length number of entries in path (or 0 if not recorded). * @param path_length number of entries in @a path (or 0 if not recorded).
* @param path peers on the GET path (or NULL if not recorded). * @param path peers on the GET path (or NULL if not recorded).
* @param desired_replication_level Desired replication level. * @param desired_replication_level Desired replication level.
* @param key Key of the requested data. * @param key Key of the requested data.
*/ */
typedef void (*GNUNET_DHT_MonitorGetCB) (void *cls, typedef void (*GNUNET_DHT_MonitorGetCB) (void *cls,
enum GNUNET_DHT_RouteOption option s, enum GNUNET_DHT_RouteOption option s,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
uint32_t hop_count, uint32_t hop_count,
uint32_t desired_replication_level , uint32_t desired_replication_level ,
unsigned int path_length, unsigned int path_length,
const struct GNUNET_PeerIdentity * path, const struct GNUNET_PeerIdentity * path,
const struct GNUNET_HashCode * key ); const struct GNUNET_HashCode * key );
/** /**
* Callback called on each GET reply going through the DHT. * Callback called on each GET reply going through the DHT.
* *
* @param cls Closure. * @param cls Closure.
* @param type The type of data in the result. * @param type The type of data in the result.
* @param get_path Peers on GET path (or NULL if not recorded). * @param get_path Peers on GET path (or NULL if not recorded).
* @param get_path_length number of entries in get_path. * @param get_path_length number of entries in @a get_path.
* @param put_path peers on the PUT path (or NULL if not recorded). * @param put_path peers on the PUT path (or NULL if not recorded).
* @param put_path_length number of entries in get_path. * @param put_path_length number of entries in @a get_path.
* @param exp Expiration time of the data. * @param exp Expiration time of the data.
* @param key Key of the data. * @param key Key of the data.
* @param data Pointer to the result data. * @param data Pointer to the result data.
* @param size Number of bytes in data. * @param size Number of bytes in @a data.
*/ */
typedef void (*GNUNET_DHT_MonitorGetRespCB) (void *cls, typedef void (*GNUNET_DHT_MonitorGetRespCB) (void *cls,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
const struct GNUNET_PeerIdenti const struct GNUNET_PeerIdenti
ty ty *get_path,
*get_path,
unsigned int get_path_length, unsigned int get_path_length,
const struct GNUNET_PeerIdenti const struct GNUNET_PeerIdenti
ty ty *put_path,
* put_path,
unsigned int put_path_length, unsigned int put_path_length,
struct GNUNET_TIME_Absolute ex p, struct GNUNET_TIME_Absolute ex p,
const struct GNUNET_HashCode * key, const struct GNUNET_HashCode * key,
const void *data, const void *data,
size_t size); size_t size);
/** /**
* Callback called on each PUT request going through the DHT. * Callback called on each PUT request going through the DHT.
* *
* @param cls Closure. * @param cls Closure.
* @param options Options, for instance RecordRoute, DemultiplexEverywhere. * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
* @param type The type of data in the request. * @param type The type of data in the request.
* @param hop_count Hop count so far. * @param hop_count Hop count so far.
* @param path_length number of entries in path (or 0 if not recorded). * @param path_length number of entries in @a path (or 0 if not recorded).
* @param path peers on the PUT path (or NULL if not recorded). * @param path peers on the PUT path (or NULL if not recorded).
* @param desired_replication_level Desired replication level. * @param desired_replication_level Desired replication level.
* @param exp Expiration time of the data. * @param exp Expiration time of the data.
* @param key Key under which data is to be stored. * @param key Key under which data is to be stored.
* @param data Pointer to the data carried. * @param data Pointer to the data carried.
* @param size Number of bytes in data. * @param size Number of bytes in data.
*/ */
typedef void (*GNUNET_DHT_MonitorPutCB) (void *cls, typedef void (*GNUNET_DHT_MonitorPutCB) (void *cls,
enum GNUNET_DHT_RouteOption option s, enum GNUNET_DHT_RouteOption option s,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
uint32_t hop_count, uint32_t hop_count,
uint32_t desired_replication_level , uint32_t desired_replication_level ,
unsigned int path_length, unsigned int path_length,
const struct GNUNET_PeerIdentity * path, const struct GNUNET_PeerIdentity * path,
struct GNUNET_TIME_Absolute exp, struct GNUNET_TIME_Absolute exp,
const struct GNUNET_HashCode * key , const struct GNUNET_HashCode *key,
const void *data, const void *data,
size_t size); size_t size);
/** /**
* Start monitoring the local DHT service. * Start monitoring the local DHT service.
* *
* @param handle Handle to the DHT service. * @param handle Handle to the DHT service.
* @param type Type of blocks that are of interest. * @param type Type of blocks that are of interest.
* @param key Key of data of interest, NULL for all. * @param key Key of data of interest, NULL for all.
* @param get_cb Callback to process monitored get messages. * @param get_cb Callback to process monitored get messages.
* @param get_resp_cb Callback to process monitored get response messages. * @param get_resp_cb Callback to process monitored get response messages.
* @param put_cb Callback to process monitored put messages. * @param put_cb Callback to process monitored put messages.
* @param cb_cls Closure for cb. * @param cb_cls Closure for callbacks
*
* @return Handle to stop monitoring. * @return Handle to stop monitoring.
*/ */
struct GNUNET_DHT_MonitorHandle * struct GNUNET_DHT_MonitorHandle *
GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle,
enum GNUNET_BLOCK_Type type, enum GNUNET_BLOCK_Type type,
const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *key,
GNUNET_DHT_MonitorGetCB get_cb, GNUNET_DHT_MonitorGetCB get_cb,
GNUNET_DHT_MonitorGetRespCB get_resp_cb, GNUNET_DHT_MonitorGetRespCB get_resp_cb,
GNUNET_DHT_MonitorPutCB put_cb, GNUNET_DHT_MonitorPutCB put_cb,
void *cb_cls); void *cb_cls);
/** /**
* Stop monitoring. * Stop monitoring.
* On return handle will no longer be valid, caller must not use again!!!
* *
* @param handle The handle to the monitor request returned by monitor_star t. * @param handle The handle to the monitor request returned by monitor_star t.
*
* On return handle will no longer be valid, caller must not use again!!!
*/ */
void void
GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group dht */
#endif #endif
/* gnunet_dht_service.h */ /* gnunet_dht_service.h */
 End of changes. 37 change blocks. 
60 lines changed or deleted 63 lines changed or added


 gnunet_disk_lib.h   gnunet_disk_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001-2012 Christian Grothoff (and other contributing authors) (C) 2001-2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_disk_lib.h * @file include/gnunet_disk_lib.h
* @brief disk IO apis * @brief disk IO apis
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_DISK_LIB_H #ifndef GNUNET_DISK_LIB_H
#define GNUNET_DISK_LIB_H #define GNUNET_DISK_LIB_H
#if WINDOWS
#define OFF_T uint64_t
#else
#define OFF_T off_t
#endif
/** /**
* Handle used to manage a pipe. * Handle used to manage a pipe.
*/ */
struct GNUNET_DISK_PipeHandle; struct GNUNET_DISK_PipeHandle;
/** /**
* Type of a handle. * Type of a handle.
*/ */
enum GNUNET_FILE_Type enum GNUNET_FILE_Type
{ {
skipping to change at line 265 skipping to change at line 259
*/ */
GNUNET_DISK_PIPE_END_READ = 0, GNUNET_DISK_PIPE_END_READ = 0,
/** /**
* The writing-end of a pipe. * The writing-end of a pipe.
*/ */
GNUNET_DISK_PIPE_END_WRITE = 1 GNUNET_DISK_PIPE_END_WRITE = 1
}; };
/** /**
* Get the number of blocks that are left on the partition that
* contains the given file (for normal users).
*
* @param part a file on the partition to check
* @return -1 on errors, otherwise the number of free blocks
*/
long
GNUNET_DISK_get_blocks_available (const char *part);
/**
* Checks whether a handle is invalid * Checks whether a handle is invalid
* *
* @param h handle to check * @param h handle to check
* @return GNUNET_YES if invalid, GNUNET_NO if valid * @return #GNUNET_YES if invalid, #GNUNET_NO if valid
*/ */
int int
GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h);
/** /**
* Check that fil corresponds to a filename * Check that fil corresponds to a filename
* (of a file that exists and that is not a directory). * (of a file that exists and that is not a directory).
* *
* @param fil filename to check * @param fil filename to check
* @return GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if som ething * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something
* else (will print an error message in that case, too). * else (will print an error message in that case, too).
*/ */
int int
GNUNET_DISK_file_test (const char *fil); GNUNET_DISK_file_test (const char *fil);
/** /**
* Move a file out of the way (create a backup) by * Move a file out of the way (create a backup) by
* renaming it to "orig.NUM~" where NUM is the smallest * renaming it to "orig.NUM~" where NUM is the smallest
* number that is not used yet. * number that is not used yet.
* *
skipping to change at line 311 skipping to change at line 295
void void
GNUNET_DISK_file_backup (const char *fil); GNUNET_DISK_file_backup (const char *fil);
/** /**
* Move the read/write pointer in a file * Move the read/write pointer in a file
* @param h handle of an open file * @param h handle of an open file
* @param offset position to move to * @param offset position to move to
* @param whence specification to which position the offset parameter relat es to * @param whence specification to which position the offset parameter relat es to
* @return the new position on success, GNUNET_SYSERR otherwise * @return the new position on success, GNUNET_SYSERR otherwise
*/ */
OFF_T off_t
GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, OFF_T offset GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset
, ,
enum GNUNET_DISK_Seek whence); enum GNUNET_DISK_Seek whence);
/** /**
* Get the size of the file (or directory) of the given file (in * Get the size of the file (or directory) of the given file (in
* bytes). * bytes).
* *
* @param filename name of the file or directory * @param filename name of the file or directory
* @param size set to the size of the file (or, * @param size set to the size of the file (or,
* in the case of directories, the sum * in the case of directories, the sum
* of all sizes of files in the directory) * of all sizes of files in the directory)
* @param includeSymLinks should symbolic links be * @param include_symbolic_links should symbolic links be
* included? * included?
* @param singleFileMode GNUNET_YES to only get size of one file * @param single_file_mode #GNUNET_YES to only get size of one file
* and return GNUNET_SYSERR for directories. * and return #GNUNET_SYSERR for directories.
* @return GNUNET_SYSERR on error, GNUNET_OK on success * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/ */
int int
GNUNET_DISK_file_size (const char *filename, uint64_t * size, GNUNET_DISK_file_size (const char *filename, uint64_t *size,
int includeSymLinks, int singleFileMode); int include_symbolic_links,
int single_file_mode);
/** /**
* Obtain some unique identifiers for the given file * Obtain some unique identifiers for the given file
* that can be used to identify it in the local system. * that can be used to identify it in the local system.
* This function is used between GNUnet processes to * This function is used between GNUnet processes to
* quickly check if two files with the same absolute path * quickly check if two files with the same absolute path
* are actually identical. The two processes represent * are actually identical. The two processes represent
* the same peer but may communicate over the network * the same peer but may communicate over the network
* (and the file may be on an NFS volume). This function * (and the file may be on an NFS volume). This function
* may not be supported on all operating systems. * may not be supported on all operating systems.
* *
* @param filename name of the file * @param filename name of the file
* @param dev set to the device ID * @param dev set to the device ID
* @param ino set to the inode ID * @param ino set to the inode ID
* @return GNUNET_OK on success * @return GNUNET_OK on success
*/ */
int int
GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev, GNUNET_DISK_file_get_identifiers (const char *filename,
uint64_t * ino); uint64_t *dev,
uint64_t *ino);
/** /**
* Create an (empty) temporary file on disk. If the given name is not * Create an (empty) temporary file on disk. If the given name is not
* an absolute path, the current 'TMPDIR' will be prepended. In any case, * an absolute path, the current 'TMPDIR' will be prepended. In any case,
* 6 random characters will be appended to the name to create a unique * 6 random characters will be appended to the name to create a unique
* filename. * filename.
* *
* @param t component to use for the name; * @param t component to use for the name;
* does NOT contain "XXXXXX" or "/tmp/". * does NOT contain "XXXXXX" or "/tmp/".
* @return NULL on error, otherwise name of fresh * @return NULL on error, otherwise name of fresh
skipping to change at line 386 skipping to change at line 372
GNUNET_DISK_mkdtemp (const char *t); GNUNET_DISK_mkdtemp (const char *t);
/** /**
* Open a file. Note that the access permissions will only be * Open a file. Note that the access permissions will only be
* used if a new file is created and if the underlying operating * used if a new file is created and if the underlying operating
* system supports the given permissions. * system supports the given permissions.
* *
* @param fn file name to be opened * @param fn file name to be opened
* @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit fl ags * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit fl ags
* @param perm permissions for the newly created file, use * @param perm permissions for the newly created file, use
* GNUNET_DISK_PERM_NONE if a file could not be created by this * #GNUNET_DISK_PERM_NONE if a file could not be created by thi s
* call (because of flags) * call (because of flags)
* @return IO handle on success, NULL on error * @return IO handle on success, NULL on error
*/ */
struct GNUNET_DISK_FileHandle * struct GNUNET_DISK_FileHandle *
GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, GNUNET_DISK_file_open (const char *fn,
enum GNUNET_DISK_OpenFlags flags,
enum GNUNET_DISK_AccessPermissions perm); enum GNUNET_DISK_AccessPermissions perm);
/** /**
* Get the size of an open file. * Get the size of an open file.
* *
* @param fh open file handle * @param fh open file handle
* @param size where to write size of the file * @param size where to write size of the file
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
OFF_T *size); off_t *size);
/** /**
* Creates an interprocess channel * Creates an interprocess channel
* *
* @param blocking_read creates an asynchronous pipe for reading if set to * @param blocking_read creates an asynchronous pipe for reading if set to
GNUNET_NO #GNUNET_NO
* @param blocking_write creates an asynchronous pipe for writing if set to * @param blocking_write creates an asynchronous pipe for writing if set to
GNUNET_NO #GNUNET_NO
* @param inherit_read 1 to make read handle inheritable, 0 otherwise (NT o nly) * @param inherit_read 1 to make read handle inheritable, 0 otherwise (NT o nly)
* @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only) * @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only)
* @return handle to the new pipe, NULL on error * @return handle to the new pipe, NULL on error
*/ */
struct GNUNET_DISK_PipeHandle * struct GNUNET_DISK_PipeHandle *
GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, GNUNET_DISK_pipe (int blocking_read,
int inherit_write); int blocking_write,
int inherit_read,
int inherit_write);
/** /**
* Creates a pipe object from a couple of file descriptors. * Creates a pipe object from a couple of file descriptors.
* Useful for wrapping existing pipe FDs. * Useful for wrapping existing pipe FDs.
* *
* @param blocking_read creates an asynchronous pipe for reading if set to * @param blocking_read creates an asynchronous pipe for reading if set to
GNUNET_NO #GNUNET_NO
* @param blocking_write creates an asynchronous pipe for writing if set to * @param blocking_write creates an asynchronous pipe for writing if set to
GNUNET_NO #GNUNET_NO
* @param fd an array of two fd values. One of them may be -1 for read-only or write-only pipes * @param fd an array of two fd values. One of them may be -1 for read-only or write-only pipes
* *
* @return handle to the new pipe, NULL on error * @return handle to the new pipe, NULL on error
*/ */
struct GNUNET_DISK_PipeHandle * struct GNUNET_DISK_PipeHandle *
GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]) GNUNET_DISK_pipe_from_fd (int blocking_read,
; int blocking_write,
int fd[2]);
/** /**
* Closes an interprocess channel * Closes an interprocess channel
* @param p pipe * @param p pipe
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
/** /**
* Closes one half of an interprocess channel * Closes one half of an interprocess channel
* *
* @param p pipe to close end of * @param p pipe to close end of
* @param end which end of the pipe to close * @param end which end of the pipe to close
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p,
enum GNUNET_DISK_PipeEnd end); enum GNUNET_DISK_PipeEnd end);
/** /**
* Detaches one of the ends from the pipe.
* Detached end is a fully-functional FileHandle, it will
* not be affected by anything you do with the pipe afterwards.
* Each end of a pipe can only be detched from it once (i.e.
* it is not duplicated).
*
* @param p pipe to detach an end from
* @param end which end of the pipe to detach
* @return Detached end on success, NULL on failure
* (or if that end is not present or is closed).
*/
struct GNUNET_DISK_FileHandle *
GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p,
enum GNUNET_DISK_PipeEnd end);
/**
* Close an open file. * Close an open file.
* *
* @param h file handle * @param h file handle
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
/** /**
* Get the handle to a particular pipe end * Get the handle to a particular pipe end
* *
* @param p pipe * @param p pipe
* @param n end to access * @param n end to access
* @return handle for the respective end * @return handle for the respective end
*/ */
const struct GNUNET_DISK_FileHandle * const struct GNUNET_DISK_FileHandle *
GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p,
enum GNUNET_DISK_PipeEnd n); enum GNUNET_DISK_PipeEnd n);
#if WINDOWS
/**
* Get a GNUnet file handle from a W32 handle (W32-only).
* Do not call on non-W32 platforms (returns NULL).
*
* @param handle native handle
* @return GNUnet file handle corresponding to the W32 handle
*/
struct GNUNET_DISK_FileHandle *
GNUNET_DISK_get_handle_from_w32_handle (HANDLE osfh);
#else
/**
* Update POSIX permissions mask of a file on disk. If both argumets
* are #GNUNET_NO, the file is made world-read-write-executable (777).
*
* @param fn name of the file to update
* @param require_uid_match #GNUNET_YES means 700
* @param require_gid_match #GNUNET_YES means 770 unless @a require_uid_mat
ch is set
*/
void
GNUNET_DISK_fix_permissions (const char *fn,
int require_uid_match,
int require_gid_match);
#endif
/**
* Get a handle from a native integer FD.
*
* @param fno native integer file descriptor
* @return file handle corresponding to the descriptor
*/
struct GNUNET_DISK_FileHandle *
GNUNET_DISK_get_handle_from_int_fd (int fno);
/** /**
* Get a handle from a native FD. * Get a handle from a native FD.
* *
* @param fd native file descriptor * @param fd native file descriptor
* @return file handle corresponding to the descriptor * @return file handle corresponding to the descriptor
*/ */
struct GNUNET_DISK_FileHandle * struct GNUNET_DISK_FileHandle *
GNUNET_DISK_get_handle_from_native (FILE *fd); GNUNET_DISK_get_handle_from_native (FILE *fd);
/** /**
* Read the contents of a binary file into a buffer. * Read the contents of a binary file into a buffer.
*
* @param h handle to an open file * @param h handle to an open file
* @param result the buffer to write the result to * @param result the buffer to write the result to
* @param len the maximum number of bytes to read * @param len the maximum number of bytes to read
* @return the number of bytes read on success, GNUNET_SYSERR on failure * @return the number of bytes read on success, #GNUNET_SYSERR on failure
*/ */
ssize_t ssize_t
GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h,
, void *result,
size_t len); size_t len);
/** /**
* Read the contents of a binary file into a buffer. * Read the contents of a binary file into a buffer.
* Guarantees not to block (returns GNUNET_SYSERR and sets errno to EAGAIN * Guarantees not to block (returns GNUNET_SYSERR and sets errno to EAGAIN
* when no data can be read). * when no data can be read).
* *
* @param h handle to an open file * @param h handle to an open file
* @param result the buffer to write the result to * @param result the buffer to write the result to
* @param len the maximum number of bytes to read * @param len the maximum number of bytes to read
* @return the number of bytes read on success, GNUNET_SYSERR on failure * @return the number of bytes read on success, #GNUNET_SYSERR on failure
*/ */
ssize_t ssize_t
GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h , GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h ,
void *result, size_t len); void *result,
size_t len);
/** /**
* Read the contents of a binary file into a buffer. * Read the contents of a binary file into a buffer.
* *
* @param fn file name * @param fn file name
* @param result the buffer to write the result to * @param result the buffer to write the result to
* @param len the maximum number of bytes to read * @param len the maximum number of bytes to read
* @return number of bytes read, GNUNET_SYSERR on failure * @return number of bytes read, #GNUNET_SYSERR on failure
*/ */
ssize_t ssize_t
GNUNET_DISK_fn_read (const char *fn, void *result, size_t len); GNUNET_DISK_fn_read (const char *fn,
void *result,
size_t len);
/** /**
* Write a buffer to a file. * Write a buffer to a file.
* *
* @param h handle to open file * @param h handle to open file
* @param buffer the data to write * @param buffer the data to write
* @param n number of bytes to write * @param n number of bytes to write
* @return number of bytes written on success, GNUNET_SYSERR on error * @return number of bytes written on success, #GNUNET_SYSERR on error
*/ */
ssize_t ssize_t
GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h,
const void *buffer, size_t n); const void *buffer,
size_t n);
/** /**
* Write a buffer to a file, blocking, if necessary. * Write a buffer to a file, blocking, if necessary.
*
* @param h handle to open file * @param h handle to open file
* @param buffer the data to write * @param buffer the data to write
* @param n number of bytes to write * @param n number of bytes to write
* @return number of bytes written on success, GNUNET_SYSERR on error * @return number of bytes written on success, #GNUNET_SYSERR on error
*/ */
ssize_t ssize_t
GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h, GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h,
const void *buffer, size_t n); const void *buffer,
size_t n);
/** /**
* Write a buffer to a file. If the file is longer than * Write a buffer to a file. If the file is longer than
* the given buffer size, it will be truncated. * the given buffer size, it will be truncated.
* *
* @param fn file name * @param fn file name
* @param buffer the data to write * @param buffer the data to write
* @param n number of bytes to write * @param n number of bytes to write
* @param mode file permissions * @param mode file permissions
* @return number of bytes written on success, GNUNET_SYSERR on error * @return number of bytes written on success, #GNUNET_SYSERR on error
*/ */
ssize_t ssize_t
GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, GNUNET_DISK_fn_write (const char *fn,
const void *buffer,
size_t n,
enum GNUNET_DISK_AccessPermissions mode); enum GNUNET_DISK_AccessPermissions mode);
/** /**
* Copy a file. * Copy a file.
* *
* @param src file to copy * @param src file to copy
* @param dst destination file name * @param dst destination file name
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_DISK_file_copy (const char *src, const char *dst); GNUNET_DISK_file_copy (const char *src, const char *dst);
/** /**
* Scan a directory for files. * Scan a directory for files.
* *
* @param dirName the name of the directory * @param dir_name the name of the directory
* @param callback the method to call for each file * @param callback the method to call for each file
* @param callback_cls closure for callback * @param callback_cls closure for @a callback
* @return the number of files found, -1 on error * @return the number of files found, -1 on error
*/ */
int int
GNUNET_DISK_directory_scan (const char *dirName, GNUNET_DISK_directory_scan (const char *dir_name,
GNUNET_FileNameCallback callback, GNUNET_FileNameCallback callback,
void *callback_cls); void *callback_cls);
/** /**
* Opaque handle used for iterating over a directory. * Opaque handle used for iterating over a directory.
*/ */
struct GNUNET_DISK_DirectoryIterator; struct GNUNET_DISK_DirectoryIterator;
/** /**
* Function called to iterate over a directory. * Function called to iterate over a directory.
* *
* @param cls closure * @param cls closure
* @param di argument to pass to "GNUNET_DISK_directory_iterator_next" to * @param di argument to pass to #GNUNET_DISK_directory_iterator_next to
* get called on the next entry (or finish cleanly); * get called on the next entry (or finish cleanly);
* NULL on error (will be the last call in that case) * NULL on error (will be the last call in that case)
* @param filename complete filename (absolute path) * @param filename complete filename (absolute path)
* @param dirname directory name (absolute path) * @param dirname directory name (absolute path)
*/ */
typedef void (*GNUNET_DISK_DirectoryIteratorCallback) (void *cls, typedef void (*GNUNET_DISK_DirectoryIteratorCallback) (void *cls,
struct struct GNUNET_DISK_D
GNUNET_DISK_Director irectoryIterator *di,
yIterator
* di,
const char *filename , const char *filename ,
const char *dirname) ; const char *dirname) ;
/** /**
* This function must be called during the DiskIteratorCallback * This function must be called during the DiskIteratorCallback
* (exactly once) to schedule the task to process the next * (exactly once) to schedule the task to process the next
* filename in the directory (if there is one). * filename in the directory (if there is one).
* *
* @param iter opaque handle for the iterator * @param iter opaque handle for the iterator
* @param can set to GNUNET_YES to terminate the iteration early * @param can set to #GNUNET_YES to terminate the iteration early
* @return GNUNET_YES if iteration will continue, * @return #GNUNET_YES if iteration will continue,
* GNUNET_NO if this was the last entry (and iteration is complete) * #GNUNET_NO if this was the last entry (and iteration is complete
, ),
* GNUNET_SYSERR if "can" was YES * #GNUNET_SYSERR if @a can was #GNUNET_YES
*/ */
int int
GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator * iter, GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator * iter,
int can); int can);
/** /**
* Scan a directory for files using the scheduler to run a task for * Scan a directory for files using the scheduler to run a task for
* each entry. The name of the directory must be expanded first (!). * each entry. The name of the directory must be expanded first (!).
* If a scheduler does not need to be used, GNUNET_DISK_directory_scan * If a scheduler does not need to be used, GNUNET_DISK_directory_scan
* may provide a simpler API. * may provide a simpler API.
* *
* @param prio priority to use * @param prio priority to use
* @param dirName the name of the directory * @param dir_name the name of the directory
* @param callback the method to call for each file * @param callback the method to call for each file
* @param callback_cls closure for callback * @param callback_cls closure for @a callback
* @return GNUNET_YES if directory is not empty and 'callback' * @return #GNUNET_YES if directory is not empty and @a callback
* will be called later, GNUNET_NO otherwise, GNUNET_SYSERR on erro * will be called later, #GNUNET_NO otherwise, #GNUNET_SYSERR on er
r. ror.
*/ */
int int
GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
const char *dirName, const char *dir_name,
GNUNET_DISK_DirectoryIteratorCallback GNUNET_DISK_DirectoryIteratorCallback
callback, void *callback_cls); callback, void *callback_cls);
/** /**
* Create the directory structure for storing * Create the directory structure for storing
* a file. * a file.
* *
* @param filename name of a file in the directory * @param filename name of a file in the directory
* @returns GNUNET_OK on success, GNUNET_SYSERR on failure, * @returns #GNUNET_OK on success, #GNUNET_SYSERR on failure,
* GNUNET_NO if directory exists but is not writeable * #GNUNET_NO if directory exists but is not writeable
*/ */
int int
GNUNET_DISK_directory_create_for_file (const char *filename); GNUNET_DISK_directory_create_for_file (const char *filename);
/** /**
* Test if "fil" is a directory and listable. Optionally, also check if the * Test if @a fil is a directory and listable. Optionally, also check if th e
* directory is readable. Will not print an error message if the directory does * directory is readable. Will not print an error message if the directory does
* not exist. Will log errors if GNUNET_SYSERR is returned (i.e., a file e xists * not exist. Will log errors if #GNUNET_SYSERR is returned (i.e., a file exists
* with the same name). * with the same name).
* *
* @param fil filename to test * @param fil filename to test
* @param is_readable GNUNET_YES to additionally check if "fil" is readable * @param is_readable #GNUNET_YES to additionally check if @a fil is readab
; le;
* GNUNET_NO to disable this check * #GNUNET_NO to disable this check
* @return GNUNET_YES if yes, GNUNET_NO if not; GNUNET_SYSERR if it * @return #GNUNET_YES if yes, #GNUNET_NO if not; #GNUNET_SYSERR if it
* does not exist or stat'ed * does not exist or `stat`ed
*/ */
int int
GNUNET_DISK_directory_test (const char *fil, int is_readable); GNUNET_DISK_directory_test (const char *fil, int is_readable);
/** /**
* Remove all files in a directory (rm -rf). Call with * Remove all files in a directory (rm -rf). Call with
* caution. * caution.
* *
* @param filename the file to remove * @param filename the file to remove
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_DISK_directory_remove (const char *filename); GNUNET_DISK_directory_remove (const char *filename);
/** /**
* Implementation of "mkdir -p" * Implementation of "mkdir -p"
* *
* @param dir the directory to create * @param dir the directory to create
* @returns GNUNET_SYSERR on failure, GNUNET_OK otherwise * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise
*/ */
int int
GNUNET_DISK_directory_create (const char *dir); GNUNET_DISK_directory_create (const char *dir);
/** /**
* Lock a part of a file. * Lock a part of a file.
* *
* @param fh file handle * @param fh file handle
* @param lockStart absolute position from where to lock * @param lock_start absolute position from where to lock
* @param lockEnd absolute position until where to lock * @param lock_end absolute position until where to lock
* @param excl GNUNET_YES for an exclusive lock * @param excl #GNUNET_YES for an exclusive lock
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh,
OFF_T lockEnd, int excl); off_t lock_start,
off_t lock_end, int excl);
/** /**
* Unlock a part of a file * Unlock a part of a file.
*
* @param fh file handle * @param fh file handle
* @param unlockStart absolute position from where to unlock * @param unlock_start absolute position from where to unlock
* @param unlockEnd absolute position until where to unlock * @param unlock_end absolute position until where to unlock
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockSta GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh,
rt, off_t unlock_start,
OFF_T unlockEnd); off_t unlock_end);
/** /**
* @brief Removes special characters as ':' from a filename. * @brief Removes special characters as ':' from a filename.
* @param fn the filename to canonicalize * @param fn the filename to canonicalize
*/ */
void void
GNUNET_DISK_filename_canonicalize (char *fn); GNUNET_DISK_filename_canonicalize (char *fn);
/** /**
* @brief Change owner of a file * @brief Change owner of a file
* @param filename file to change * @param filename file to change
* @param user new owner of the file * @param user new owner of the file
* @return GNUNET_OK on success, GNUNET_SYSERR on failure * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/ */
int int
GNUNET_DISK_file_change_owner (const char *filename, const char *user); GNUNET_DISK_file_change_owner (const char *filename, const char *user);
/** /**
* Construct full path to a file inside of the private
* directory used by GNUnet. Also creates the corresponding
* directory. If the resulting name is supposed to be
* a directory, end the last argument in '/' (or pass
* DIR_SEPARATOR_STR as the last argument before NULL).
*
* @param cfg configuration to use
* @param serviceName name of the service asking
* @param ... is NULL-terminated list of
* path components to append to the
* private directory name.
* @return the constructed filename
*/
char *
GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cf
g,
const char *serviceName, ...);
/**
* Opaque handle for a memory-mapping operation. * Opaque handle for a memory-mapping operation.
*/ */
struct GNUNET_DISK_MapHandle; struct GNUNET_DISK_MapHandle;
/** /**
* Map a file into memory * Map a file into memory
* @param h open file handle * @param h open file handle
* @param m handle to the new mapping (will be set) * @param m handle to the new mapping (will be set)
* @param access access specification, GNUNET_DISK_MAP_TYPE_xxx * @param access access specification, GNUNET_DISK_MAP_TYPE_xxx
* @param len size of the mapping * @param len size of the mapping
skipping to change at line 755 skipping to change at line 792
*/ */
void * void *
GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h,
struct GNUNET_DISK_MapHandle **m, struct GNUNET_DISK_MapHandle **m,
enum GNUNET_DISK_MapType access, size_t len); enum GNUNET_DISK_MapType access, size_t len);
/** /**
* Unmap a file * Unmap a file
* *
* @param h mapping handle * @param h mapping handle
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h);
/** /**
* Write file changes to disk * Write file changes to disk
* @param h handle to an open file * @param h handle to an open file
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
 End of changes. 62 change blocks. 
129 lines changed or deleted 162 lines changed or added


 gnunet_dns_service.h   gnunet_dns_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2012 Christian Grothoff (and other contributing authors) (C) 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_dns_service.h * @file include/gnunet_dns_service.h
* @brief API to access the DNS service. * @brief API to access the DNS service.
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_DNS_SERVICE_NEW_H #ifndef GNUNET_DNS_SERVICE_H
#define GNUNET_DNS_SERVICE_NEW_H #define GNUNET_DNS_SERVICE_H
#include "gnunet_common.h"
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
/** /**
* Opaque DNS handle * Opaque DNS handle
*/ */
struct GNUNET_DNS_Handle; struct GNUNET_DNS_Handle;
/** /**
* Handle to identify an individual DNS request. * Handle to identify an individual DNS request.
*/ */
 End of changes. 3 change blocks. 
4 lines changed or deleted 3 lines changed or added


 gnunet_dnsparser_lib.h   gnunet_dnsparser_lib.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2010, 2011, 2012 Christian Grothoff (and other contributing autho rs) (C) 2010-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 30 skipping to change at line 30
/** /**
* @file include/gnunet_dnsparser_lib.h * @file include/gnunet_dnsparser_lib.h
* @brief API for helper library to parse DNS packets. * @brief API for helper library to parse DNS packets.
* @author Philipp Toelke * @author Philipp Toelke
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_DNSPARSER_LIB_H #ifndef GNUNET_DNSPARSER_LIB_H
#define GNUNET_DNSPARSER_LIB_H #define GNUNET_DNSPARSER_LIB_H
#include "platform.h" #include "gnunet_util_lib.h"
#include "gnunet_common.h" #include "gnunet_tun_lib.h"
/** /**
* Maximum length of a label in DNS. * Maximum length of a label in DNS.
*/ */
#define GNUNET_DNSPARSER_MAX_LABEL_LENGTH 63 #define GNUNET_DNSPARSER_MAX_LABEL_LENGTH 63
/** /**
* Maximum length of a name in DNS. * Maximum length of a name in DNS.
*/ */
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH 253 #define GNUNET_DNSPARSER_MAX_NAME_LENGTH 253
skipping to change at line 55 skipping to change at line 55
*/ */
#define GNUNET_DNSPARSER_TYPE_A 1 #define GNUNET_DNSPARSER_TYPE_A 1
#define GNUNET_DNSPARSER_TYPE_NS 2 #define GNUNET_DNSPARSER_TYPE_NS 2
#define GNUNET_DNSPARSER_TYPE_CNAME 5 #define GNUNET_DNSPARSER_TYPE_CNAME 5
#define GNUNET_DNSPARSER_TYPE_SOA 6 #define GNUNET_DNSPARSER_TYPE_SOA 6
#define GNUNET_DNSPARSER_TYPE_PTR 12 #define GNUNET_DNSPARSER_TYPE_PTR 12
#define GNUNET_DNSPARSER_TYPE_MX 15 #define GNUNET_DNSPARSER_TYPE_MX 15
#define GNUNET_DNSPARSER_TYPE_TXT 16 #define GNUNET_DNSPARSER_TYPE_TXT 16
#define GNUNET_DNSPARSER_TYPE_AAAA 28 #define GNUNET_DNSPARSER_TYPE_AAAA 28
#define GNUNET_DNSPARSER_TYPE_SRV 33 #define GNUNET_DNSPARSER_TYPE_SRV 33
#define GNUNET_DNSPARSER_TYPE_CERT 37
#define GNUNET_DNSPARSER_TYPE_TLSA 52 #define GNUNET_DNSPARSER_TYPE_TLSA 52
/** /**
* A few common DNS classes (ok, only one is common, but I list a
* couple more to make it clear what we're talking about here).
*/
#define GNUNET_DNSPARSER_CLASS_INTERNET 1
#define GNUNET_DNSPARSER_CLASS_CHAOS 3
#define GNUNET_DNSPARSER_CLASS_HESIOD 4
#define GNUNET_DNSPARSER_OPCODE_QUERY 0
#define GNUNET_DNSPARSER_OPCODE_INVERSE_QUERY 1
#define GNUNET_DNSPARSER_OPCODE_STATUS 2
/**
* RFC 1035 codes.
*/
#define GNUNET_DNSPARSER_RETURN_CODE_NO_ERROR 0
#define GNUNET_DNSPARSER_RETURN_CODE_FORMAT_ERROR 1
#define GNUNET_DNSPARSER_RETURN_CODE_SERVER_FAILURE 2
#define GNUNET_DNSPARSER_RETURN_CODE_NAME_ERROR 3
#define GNUNET_DNSPARSER_RETURN_CODE_NOT_IMPLEMENTED 4
#define GNUNET_DNSPARSER_RETURN_CODE_REFUSED 5
/**
* RFC 2136 codes
*/
#define GNUNET_DNSPARSER_RETURN_CODE_YXDOMAIN 6
#define GNUNET_DNSPARSER_RETURN_CODE_YXRRSET 7
#define GNUNET_DNSPARSER_RETURN_CODE_NXRRSET 8
#define GNUNET_DNSPARSER_RETURN_CODE_NOT_AUTH 9
#define GNUNET_DNSPARSER_RETURN_CODE_NOT_ZONE 10
/**
* DNS flags (largely RFC 1035 / RFC 2136).
*/
struct GNUNET_DNSPARSER_Flags
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
/**
* Set to 1 if recursion is desired (client -> server)
*/
unsigned int recursion_desired : 1 GNUNET_PACKED;
/**
* Set to 1 if message is truncated
*/
unsigned int message_truncated : 1 GNUNET_PACKED;
/**
* Set to 1 if this is an authoritative answer
*/
unsigned int authoritative_answer : 1 GNUNET_PACKED;
/**
* See GNUNET_DNSPARSER_OPCODE_ defines.
*/
unsigned int opcode : 4 GNUNET_PACKED;
/**
* query:0, response:1
*/
unsigned int query_or_response : 1 GNUNET_PACKED;
/**
* See GNUNET_DNSPARSER_RETURN_CODE_ defines.
*/
unsigned int return_code : 4 GNUNET_PACKED;
/**
* See RFC 4035.
*/
unsigned int checking_disabled : 1 GNUNET_PACKED;
/**
* Response has been cryptographically verified, RFC 4035.
*/
unsigned int authenticated_data : 1 GNUNET_PACKED;
/**
* Always zero.
*/
unsigned int zero : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is available (server -> client)
*/
unsigned int recursion_available : 1 GNUNET_PACKED;
#elif __BYTE_ORDER == __BIG_ENDIAN
/**
* query:0, response:1
*/
unsigned int query_or_response : 1 GNUNET_PACKED;
/**
* See GNUNET_DNSPARSER_OPCODE_ defines.
*/
unsigned int opcode : 4 GNUNET_PACKED;
/**
* Set to 1 if this is an authoritative answer
*/
unsigned int authoritative_answer : 1 GNUNET_PACKED;
/**
* Set to 1 if message is truncated
*/
unsigned int message_truncated : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is desired (client -> server)
*/
unsigned int recursion_desired : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is available (server -> client)
*/
unsigned int recursion_available : 1 GNUNET_PACKED;
/**
* Always zero.
*/
unsigned int zero : 1 GNUNET_PACKED;
/**
* Response has been cryptographically verified, RFC 4035.
*/
unsigned int authenticated_data : 1 GNUNET_PACKED;
/**
* See RFC 4035.
*/
unsigned int checking_disabled : 1 GNUNET_PACKED;
/**
* See GNUNET_DNSPARSER_RETURN_CODE_ defines.
*/
unsigned int return_code : 4 GNUNET_PACKED;
#else
#error byteorder undefined
#endif
} GNUNET_GCC_STRUCT_LAYOUT;
/**
* A DNS query. * A DNS query.
*/ */
struct GNUNET_DNSPARSER_Query struct GNUNET_DNSPARSER_Query
{ {
/** /**
* Name of the record that the query is for (0-terminated). * Name of the record that the query is for (0-terminated).
* In UTF-8 format. The library will convert from and to DNS-IDNA * In UTF-8 format. The library will convert from and to DNS-IDNA
* as necessary. Use 'GNUNET_DNSPARSER_check_label' to test if an * as necessary. Use 'GNUNET_DNSPARSER_check_label' to test if an
* individual label is well-formed. If a given name is not well-formed, * individual label is well-formed. If a given name is not well-formed,
* creating the DNS packet will fail. * creating the DNS packet will fail.
*/ */
char *name; char *name;
/** /**
* See GNUNET_DNSPARSER_TYPE_*. * See GNUNET_DNSPARSER_TYPE_*.
*/ */
uint16_t type; uint16_t type;
/** /**
* See GNUNET_DNSPARSER_CLASS_*. * See GNUNET_TUN_DNS_CLASS_*.
*/ */
uint16_t class; uint16_t dns_traffic_class;
}; };
/** /**
* Information from MX records (RFC 1035). * Information from MX records (RFC 1035).
*/ */
struct GNUNET_DNSPARSER_MxRecord struct GNUNET_DNSPARSER_MxRecord
{ {
/** /**
skipping to change at line 319 skipping to change at line 177
uint16_t weight; uint16_t weight;
/** /**
* TCP or UDP port of the service. * TCP or UDP port of the service.
*/ */
uint16_t port; uint16_t port;
}; };
/** /**
* DNS CERT types as defined in RFC 4398.
*/
enum GNUNET_DNSPARSER_CertType
{
/**
* Reserved value
*/
GNUNET_DNSPARSER_CERTTYPE_RESERVED = 0,
/**
* An x509 PKIX certificate
*/
GNUNET_DNSPARSER_CERTTYPE_PKIX = 1,
/**
* A SKPI certificate
*/
GNUNET_DNSPARSER_CERTTYPE_SKPI = 2,
/**
* A PGP certificate
*/
GNUNET_DNSPARSER_CERTTYPE_PGP = 3,
/**
* An x509 PKIX cert URL
*/
GNUNET_DNSPARSER_CERTTYPE_IPKIX = 4,
/**
* A SKPI cert URL
*/
GNUNET_DNSPARSER_CERTTYPE_ISKPI = 5,
/**
* A PGP cert fingerprint and URL
*/
GNUNET_DNSPARSER_CERTTYPE_IPGP = 6,
/**
* An attribute Certificate
*/
GNUNET_DNSPARSER_CERTTYPE_ACPKIX = 7,
/**
* An attribute cert URL
*/
GNUNET_DNSPARSER_CERTTYPE_IACKPIX = 8
};
/**
* DNSCERT algorithms as defined in http://www.iana.org/assignments/
* dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml, under dns-sec-alg-number
s-1
*/
enum GNUNET_DNSPARSER_CertAlgorithm
{
/**
* No defined
*/
GNUNET_DNSPARSER_CERTALGO_UNDEFINED = 0,
/**
* RSA/MD5
*/
GNUNET_DNSPARSER_CERTALGO_RSAMD5 = 1,
/**
* Diffie-Hellman
*/
GNUNET_DNSPARSER_CERTALGO_DH = 2,
/**
* DSA/SHA1
*/
GNUNET_DNSPARSER_CERTALGO_DSASHA = 3,
/**
* Reserved
*/
GNUNET_DNSPARSER_CERTALGO_RSRVD4 = 4,
/**
* RSA/SHA1
*/
GNUNET_DNSPARSER_CERTALGO_RSASHA = 5,
/**
* DSA/NSEC3/SHA
*/
GNUNET_DNSPARSER_CERTALGO_DSANSEC3 = 6,
/**
* RSA/NSEC3/SHA
*/
GNUNET_DNSPARSER_CERTALGO_RSANSEC3 = 7,
/**
* RSA/SHA256
*/
GNUNET_DNSPARSER_CERTALGO_RSASHA256 = 8,
/**
* Reserved
*/
GNUNET_DNSPARSER_CERTALGO_RSRVD9 = 9,
/**
* RSA/SHA512
*/
GNUNET_DNSPARSER_CERTALGO_RSASHA512 = 10,
/**
* GOST R 34.10-2001
*/
GNUNET_DNSPARSER_CERTALGO_GOST_R34 = 12,
/**
* ECDSA Curve P-256/SHA256
*/
GNUNET_DNSPARSER_CERTALGO_ECDSA_P256SHA256 = 13,
/**
* ECDSA Curve P-384/SHA384
*/
GNUNET_DNSPARSER_CERTALGO_ECDSA_P384SHA384 = 14
};
/**
* Information from CERT records (RFC 4034).
*/
struct GNUNET_DNSPARSER_CertRecord
{
/**
* Certificate type
*/
enum GNUNET_DNSPARSER_CertType cert_type;
/**
* Certificate KeyTag
*/
uint16_t cert_tag;
/**
* Algorithm
*/
enum GNUNET_DNSPARSER_CertAlgorithm algorithm;
/**
* Number of bytes in @e certificate_data
*/
size_t certificate_size;
/**
* Data of the certificate.
*/
char *certificate_data;
};
/**
* Information from SOA records (RFC 1035). * Information from SOA records (RFC 1035).
*/ */
struct GNUNET_DNSPARSER_SoaRecord struct GNUNET_DNSPARSER_SoaRecord
{ {
/** /**
*The domainname of the name server that was the * The domainname of the name server that was the
* original or primary source of data for this zone. * original or primary source of data for this zone.
* In UTF-8 format. The library will convert from and to DNS-IDNA * In UTF-8 format. The library will convert from and to DNS-IDNA
* as necessary. Use 'GNUNET_DNSPARSER_check_label' to test if an * as necessary. Use #GNUNET_DNSPARSER_check_label to test if an
* individual label is well-formed. If a given name is not well-formed, * individual label is well-formed. If a given name is not well-formed,
* creating the DNS packet will fail. * creating the DNS packet will fail.
*/ */
char *mname; char *mname;
/** /**
* A domainname which specifies the mailbox of the * A domainname which specifies the mailbox of the
* person responsible for this zone. * person responsible for this zone.
* In UTF-8 format. The library will convert from and to DNS-IDNA * In UTF-8 format. The library will convert from and to DNS-IDNA
* as necessary. Use 'GNUNET_DNSPARSER_check_label' to test if an * as necessary. Use 'GNUNET_DNSPARSER_check_label' to test if an
skipping to change at line 400 skipping to change at line 420
/** /**
* A DNS response record. * A DNS response record.
*/ */
struct GNUNET_DNSPARSER_Record struct GNUNET_DNSPARSER_Record
{ {
/** /**
* Name of the record that the query is for (0-terminated). * Name of the record that the query is for (0-terminated).
* In UTF-8 format. The library will convert from and to DNS-IDNA * In UTF-8 format. The library will convert from and to DNS-IDNA
* as necessary. Use 'GNUNET_DNSPARSER_check_label' to test if an * as necessary. Use #GNUNET_DNSPARSER_check_label to test if an
* individual label is well-formed. If a given name is not well-formed, * individual label is well-formed. If a given name is not well-formed,
* creating the DNS packet will fail. * creating the DNS packet will fail.
*/ */
char *name; char *name;
/** /**
* Payload of the record (which one of these is valid depends on the 'typ e'). * Payload of the record (which one of these is valid depends on the 'typ e').
*/ */
union union
{ {
/** /**
* For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname. * For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname.
* In UTF-8 format. The library will convert from and to DNS-IDNA * In UTF-8 format. The library will convert from and to DNS-IDNA
* as necessary. Use 'GNUNET_DNSPARSER_check_label' to test if an * as necessary. Use #GNUNET_DNSPARSER_check_label to test if an
* individual label is well-formed. If a given name is not well-formed, * individual label is well-formed. If a given name is not well-formed,
* creating the DNS packet will fail. * creating the DNS packet will fail.
*/ */
char *hostname; char *hostname;
/** /**
* SOA data for SOA records. * SOA data for SOA records.
*/ */
struct GNUNET_DNSPARSER_SoaRecord *soa; struct GNUNET_DNSPARSER_SoaRecord *soa;
/** /**
* CERT data for CERT records.
*/
struct GNUNET_DNSPARSER_CertRecord *cert;
/**
* MX data for MX records. * MX data for MX records.
*/ */
struct GNUNET_DNSPARSER_MxRecord *mx; struct GNUNET_DNSPARSER_MxRecord *mx;
/** /**
* SRV data for SRV records. * SRV data for SRV records.
*/ */
struct GNUNET_DNSPARSER_SrvRecord *srv; struct GNUNET_DNSPARSER_SrvRecord *srv;
/** /**
skipping to change at line 454 skipping to change at line 479
* When does the record expire? * When does the record expire?
*/ */
struct GNUNET_TIME_Absolute expiration_time; struct GNUNET_TIME_Absolute expiration_time;
/** /**
* See GNUNET_DNSPARSER_TYPE_*. * See GNUNET_DNSPARSER_TYPE_*.
*/ */
uint16_t type; uint16_t type;
/** /**
* See GNUNET_DNSPARSER_CLASS_*. * See GNUNET_TUN_DNS_CLASS_*.
*/ */
uint16_t class; uint16_t dns_traffic_class;
}; };
/** /**
* Easy-to-process, parsed version of a DNS packet. * Easy-to-process, parsed version of a DNS packet.
*/ */
struct GNUNET_DNSPARSER_Packet struct GNUNET_DNSPARSER_Packet
{ {
/** /**
* Array of all queries in the packet, must contain "num_queries" entries . * Array of all queries in the packet, must contain "num_queries" entries .
skipping to change at line 508 skipping to change at line 533
unsigned int num_authority_records; unsigned int num_authority_records;
/** /**
* Number of additional records in the packet, should be 0 for queries. * Number of additional records in the packet, should be 0 for queries.
*/ */
unsigned int num_additional_records; unsigned int num_additional_records;
/** /**
* Bitfield of DNS flags. * Bitfield of DNS flags.
*/ */
struct GNUNET_DNSPARSER_Flags flags; struct GNUNET_TUN_DnsFlags flags;
/** /**
* DNS ID (to match replies to requests). * DNS ID (to match replies to requests).
*/ */
uint16_t id; uint16_t id;
}; };
/** /**
* Check if a label in UTF-8 format can be coded into valid IDNA. * Check if a label in UTF-8 format can be coded into valid IDNA.
* This can fail if the ASCII-conversion becomes longer than 63 characters. * This can fail if the ASCII-conversion becomes longer than 63 characters.
* *
* @param label label to check (UTF-8 string) * @param label label to check (UTF-8 string)
* @return GNUNET_OK if the label can be converted to IDNA, * @return #GNUNET_OK if the label can be converted to IDNA,
* GNUNET_SYSERR if the label is not valid for DNS names * #GNUNET_SYSERR if the label is not valid for DNS names
*/ */
int int
GNUNET_DNSPARSER_check_label (const char *label); GNUNET_DNSPARSER_check_label (const char *label);
/** /**
* Check if a hostname in UTF-8 format can be coded into valid IDNA. * Check if a hostname in UTF-8 format can be coded into valid IDNA.
* This can fail if a label becomes longer than 63 characters or if * This can fail if a label becomes longer than 63 characters or if
* the entire name exceeds 253 characters. * the entire name exceeds 253 characters.
* *
* @param name name to check (UTF-8 string) * @param name name to check (UTF-8 string)
* @return GNUNET_OK if the label can be converted to IDNA, * @return #GNUNET_OK if the label can be converted to IDNA,
* GNUNET_SYSERR if the label is not valid for DNS names * #GNUNET_SYSERR if the label is not valid for DNS names
*/ */
int int
GNUNET_DNSPARSER_check_name (const char *name); GNUNET_DNSPARSER_check_name (const char *name);
/** /**
* Parse a UDP payload of a DNS packet in to a nice struct for further * Parse a UDP payload of a DNS packet in to a nice struct for further
* processing and manipulation. * processing and manipulation.
* *
* @param udp_payload wire-format of the DNS packet * @param udp_payload wire-format of the DNS packet
* @param udp_payload_length number of bytes in udp_payload * @param udp_payload_length number of bytes in @a udp_payload
* @return NULL on error, otherwise the parsed packet * @return NULL on error, otherwise the parsed packet
*/ */
struct GNUNET_DNSPARSER_Packet * struct GNUNET_DNSPARSER_Packet *
GNUNET_DNSPARSER_parse (const char *udp_payload, GNUNET_DNSPARSER_parse (const char *udp_payload,
size_t udp_payload_length); size_t udp_payload_length);
/** /**
* Free memory taken by a packet. * Free memory taken by a packet.
* *
* @param p packet to free * @param p packet to free
*/ */
void void
GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p); GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p);
/** /**
* Given a DNS packet, generate the corresponding UDP payload. * Given a DNS packet @a p, generate the corresponding UDP payload.
* Note that we do not attempt to pack the strings with pointers
* as this would complicate the code and this is about being
* simple and secure, not fast, fancy and broken like bind.
* *
* @param p packet to pack * @param p packet to pack
* @param max maximum allowed size for the resulting UDP payload * @param max maximum allowed size for the resulting UDP payload
* @param buf set to a buffer with the packed message * @param buf set to a buffer with the packed message
* @param buf_length set to the length of buf * @param buf_length set to the length of @a buf
* @return GNUNET_SYSERR if 'p' is invalid * @return #GNUNET_SYSERR if @a p is invalid
* GNUNET_NO if 'p' was truncated (but there is still a result in ' * #GNUNET_NO if @a p was truncated (but there is still a result in
buf') @a buf)
* GNUNET_OK if 'p' was packed completely into '*buf' * #GNUNET_OK if @a p was packed completely into @a buf
*/ */
int int
GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p,
uint16_t max, uint16_t max,
char **buf, char **buf,
size_t *buf_length); size_t *buf_length);
/* ***************** low-level packing API ******************** */
/**
* Add a DNS name to the UDP packet at the given location, converting
* the name to IDNA notation as necessary.
*
* @param dst where to write the name (UDP packet)
* @param dst_len number of bytes in @a dst
* @param off pointer to offset where to write the name (increment by bytes
used)
* must not be changed if there is an error
* @param name name to write
* @return #GNUNET_SYSERR if @a name is invalid
* #GNUNET_NO if @a name did not fit
* #GNUNET_OK if @a name was added to @a dst
*/
int
GNUNET_DNSPARSER_builder_add_name (char *dst,
size_t dst_len,
size_t *off,
const char *name);
/**
* Add a DNS query to the UDP packet at the given location.
*
* @param dst where to write the query
* @param dst_len number of bytes in @a dst
* @param off pointer to offset where to write the query (increment by byte
s used)
* must not be changed if there is an error
* @param query query to write
* @return #GNUNET_SYSERR if @a query is invalid
* #GNUNET_NO if @a query did not fit
* #GNUNET_OK if @a query was added to @a dst
*/
int
GNUNET_DNSPARSER_builder_add_query (char *dst,
size_t dst_len,
size_t *off,
const struct GNUNET_DNSPARSER_Query *que
ry);
/**
* Add an MX record to the UDP packet at the given location.
*
* @param dst where to write the mx record
* @param dst_len number of bytes in @a dst
* @param off pointer to offset where to write the mx information (incremen
t by bytes used);
* can also change if there was an error
* @param mx mx information to write
* @return #GNUNET_SYSERR if @a mx is invalid
* #GNUNET_NO if @a mx did not fit
* #GNUNET_OK if @a mx was added to @a dst
*/
int
GNUNET_DNSPARSER_builder_add_mx (char *dst,
size_t dst_len,
size_t *off,
const struct GNUNET_DNSPARSER_MxRecord *mx)
;
/**
* Add an SOA record to the UDP packet at the given location.
*
* @param dst where to write the SOA record
* @param dst_len number of bytes in @a dst
* @param off pointer to offset where to write the SOA information (increme
nt by bytes used)
* can also change if there was an error
* @param soa SOA information to write
* @return #GNUNET_SYSERR if @a soa is invalid
* #GNUNET_NO if @a soa did not fit
* #GNUNET_OK if @a soa was added to @a dst
*/
int
GNUNET_DNSPARSER_builder_add_soa (char *dst,
size_t dst_len,
size_t *off,
const struct GNUNET_DNSPARSER_SoaRecord *s
oa);
/**
* Add CERT record to the UDP packet at the given location.
*
* @param dst where to write the CERT record
* @param dst_len number of bytes in @a dst
* @param off pointer to offset where to write the CERT information (increm
ent by bytes used)
* can also change if there was an error
* @param cert CERT information to write
* @return #GNUNET_SYSERR if @a soa is invalid
* #GNUNET_NO if @a soa did not fit
* #GNUNET_OK if @a soa was added to @a dst
*/
int
GNUNET_DNSPARSER_builder_add_cert (char *dst,
size_t dst_len,
size_t *off,
const struct GNUNET_DNSPARSER_CertRecord
*cert);
/**
* Add an SRV record to the UDP packet at the given location.
*
* @param dst where to write the SRV record
* @param dst_len number of bytes in @a dst
* @param off pointer to offset where to write the SRV information (increme
nt by bytes used)
* can also change if there was an error
* @param srv SRV information to write
* @return #GNUNET_SYSERR if @a srv is invalid
* #GNUNET_NO if @a srv did not fit
* #GNUNET_OK if @a srv was added to @a dst
*/
int
GNUNET_DNSPARSER_builder_add_srv (char *dst,
size_t dst_len,
size_t *off,
const struct GNUNET_DNSPARSER_SrvRecord *s
rv);
/* ***************** low-level parsing API ******************** */
/**
* Parse a DNS record entry.
*
* @param udp_payload entire UDP payload
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the record to parse in the udp_paylo
ad (to be
* incremented by the size of the record)
* @param r where to write the record information
* @return #GNUNET_OK on success, #GNUNET_SYSERR if the record is malformed
*/
int
GNUNET_DNSPARSER_parse_record (const char *udp_payload,
size_t udp_payload_length,
size_t *off,
struct GNUNET_DNSPARSER_Record *r);
/**
* Parse name inside of a DNS query or record.
*
* @param udp_payload entire UDP payload
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the name to parse in the udp_payload
(to be
* incremented by the size of the name)
* @return name as 0-terminated C string on success, NULL if the payload is
malformed
*/
char *
GNUNET_DNSPARSER_parse_name (const char *udp_payload,
size_t udp_payload_length,
size_t *off);
/**
* Parse a DNS query entry.
*
* @param udp_payload entire UDP payload
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the query to parse in the udp_payloa
d (to be
* incremented by the size of the query)
* @param q where to write the query information
* @return #GNUNET_OK on success, #GNUNET_SYSERR if the query is malformed
*/
int
GNUNET_DNSPARSER_parse_query (const char *udp_payload,
size_t udp_payload_length,
size_t *off,
struct GNUNET_DNSPARSER_Query *q);
/**
* Parse a DNS SOA record.
*
* @param udp_payload reference to UDP packet
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the query to parse in the SOA record
(to be
* incremented by the size of the record), unchanged on
error
* @return the parsed SOA record, NULL on error
*/
struct GNUNET_DNSPARSER_SoaRecord *
GNUNET_DNSPARSER_parse_soa (const char *udp_payload,
size_t udp_payload_length,
size_t *off);
/**
* Parse a DNS CERT record.
*
* @param udp_payload reference to UDP packet
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the query to parse in the CERT recor
d (to be
* incremented by the size of the record), unchanged on
error
* @return the parsed CERT record, NULL on error
*/
struct GNUNET_DNSPARSER_CertRecord *
GNUNET_DNSPARSER_parse_cert (const char *udp_payload,
size_t udp_payload_length,
size_t *off);
/**
* Parse a DNS MX record.
*
* @param udp_payload reference to UDP packet
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the query to parse in the MX record
(to be
* incremented by the size of the record), unchanged on
error
* @return the parsed MX record, NULL on error
*/
struct GNUNET_DNSPARSER_MxRecord *
GNUNET_DNSPARSER_parse_mx (const char *udp_payload,
size_t udp_payload_length,
size_t *off);
/**
* Parse a DNS SRV record.
*
* @param r_name name of the SRV record
* @param udp_payload reference to UDP packet
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the query to parse in the SRV record
(to be
* incremented by the size of the record), unchanged on
error
* @return the parsed SRV record, NULL on error
*/
struct GNUNET_DNSPARSER_SrvRecord *
GNUNET_DNSPARSER_parse_srv (const char *r_name,
const char *udp_payload,
size_t udp_payload_length,
size_t *off);
/* ***************** low-level deallocation API ******************** */
/**
* Free the given DNS record.
*
* @param r record to free
*/
void
GNUNET_DNSPARSER_free_record (struct GNUNET_DNSPARSER_Record *r);
/**
* Free MX information record.
*
* @param mx record to free
*/
void
GNUNET_DNSPARSER_free_mx (struct GNUNET_DNSPARSER_MxRecord *mx);
/**
* Free SRV information record.
*
* @param srv record to free
*/
void
GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv);
/**
* Free SOA information record.
*
* @param soa record to free
*/
void
GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa);
/**
* Free CERT information record.
*
* @param cert record to free
*/
void
GNUNET_DNSPARSER_free_cert (struct GNUNET_DNSPARSER_CertRecord *cert);
#endif #endif
 End of changes. 22 change blocks. 
167 lines changed or deleted 478 lines changed or added


 gnunet_dv_service.h   gnunet_dv_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet.
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @author Christian Grothoff
* @file include/gnunet_dv_service.h * @file include/gnunet_dv_service.h
* @brief API to deal with dv service * @brief DV service API (should only be used by the DV plugin)
*/
#ifndef GNUNET_SERVICE_DV_H
#define GNUNET_SERVICE_DV_H
#include "gnunet_util_lib.h"
#include "gnunet_ats_service.h"
/**
* Signature of a function to be called if DV
* starts to be able to talk to a peer.
* *
* @author Christian Grothoff * @param cls closure
* @author Nathan Evans * @param peer newly connected peer
* @param distance distance to the peer
* @param network the peer is located in
*/ */
typedef void (*GNUNET_DV_ConnectCallback)(void *cls,
const struct GNUNET_PeerIdentity *
peer,
uint32_t distance,
enum GNUNET_ATS_Network_Type netw
ork);
#ifndef GNUNET_DV_SERVICE_H /**
#define GNUNET_DV_SERVICE_H * Signature of a function to be called if DV
* distance to a peer is changed.
*
* @param cls closure
* @param peer connected peer
* @param distance new distance to the peer
* @param network this network will be used to reach the next hop
*/
typedef void (*GNUNET_DV_DistanceChangedCallback)(void *cls,
const struct GNUNET_PeerId
entity *peer,
uint32_t distance,
enum GNUNET_ATS_Network_T
ype network);
#ifdef __cplusplus /**
extern "C" * Signature of a function to be called if DV
{ * is no longer able to talk to a peer.
#if 0 /* keep Emacsens' auto-indent happy */ *
} * @param cls closure
#endif * @param peer peer that disconnected
#endif */
typedef void (*GNUNET_DV_DisconnectCallback)(void *cls,
const struct GNUNET_PeerIdentit
y *peer);
/**
* Signature of a function to be called if DV
* receives a message for this peer.
*
* @param cls closure
* @param sender sender of the message
* @param distance how far did the message travel
* @param msg actual message payload
*/
typedef void (*GNUNET_DV_MessageReceivedCallback)(void *cls,
const struct GNUNET_PeerId
entity *sender,
uint32_t distance,
const struct GNUNET_Messag
eHeader *msg);
#include "gnunet_common.h" /**
#include "gnunet_configuration_lib.h" * Signature of a function called once the delivery of a
#include "gnunet_scheduler_lib.h" * message has been successful.
#include "gnunet_transport_plugin.h" *
* @param cls closure
* @param ok GNUNET_OK on success, GNUNET_SYSERR on error
*/
typedef void (*GNUNET_DV_MessageSentCallback)(void *cls,
int ok);
/** /**
* Version of the dv API. * Handle to the DV service.
*/ */
#define GNUNET_DV_VERSION 0x00000000 struct GNUNET_DV_ServiceHandle;
/** /**
* Opaque handle for the dv service. * Connect to the DV service.
*
* @param cfg configuration
* @param cls closure for callbacks
* @param connect_cb function to call on connects
* @param distance_cb function to call if distances change
* @param disconnect_cb function to call on disconnects
* @param message_cb function to call if we receive messages
* @return handle to access the service
*/ */
struct GNUNET_DV_Handle; struct GNUNET_DV_ServiceHandle *
GNUNET_DV_service_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
void *cls,
GNUNET_DV_ConnectCallback connect_cb,
GNUNET_DV_DistanceChangedCallback distance_cb,
GNUNET_DV_DisconnectCallback disconnect_cb,
GNUNET_DV_MessageReceivedCallback message_cb);
/** /**
* Send a message from the plugin to the DV service indicating that * Disconnect from DV service.
* a message should be sent via DV to some peer.
* *
* @param dv_handle the handle to the DV api * @param sh service handle
* @param target the final target of the message */
* @param msgbuf the msg(s) to send void
* @param msgbuf_size the size of msgbuf GNUNET_DV_service_disconnect (struct GNUNET_DV_ServiceHandle *sh);
* @param priority priority to pass on to core when sending the message
* @param timeout how long can this message be delayed (pass through to cor /**
e) * Handle for a send operation.
* @param addr the address of this peer (internally known to DV) */
* @param addrlen the length of the peer address struct GNUNET_DV_TransmitHandle;
* @param cont continuation to call once the message has been sent (or fail
ed) /**
* @param cont_cls closure for continuation * Send a message via DV service.
* *
* @param sh service handle
* @param target intended recpient
* @param msg message payload
* @param cb function to invoke when done
* @param cb_cls closure for 'cb'
* @return handle to cancel the operation
*/ */
int struct GNUNET_DV_TransmitHandle *
GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle, GNUNET_DV_send (struct GNUNET_DV_ServiceHandle *sh,
const struct GNUNET_PeerIdentity *target, const char *msgbu const struct GNUNET_PeerIdentity *target,
f, const struct GNUNET_MessageHeader *msg,
size_t msgbuf_size, unsigned int priority, GNUNET_DV_MessageSentCallback cb,
struct GNUNET_TIME_Relative timeout, const void *addr, void *cb_cls);
size_t addrlen, GNUNET_TRANSPORT_TransmitContinuation cont,
void *cont_cls);
#if 0 /* keep Emacsens' auto-indent happy */ /**
{ * Abort send operation (naturally, the message may have
#endif * already been transmitted; this only stops the 'cb'
#ifdef __cplusplus * from being called again).
} *
#endif * @param th send operation to cancel
*/
void
GNUNET_DV_send_cancel (struct GNUNET_DV_TransmitHandle *th);
#endif #endif
 End of changes. 18 change blocks. 
65 lines changed or deleted 141 lines changed or added


 gnunet_fs_service.h   gnunet_fs_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other c ontributing authors) (C) 2004--2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
skipping to change at line 29 skipping to change at line 29
*/ */
/** /**
* @file include/gnunet_fs_service.h * @file include/gnunet_fs_service.h
* @brief API for file-sharing via GNUnet * @brief API for file-sharing via GNUnet
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_FS_LIB_H #ifndef GNUNET_FS_LIB_H
#define GNUNET_FS_LIB_H #define GNUNET_FS_LIB_H
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_scheduler_lib.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/** /**
skipping to change at line 57 skipping to change at line 56
* 3.0.x: with namespaces * 3.0.x: with namespaces
* 3.1.x: with namespace meta-data * 3.1.x: with namespace meta-data
* 3.2.x: with collections * 3.2.x: with collections
* 4.0.x: with expiration, variable meta-data, kblocks * 4.0.x: with expiration, variable meta-data, kblocks
* 4.1.x: with new error and configuration handling * 4.1.x: with new error and configuration handling
* 5.0.x: with location URIs * 5.0.x: with location URIs
* 6.0.0: with support for OR in KSKs * 6.0.0: with support for OR in KSKs
* 6.1.x: with simplified namespace support * 6.1.x: with simplified namespace support
* 9.0.0: CPS-style integrated API * 9.0.0: CPS-style integrated API
* 9.1.1: asynchronous directory scanning * 9.1.1: asynchronous directory scanning
* 9.2.0: unified K-Block and S-block format (#2564)
*/ */
#define GNUNET_FS_VERSION 0x00090103 #define GNUNET_FS_VERSION 0x00090200
/* ******************** URI API *********************** */ /* ******************** URI API *********************** */
#define GNUNET_FS_URI_PREFIX "gnunet://fs/" #define GNUNET_FS_URI_PREFIX "gnunet://fs/"
#define GNUNET_FS_URI_KSK_INFIX "ksk/" #define GNUNET_FS_URI_KSK_INFIX "ksk/"
#define GNUNET_FS_URI_SKS_INFIX "sks/" #define GNUNET_FS_URI_SKS_INFIX "sks/"
#define GNUNET_FS_URI_CHK_INFIX "chk/" #define GNUNET_FS_URI_CHK_INFIX "chk/"
#define GNUNET_FS_URI_LOC_INFIX "loc/" #define GNUNET_FS_URI_LOC_INFIX "loc/"
/** /**
skipping to change at line 85 skipping to change at line 85
* A Universal Resource Identifier (URI), opaque. * A Universal Resource Identifier (URI), opaque.
*/ */
struct GNUNET_FS_Uri; struct GNUNET_FS_Uri;
/** /**
* Iterator over keywords * Iterator over keywords
* *
* @param cls closure * @param cls closure
* @param keyword the keyword * @param keyword the keyword
* @param is_mandatory is the keyword mandatory (in a search) * @param is_mandatory is the keyword mandatory (in a search)
* @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to abort
*/ */
typedef int (*GNUNET_FS_KeywordIterator) (void *cls, const char *keyword, typedef int (*GNUNET_FS_KeywordIterator) (void *cls, const char *keyword,
int is_mandatory); int is_mandatory);
/** /**
* Get a unique key from a URI. This is for putting URIs * Get a unique key from a URI. This is for putting URIs
* into HashMaps. The key may change between FS implementations. * into HashMaps. The key may change between FS implementations.
* *
* @param uri uri to convert to a unique key * @param uri uri to convert to a unique key
* @param key wherer to store the unique key * @param key wherer to store the unique key
*/ */
void void
GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, struct GNUNET_HashCo GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
de * key); struct GNUNET_HashCode *key);
/** /**
* Convert a URI to a UTF-8 String. * Convert a URI to a UTF-8 String.
* *
* @param uri uri to convert to a string * @param uri uri to convert to a string
* @return the UTF-8 string * @return the UTF-8 string
*/ */
char * char *
GNUNET_FS_uri_to_string (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_to_string (const struct GNUNET_FS_Uri *uri);
skipping to change at line 128 skipping to change at line 129
/** /**
* Add the given keyword to the set of keywords represented by the URI. * Add the given keyword to the set of keywords represented by the URI.
* Does nothing if the keyword is already present. * Does nothing if the keyword is already present.
* *
* @param uri ksk uri to modify * @param uri ksk uri to modify
* @param keyword keyword to add * @param keyword keyword to add
* @param is_mandatory is this keyword mandatory? * @param is_mandatory is this keyword mandatory?
*/ */
void void
GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, const char *keywo GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri,
rd, const char *keyword,
int is_mandatory); int is_mandatory);
/** /**
* Remove the given keyword from the set of keywords represented by the URI . * Remove the given keyword from the set of keywords represented by the URI .
* Does nothing if the keyword is not present. * Does nothing if the keyword is not present.
* *
* @param uri ksk uri to modify * @param uri ksk uri to modify
* @param keyword keyword to add * @param keyword keyword to add
*/ */
void void
skipping to change at line 174 skipping to change at line 176
* @return 0 if this is not a keyword URI * @return 0 if this is not a keyword URI
*/ */
unsigned int unsigned int
GNUNET_FS_uri_ksk_get_keyword_count (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_ksk_get_keyword_count (const struct GNUNET_FS_Uri *uri);
/** /**
* Iterate over all keywords in this keyword URI. * Iterate over all keywords in this keyword URI.
* *
* @param uri ksk uri to get the keywords from * @param uri ksk uri to get the keywords from
* @param iterator function to call on each keyword * @param iterator function to call on each keyword
* @param iterator_cls closure for iterator * @param iterator_cls closure for @a iterator
* @return -1 if this is not a keyword URI, otherwise number of * @return -1 if this is not a keyword URI, otherwise number of
* keywords iterated over until iterator aborted * keywords iterated over until iterator aborted
*/ */
int int
GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri, GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri,
GNUNET_FS_KeywordIterator iterator, GNUNET_FS_KeywordIterator iterator,
void *iterator_cls); void *iterator_cls);
/** /**
* Obtain the identity of the peer offering the data * Obtain the identity of the peer offering the data
* *
* @param uri the location URI to inspect * @param uri the location URI to inspect
* @param peer where to store the identify of the peer (presumably) offerin g the content * @param peer where to store the identify of the peer (presumably) offerin g the content
* @return GNUNET_SYSERR if this is not a location URI, otherwise GNUNET_OK * @return #GNUNET_SYSERR if this is not a location URI, otherwise #GNUNET_ OK
*/ */
int int
GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri, GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri,
struct GNUNET_PeerIdentity *peer); struct GNUNET_PeerIdentity *peer);
/** /**
* Obtain the URI of the content itself. * Obtain the URI of the content itself.
* *
* @param uri location URI to get the content URI from * @param uri location URI to get the content URI from
* @return NULL if argument is not a location URI * @return NULL if argument is not a location URI
skipping to change at line 283 skipping to change at line 285
* quotes are required for keywords starting with * quotes are required for keywords starting with
* "+"); there is no mechanism for having double * "+"); there is no mechanism for having double
* quotes in the actual keywords (if the user * quotes in the actual keywords (if the user
* did specifically specify double quotes, the * did specifically specify double quotes, the
* caller should convert each double quote * caller should convert each double quote
* into two single quotes). * into two single quotes).
* @return an FS URI for the given keywords, NULL * @return an FS URI for the given keywords, NULL
* if keywords is not legal (i.e. empty). * if keywords is not legal (i.e. empty).
*/ */
struct GNUNET_FS_Uri * struct GNUNET_FS_Uri *
GNUNET_FS_uri_ksk_create_from_args (unsigned int argc, const char **argv); GNUNET_FS_uri_ksk_create_from_args (unsigned int argc,
const char **argv);
/** /**
* Test if two URIs are equal. * Test if two URIs are equal.
* *
* @param u1 one of the URIs * @param u1 one of the URIs
* @param u2 the other URI * @param u2 the other URI
* @return GNUNET_YES if the URIs are equal * @return #GNUNET_YES if the URIs are equal
*/ */
int int
GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
const struct GNUNET_FS_Uri *u2); const struct GNUNET_FS_Uri *u2);
/** /**
* Is this a namespace URI? * Is this a namespace URI?
* *
* @param uri the uri to check * @param uri the uri to check
* @return GNUNET_YES if this is an SKS uri * @return #GNUNET_YES if this is an SKS uri
*/ */
int int
GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri);
/** /**
* Handle to one of our namespaces.
*/
struct GNUNET_FS_Namespace;
/**
* Create an SKS URI from a namespace and an identifier.
*
* @param ns namespace
* @param id identifier
* @param emsg where to store an error message
* @return an FS URI for the given namespace and identifier
*/
struct GNUNET_FS_Uri *
GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id,
char **emsg);
/**
* Create an SKS URI from a namespace ID and an identifier. * Create an SKS URI from a namespace ID and an identifier.
* *
* @param nsid namespace ID * @param ns pseudonym to use
* @param id identifier * @param id identifier
* @return an FS URI for the given namespace and identifier * @return an FS URI for the given namespace and identifier
*/ */
struct GNUNET_FS_Uri * struct GNUNET_FS_Uri *
GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_HashCode * nsid, const ch GNUNET_FS_uri_sks_create (const struct GNUNET_CRYPTO_EcdsaPublicKey *ns,
ar *id); const char *id);
/** /**
* Get the ID of a namespace from the given * Get the public key of a namespace from the given
* namespace URI. * namespace URI.
* *
* @param uri the uri to get the namespace ID from * @param uri the uri to get the namespace ID from
* @param nsid where to store the ID of the namespace * @param pseudonym where to store the public key of the namespace
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
struct GNUNET_HashCode * nsid); struct GNUNET_CRYPTO_EcdsaPublicKey *pseud onym);
/** /**
* Get the content identifier of an SKS URI. * Get the content identifier of an SKS URI.
* *
* @param uri the sks uri * @param uri the sks uri
* @return NULL on error (not a valid SKS URI) * @return NULL on error (not a valid SKS URI)
*/ */
char * char *
GNUNET_FS_uri_sks_get_content_id (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_sks_get_content_id (const struct GNUNET_FS_Uri *uri);
/** /**
* Convert namespace URI to a human readable format
* (using the namespace description, if available).
*
* @param cfg configuration to use
* @param uri SKS uri to convert
* @return NULL on error (not an SKS URI)
*/
char *
GNUNET_FS_uri_sks_to_string_fancy (struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_FS_Uri *uri);
/**
* Is this a keyword URI? * Is this a keyword URI?
* *
* @param uri the uri * @param uri the uri
* @return GNUNET_YES if this is a KSK uri * @return #GNUNET_YES if this is a KSK uri
*/ */
int int
GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri);
/** /**
* Is this a file (or directory) URI? * Is this a file (or directory) URI?
* *
* @param uri the uri to check * @param uri the uri to check
* @return GNUNET_YES if this is a CHK uri * @return #GNUNET_YES if this is a CHK uri
*/ */
int int
GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri);
/** /**
* What is the size of the file that this URI * What is the size of the file that this URI
* refers to? * refers to?
* *
* @param uri the CHK (or LOC) URI to inspect * @param uri the CHK (or LOC) URI to inspect
* @return size of the file as specified in the CHK URI * @return size of the file as specified in the CHK URI
*/ */
uint64_t uint64_t
GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri *uri);
/** /**
* Is this a location URI? * Is this a location URI?
* *
* @param uri the uri to check * @param uri the uri to check
* @return GNUNET_YES if this is a LOC uri * @return #GNUNET_YES if this is a LOC uri
*/ */
int int
GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri); GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri);
/** /**
* Construct a keyword-URI from meta-data (take all entries * Construct a keyword-URI from meta-data (take all entries
* in the meta-data and construct one large keyword URI * in the meta-data and construct one large keyword URI
* that lists all keywords that can be found in the meta-data). * that lists all keywords that can be found in the meta-data).
* *
* @param md metadata to use * @param md metadata to use
skipping to change at line 426 skipping to change at line 401
/** /**
* Command-line option parser function that allows the user * Command-line option parser function that allows the user
* to specify one or more '-k' options with keywords. Each * to specify one or more '-k' options with keywords. Each
* specified keyword will be added to the URI. A pointer to * specified keyword will be added to the URI. A pointer to
* the URI must be passed as the "scls" argument. * the URI must be passed as the "scls" argument.
* *
* @param ctx command line processor context * @param ctx command line processor context
* @param scls must be of type "struct GNUNET_FS_Uri **" * @param scls must be of type "struct GNUNET_FS_Uri **"
* @param option name of the option (typically 'k') * @param option name of the option (typically 'k')
* @param value command line argument given * @param value command line argument given
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorCon text GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorCon text
*ctx, void *scls, const char *option, *ctx, void *scls, const char *option,
const char *value); const char *value);
/** /**
* Command-line option parser function that allows the user to specify * Command-line option parser function that allows the user to specify
* one or more '-m' options with metadata. Each specified entry of * one or more '-m' options with metadata. Each specified entry of
* the form "type=value" will be added to the metadata. A pointer to * the form "type=value" will be added to the metadata. A pointer to
* the metadata must be passed as the "scls" argument. * the metadata must be passed as the "scls" argument.
* *
* @param ctx command line processor context * @param ctx command line processor context
* @param scls must be of type "struct GNUNET_CONTAINER_MetaData **" * @param scls must be of type `struct GNUNET_CONTAINER_MetaData **`
* @param option name of the option (typically 'k') * @param option name of the option (typically 'k')
* @param value command line argument given * @param value command line argument given
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorCon text GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorCon text
*ctx, void *scls, const char *option, *ctx, void *scls, const char *option,
const char *value); const char *value);
/* ************************* sharing API ***************** */ /* ************************* sharing API ***************** */
/** /**
* Possible status codes used in the callback for the * Possible status codes used in the callback for the
skipping to change at line 677 skipping to change at line 652
/** /**
* Notification that the unindexing of this file * Notification that the unindexing of this file
* was completed. * was completed.
*/ */
GNUNET_FS_STATUS_UNINDEX_COMPLETED = 35, GNUNET_FS_STATUS_UNINDEX_COMPLETED = 35,
/** /**
* Notification that the unindexing of this file * Notification that the unindexing of this file
* was stopped (final event for this action). * was stopped (final event for this action).
*/ */
GNUNET_FS_STATUS_UNINDEX_STOPPED = 36 GNUNET_FS_STATUS_UNINDEX_STOPPED = 36,
/**
* Notification that we are making progress sharing a directory.
*/
GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY = 37
}; };
/** /**
* Handle for controlling an upload. * Handle for controlling an upload.
*/ */
struct GNUNET_FS_PublishContext; struct GNUNET_FS_PublishContext;
/** /**
* Handle for controlling an unindexing operation. * Handle for controlling an unindexing operation.
*/ */
skipping to change at line 799 skipping to change at line 780
uint32_t anonymity; uint32_t anonymity;
/** /**
* Additional values for specific events. * Additional values for specific events.
*/ */
union union
{ {
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_PUBLISH_PROGRESS events. * #GNUNET_FS_STATUS_PUBLISH_PROGRESS events.
*/ */
struct struct
{ {
/** /**
* Data block we just published. * Data block we just published.
*/ */
const void *data; const void *data;
/** /**
skipping to change at line 829 skipping to change at line 810
/** /**
* Depth of the given block in the tree; * Depth of the given block in the tree;
* 0 would be the lowest level (DBLOCKs). * 0 would be the lowest level (DBLOCKs).
*/ */
unsigned int depth; unsigned int depth;
} progress; } progress;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_PUBLISH_RESUME events. * #GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY events.
*/
struct
{
/**
* How far are we along in the overall directory?
*/
uint64_t completed;
/**
* How big do we estimate the entire directory to be?
*/
uint64_t total;
/**
* At what time do we expect to finish the upload of the
* CONTENTS of the directory. (The direcory itself will take
* extra time, indicated with the "eta" member at the
* "publish"-level of this struct.)
*/
struct GNUNET_TIME_Relative eta;
} progress_directory;
/**
* These values are only valid for
* #GNUNET_FS_STATUS_PUBLISH_RESUME events.
*/ */
struct struct
{ {
/** /**
* Error message, NULL if no error was encountered so far. * Error message, NULL if no error was encountered so far.
*/ */
const char *message; const char *message;
/** /**
* URI of the file (if the download had been completed) * URI of the file (if the download had been completed)
*/ */
const struct GNUNET_FS_Uri *chk_uri; const struct GNUNET_FS_Uri *chk_uri;
} resume; } resume;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_PUBLISH_COMPLETED events. * #GNUNET_FS_STATUS_PUBLISH_COMPLETED events.
*/ */
struct struct
{ {
/** /**
* URI of the file. * URI of the file.
*/ */
const struct GNUNET_FS_Uri *chk_uri; const struct GNUNET_FS_Uri *chk_uri;
} completed; } completed;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_PUBLISH_ERROR events. * #GNUNET_FS_STATUS_PUBLISH_ERROR events.
*/ */
struct struct
{ {
/** /**
* Error message, never NULL. * Error message, never NULL.
*/ */
const char *message; const char *message;
} error; } error;
skipping to change at line 962 skipping to change at line 970
int is_active; int is_active;
/** /**
* Additional values for specific events. * Additional values for specific events.
*/ */
union union
{ {
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_DOWNLOAD_PROGRESS events. * #GNUNET_FS_STATUS_DOWNLOAD_PROGRESS events.
*/ */
struct struct
{ {
/** /**
* Data block we just obtained, can be NULL (even if * Data block we just obtained, can be NULL (even if
* data_len > 0) if we found the entire block 'intact' on * data_len > 0) if we found the entire block 'intact' on
* disk. In this case, it is also possible for 'data_len' * disk. In this case, it is also possible for 'data_len'
* to be larger than an individual (32k) block. * to be larger than an individual (32k) block.
*/ */
skipping to change at line 987 skipping to change at line 995
*/ */
uint64_t offset; uint64_t offset;
/** /**
* Length of the data block. * Length of the data block.
*/ */
uint64_t data_len; uint64_t data_len;
/** /**
* How much time passed between us asking for this block and * How much time passed between us asking for this block and
* actually getting it? GNUNET_TIME_UNIT_FOREVER_REL if unknown. * actually getting it? #GNUNET_TIME_UNIT_FOREVER_REL if unknown.
*/ */
struct GNUNET_TIME_Relative block_download_duration; struct GNUNET_TIME_Relative block_download_duration;
/** /**
* Depth of the given block in the tree; * Depth of the given block in the tree;
* 0 would be the lowest level (DBLOCKS). * 0 would be the lowest level (DBLOCKS).
*/ */
unsigned int depth; unsigned int depth;
/** /**
skipping to change at line 1017 skipping to change at line 1025
* because we might have the same request pending for multiple cli ents, * because we might have the same request pending for multiple cli ents,
* and of course because a transmission may have failed at a lower * and of course because a transmission may have failed at a lower
* layer). * layer).
*/ */
uint32_t num_transmissions; uint32_t num_transmissions;
} progress; } progress;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_DOWNLOAD_START events. * #GNUNET_FS_STATUS_DOWNLOAD_START events.
*/ */
struct struct
{ {
/** /**
* Known metadata for the download. * Known metadata for the download.
*/ */
const struct GNUNET_CONTAINER_MetaData *meta; const struct GNUNET_CONTAINER_MetaData *meta;
} start; } start;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_DOWNLOAD_RESUME events. * #GNUNET_FS_STATUS_DOWNLOAD_RESUME events.
*/ */
struct struct
{ {
/** /**
* Known metadata for the download. * Known metadata for the download.
*/ */
const struct GNUNET_CONTAINER_MetaData *meta; const struct GNUNET_CONTAINER_MetaData *meta;
/** /**
* Error message, NULL if we have not encountered any error yet. * Error message, NULL if we have not encountered any error yet.
*/ */
const char *message; const char *message;
} resume; } resume;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_DOWNLOAD_ERROR events. * #GNUNET_FS_STATUS_DOWNLOAD_ERROR events.
*/ */
struct struct
{ {
/** /**
* Error message. * Error message.
*/ */
const char *message; const char *message;
} error; } error;
skipping to change at line 1124 skipping to change at line 1132
uint32_t anonymity; uint32_t anonymity;
/** /**
* Additional values for specific events. * Additional values for specific events.
*/ */
union union
{ {
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_SEARCH_RESULT events. * #GNUNET_FS_STATUS_SEARCH_RESULT events.
*/ */
struct struct
{ {
/** /**
* Metadata for the search result. * Metadata for the search result.
*/ */
const struct GNUNET_CONTAINER_MetaData *meta; const struct GNUNET_CONTAINER_MetaData *meta;
/** /**
skipping to change at line 1154 skipping to change at line 1162
/** /**
* Applicability rank (the larger, the better the result * Applicability rank (the larger, the better the result
* fits the search criteria). * fits the search criteria).
*/ */
uint32_t applicability_rank; uint32_t applicability_rank;
} result; } result;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_SEARCH_RESUME_RESULT events. * #GNUNET_FS_STATUS_SEARCH_RESUME_RESULT events.
*/ */
struct struct
{ {
/** /**
* Metadata for the search result. * Metadata for the search result.
*/ */
const struct GNUNET_CONTAINER_MetaData *meta; const struct GNUNET_CONTAINER_MetaData *meta;
/** /**
skipping to change at line 1197 skipping to change at line 1205
* Updated applicability rank (the larger, * Updated applicability rank (the larger,
* the better the result fits the search * the better the result fits the search
* criteria). * criteria).
*/ */
uint32_t applicability_rank; uint32_t applicability_rank;
} resume_result; } resume_result;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_SEARCH_UPDATE events. * #GNUNET_FS_STATUS_SEARCH_UPDATE events.
*/ */
struct struct
{ {
/** /**
* Private context set for for this result * Private context set for for this result
* during the "RESULT" event. * during the "RESULT" event.
*/ */
void *cctx; void *cctx;
skipping to change at line 1246 skipping to change at line 1254
/** /**
* How long has the current probe been active? * How long has the current probe been active?
*/ */
struct GNUNET_TIME_Relative current_probe_time; struct GNUNET_TIME_Relative current_probe_time;
} update; } update;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND events. * #GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND events.
* These events are automatically triggered for * These events are automatically triggered for
* each search result before the * each search result before the
* GNUNET_FS_STATUS_SEARCH_SUSPEND event. This * #GNUNET_FS_STATUS_SEARCH_SUSPEND event. This
* happens primarily to give the client a chance * happens primarily to give the client a chance
* to clean up the "cctx" (if needed). * to clean up the "cctx" (if needed).
*/ */
struct struct
{ {
/** /**
* Private context set for for this result * Private context set for for this result
* during the "RESULT" event. * during the "RESULT" event.
*/ */
skipping to change at line 1276 skipping to change at line 1284
/** /**
* URI for the search result. * URI for the search result.
*/ */
const struct GNUNET_FS_Uri *uri; const struct GNUNET_FS_Uri *uri;
} result_suspend; } result_suspend;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED events. * #GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED events.
* These events are automatically triggered for * These events are automatically triggered for
* each search result before the * each search result before the
* GNUNET_FS_STATUS_SEARCH_STOPPED event. This * #GNUNET_FS_STATUS_SEARCH_STOPPED event. This
* happens primarily to give the client a chance * happens primarily to give the client a chance
* to clean up the "cctx" (if needed). * to clean up the "cctx" (if needed).
*/ */
struct struct
{ {
/** /**
* Private context set for for this result * Private context set for for this result
* during the "RESULT" event. * during the "RESULT" event.
*/ */
skipping to change at line 1306 skipping to change at line 1314
/** /**
* URI for the search result. * URI for the search result.
*/ */
const struct GNUNET_FS_Uri *uri; const struct GNUNET_FS_Uri *uri;
} result_stopped; } result_stopped;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_SEARCH_RESUME events. * #GNUNET_FS_STATUS_SEARCH_RESUME events.
*/ */
struct struct
{ {
/** /**
* Error message, NULL if we have not encountered any error yet. * Error message, NULL if we have not encountered any error yet.
*/ */
const char *message; const char *message;
/** /**
* Is this search currently paused? * Is this search currently paused?
*/ */
int is_paused; int is_paused;
} resume; } resume;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_SEARCH_ERROR events. * #GNUNET_FS_STATUS_SEARCH_ERROR events.
*/ */
struct struct
{ {
/** /**
* Error message. * Error message.
*/ */
const char *message; const char *message;
} error; } error;
/** /**
* Values for all "GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE" events. * Values for #GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE events.
*/ */
struct struct
{ {
/** /**
* Handle to the namespace (NULL if it is not a local
* namespace).
*/
struct GNUNET_FS_Namespace *ns;
/**
* Short, human-readable name of the namespace. * Short, human-readable name of the namespace.
*/ */
const char *name; const char *name;
/** /**
* Root identifier for the namespace, can be NULL. * Root identifier for the namespace, can be NULL.
*/ */
const char *root; const char *root;
/** /**
* Metadata for the namespace. * Metadata for the namespace.
*/ */
const struct GNUNET_CONTAINER_MetaData *meta; const struct GNUNET_CONTAINER_MetaData *meta;
/** /**
* Hash-identifier for the namespace. * Public key of the namespace.
*/ */
struct GNUNET_HashCode id; struct GNUNET_CRYPTO_EcdsaPublicKey pseudonym;
} ns; } ns;
} specifics; } specifics;
} search; } search;
/** /**
* Values for all "GNUNET_FS_STATUS_UNINDEX_*" events. * Values for all "GNUNET_FS_STATUS_UNINDEX_*" events.
*/ */
skipping to change at line 1429 skipping to change at line 1431
uint64_t completed; uint64_t completed;
/** /**
* Additional values for specific events. * Additional values for specific events.
*/ */
union union
{ {
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_UNINDEX_PROGRESS events. * #GNUNET_FS_STATUS_UNINDEX_PROGRESS events.
*/ */
struct struct
{ {
/** /**
* Data block we just unindexed. * Data block we just unindexed.
*/ */
const void *data; const void *data;
/** /**
skipping to change at line 1459 skipping to change at line 1461
/** /**
* Depth of the given block in the tree; * Depth of the given block in the tree;
* 0 would be the lowest level (DBLOCKS). * 0 would be the lowest level (DBLOCKS).
*/ */
unsigned int depth; unsigned int depth;
} progress; } progress;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_UNINDEX_RESUME events. * #GNUNET_FS_STATUS_UNINDEX_RESUME events.
*/ */
struct struct
{ {
/** /**
* Error message, NULL if we have not encountered any error yet. * Error message, NULL if we have not encountered any error yet.
*/ */
const char *message; const char *message;
} resume; } resume;
/** /**
* These values are only valid for * These values are only valid for
* GNUNET_FS_STATUS_UNINDEX_ERROR events. * #GNUNET_FS_STATUS_UNINDEX_ERROR events.
*/ */
struct struct
{ {
/** /**
* Error message. * Error message.
*/ */
const char *message; const char *message;
} error; } error;
skipping to change at line 1496 skipping to change at line 1498
} unindex; } unindex;
} value; } value;
/** /**
* Specific status code (determines the event type). * Specific status code (determines the event type).
*/ */
enum GNUNET_FS_Status status; enum GNUNET_FS_Status status;
/**
* File-sharing handle that generated the event.
*/
struct GNUNET_FS_Handle *fsh;
}; };
/** /**
* Notification of FS to a client about the progress of an * Notification of FS to a client about the progress of an
* operation. Callbacks of this type will be used for uploads, * operation. Callbacks of this type will be used for uploads,
* downloads and searches. Some of the arguments depend a bit * downloads and searches. Some of the arguments depend a bit
* in their meaning on the context in which the callback is used. * in their meaning on the context in which the callback is used.
* *
* @param cls closure * @param cls closure
* @param info details about the event, specifying the event type * @param info details about the event, specifying the event type
* and various bits about the event * and various bits about the event
* @return client-context (for the next progress call * @return client-context (for the next progress call
* for this operation; should be set to NULL for * for this operation; should be set to NULL for
* SUSPEND and STOPPED events). The value returned * SUSPEND and STOPPED events). The value returned
* will be passed to future callbacks in the respective * will be passed to future callbacks in the respective
* field in the GNUNET_FS_ProgressInfo struct. * field in the `struct GNUNET_FS_ProgressInfo`.
*/ */
typedef void *(*GNUNET_FS_ProgressCallback) (void *cls, typedef void *(*GNUNET_FS_ProgressCallback) (void *cls,
const struct GNUNET_FS_Progres sInfo *info); const struct GNUNET_FS_Progres sInfo *info);
/** /**
* General (global) option flags for file-sharing. * General (global) option flags for file-sharing.
*/ */
enum GNUNET_FS_Flags enum GNUNET_FS_Flags
{ {
/** /**
* No special flags set. * No special flags set.
*/ */
GNUNET_FS_FLAGS_NONE = 0, GNUNET_FS_FLAGS_NONE = 0,
/** /**
* Is persistence of operations desired? * Is persistence of operations desired?
* (will create SUSPEND/RESUME events). * (will create SUSPEND/RESUME events).
*/ */
GNUNET_FS_FLAGS_PERSISTENCE = 1, GNUNET_FS_FLAGS_PERSISTENCE = 1,
/** /**
* Should we automatically trigger probes for search results * Should we automatically trigger probes for search results
* to determine availability? * to determine availability?
* (will create GNUNET_FS_STATUS_SEARCH_UPDATE events). * (will create #GNUNET_FS_STATUS_SEARCH_UPDATE events).
*/ */
GNUNET_FS_FLAGS_DO_PROBES = 2 GNUNET_FS_FLAGS_DO_PROBES = 2
}; };
/** /**
* Options specified in the VARARGs portion of GNUNET_FS_start. * Options specified in the VARARGs portion of GNUNET_FS_start.
*/ */
enum GNUNET_FS_OPTIONS enum GNUNET_FS_OPTIONS
{ {
/** /**
skipping to change at line 1612 skipping to change at line 1618
* Naturally, there is no guarantee that the other peers will keep * Naturally, there is no guarantee that the other peers will keep
* these blocks for any period of time (since they won't have any * these blocks for any period of time (since they won't have any
* priority or might be too busy to even store the block in the * priority or might be too busy to even store the block in the
* first place). * first place).
*/ */
uint32_t replication_level; uint32_t replication_level;
}; };
/** /**
* Return the current year (i.e. '2011').
*/
unsigned int
GNUNET_FS_get_current_year (void);
/**
* Convert a year to an expiration time of January 1st of that year.
*
* @param year a year (after 1970, please ;-)).
* @return absolute time for January 1st of that year.
*/
struct GNUNET_TIME_Absolute
GNUNET_FS_year_to_time (unsigned int year);
/**
* Convert an expiration time to the respective year (rounds)
*
* @param at absolute time
* @return year a year (after 1970), 0 on error
*/
unsigned int
GNUNET_FS_time_to_year (struct GNUNET_TIME_Absolute at);
/**
* Handle to the file-sharing service. * Handle to the file-sharing service.
*/ */
struct GNUNET_FS_Handle; struct GNUNET_FS_Handle;
/** /**
* Setup a connection to the file-sharing service. * Setup a connection to the file-sharing service.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param client_name unique identifier for this client * @param client_name unique identifier for this client
* @param upcb function to call to notify about FS actions * @param upcb function to call to notify about FS actions
* @param upcb_cls closure for upcb * @param upcb_cls closure for @a upcb
* @param flags specific attributes for fs-operations * @param flags specific attributes for fs-operations
* @param ... list of optional options, terminated with GNUNET_FS_OPTIONS_E ND * @param ... list of optional options, terminated with #GNUNET_FS_OPTIONS_ END
* @return NULL on error * @return NULL on error
*/ */
struct GNUNET_FS_Handle * struct GNUNET_FS_Handle *
GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *client_name, GNUNET_FS_ProgressCallback upcb, const char *client_name, GNUNET_FS_ProgressCallback upcb,
void *upcb_cls, enum GNUNET_FS_Flags flags, ...); void *upcb_cls, enum GNUNET_FS_Flags flags, ...);
/** /**
* Close our connection with the file-sharing service. * Close our connection with the file-sharing service.
* The callback given to GNUNET_FS_start will no longer be * The callback given to GNUNET_FS_start will no longer be
* called after this function returns. * called after this function returns.
* *
* @param h handle that was returned from GNUNET_FS_start * @param h handle that was returned from GNUNET_FS_start
*/ */
void void
GNUNET_FS_stop (struct GNUNET_FS_Handle *h); GNUNET_FS_stop (struct GNUNET_FS_Handle *h);
/** /**
* Function called on entries in a GNUNET_FS_FileInformation publish-struct ure. * Function called on entries in a `struct GNUNET_FS_FileInformation` itera tion.
* *
* @param cls closure * @param cls closure
* @param fi the entry in the publish-structure * @param fi the entry in the publish-structure
* @param length length of the file or directory * @param length length of the file or directory
* @param meta metadata for the file or directory (can be modified) * @param meta metadata for the file or directory (can be modified)
* @param uri pointer to the keywords that will be used for this entry (can be modified) * @param uri pointer to the keywords that will be used for this entry (can be modified)
* @param bo block options (can be modified) * @param bo block options (can be modified)
* @param do_index should we index (can be modified) * @param do_index should we index (can be modified)
* @param client_info pointer to client context set upon creation (can be m odified) * @param client_info pointer to client context set upon creation (can be m odified)
* @return GNUNET_OK to continue, GNUNET_NO to remove * @return #GNUNET_OK to continue, #GNUNET_NO to remove
* this entry from the directory, GNUNET_SYSERR * this entry from the directory, #GNUNET_SYSERR
* to abort the iteration * to abort the iteration
*/ */
typedef int (*GNUNET_FS_FileInformationProcessor) (void *cls, typedef int (*GNUNET_FS_FileInformationProcessor) (void *cls,
struct struct
GNUNET_FS_FileInformatio n * GNUNET_FS_FileInformatio n *
fi, uint64_t length, fi, uint64_t length,
struct struct
GNUNET_CONTAINER_MetaDat a * GNUNET_CONTAINER_MetaDat a *
meta, meta,
struct GNUNET_FS_Uri ** uri, struct GNUNET_FS_Uri ** uri,
struct GNUNET_FS_BlockOp tions struct GNUNET_FS_BlockOp tions
* bo, int *do_index, * bo, int *do_index,
void **client_info); void **client_info);
/** /**
* Obtain the name under which this file information * Obtain the name under which this file information
* structure is stored on disk. Only works for top-level * structure is stored on disk. Only works for top-level
* file information structures. * file information structures.
* *
* @param s structure to get the filename for * @param s structure to get the filename for
* @return NULL on error, otherwise filename that * @return NULL on error, otherwise filename that can be used
* can be passed to "GNUNET_FS_file_information_recover"
* to read this fi-struct from disk. * to read this fi-struct from disk.
*/ */
const char * const char *
GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s); GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s);
/** /**
* Obtain the filename from the file information structure. * Obtain the filename from the file information structure.
* *
* @param s structure to get the filename for * @param s structure to get the filename for
* @return "filename" field of the structure (can be NULL) * @return "filename" field of the structure (can be NULL)
skipping to change at line 1736 skipping to change at line 1717
/** /**
* Create an entry for a file in a publish-structure. * Create an entry for a file in a publish-structure.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param client_info initial client-info value for this entry * @param client_info initial client-info value for this entry
* @param filename name of the file or directory to publish * @param filename name of the file or directory to publish
* @param keywords under which keywords should this file be available * @param keywords under which keywords should this file be available
* directly; can be NULL * directly; can be NULL
* @param meta metadata for the file * @param meta metadata for the file
* @param do_index GNUNET_YES for index, GNUNET_NO for insertion, * @param do_index #GNUNET_YES for index, #GNUNET_NO for insertion,
* GNUNET_SYSERR for simulation * #GNUNET_SYSERR for simulation
* @param bo block options * @param bo block options
* @return publish structure entry for the file * @return publish structure entry for the file
*/ */
struct GNUNET_FS_FileInformation * struct GNUNET_FS_FileInformation *
GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
void *client_info, void *client_info,
const char *filename, const char *filename,
const struct GNUNET_FS_Uri const struct GNUNET_FS_Uri
*keywords, *keywords,
const struct const struct
skipping to change at line 1764 skipping to change at line 1745
* Create an entry for a file in a publish-structure. * Create an entry for a file in a publish-structure.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param client_info initial client-info value for this entry * @param client_info initial client-info value for this entry
* @param length length of the file * @param length length of the file
* @param data data for the file (should not be used afterwards by * @param data data for the file (should not be used afterwards by
* the caller; callee will "free") * the caller; callee will "free")
* @param keywords under which keywords should this file be available * @param keywords under which keywords should this file be available
* directly; can be NULL * directly; can be NULL
* @param meta metadata for the file * @param meta metadata for the file
* @param do_index GNUNET_YES for index, GNUNET_NO for insertion, * @param do_index #GNUNET_YES for index, #GNUNET_NO for insertion,
* GNUNET_SYSERR for simulation * #GNUNET_SYSERR for simulation
* @param bo block options * @param bo block options
* @return publish structure entry for the file * @return publish structure entry for the file
*/ */
struct GNUNET_FS_FileInformation * struct GNUNET_FS_FileInformation *
GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
void *client_info, uint64_t le ngth, void *client_info, uint64_t le ngth,
void *data, void *data,
const struct GNUNET_FS_Uri const struct GNUNET_FS_Uri
*keywords, *keywords,
const struct const struct
skipping to change at line 1799 skipping to change at line 1780
* (used to close the file descriptor but NOT fully * (used to close the file descriptor but NOT fully
* clean up the reader's state); in this case, * clean up the reader's state); in this case,
* a value of '0' for max should be ignored * a value of '0' for max should be ignored
* @param max maximum number of bytes that should be * @param max maximum number of bytes that should be
* copied to buf; readers are not allowed * copied to buf; readers are not allowed
* to provide less data unless there is an error; * to provide less data unless there is an error;
* a value of "0" will be used at the end to allow * a value of "0" will be used at the end to allow
* the reader to clean up its internal state * the reader to clean up its internal state
* @param buf where the reader should write the data * @param buf where the reader should write the data
* @param emsg location for the reader to store an error message * @param emsg location for the reader to store an error message
* @return number of bytes written, usually "max", 0 on error * @return number of bytes written, usually @a max, 0 on error
*/ */
typedef size_t (*GNUNET_FS_DataReader) (void *cls, uint64_t offset, size_t max, typedef size_t (*GNUNET_FS_DataReader) (void *cls, uint64_t offset, size_t max,
void *buf, char **emsg); void *buf, char **emsg);
/** /**
* Create an entry for a file in a publish-structure. * Create an entry for a file in a publish-structure.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param client_info initial client-info value for this entry * @param client_info initial client-info value for this entry
* @param length length of the file * @param length length of the file
* @param reader function that can be used to obtain the data for the file * @param reader function that can be used to obtain the data for the file
* @param reader_cls closure for "reader" * @param reader_cls closure for @a reader
* @param keywords under which keywords should this file be available * @param keywords under which keywords should this file be available
* directly; can be NULL * directly; can be NULL
* @param meta metadata for the file * @param meta metadata for the file
* @param do_index GNUNET_YES for index, GNUNET_NO for insertion, * @param do_index #GNUNET_YES for index, #GNUNET_NO for insertion,
* GNUNET_SYSERR for simulation * #GNUNET_SYSERR for simulation
* @param bo block options * @param bo block options
* @return publish structure entry for the file * @return publish structure entry for the file
*/ */
struct GNUNET_FS_FileInformation * struct GNUNET_FS_FileInformation *
GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h, GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
void *client_info, void *client_info,
uint64_t length, uint64_t length,
GNUNET_FS_DataReader reader, GNUNET_FS_DataReader reader,
void *reader_cls, void *reader_cls,
const struct GNUNET_FS_Uri const struct GNUNET_FS_Uri
*keywords, *keywords,
const struct const struct
GNUNET_CONTAINER_MetaData *m eta, GNUNET_CONTAINER_MetaData *m eta,
int do_index, int do_index,
const struct const struct
GNUNET_FS_BlockOptions *bo); GNUNET_FS_BlockOptions *bo);
/** /**
* Create an entry for an empty directory in a publish-structure. * Create an entry for an empty directory in a publish-structure.
* This function should be used by applications for which the
* use of "GNUNET_FS_file_information_create_from_directory"
* is not appropriate.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param client_info initial client-info value for this entry * @param client_info initial client-info value for this entry
* @param keywords under which keywords should this directory be available * @param keywords under which keywords should this directory be available
* directly; can be NULL * directly; can be NULL
* @param meta metadata for the directory * @param meta metadata for the directory
* @param bo block options * @param bo block options
* @param filename name of the directory; can be NULL * @param filename name of the directory; can be NULL
* @return publish structure entry for the directory , NULL on error * @return publish structure entry for the directory , NULL on error
*/ */
skipping to change at line 1865 skipping to change at line 1843
GNUNET_CONTAINER_MetaDat a GNUNET_CONTAINER_MetaDat a
*meta, *meta,
const struct const struct
GNUNET_FS_BlockOptions * bo, GNUNET_FS_BlockOptions * bo,
const char *filename); const char *filename);
/** /**
* Test if a given entry represents a directory. * Test if a given entry represents a directory.
* *
* @param ent check if this FI represents a directory * @param ent check if this FI represents a directory
* @return GNUNET_YES if so, GNUNET_NO if not * @return #GNUNET_YES if so, #GNUNET_NO if not
*/ */
int int
GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInforma tion GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInforma tion
*ent); *ent);
/** /**
* Add an entry to a directory in a publish-structure. Clients * Add an entry to a directory in a publish-structure. Clients
* should never modify publish structures that were passed to * should never modify publish structures that were passed to
* "GNUNET_FS_publish_start" already. * #GNUNET_FS_publish_start already.
* *
* @param dir the directory * @param dir the directory
* @param ent the entry to add; the entry must not have been * @param ent the entry to add; the entry must not have been
* added to any other directory at this point and * added to any other directory at this point and
* must not include "dir" in its structure * must not include @a dir in its structure
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir, GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
struct GNUNET_FS_FileInformation *ent); struct GNUNET_FS_FileInformation *ent);
/** /**
* Inspect a file or directory in a publish-structure. Clients * Inspect a file or directory in a publish-structure. Clients
* should never modify publish structures that were passed to * should never modify publish structures that were passed to
* "GNUNET_FS_publish_start" already. When called on a directory, * #GNUNET_FS_publish_start already. When called on a directory,
* this function will FIRST call "proc" with information about * this function will FIRST call @a proc with information about
* the directory itself and then for each of the files in the * the directory itself and then for each of the files in the
* directory (but not for files in subdirectories). When called * directory (but not for files in subdirectories). When called
* on a file, "proc" will be called exactly once (with information * on a file, @a proc will be called exactly once (with information
* about the specific file). * about the specific file).
* *
* @param dir the directory * @param dir the directory
* @param proc function to call on each entry * @param proc function to call on each entry
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
*/ */
void void
GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir, GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
GNUNET_FS_FileInformationProcessor proc , GNUNET_FS_FileInformationProcessor proc ,
void *proc_cls); void *proc_cls);
/** /**
* Destroy publish-structure. Clients should never destroy publish * Destroy publish-structure. Clients should never destroy publish
* structures that were passed to "GNUNET_FS_publish_start" already. * structures that were passed to #GNUNET_FS_publish_start already.
* *
* @param fi structure to destroy * @param fi structure to destroy
* @param cleaner function to call on each entry in the structure * @param cleaner function to call on each entry in the structure
* (useful to clean up client_info); can be NULL; return * (useful to clean up client_info); can be NULL; return
* values are ignored * values are ignored
* @param cleaner_cls closure for cleaner * @param cleaner_cls closure for @a cleaner
*/ */
void void
GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
GNUNET_FS_FileInformationProcessor clea ner, GNUNET_FS_FileInformationProcessor clea ner,
void *cleaner_cls); void *cleaner_cls);
/** /**
* Options for publishing. Compatible options * Options for publishing. Compatible options
* can be OR'ed together. * can be OR'ed together.
*/ */
enum GNUNET_FS_PublishOptions enum GNUNET_FS_PublishOptions
{ {
/** /**
* No options (use defaults for everything). * No options (use defaults for everything).
*/ */
GNUNET_FS_PUBLISH_OPTION_NONE = 0, GNUNET_FS_PUBLISH_OPTION_NONE = 0,
/** /**
* Simulate publishing. With this option, no data will be stored * Simulate publishing. With this option, no data will be stored
* in the datastore. Useful for computing URIs from files. * in the datastore. Useful for computing URIs from files.
*/ */
GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY = 1 GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY = 1
}; };
/** /**
* Publish a file or directory. * Publish a file or directory.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param fi information about the file or directory structure to publish * @param fi information about the file or directory structure to publish
* @param ns namespace to publish the file in, NULL for no namespace * @param ns namespace to publish the file in, NULL for no namespace
* @param nid identifier to use for the publishd content in the namespace * @param nid identifier to use for the publishd content in the namespace
* (can be NULL, must be NULL if namespace is NULL) * (can be NULL, must be NULL if namespace is NULL)
* @param nuid update-identifier that will be used for future updates * @param nuid update-identifier that will be used for future updates
* (can be NULL, must be NULL if namespace or nid is NULL) * (can be NULL, must be NULL if namespace or nid is NULL)
* @param options options for the publication * @param options options for the publication
* @return context that can be used to control the publish operation * @return context that can be used to control the publish operation
*/ */
struct GNUNET_FS_PublishContext * struct GNUNET_FS_PublishContext *
GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
struct GNUNET_FS_FileInformation *fi, struct GNUNET_FS_FileInformation *fi,
struct GNUNET_FS_Namespace *ns, const char *nid, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
const char *nid,
const char *nuid, const char *nuid,
enum GNUNET_FS_PublishOptions options); enum GNUNET_FS_PublishOptions options);
/** /**
* Stop a publication. Will abort incomplete publications (but * Stop a publication. Will abort incomplete publications (but
* not remove blocks that have already been published) or * not remove blocks that have already been published) or
* simply clean up the state for completed publications. * simply clean up the state for completed publications.
* Must NOT be called from within the event callback! * Must NOT be called from within the event callback!
* *
* @param pc context for the publication to stop * @param pc context for the publication to stop
skipping to change at line 1978 skipping to change at line 1957
/** /**
* Signature of a function called as the continuation of a KBlock or * Signature of a function called as the continuation of a KBlock or
* SBlock publication. * SBlock publication.
* *
* @param cls closure * @param cls closure
* @param uri URI under which the block is now available, NULL on error * @param uri URI under which the block is now available, NULL on error
* @param emsg error message, NULL on success * @param emsg error message, NULL on success
*/ */
typedef void (*GNUNET_FS_PublishContinuation) (void *cls, typedef void (*GNUNET_FS_PublishContinuation) (void *cls,
const struct GNUNET_FS_Uri * uri, const struct GNUNET_FS_Uri * uri,
const char *emsg); const char *emsg);
/** /**
* Handle to cancel publish KSK operation. * Handle to cancel publish KSK operation.
*/ */
struct GNUNET_FS_PublishKskContext; struct GNUNET_FS_PublishKskContext;
/** /**
* Publish a KBlock on GNUnet. * Publish a KBlock on GNUnet.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param ksk_uri keywords to use * @param ksk_uri keywords to use
* @param meta metadata to use * @param meta metadata to use
* @param uri URI to refer to in the KBlock * @param uri URI to refer to in the KBlock
* @param bo block options * @param bo block options
* @param options publication options * @param options publication options
* @param cont continuation * @param cont continuation
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return NULL on error ('cont' will still be called) * @return NULL on error (@a cont will still be called)
*/ */
struct GNUNET_FS_PublishKskContext * struct GNUNET_FS_PublishKskContext *
GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_FS_Uri *ksk_uri,
const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_CONTAINER_MetaData *meta,
const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo, const struct GNUNET_FS_BlockOptions *bo,
enum GNUNET_FS_PublishOptions options, enum GNUNET_FS_PublishOptions options,
GNUNET_FS_PublishContinuation cont, void *cont_cls); GNUNET_FS_PublishContinuation cont, void *cont_cls);
skipping to change at line 2033 skipping to change at line 2012
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param ns namespace to publish in * @param ns namespace to publish in
* @param identifier identifier to use * @param identifier identifier to use
* @param update update identifier to use * @param update update identifier to use
* @param meta metadata to use * @param meta metadata to use
* @param uri URI to refer to in the SBlock * @param uri URI to refer to in the SBlock
* @param bo block options * @param bo block options
* @param options publication options * @param options publication options
* @param cont continuation * @param cont continuation
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return NULL on error ('cont' will still be called) * @return NULL on error (@a cont will still be called)
*/ */
struct GNUNET_FS_PublishSksContext * struct GNUNET_FS_PublishSksContext *
GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
struct GNUNET_FS_Namespace *ns, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
const char *identifier, const char *update, const char *identifier,
const char *update,
const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_CONTAINER_MetaData *meta,
const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_Uri *uri,
const struct GNUNET_FS_BlockOptions *bo, const struct GNUNET_FS_BlockOptions *bo,
enum GNUNET_FS_PublishOptions options, enum GNUNET_FS_PublishOptions options,
GNUNET_FS_PublishContinuation cont, void *cont_cls); GNUNET_FS_PublishContinuation cont, void *cont_cls);
/** /**
* Abort the SKS publishing operation. * Abort the SKS publishing operation.
* *
* @param psc context of the operation to abort. * @param psc context of the operation to abort.
*/ */
void void
GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc); GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc);
/** /**
* Type of a function called by "GNUNET_FS_get_indexed_files". * Type of a function called by #GNUNET_FS_get_indexed_files.
* *
* @param cls closure * @param cls closure
* @param filename the name of the file, NULL for end of list * @param filename the name of the file, NULL for end of list
* @param file_id hash of the contents of the indexed file * @param file_id hash of the contents of the indexed file
* @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort
*/ */
typedef int (*GNUNET_FS_IndexedFileProcessor) (void *cls, const char *filen ame, typedef int (*GNUNET_FS_IndexedFileProcessor) (void *cls, const char *filen ame,
const struct GNUNET_HashCode * file_id); const struct GNUNET_HashCode * file_id);
/** /**
* Handle to cancel 'GNUNET_FS_get_indexed_files'. * Handle to cancel 'GNUNET_FS_get_indexed_files'.
*/ */
struct GNUNET_FS_GetIndexedContext; struct GNUNET_FS_GetIndexedContext;
/** /**
* Iterate over all indexed files. * Iterate over all indexed files.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param iterator function to call on each indexed file * @param iterator function to call on each indexed file
* @param iterator_cls closure for iterator * @param iterator_cls closure for @a iterator
* @return NULL on error ('iter' is not called) * @return NULL on error (@a iterator is not called)
*/ */
struct GNUNET_FS_GetIndexedContext * struct GNUNET_FS_GetIndexedContext *
GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
GNUNET_FS_IndexedFileProcessor iterator, GNUNET_FS_IndexedFileProcessor iterator,
void *iterator_cls); void *iterator_cls);
/** /**
* Cancel iteration over all indexed files. * Cancel iteration over all indexed files.
* *
* @param gic operation to cancel * @param gic operation to cancel
skipping to change at line 2100 skipping to change at line 2080
/** /**
* Unindex a file. * Unindex a file.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param filename file to unindex * @param filename file to unindex
* @param cctx initial value for the client context * @param cctx initial value for the client context
* @return NULL on error, otherwise handle * @return NULL on error, otherwise handle
*/ */
struct GNUNET_FS_UnindexContext * struct GNUNET_FS_UnindexContext *
GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename, GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
const char *filename,
void *cctx); void *cctx);
/** /**
* Clean up after completion of an unindex operation. * Clean up after completion of an unindex operation.
* *
* @param uc handle * @param uc handle
*/ */
void void
GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc); GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc);
/** /**
* Context for advertising a namespace.
*/
struct GNUNET_FS_AdvertisementContext;
/**
* Publish an advertismement for a namespace.
*
* @param h handle to the file sharing subsystem
* @param ksk_uri keywords to use for advertisment
* @param ns handle for the namespace that should be advertised
* @param meta meta-data for the namespace advertisement
* @param bo block options
* @param rootEntry name of the root of the namespace
* @param cont continuation
* @param cont_cls closure for cont
* @return NULL on error ('cont' will still be called)
*/
struct GNUNET_FS_AdvertisementContext *
GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
struct GNUNET_FS_Uri *ksk_uri,
struct GNUNET_FS_Namespace *ns,
const struct GNUNET_CONTAINER_MetaData *meta
,
const struct GNUNET_FS_BlockOptions *bo,
const char *rootEntry,
GNUNET_FS_PublishContinuation cont,
void *cont_cls);
/**
* Abort the namespace advertisement operation.
*
* @param ac context of the operation to abort.
*/
void
GNUNET_FS_namespace_advertise_cancel (struct GNUNET_FS_AdvertisementContext
*ac);
/**
* Create a namespace with the given name; if one already
* exists, return a handle to the existing namespace.
*
* @param h handle to the file sharing subsystem
* @param name name to use for the namespace
* @return handle to the namespace, NULL on error (i.e. invalid filename)
*/
struct GNUNET_FS_Namespace *
GNUNET_FS_namespace_create (struct GNUNET_FS_Handle *h, const char *name);
/**
* Duplicate a namespace handle.
*
* @param ns namespace handle
* @return duplicated handle to the namespace
*/
struct GNUNET_FS_Namespace *
GNUNET_FS_namespace_dup (struct GNUNET_FS_Namespace *ns);
/**
* Delete a namespace handle. Can be used for a clean shutdown (free
* memory) or also to freeze the namespace to prevent further
* insertions by anyone.
*
* @param ns handle to the namespace that should be deleted / freed
* @param freeze prevents future insertions; creating a namespace
* with the same name again will create a fresh namespace instead
*
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *ns, int freeze);
/**
* Callback with information about local (!) namespaces.
* Contains the names of the local namespace and the global
* ID.
*
* @param cls closure
* @param name human-readable identifier of the namespace
* @param id hash identifier for the namespace
*/
typedef void (*GNUNET_FS_NamespaceInfoProcessor) (void *cls, const char *na
me,
const struct GNUNET_HashC
ode * id);
/**
* Build a list of all available local (!) namespaces The returned
* names are only the nicknames since we only iterate over the local
* namespaces.
*
* @param h handle to the file sharing subsystem
* @param cb function to call on each known namespace
* @param cb_cls closure for cb
*/
void
GNUNET_FS_namespace_list (struct GNUNET_FS_Handle *h,
GNUNET_FS_NamespaceInfoProcessor cb, void *cb_cls
);
/**
* Function called on updateable identifiers. * Function called on updateable identifiers.
* *
* @param cls closure * @param cls closure
* @param last_id last identifier * @param last_id last identifier
* @param last_uri uri used for the content published under the last_id * @param last_uri uri used for the content published under the @a last_id
* @param last_meta metadata associated with last_uri * @param last_meta metadata associated with @a last_uri
* @param next_id identifier that should be used for updates * @param next_id identifier that should be used for updates
*/ */
typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls, const char *last_ typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls,
id, const char *last_id,
const struct GNUNET_FS_Uri * const struct GNUNET_FS_Uri *
last_uri, last_uri,
const struct const struct GNUNET_CONTAINE
GNUNET_CONTAINER_MetaData * R_MetaData *last_meta,
last_meta, const char *next_ const char *next_id);
id);
/** /**
* List all of the identifiers in the namespace for which we could * List all of the identifiers in the namespace for which we could
* produce an update. Namespace updates form a graph where each node * produce an update. Namespace updates form a graph where each node
* has a name. Each node can have any number of URI/meta-data entries * has a name. Each node can have any number of URI/meta-data entries
* which can each be linked to other nodes. Cycles are possible. * which can each be linked to other nodes. Cycles are possible.
* *
* Calling this function with "next_id" NULL will cause the library to * Calling this function with @a next_id NULL will cause the library to
* call "ip" with a root for each strongly connected component of the * call @a ip with a root for each strongly connected component of the
* graph (a root being a node from which all other nodes in the Scc * graph (a root being a node from which all other nodes in the Scc
* are reachable). * are reachable).
* *
* Calling this function with "next_id" being the name of a node will * Calling this function with @a next_id being the name of a node will
* cause the library to call "ip" with all children of the node. Note * cause the library to call @a ip with all children of the node. Note
* that cycles within an SCC are possible (including self-loops). * that cycles within an SCC are possible (including self-loops).
* *
* @param h fs handle to use
* @param ns namespace to inspect for updateable content * @param ns namespace to inspect for updateable content
* @param next_id ID to look for; use NULL to look for SCC roots * @param next_id ID to look for; use NULL to look for SCC roots
* @param ip function to call on each updateable identifier * @param ip function to call on each updateable identifier
* @param ip_cls closure for ip * @param ip_cls closure for @a ip
*/ */
void void
GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *ns, GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivate
Key *ns,
const char *next_id, const char *next_id,
GNUNET_FS_IdentifierProcessor ip, GNUNET_FS_IdentifierProcessor ip,
void *ip_cls); void *ip_cls);
/** /**
* Options for searching. Compatible options * Options for searching. Compatible options
* can be OR'ed together. * can be OR'ed together.
*/ */
enum GNUNET_FS_SearchOptions enum GNUNET_FS_SearchOptions
{ {
skipping to change at line 2306 skipping to change at line 2193
/** /**
* Stop search for content. * Stop search for content.
* *
* @param sc context for the search that should be stopped * @param sc context for the search that should be stopped
*/ */
void void
GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc); GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc);
/** /**
* Start download probes for the given search result.
*
* @param h file-sharing handle to use for the operation
* @param uri URI to probe
* @param meta meta data associated with the URI
* @param client_info client info pointer to use for associated events
* @param anonymity anonymity level to use for the probes
* @return the search result handle to access the probe activity
*/
struct GNUNET_FS_SearchResult *
GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_CONTAINER_MetaData *meta,
void *client_info,
uint32_t anonymity);
/**
* Stop probe activity. Must ONLY be used on values
* returned from #GNUNET_FS_probe.
*
* @param sr search result to stop probing for (freed)
* @return the value of the 'client_info' pointer
*/
void *
GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr);
/**
* Options for downloading. Compatible options * Options for downloading. Compatible options
* can be OR'ed together. * can be OR'ed together.
*/ */
enum GNUNET_FS_DownloadOptions enum GNUNET_FS_DownloadOptions
{ {
/** /**
* No options (use defaults for everything). * No options (use defaults for everything).
*/ */
GNUNET_FS_DOWNLOAD_OPTION_NONE = 0, GNUNET_FS_DOWNLOAD_OPTION_NONE = 0,
/** /**
* Only download from the local host, do not access remote systems (no * Only download from the local host, do not access remote systems (no P2
P2P) P)
*/ */
GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY = 1, GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY = 1,
/** /**
* Do a recursive download (that is, automatically trigger the * Do a recursive download (that is, automatically trigger the
* download of files in directories). * download of files in directories).
*/ */
GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE = 2, GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE = 2,
/** /**
* Do not append temporary data to * Do not append temporary data to
* the target file (for the IBlocks). * the target file (for the IBlocks).
*/ */
GNUNET_FS_DOWNLOAD_NO_TEMPORARIES = 4, GNUNET_FS_DOWNLOAD_NO_TEMPORARIES = 4,
/** /**
* Internal option used to flag this download as a 'probe' for a * Internal option used to flag this download as a 'probe' for a
* search result. Impacts the priority with which the download is * search result. Impacts the priority with which the download is
* run and causes signalling callbacks to be done differently. * run and causes signalling callbacks to be done differently.
* Also, probe downloads are not serialized on suspension. Normal * Also, probe downloads are not serialized on suspension. Normal
* clients should not use this! * clients should not use this!
*/ */
GNUNET_FS_DOWNLOAD_IS_PROBE = (1 << 31) GNUNET_FS_DOWNLOAD_IS_PROBE = (1 << 31)
}; };
/** /**
* Download parts of a file. Note that this will store * Download parts of a file. Note that this will store
* the blocks at the respective offset in the given file. Also, the * the blocks at the respective offset in the given file. Also, the
* download is still using the blocking of the underlying FS * download is still using the blocking of the underlying FS
* encoding. As a result, the download may *write* outside of the * encoding. As a result, the download may *write* outside of the
* given boundaries (if offset and length do not match the 32k FS * given boundaries (if offset and length do not match the 32k FS
* block boundaries). <p> * block boundaries).
* *
* The given range can be used to focus a download towards a * The given range can be used to focus a download towards a
* particular portion of the file (optimization), not to strictly * particular portion of the file (optimization), not to strictly
* limit the download to exactly those bytes. * limit the download to exactly those bytes.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param uri the URI of the file (determines what to download); CHK or LOC URI * @param uri the URI of the file (determines what to download); CHK or LOC URI
* @param meta known metadata for the file (can be NULL) * @param meta known metadata for the file (can be NULL)
* @param filename where to store the file, maybe NULL (then no file is * @param filename where to store the file, maybe NULL (then no file is
* created on disk and data must be grabbed from the callbacks) * created on disk and data must be grabbed from the callbacks)
skipping to change at line 2394 skipping to change at line 2308
* will be associated with the search result (and the association * will be associated with the search result (and the association
* will be preserved when serializing/deserializing the state). * will be preserved when serializing/deserializing the state).
* If the search is stopped, the download will not be aborted but * If the search is stopped, the download will not be aborted but
* be 'promoted' to a stand-alone download. * be 'promoted' to a stand-alone download.
* *
* As with the other download function, this will store * As with the other download function, this will store
* the blocks at the respective offset in the given file. Also, the * the blocks at the respective offset in the given file. Also, the
* download is still using the blocking of the underlying FS * download is still using the blocking of the underlying FS
* encoding. As a result, the download may *write* outside of the * encoding. As a result, the download may *write* outside of the
* given boundaries (if offset and length do not match the 32k FS * given boundaries (if offset and length do not match the 32k FS
* block boundaries). <p> * block boundaries).
* *
* The given range can be used to focus a download towards a * The given range can be used to focus a download towards a
* particular portion of the file (optimization), not to strictly * particular portion of the file (optimization), not to strictly
* limit the download to exactly those bytes. * limit the download to exactly those bytes.
* *
* @param h handle to the file sharing subsystem * @param h handle to the file sharing subsystem
* @param sr the search result to use for the download (determines uri and * @param sr the search result to use for the download (determines uri and
* meta data and associations) * meta data and associations)
* @param filename where to store the file, maybe NULL (then no file is * @param filename where to store the file, maybe NULL (then no file is
* created on disk and data must be grabbed from the callbacks) * created on disk and data must be grabbed from the callbacks)
skipping to change at line 2444 skipping to change at line 2358
/* ******************** Directory API *********************** */ /* ******************** Directory API *********************** */
#define GNUNET_FS_DIRECTORY_MIME "application/gnunet-directory" #define GNUNET_FS_DIRECTORY_MIME "application/gnunet-directory"
#define GNUNET_FS_DIRECTORY_MAGIC "\211GND\r\n\032\n" #define GNUNET_FS_DIRECTORY_MAGIC "\211GND\r\n\032\n"
#define GNUNET_FS_DIRECTORY_EXT ".gnd" #define GNUNET_FS_DIRECTORY_EXT ".gnd"
/** /**
* Does the meta-data claim that this is a directory? * Does the meta-data claim that this is a directory?
* Checks if the mime-type is that of a GNUnet directory. * Checks if the mime-type is that of a GNUnet directory.
* *
* @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if * @return #GNUNET_YES if it is, #GNUNET_NO if it is not, #GNUNET_SYSERR if
* we have no mime-type information (treat as 'GNUNET_NO') * we have no mime-type information (treat as #GNUNET_NO)
*/ */
int int
GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaD ata GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaD ata
*md); *md);
/** /**
* Set the MIMETYPE information for the given * Set the MIMETYPE information for the given
* metadata to "application/gnunet-directory". * metadata to "application/gnunet-directory".
* *
* @param md metadata to add mimetype to * @param md metadata to add mimetype to
skipping to change at line 2467 skipping to change at line 2381
void void
GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md); GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
/** /**
* Suggest a filename based on given metadata. * Suggest a filename based on given metadata.
* *
* @param md given meta data * @param md given meta data
* @return NULL if meta data is useless for suggesting a filename * @return NULL if meta data is useless for suggesting a filename
*/ */
char * char *
GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaDat GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaDat
a a *md);
*md);
/** /**
* Function used to process entries in a directory. * Function used to process entries in a directory.
* *
* @param cls closure * @param cls closure
* @param filename name of the file in the directory * @param filename name of the file in the directory
* @param uri URI of the file * @param uri URI of the file
* @param metadata metadata for the file; metadata for * @param metadata metadata for the file; metadata for
* the directory if everything else is NULL/zero * the directory if everything else is NULL/zero
* @param length length of the available data for the file * @param length length of the available data for the file
skipping to change at line 2508 skipping to change at line 2421
* a client can call this function on the buffer in the * a client can call this function on the buffer in the
* GNUNET_FS_ProgressCallback. Also, directories can optionally * GNUNET_FS_ProgressCallback. Also, directories can optionally
* include the contents of (small) files embedded in the directory * include the contents of (small) files embedded in the directory
* itself; for those files, the processor may be given the * itself; for those files, the processor may be given the
* contents of the file directly by this function. * contents of the file directly by this function.
* *
* @param size number of bytes in data * @param size number of bytes in data
* @param data pointer to the beginning of the directory * @param data pointer to the beginning of the directory
* @param offset offset of data in the directory * @param offset offset of data in the directory
* @param dep function to call on each entry * @param dep function to call on each entry
* @param dep_cls closure for dep * @param dep_cls closure for @a dep
* @return GNUNET_OK if this could be a block in a directory, * @return #GNUNET_OK if this could be a block in a directory,
* GNUNET_NO if this could be part of a directory (but not 100% OK) * #GNUNET_NO if this could be part of a directory (but not 100% OK
* GNUNET_SYSERR if 'data' does not represent a directory )
* #GNUNET_SYSERR if 'data' does not represent a directory
*/ */
int int
GNUNET_FS_directory_list_contents (size_t size, const void *data, GNUNET_FS_directory_list_contents (size_t size, const void *data,
uint64_t offset, uint64_t offset,
GNUNET_FS_DirectoryEntryProcessor dep, GNUNET_FS_DirectoryEntryProcessor dep,
void *dep_cls); void *dep_cls);
/** /**
* Opaque handle to a directory builder. * Opaque handle to a directory builder.
*/ */
skipping to change at line 2557 skipping to change at line 2470
const void *data); const void *data);
/** /**
* Finish building the directory. Frees the * Finish building the directory. Frees the
* builder context and returns the directory * builder context and returns the directory
* in-memory. * in-memory.
* *
* @param bld directory to finish * @param bld directory to finish
* @param rsize set to the number of bytes needed * @param rsize set to the number of bytes needed
* @param rdata set to the encoded directory * @param rdata set to the encoded directory
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
size_t * rsize, void **rdata); size_t * rsize, void **rdata);
/* ******************** DirScanner API *********************** */ /* ******************** DirScanner API *********************** */
/** /**
* Progress reasons of the directory scanner. * Progress reasons of the directory scanner.
*/ */
skipping to change at line 2611 skipping to change at line 2524
GNUNET_FS_DIRSCANNER_INTERNAL_ERROR GNUNET_FS_DIRSCANNER_INTERNAL_ERROR
}; };
/** /**
* Function called over time as the directory scanner makes * Function called over time as the directory scanner makes
* progress on the job at hand. * progress on the job at hand.
* *
* @param cls closure * @param cls closure
* @param filename which file we are making progress on * @param filename which file we are making progress on
* @param is_directory GNUNET_YES if this is a directory, * @param is_directory #GNUNET_YES if this is a directory,
* GNUNET_NO if this is a file * #GNUNET_NO if this is a file
* GNUNET_SYSERR if it is neither (or unknown) * #GNUNET_SYSERR if it is neither (or unknown)
* @param reason kind of progress we are making * @param reason kind of progress we are making
*/ */
typedef void (*GNUNET_FS_DirScannerProgressCallback) (void *cls, typedef void (*GNUNET_FS_DirScannerProgressCallback) (void *cls,
const char *filename, const char *filename,
int is_directory, int is_directory,
enum GNUNET_FS_DirScan nerProgressUpdateReason reason); enum GNUNET_FS_DirScan nerProgressUpdateReason reason);
/** /**
* A node of a directory tree (produced by dirscanner) * A node of a directory tree (produced by dirscanner)
*/ */
skipping to change at line 2675 skipping to change at line 2588
* Name of the file/directory * Name of the file/directory
*/ */
char *filename; char *filename;
/** /**
* Base name of the file/directory. * Base name of the file/directory.
*/ */
char *short_filename; char *short_filename;
/** /**
* GNUNET_YES if this is a directory * #GNUNET_YES if this is a directory
*/ */
int is_directory; int is_directory;
}; };
/** /**
* Opaqe handle to an asynchronous directory scanning activity. * Opaqe handle to an asynchronous directory scanning activity.
*/ */
struct GNUNET_FS_DirScanner; struct GNUNET_FS_DirScanner;
/** /**
* Start a directory scanner. * Start a directory scanner.
* *
* @param filename name of the directory to scan * @param filename name of the directory to scan
* @param disable_extractor GNUNET_YES to not to run libextractor on files (only build a tree) * @param disable_extractor #GNUNET_YES to not to run libextractor on files (only build a tree)
* @param ex if not NULL, must be a list of extra plugins for extractor * @param ex if not NULL, must be a list of extra plugins for extractor
* @param cb the callback to call when there are scanning progress messages * @param cb the callback to call when there are scanning progress messages
* @param cb_cls closure for 'cb' * @param cb_cls closure for @a cb
* @return directory scanner object to be used for controlling the scanner * @return directory scanner object to be used for controlling the scanner
*/ */
struct GNUNET_FS_DirScanner * struct GNUNET_FS_DirScanner *
GNUNET_FS_directory_scan_start (const char *filename, GNUNET_FS_directory_scan_start (const char *filename,
int disable_extractor, int disable_extractor,
const char *ex, const char *ex,
GNUNET_FS_DirScannerProgressCallback cb, GNUNET_FS_DirScannerProgressCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Abort the scan. Must not be called from within the progress_callback * Abort the scan. Must not be called from within the progress_callback
* function. * function.
* *
* @param ds directory scanner structure * @param ds directory scanner structure
*/ */
void void
GNUNET_FS_directory_scan_abort (struct GNUNET_FS_DirScanner *ds); GNUNET_FS_directory_scan_abort (struct GNUNET_FS_DirScanner *ds);
/** /**
* Obtain the result of the scan after the scan has signalled * Obtain the result of the scan after the scan has signalled
* completion. Must not be called prior to completion. The 'ds' is * completion. Must not be called prior to completion. The @a ds is
* freed as part of this call. * freed as part of this call.
* *
* @param ds directory scanner structure * @param ds directory scanner structure
* @return the results of the scan (a directory tree) * @return the results of the scan (a directory tree)
*/ */
struct GNUNET_FS_ShareTreeItem * struct GNUNET_FS_ShareTreeItem *
GNUNET_FS_directory_scan_get_result (struct GNUNET_FS_DirScanner *ds); GNUNET_FS_directory_scan_get_result (struct GNUNET_FS_DirScanner *ds);
/** /**
* Process a share item tree, moving frequent keywords up and * Process a share item tree, moving frequent keywords up and
 End of changes. 113 change blocks. 
329 lines changed or deleted 236 lines changed or added


 gnunet_getopt_lib.h   gnunet_getopt_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2011 Christian Grothoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_getopt_lib.h * @file include/gnunet_getopt_lib.h
* @brief command line parsing and --help formatting * @brief command line parsing and --help formatting
*
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup getopt command-line parsing
* @{
*/ */
#ifndef GNUNET_GETOPT_LIB_H #ifndef GNUNET_GETOPT_LIB_H
#define GNUNET_GETOPT_LIB_H #define GNUNET_GETOPT_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
skipping to change at line 86 skipping to change at line 87
}; };
/** /**
* @brief Process a command line option * @brief Process a command line option
* *
* @param ctx context for all options * @param ctx context for all options
* @param scls specific closure (for this processor) * @param scls specific closure (for this processor)
* @param option long name of the option (i.e. "config" for --config) * @param option long name of the option (i.e. "config" for --config)
* @param value argument, NULL if none was given * @param value argument, NULL if none was given
* @return GNUNET_OK to continue processing other options, GNUNET_SYSERR to abort * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort
*/ */
typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (struct typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (struct
GNUNET_GETOPT_Comm GNUNET_GETOPT_Comm
andLineProcessorContext andLineProcessorContext *ctx,
* ctx, void *scls, void *scls,
const char *option , const char *option ,
const char *value) ; const char *value) ;
/** /**
* @brief Definition of a command line option. * @brief Definition of a command line option.
*/ */
struct GNUNET_GETOPT_CommandLineOption struct GNUNET_GETOPT_CommandLineOption
{ {
/** /**
* Short name of the option (use '\\0' for none). * Short name of the option.
*/ */
const char shortName; const char shortName;
/** /**
* Long name of the option (may not be NULL) * Long name of the option (may not be NULL)
*/ */
const char *name; const char *name;
/** /**
* Name of the argument for the user in help text * Name of the argument for the user in help text
*/ */
const char *argumentHelp; const char *argumentHelp;
/** /**
* Help text for the option (description) * Help text for the option (description)
*/ */
const char *description; const char *description;
/** /**
* Is an argument required? 0: GNUNET_NO (includes optional), 1: GNUNET_ YES. * Is an argument required? 0: #GNUNET_NO (includes optional), 1: #GNUNE T_YES.
*/ */
int require_argument; int require_argument;
/** /**
* Handler for the option. * Handler for the option.
*/ */
GNUNET_GETOPT_CommandLineOptionProcessor processor; GNUNET_GETOPT_CommandLineOptionProcessor processor;
/** /**
* Specific closure to pass to the processor. * Specific closure to pass to the processor.
skipping to change at line 198 skipping to change at line 199
* Marker for the end of the list of options. * Marker for the end of the list of options.
*/ */
#define GNUNET_GETOPT_OPTION_END \ #define GNUNET_GETOPT_OPTION_END \
{ '\0', NULL, NULL, NULL, 0, NULL, NULL } { '\0', NULL, NULL, NULL, 0, NULL, NULL }
/** /**
* Parse the command line. * Parse the command line.
* *
* @param binaryOptions Name of application with option summary * @param binaryOptions Name of application with option summary
* @param allOptions defined options and handlers * @param allOptions defined options and handlers
* @param argc number of arguments * @param argc number of arguments in @a argv
* @param argv actual arguments * @param argv actual arguments
* @return index into argv with first non-option * @return index into argv with first non-option
* argument, or GNUNET_SYSERR on error * argument, or #GNUNET_SYSERR on error
*/ */
int int
GNUNET_GETOPT_run (const char *binaryOptions, GNUNET_GETOPT_run (const char *binaryOptions,
const struct GNUNET_GETOPT_CommandLineOption *allOptions , const struct GNUNET_GETOPT_CommandLineOption *allOptions ,
unsigned int argc, char *const *argv); unsigned int argc, char *const *argv);
/** /**
* Set an option of type 'unsigned long long' from the command line. * Set an option of type 'unsigned long long' from the command line.
* A pointer to this function should be passed as part of the * A pointer to this function should be passed as part of the
* 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
* of this type. It should be followed by a pointer to a value of * of this type. It should be followed by a pointer to a value of
* type 'unsigned long long'. * type `unsigned long long`.
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (will point to the 'unsigned long long') * @param scls additional closure (will point to the 'unsigned long long')
* @param option name of the option * @param option name of the option
* @param value actual value of the option as a string. * @param value actual value of the option as a string.
* @return GNUNET_OK if parsing the value worked * @return #GNUNET_OK if parsing the value worked
*/ */
int int
GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext * ctx, GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext * ctx,
void *scls, const char *option, const char *value) ; void *scls, const char *option, const char *value) ;
/** /**
* Set an option of type 'struct GNUNET_TIME_Relative' from the command lin e. * Set an option of type 'struct GNUNET_TIME_Relative' from the command lin e.
* A pointer to this function should be passed as part of the * A pointer to this function should be passed as part of the
* 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
* of this type. It should be followed by a pointer to a value of * of this type. It should be followed by a pointer to a value of
* type 'struct GNUNET_TIME_Relative'. * type `struct GNUNET_TIME_Relative`.
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (will point to the 'struct GNUNET_TIME_Re lative') * @param scls additional closure (will point to the 'struct GNUNET_TIME_Re lative')
* @param option name of the option * @param option name of the option
* @param value actual value of the option as a string. * @param value actual value of the option as a string.
* @return GNUNET_OK if parsing the value worked * @return #GNUNET_OK if parsing the value worked
*/ */
int int
GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorC ontext *ctx, GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorC ontext *ctx,
void *scls, const char *option, const char *value); void *scls, const char *option, const char *value);
/** /**
* Set an option of type 'unsigned int' from the command line. * Set an option of type 'unsigned int' from the command line.
* A pointer to this function should be passed as part of the * A pointer to this function should be passed as part of the
* 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
* of this type. It should be followed by a pointer to a value of * of this type. It should be followed by a pointer to a value of
* type 'unsigned int'. * type `unsigned int`.
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (will point to the 'unsigned int') * @param scls additional closure (will point to the 'unsigned int')
* @param option name of the option * @param option name of the option
* @param value actual value of the option as a string. * @param value actual value of the option as a string.
* @return GNUNET_OK if parsing the value worked * @return #GNUNET_OK if parsing the value worked
*/ */
int int
GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *c tx, GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *c tx,
void *scls, const char *option, const char *value); void *scls, const char *option, const char *value);
/** /**
* Set an option of type 'int' from the command line to 1 if the * Set an option of type 'int' from the command line to 1 if the
* given option is present. * given option is present.
* A pointer to this function should be passed as part of the * A pointer to this function should be passed as part of the
* 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
* of this type. It should be followed by a pointer to a value of * of this type. It should be followed by a pointer to a value of
* type 'int'. * type `int`.
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (will point to the 'int') * @param scls additional closure (will point to the `int`)
* @param option name of the option * @param option name of the option
* @param value not used (NULL) * @param value not used (NULL)
* @return GNUNET_OK * @return #GNUNET_OK (always)
*/ */
int int
GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ct x, GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ct x,
void *scls, const char *option, const char *value); void *scls, const char *option, const char *value);
/** /**
* Set an option of type 'char *' from the command line. * Set an option of type 'char *' from the command line.
* A pointer to this function should be passed as part of the * A pointer to this function should be passed as part of the
* `struct GNUNET_GETOPT_CommandLineOption` array to initialize options
* of this type. It should be followed by a pointer to a value of
* type `char *`, which will be allocated with the requested string.
*
* @param ctx command line processing context
* @param scls additional closure (will point to the `char *`,
* which will be allocated)
* @param option name of the option
* @param value actual value of the option (a string)
* @return #GNUNET_OK (always)
*/
int
GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext
*ctx,
void *scls, const char *option, const char *value
);
/**
* Set an option of type 'char *' from the command line doing fs expansion.
* A pointer to this function should be passed as part of the
* 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
* of this type. It should be followed by a pointer to a value of * of this type. It should be followed by a pointer to a value of
* type 'char *', which will be allocated with the requested string. * type 'char *', which will be allocated with the requested string.
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (will point to the 'char *', * @param scls additional closure (will point to the 'char *',
* which will be allocated) * which will be allocated)
* @param option name of the option * @param option name of the option
* @param value actual value of the option (a string) * @param value actual value of the option (a string)
* @return GNUNET_OK * @return #GNUNET_OK (always)
*/ */
int int
GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContex
*ctx, t *ctx,
void *scls, const char *option, const char *value void *scls, const char *option, const char *val
); ue);
/** /**
* Set an option of type 'unsigned int' from the command line. Each * Set an option of type 'unsigned int' from the command line. Each
* time the option flag is given, the value is incremented by one. * time the option flag is given, the value is incremented by one.
* A pointer to this function should be passed as part of the * A pointer to this function should be passed as part of the
* 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
* of this type. It should be followed by a pointer to a value of * of this type. It should be followed by a pointer to a value of
* type 'int'. * type 'int'.
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (will point to the 'int') * @param scls additional closure (will point to the 'int')
* @param option name of the option * @param option name of the option
* @param value not used (NULL) * @param value not used (NULL)
* @return GNUNET_OK * @return #GNUNET_OK (always)
*/ */
int int
GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorCon text GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorCon text
*ctx, void *scls, const char *option, *ctx, void *scls, const char *option,
const char *value); const char *value);
/* *************** internal prototypes - use macros above! ************* */ /* *************** internal prototypes - use macros above! ************* */
/** /**
* Print out details on command line options (implements --help). * Print out details on command line options (implements --help).
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (points to about text) * @param scls additional closure (points to about text)
* @param option name of the option * @param option name of the option
* @param value not used (NULL) * @param value not used (NULL)
* @return GNUNET_NO (do not continue, not an error) * @return #GNUNET_NO (do not continue, not an error)
*/ */
int int
GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContex t GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContex t
*ctx, void *scls, const char *option, *ctx, void *scls, const char *option,
const char *value); const char *value);
/** /**
* Print out program version (implements --version). * Print out program version (implements --version).
* *
* @param ctx command line processing context * @param ctx command line processing context
* @param scls additional closure (points to version string) * @param scls additional closure (points to version string)
* @param option name of the option * @param option name of the option
* @param value not used (NULL) * @param value not used (NULL)
* @return GNUNET_NO (do not continue, not an error) * @return #GNUNET_NO (do not continue, not an error)
*/ */
int int
GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorCont ext GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorCont ext
*ctx, void *scls, const char *option, *ctx, void *scls, const char *option,
const char *value); const char *value);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group getopt */
/* ifndef GNUNET_GETOPT_LIB_H */ /* ifndef GNUNET_GETOPT_LIB_H */
#endif #endif
/* end of gnunet_getopt_lib.h */ /* end of gnunet_getopt_lib.h */
 End of changes. 30 change blocks. 
32 lines changed or deleted 55 lines changed or added


 gnunet_gns_service.h   gnunet_gns_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2012 Christian Grothoff (and other contributing authors) (C) 2012-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
skipping to change at line 58 skipping to change at line 58
* Connection to the GNS service. * Connection to the GNS service.
*/ */
struct GNUNET_GNS_Handle; struct GNUNET_GNS_Handle;
/** /**
* Handle to control a lookup operation. * Handle to control a lookup operation.
*/ */
struct GNUNET_GNS_LookupRequest; struct GNUNET_GNS_LookupRequest;
/** /**
* Handle to control a shorten operation.
*/
struct GNUNET_GNS_ShortenRequest;
/**
* Handle to control a get authority operation
*/
struct GNUNET_GNS_GetAuthRequest;
/**
* Record types
* Based on GNUNET_DNSPARSER_TYPEs (standard DNS)
*/
enum GNUNET_GNS_RecordType
{
/* Standard DNS */
/* struct in_addr */
GNUNET_GNS_RECORD_A = GNUNET_DNSPARSER_TYPE_A,
/* char */
GNUNET_GNS_RECORD_NS = GNUNET_DNSPARSER_TYPE_NS,
/* char */
GNUNET_GNS_RECORD_CNAME = GNUNET_DNSPARSER_TYPE_CNAME,
/* struct soa_data */
GNUNET_GNS_RECORD_SOA = GNUNET_DNSPARSER_TYPE_SOA,
/* struct srv_data */
GNUNET_GNS_RECORD_SRV = GNUNET_DNSPARSER_TYPE_SRV,
/* char */
GNUNET_GNS_RECORD_PTR = GNUNET_DNSPARSER_TYPE_PTR,
/* uint16_t, char */
GNUNET_GNS_RECORD_MX = GNUNET_DNSPARSER_TYPE_MX,
/* char */
GNUNET_GNS_RECORD_TXT = GNUNET_DNSPARSER_TYPE_TXT,
/* struct in6_addr */
GNUNET_GNS_RECORD_AAAA = GNUNET_DNSPARSER_TYPE_AAAA,
/* GNS specific */
/* struct GNUNET_CRYPTO_ShortHashCode */
GNUNET_GNS_RECORD_PKEY = GNUNET_NAMESTORE_TYPE_PKEY,
/* char */
GNUNET_GNS_RECORD_PSEU = GNUNET_NAMESTORE_TYPE_PSEU,
GNUNET_GNS_RECORD_ANY = GNUNET_NAMESTORE_TYPE_ANY,
/* char */
GNUNET_GNS_RECORD_LEHO = GNUNET_NAMESTORE_TYPE_LEHO,
/* struct vpn_data */
GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN,
/* revocation */
GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV
};
/**
* Initialize the connection with the GNS service. * Initialize the connection with the GNS service.
* *
* @param cfg configuration to use * @param cfg configuration to use
*
* @return handle to the GNS service, or NULL on error * @return handle to the GNS service, or NULL on error
*/ */
struct GNUNET_GNS_Handle * struct GNUNET_GNS_Handle *
GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
/** /**
* Shutdown connection with the GNS service. * Shutdown connection with the GNS service.
* *
* @param handle connection to shut down * @param handle connection to shut down
*/ */
void void
GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle); GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle);
/* *************** Standard API: lookup ******************* */
/** /**
* Iterator called on obtained result for a GNS * Iterator called on obtained result for a GNS lookup.
* lookup
* *
* @param cls closure * @param cls closure
* @param rd_count number of records * @param rd_count number of records in @a rd
* @param rd the records in reply * @param rd the records in reply
*/ */
typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls, typedef void (*GNUNET_GNS_LookupResultProcessor) (void *cls,
uint32_t rd_count, uint32_t rd_count,
const struct GNUNET_NAMEST ORE_RecordData *rd); const struct GNUNET_GNSREC ORD_Data *rd);
/** /**
* Perform an asynchronous lookup operation on the GNS * Perform an asynchronous lookup operation on the GNS.
* in the default zone.
* *
* @param handle handle to the GNS service * @param handle handle to the GNS service
* @param name the name to look up * @param name the name to look up
* @param type the GNUNET_GNS_RecordType to look for * @param zone zone to look in
* @param only_cached GNUNET_NO to only check locally not DHT for performan * @param type the GNS record type to look for
ce * @param only_cached #GNUNET_YES to only check locally (not in the DHT)
* @param shorten_key the private key of the shorten zone (can be NULL) * @param shorten_zone_key the private key of the shorten zone (can be NULL
);
* specify to enable automatic shortening (given a PSEU
* record, if a given pseudonym is not yet used in the
* shorten zone, we automatically add the respective zon
e
* under that name)
* @param proc function to call on result * @param proc function to call on result
* @param proc_cls closure for processor * @param proc_cls closure for processor
*
* @return handle to the queued request * @return handle to the queued request
*/ */
struct GNUNET_GNS_LookupRequest* struct GNUNET_GNS_LookupRequest *
GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
const char * name, const char *name,
enum GNUNET_GNS_RecordType type, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
int type,
int only_cached, int only_cached,
struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key, const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_ key,
GNUNET_GNS_LookupResultProcessor proc, GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls); void *proc_cls);
/** /**
* Perform an asynchronous lookup operation on the GNS
* in the zone specified by 'zone'.
*
* @param handle handle to the GNS service
* @param name the name to look up
* @param zone the zone to start the resolution in
* @param type the GNUNET_GNS_RecordType to look for
* @param only_cached GNUNET_YES to only check locally not DHT for performa
nce
* @param shorten_key the private key of the shorten zone (can be NULL)
* @param proc function to call on result
* @param proc_cls closure for processor
*
* @return handle to the queued request
*/
struct GNUNET_GNS_LookupRequest*
GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
struct GNUNET_CRYPTO_ShortHashCode *zone,
enum GNUNET_GNS_RecordType type,
int only_cached,
struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls);
/**
* Cancel pending lookup request * Cancel pending lookup request
* *
* @param lr the lookup request to cancel * @param lr the lookup request to cancel
*/ */
void void
GNUNET_GNS_cancel_lookup_request (struct GNUNET_GNS_LookupRequest *lr); GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr);
/* *************** Standard API: shorten ******************* */
/**
* Processor called on for a name shortening result
* called only once
*
* @param cls closure
* @param short_name the shortened name or NULL if no result / error
*/
typedef void (*GNUNET_GNS_ShortenResultProcessor) (void *cls,
const char* short_name);
/**
* Perform a name shortening operation on the GNS.
*
* @param handle handle to the GNS service
* @param name the name to look up
* @param private_zone the public zone of the private zone
* @param shorten_zone the public zone of the shorten zone
* @param proc function to call on result
* @param proc_cls closure for processor
* @return handle to the operation
*/
struct GNUNET_GNS_ShortenRequest*
GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
const char * name,
struct GNUNET_CRYPTO_ShortHashCode *private_zone,
struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls);
/**
* Perform a name shortening operation on the GNS.
*
* @param handle handle to the GNS service
* @param name the name to look up
* @param private_zone the public zone of the private zone
* @param shorten_zone the public zone of the shorten zone
* @param zone the zone to start the resolution in
* @param proc function to call on result
* @param proc_cls closure for processor
* @return handle to the operation
*/
struct GNUNET_GNS_ShortenRequest*
GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
const char * name,
struct GNUNET_CRYPTO_ShortHashCode *private_zone,
struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
struct GNUNET_CRYPTO_ShortHashCode *zone,
GNUNET_GNS_ShortenResultProcessor proc,
void *proc_cls);
/**
* Cancel pending shorten request
*
* @param sr the lookup request to cancel
*/
void
GNUNET_GNS_cancel_shorten_request (struct GNUNET_GNS_ShortenRequest *sr);
/* *************** Standard API: get authority ******************* */
/**
* Processor called on for a name shortening result
* called only once
*
* @param cls closure
* @param auth_name the name of the auhtority or NULL
*/
typedef void (*GNUNET_GNS_GetAuthResultProcessor) (void *cls,
const char* short_name);
/**
* Perform an authority lookup for a given name.
*
* @param handle handle to the GNS service
* @param name the name to look up authority for
* @param proc function to call on result
* @param proc_cls closure for processor
* @return handle to the operation
*/
struct GNUNET_GNS_GetAuthRequest*
GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
const char * name,
GNUNET_GNS_GetAuthResultProcessor proc,
void *proc_cls);
/**
* Cancel pending get auth request
*
* @param gar the lookup request to cancel
*/
void
GNUNET_GNS_cancel_get_auth_request (struct GNUNET_GNS_GetAuthRequest *gar);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
/* gnunet_gns_service.h */ /* gnunet_gns_service.h */
 End of changes. 15 change blocks. 
203 lines changed or deleted 21 lines changed or added


 gnunet_hello_lib.h   gnunet_hello_lib.h 
skipping to change at line 38 skipping to change at line 38
#define GNUNET_HELLO_LIB_H #define GNUNET_HELLO_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h" #include "gnunet_util_lib.h"
#include "gnunet_crypto_lib.h"
/** /**
* Prefix that every HELLO URI must start with. * Prefix that every HELLO URI must start with.
*/ */
#define GNUNET_HELLO_URI_PREFIX "gnunet://hello/" #define GNUNET_HELLO_URI_PREFIX "gnunet://hello/"
/** /**
* Prefix that every FRIEND HELLO URI must start with.
*/
#define GNUNET_FRIEND_HELLO_URI_PREFIX "gnunet://friend-hello/"
/**
* An address for communicating with a peer. We frequently * An address for communicating with a peer. We frequently
* need this tuple and the components cannot really be * need this tuple and the components cannot really be
* separated. This is NOT the format that would be used * separated. This is NOT the format that would be used
* on the wire. * on the wire.
*/ */
struct GNUNET_HELLO_Address struct GNUNET_HELLO_Address
{ {
/** /**
* For which peer is this an address? * For which peer is this an address?
skipping to change at line 137 skipping to change at line 141
#define GNUNET_HELLO_address_free(addr) GNUNET_free(addr) #define GNUNET_HELLO_address_free(addr) GNUNET_free(addr)
/** /**
* A HELLO message is used to exchange information about * A HELLO message is used to exchange information about
* transports with other peers. This struct is guaranteed * transports with other peers. This struct is guaranteed
* to start with a "GNUNET_MessageHeader", everything else * to start with a "GNUNET_MessageHeader", everything else
* should be internal to the HELLO library. * should be internal to the HELLO library.
*/ */
struct GNUNET_HELLO_Message; struct GNUNET_HELLO_Message;
/** Return HELLO type
*
* @param h HELLO Message to test
* @return GNUNET_YES or GNUNET_NO
*/
int
GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h);
/** /**
* Copy the given address information into * Copy the given address information into
* the given buffer using the format of HELLOs. * the given buffer using the format of HELLOs.
* *
* @param address address to add * @param address address to add
* @param expiration expiration for the address * @param expiration expiration for the address
* @param target where to copy the address * @param target where to copy the address
* @param max maximum number of bytes to copy to target * @param max maximum number of bytes to copy to target
* @return number of bytes copied, 0 if * @return number of bytes copied, 0 if
* the target buffer was not big enough. * the target buffer was not big enough.
skipping to change at line 173 skipping to change at line 185
*/ */
typedef size_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, typedef size_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
size_t max, size_t max,
void *buf); void *buf);
/** /**
* Construct a HELLO message given the public key, * Construct a HELLO message given the public key,
* expiration time and an iterator that spews the * expiration time and an iterator that spews the
* transport addresses. * transport addresses.
* *
* If friend only is set to GNUNET_YES we create a FRIEND_HELLO which will
* not be gossiped to other peers
*
* @return the hello message * @return the hello message
*/ */
struct GNUNET_HELLO_Message * struct GNUNET_HELLO_Message *
GNUNET_HELLO_create (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *publicKey,
*publicKey,
GNUNET_HELLO_GenerateAddressListCallback addrgen, GNUNET_HELLO_GenerateAddressListCallback addrgen,
void *addrgen_cls); void *addrgen_cls,
int friend_only);
/** /**
* Return the size of the given HELLO message. * Return the size of the given HELLO message.
* @param hello to inspect * @param hello to inspect
* @return the size, 0 if HELLO is invalid * @return the size, 0 if HELLO is invalid
*/ */
uint16_t uint16_t
GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello); GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello);
/** /**
skipping to change at line 295 skipping to change at line 310
/** /**
* Get the public key from a HELLO message. * Get the public key from a HELLO message.
* *
* @param hello the hello message * @param hello the hello message
* @param publicKey where to copy the public key information, can be NULL * @param publicKey where to copy the public key information, can be NULL
* @return GNUNET_SYSERR if the HELLO was malformed * @return GNUNET_SYSERR if the HELLO was malformed
*/ */
int int
GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello,
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded struct GNUNET_CRYPTO_EddsaPublicKey *publicKey);
*publicKey);
/** /**
* Get the peer identity from a HELLO message. * Get the peer identity from a HELLO message.
* *
* @param hello the hello message * @param hello the hello message
* @param peer where to store the peer's identity * @param peer where to store the peer's identity
* @return GNUNET_SYSERR if the HELLO was malformed * @return GNUNET_SYSERR if the HELLO was malformed
*/ */
int int
GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello,
skipping to change at line 345 skipping to change at line 359
* Parse a hello URI string to a hello message. * Parse a hello URI string to a hello message.
* *
* @param uri URI string to parse * @param uri URI string to parse
* @param pubkey Pointer to struct where public key is parsed * @param pubkey Pointer to struct where public key is parsed
* @param hello Pointer to struct where hello message is parsed * @param hello Pointer to struct where hello message is parsed
* @param plugins_find Function to find transport plugins by name * @param plugins_find Function to find transport plugins by name
* @return GNUNET_OK on success, GNUNET_SYSERR if the URI was invalid, GNUN ET_NO on other errors * @return GNUNET_OK on success, GNUNET_SYSERR if the URI was invalid, GNUN ET_NO on other errors
*/ */
int int
GNUNET_HELLO_parse_uri (const char *uri, GNUNET_HELLO_parse_uri (const char *uri,
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub key, struct GNUNET_CRYPTO_EddsaPublicKey *pubkey,
struct GNUNET_HELLO_Message **hello, struct GNUNET_HELLO_Message **hello,
GNUNET_HELLO_TransportPluginsFind plugins_find); GNUNET_HELLO_TransportPluginsFind plugins_find);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
 End of changes. 8 change blocks. 
8 lines changed or deleted 22 lines changed or added


 gnunet_helper_lib.h   gnunet_helper_lib.h 
skipping to change at line 23 skipping to change at line 23
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_helper_lib.h * @file include/gnunet_helper_lib.h
* @brief API for dealing with (SUID) helper processes that communicate via * @brief API for dealing with (SUID) helper processes that communicate via
GNUNET_MessageHeaders on stdin/stdout * GNUNET_MessageHeaders on stdin/stdout
* @author Philipp Toelke * @author Philipp Toelke
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_HELPER_LIB_H #ifndef GNUNET_HELPER_LIB_H
#define GNUNET_HELPER_LIB_H #define GNUNET_HELPER_LIB_H
#include "gnunet_scheduler_lib.h" #include "gnunet_scheduler_lib.h"
#include "gnunet_server_lib.h" #include "gnunet_server_lib.h"
skipping to change at line 72 skipping to change at line 73
*/ */
struct GNUNET_HELPER_Handle * struct GNUNET_HELPER_Handle *
GNUNET_HELPER_start (int with_control_pipe, GNUNET_HELPER_start (int with_control_pipe,
const char *binary_name, const char *binary_name,
char *const binary_argv[], char *const binary_argv[],
GNUNET_SERVER_MessageTokenizerCallback cb, GNUNET_SERVER_MessageTokenizerCallback cb,
GNUNET_HELPER_ExceptionCallback exp_cb, GNUNET_HELPER_ExceptionCallback exp_cb,
void *cb_cls); void *cb_cls);
/** /**
* Kills the helper, closes the pipe and frees the handle * Sends termination signal to the helper process. The helper process is n
ot
* reaped; call GNUNET_HELPER_wait() for reaping the dead helper process.
*
* @param h the helper handle
* @param soft_kill if #GNUNET_YES, signals termination by closing the help
er's
* stdin; #GNUNET_NO to signal termination by sending SIGTERM to h
elper
* @return #GNUNET_OK on success; #GNUNET_SYSERR on error
*/
int
GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill);
/**
* Reap the helper process. This call is blocking (!). The helper process
* should either be sent a termination signal before or should be dead befo
re
* calling this function
*
* @param h the helper handle
* @return #GNUNET_OK on success; #GNUNET_SYSERR on error
*/
int
GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h);
/**
* Free's the resources occupied by the helper handle
*
* @param h the helper handle to free
*/
void
GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h);
/**
* Kills the helper, closes the pipe, frees the handle and calls wait() on
the
* helper process
* *
* @param h handle to helper to stop * @param h handle to helper to stop
* @param soft_kill if #GNUNET_YES, signals termination by closing the help
er's
* stdin; #GNUNET_NO to signal termination by sending SIGTERM to h
elper
*/ */
void void
GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h); GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill);
/** /**
* Continuation function. * Continuation function.
* *
* @param cls closure * @param cls closure
* @param result GNUNET_OK on success, * @param result #GNUNET_OK on success,
* GNUNET_NO if helper process died * #GNUNET_NO if helper process died
* GNUNET_SYSERR during GNUNET_HELPER_stop * #GNUNET_SYSERR during GNUNET_HELPER_destroy
*/ */
typedef void (*GNUNET_HELPER_Continuation)(void *cls, typedef void (*GNUNET_HELPER_Continuation)(void *cls,
int result); int result);
/** /**
* Handle to cancel 'send' * Handle to cancel 'send'
*/ */
struct GNUNET_HELPER_SendHandle; struct GNUNET_HELPER_SendHandle;
/** /**
* Send an message to the helper. * Send an message to the helper.
* *
* @param h helper to send message to * @param h helper to send message to
* @param msg message to send * @param msg message to send
* @param can_drop can the message be dropped if there is already one in th e queue? * @param can_drop can the message be dropped if there is already one in th e queue?
* @param cont continuation to run once the message is out * @param cont continuation to run once the message is out (#GNUNET_OK on s
* @param cont_cls closure for 'cont' uccees, #GNUNET_NO
* if the helper process died, #GNUNET_SYSERR during #GNUNET_HE
LPER_destroy).
* @param cont_cls closure for @a cont
* @return NULL if the message was dropped, * @return NULL if the message was dropped,
* otherwise handle to cancel *cont* (actual transmission may * otherwise handle to cancel @a cont (actual transmission may
* not be abortable) * not be abortable)
*/ */
struct GNUNET_HELPER_SendHandle * struct GNUNET_HELPER_SendHandle *
GNUNET_HELPER_send (struct GNUNET_HELPER_Handle *h, GNUNET_HELPER_send (struct GNUNET_HELPER_Handle *h,
const struct GNUNET_MessageHeader *msg, const struct GNUNET_MessageHeader *msg,
int can_drop, int can_drop,
GNUNET_HELPER_Continuation cont, GNUNET_HELPER_Continuation cont,
void *cont_cls); void *cont_cls);
/** /**
* Cancel a 'send' operation. If possible, transmitting the * Cancel a #GNUNET_HELPER_send operation. If possible, transmitting
* message is also aborted, but at least 'cont' won't be * the message is also aborted, but at least 'cont' won't be called.
* called.
* *
* @param sh operation to cancel * @param sh operation to cancel
*/ */
void void
GNUNET_HELPER_send_cancel (struct GNUNET_HELPER_SendHandle *sh); GNUNET_HELPER_send_cancel (struct GNUNET_HELPER_SendHandle *sh);
#endif /* end of include guard: GNUNET_HELPER_LIB_H */ #endif
/* end of include guard: GNUNET_HELPER_LIB_H */
 End of changes. 9 change blocks. 
13 lines changed or deleted 56 lines changed or added


 gnunet_load_lib.h   gnunet_load_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2010 Christian Grothoff (and other contributing authors) (C) 2010 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gnunet_mesh_service.h   gnunet_mesh_service.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009, 2010 Christian Grothoff (and other contributing authors) (C) 2009 - 2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_mesh_service.h * @file include/gnunet_mesh_service.h
* @brief mesh service; establish tunnels to distant peers * @brief mesh service; establish channels to distant peers
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_MESH_SERVICE_H #ifndef GNUNET_MESH_SERVICE_H
#define GNUNET_MESH_SERVICE_H #define GNUNET_MESH_SERVICE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_transport_service.h" #include "gnunet_transport_service.h"
/** /**
* Version number of GNUnet-mesh API. * Version number of GNUnet-mesh API.
*/ */
#define GNUNET_MESH_VERSION 0x00000000 #define GNUNET_MESH_VERSION 0x00000003
/** /**
* Opaque handle to the service. * Opaque handle to the service.
*/ */
struct GNUNET_MESH_Handle; struct GNUNET_MESH_Handle;
/** /**
* Opaque handle to a tunnel. * Opaque handle to a channel.
*/ */
struct GNUNET_MESH_Tunnel; struct GNUNET_MESH_Channel;
/**
* Channel options.
* Second line indicates filed in the MeshChannelInfo union carrying the an
swer.
*/
enum GNUNET_MESH_ChannelOption
{
/**
* Default options: unreliable, default buffering, not out of order.
*/
GNUNET_MESH_OPTION_DEFAULT = 0x0,
/**
* Disable buffering on intermediate nodes (for minimum latency).
* Yes/No.
*/
GNUNET_MESH_OPTION_NOBUFFER = 0x1,
/**
* Enable channel reliability, lost messages will be retransmitted.
* Yes/No.
*/
GNUNET_MESH_OPTION_RELIABLE = 0x2,
/**
* Enable out of order delivery of messages.
* Yes/No.
*/
GNUNET_MESH_OPTION_OOORDER = 0x4,
/**
* Who is the peer at the other end of the channel.
* Only for use in @c GNUNET_MESH_channel_get_info
* struct GNUNET_PeerIdentity *peer
*/
GNUNET_MESH_OPTION_PEER = 0x8
};
/** /**
* Functions with this signature are called whenever a message is * Functions with this signature are called whenever a message is
* received. * received.
* *
* @param cls closure (set from GNUNET_MESH_connect) * Each time the function must call #GNUNET_MESH_receive_done on the channe
* @param tunnel connection to the other end l
* @param tunnel_ctx place to store local state associated with the tunnel * in order to receive the next message. This doesn't need to be immediate:
* @param sender who sent the message * can be delayed if some processing is done on the message.
* @param message the actual message *
* @param atsi performance data for the connection * @param cls Closure (set from #GNUNET_MESH_connect).
* @return GNUNET_OK to keep the connection open, * @param channel Connection to the other end.
* GNUNET_SYSERR to close it (signal serious error) * @param channel_ctx Place to store local state associated with the channe
l.
* @param message The actual message.
* @return #GNUNET_OK to keep the channel open,
* #GNUNET_SYSERR to close it (signal serious error).
*/ */
typedef int (*GNUNET_MESH_MessageCallback) (void *cls, typedef int (*GNUNET_MESH_MessageCallback) (void *cls,
struct GNUNET_MESH_Tunnel * tun struct GNUNET_MESH_Channel *cha
nel, nnel,
void **tunnel_ctx, void **channel_ctx,
const struct GNUNET_PeerIdentit const struct GNUNET_MessageHead
y * er *message);
sender,
const struct GNUNET_MessageHead
er *
message,
const struct GNUNET_ATS_Informa
tion
* atsi);
/** /**
* Message handler. Each struct specifies how to handle on particular * Message handler. Each struct specifies how to handle on particular
* type of message received. * type of message received.
*/ */
struct GNUNET_MESH_MessageHandler struct GNUNET_MESH_MessageHandler
{ {
/** /**
* Function to call for messages of "type". * Function to call for messages of "type".
*/ */
skipping to change at line 101 skipping to change at line 136
* Type of the message this handler covers. * Type of the message this handler covers.
*/ */
uint16_t type; uint16_t type;
/** /**
* Expected size of messages of this type. Use 0 for variable-size. * Expected size of messages of this type. Use 0 for variable-size.
* If non-zero, messages of the given type will be discarded if they * If non-zero, messages of the given type will be discarded if they
* do not have the right size. * do not have the right size.
*/ */
uint16_t expected_size; uint16_t expected_size;
}; };
/** /**
* Method called whenever another peer has added us to a tunnel * Method called whenever another peer has added us to a channel
* the other peer initiated. * the other peer initiated.
* Only called (once) upon reception of data with a message type which was * Only called (once) upon reception of data with a message type which was
* subscribed to in GNUNET_MESH_connect. A call to GNUNET_MESH_tunnel_destr * subscribed to in #GNUNET_MESH_connect.
oy *
* causes te tunnel to be ignored and no further notifications are sent abo * A call to #GNUNET_MESH_channel_destroy causes te channel to be ignored.
ut In
* the same tunnel. * this case the handler MUST return NULL.
* *
* @param cls closure * @param cls closure
* @param tunnel new handle to the tunnel * @param channel new handle to the channel
* @param initiator peer that started the tunnel * @param initiator peer that started the channel
* @param atsi performance information for the tunnel * @param port Port this channel is for.
* @return initial tunnel context for the tunnel * @param options MeshOption flag field, with all active option bits set to
1.
*
* @return initial channel context for the channel
* (can be NULL -- that's not an error) * (can be NULL -- that's not an error)
*/ */
typedef void *(GNUNET_MESH_InboundTunnelNotificationHandler) (void *cls, typedef void *(GNUNET_MESH_InboundChannelNotificationHandler) (void *cls,
struct struct
GNUNET_MESH_T GNUNET_MESH_
unnel Channel
* tunnel, * channel,
const struct const struct
GNUNET_PeerId GNUNET_PeerI
entity dentity
* initiator, * initiator,
const struct uint32_t por
GNUNET_ATS_In t,
formation enum GNUNET_
* atsi); MESH_ChannelOption
options);
/**
* Function called whenever an inbound tunnel is destroyed. Should clean u /**
p * Function called whenever a channel is destroyed. Should clean up
* any associated state. This function is NOT called if the client has * any associated state.
* explicitly asked for the tunnel to be destroyed using *
* GNUNET_MESH_tunnel_destroy. It must NOT call GNUNET_MESH_tunnel_destroy * It must NOT call #GNUNET_MESH_channel_destroy on the channel.
on *
* the tunnel. * @param cls closure (set from #GNUNET_MESH_connect)
* * @param channel connection to the other end (henceforth invalid)
* @param cls closure (set from GNUNET_MESH_connect) * @param channel_ctx place where local state associated
* @param tunnel connection to the other end (henceforth invalid) * with the channel is stored
* @param tunnel_ctx place where local state associated */
* with the tunnel is stored typedef void (GNUNET_MESH_ChannelEndHandler) (void *cls,
*/ const struct GNUNET_MESH_Chan
typedef void (GNUNET_MESH_TunnelEndHandler) (void *cls, nel *
const struct GNUNET_MESH_Tunne channel,
l * void *channel_ctx);
tunnel, void *tunnel_ctx);
/**
* Type for an application. Values defined in gnunet_applications.h
*/
typedef uint32_t GNUNET_MESH_ApplicationType;
/** /**
* Connect to the mesh service. * Connect to the mesh service.
* *
* @param cfg configuration to use * @param cfg Configuration to use.
* @param cls closure for the various callbacks that follow * @param cls Closure for the various callbacks that follow (including
* (including handlers in the handlers array) * handlers in the handlers array).
* @param new_tunnel function called when an *inbound* tunnel is created * @param new_channel Function called when an *incoming* channel is created
* @param cleaner function called when an *inbound* tunnel is destroyed by .
the * Can be NULL if no inbound channels are desired.
* remote peer, it is *not* called if GNUNET_MESH_tunnel_des * See @a ports.
troy * @param cleaner Function called when a channel is destroyed by the remote
* is called on the tunnel peer.
* @param handlers callbacks for messages we care about, NULL-terminated * It is NOT called if #GNUNET_MESH_channel_destroy is calle
* note that the mesh is allowed to drop notifications about d on
* inbound messages if the client does not process them fast * the channel.
* enough (for this notification type, a bounded queue is us * @param handlers Callbacks for messages we care about, NULL-terminated. E
ed) ach
* @param stypes list of the applications that this client claims to provid * one must call #GNUNET_MESH_receive_done on the channel t
e o
* receive the next message. Messages of a type that is no
t
* in the handlers array are ignored if received.
* @param ports NULL or 0-terminated array of port numbers for incoming cha
nnels.
* See @a new_channel.
*
* @return handle to the mesh service NULL on error * @return handle to the mesh service NULL on error
* (in this case, init is never called) * (in this case, init is never called)
*/ */
struct GNUNET_MESH_Handle * struct GNUNET_MESH_Handle *
GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *c ls, GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *c ls,
GNUNET_MESH_InboundTunnelNotificationHandler new_tunne GNUNET_MESH_InboundChannelNotificationHandler new_chan
l, nel,
GNUNET_MESH_TunnelEndHandler cleaner, GNUNET_MESH_ChannelEndHandler cleaner,
const struct GNUNET_MESH_MessageHandler *handlers, const struct GNUNET_MESH_MessageHandler *handlers,
const GNUNET_MESH_ApplicationType *stypes); const uint32_t *ports);
/** /**
* Disconnect from the mesh service. All tunnels will be destroyed. All tun nel * Disconnect from the mesh service. All channels will be destroyed. All ch annel
* disconnect callbacks will be called on any still connected peers, notify ing * disconnect callbacks will be called on any still connected peers, notify ing
* about their disconnection. The registered inbound tunnel cleaner will be * about their disconnection. The registered inbound channel cleaner will b
* called should any inbound tunnels still exist. e
* called should any inbound channels still exist.
* *
* @param handle connection to mesh to disconnect * @param handle connection to mesh to disconnect
*/ */
void void
GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle); GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle);
/** /**
* Method called whenever a peer has disconnected from the tunnel. * Create a new channel towards a remote peer.
* Implementations of this callback must NOT call
* GNUNET_MESH_tunnel_destroy immediately, but instead schedule those
* to run in some other task later. However, calling
* "GNUNET_MESH_notify_transmit_ready_cancel" is allowed.
*
* @param cls closure
* @param peer peer identity the tunnel stopped working with
*/
typedef void (*GNUNET_MESH_PeerDisconnectHandler) (void *cls,
const struct
GNUNET_PeerIdentity * pe
er);
/**
* Method called whenever a peer has connected to the tunnel.
* *
* @param cls closure * If the destination port is not open by any peer or the destination peer
* @param peer peer identity the tunnel was created to, NULL on timeout * does not accept the channel, #GNUNET_MESH_ChannelEndHandler will be call
* @param atsi performance data for the connection ed
* * for this channel.
* TODO: change to return int to let client allow the new peer or not?
*/
typedef void (*GNUNET_MESH_PeerConnectHandler) (void *cls,
const struct GNUNET_PeerIde
ntity
* peer,
const struct
GNUNET_ATS_Information * at
si);
/**
* Announce to ther peer the availability of services described by the rege
x,
* in order to be reachable to other peers via connect_by_string.
*
* Note that the first GNUNET_REGEX_INITIAL_BYTES characters are considered
* to be part of a prefix, (for instance 'gnunet://').
* If you put a variable part in there (*, +. ()), all matching strings
* will be stored in the DHT.
*
* @param h Handle to mesh.
* @param regex String with the regular expression describing local service
s.
* @param compression_characters How many characters can be assigned to one
* edge of the graph. The bigger the variabil
ity
* of the data, the smaller this parameter sh
ould
* be (down to 1).
* For maximum compression, use strlen (regex
)
* or 0 (special value). Use with care!
*/
void
GNUNET_MESH_announce_regex (struct GNUNET_MESH_Handle *h,
const char *regex,
unsigned int compression_characters);
/**
* Create a new tunnel (we're initiator and will be allowed to add/remove p
eers
* and to broadcast).
* *
* @param h mesh handle * @param h mesh handle
* @param tunnel_ctx client's tunnel context to associate with the tunnel * @param channel_ctx client's channel context to associate with the channe
* @param connect_handler function to call when peers are actually connecte l
d * @param peer peer identity the channel should go to
* @param disconnect_handler function to call when peers are disconnected * @param port Port number.
* @param handler_cls closure for connect/disconnect handlers * @param options MeshOption flag field, with all desired option bits set t
*/ o 1.
struct GNUNET_MESH_Tunnel *
GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, void *tunnel_ctx,
GNUNET_MESH_PeerConnectHandler connect_handler,
GNUNET_MESH_PeerDisconnectHandler disconnect_han
dler,
void *handler_cls);
/**
* Destroy an existing tunnel. The existing callback for the tunnel will NO
T
* be called.
* *
* @param tunnel tunnel handle * @return handle to the channel
*/ */
void struct GNUNET_MESH_Channel *
GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel); GNUNET_MESH_channel_create (struct GNUNET_MESH_Handle *h,
void *channel_ctx,
const struct GNUNET_PeerIdentity *peer,
uint32_t port,
enum GNUNET_MESH_ChannelOption options);
/** /**
* Request that the tunnel data rate is limited to the speed of the slowest * Destroy an existing channel.
* receiver.
* *
* @param tunnel Tunnel affected. * The existing end callback for the channel will be called immediately.
*/ * Any pending outgoing messages will be sent but no incoming messages will
void be
GNUNET_MESH_tunnel_speed_min (struct GNUNET_MESH_Tunnel *tunnel); * accepted and no data callbacks will be called.
/**
* Request that the tunnel data rate is limited to the speed of the fastest
* receiver. This is the default behavior.
* *
* @param tunnel Tunnel affected. * @param channel Channel handle, becomes invalid after this call.
*/ */
void void
GNUNET_MESH_tunnel_speed_max (struct GNUNET_MESH_Tunnel *tunnel); GNUNET_MESH_channel_destroy (struct GNUNET_MESH_Channel *channel);
/** /**
* Turn on/off the buffering status of the tunnel. * Struct to retrieve info about a channel.
*
* @param tunnel Tunnel affected.
* @param buffer GNUNET_YES to turn buffering on (default),
* GNUNET_NO otherwise.
*/ */
void union GNUNET_MESH_ChannelInfo
GNUNET_MESH_tunnel_buffer (struct GNUNET_MESH_Tunnel *tunnel, int buffer); {
/**
* Request that a peer should be added to the tunnel. The connect handler
* will be called when the peer connects
*
* @param tunnel handle to existing tunnel
* @param peer peer to add
*/
void
GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel,
const struct GNUNET_PeerIdentity *pee
r);
/**
* Request that a peer should be removed from the tunnel. The existing
* disconnect handler will be called ONCE if we were connected.
*
* @param tunnel handle to existing tunnel
* @param peer peer to remove
*/
void
GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel,
const struct GNUNET_PeerIdentity *pee
r);
/**
* Request that the mesh should try to connect to a peer supporting the giv
en
* message type.
*
* @param tunnel handle to existing tunnel
* @param app_type application type that must be supported by the peer
* (MESH should discover peer in proximity handling this ty
pe)
*/
void
GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel
,
GNUNET_MESH_ApplicationType app_t
ype);
/** /**
* Request that the mesh should try to connect to a peer matching the * #GNUNET_YES / #GNUNET_NO, for binary flags.
* description given in the service string. */
* int yes_no;
* @param tunnel handle to existing tunnel
* @param description string describing the destination node requirements
*/
void
GNUNET_MESH_peer_request_connect_by_string (struct GNUNET_MESH_Tunnel *tunn
el,
const char *description);
/** /**
* Request that the given peer isn't added to this tunnel in calls to * Peer on the other side of the channel
* connect_by_* calls, (due to misbehaviour, bad performance, ...). */
* const struct GNUNET_PeerIdentity peer;
* @param tunnel handle to existing tunnel. };
* @param peer peer identity of the peer which should be blacklisted
* for the tunnel.
*/
void
GNUNET_MESH_peer_blacklist (struct GNUNET_MESH_Tunnel *tunnel,
const struct GNUNET_PeerIdentity *peer);
/** /**
* Request that the given peer isn't blacklisted anymore from this tunnel, * Get information about a channel.
* and therefore can be added in future calls to connect_by_*.
* The peer must have been previously blacklisted for this tunnel.
* *
* @param tunnel handle to existing tunnel. * @param channel Channel handle.
* @param peer peer identity of the peer which shouldn't be blacklisted * @param option Query type GNUNET_MESH_OPTION_*
* for the tunnel anymore. * @param ... dependant on option, currently not used
*/ * @return Union with an answer to the query.
void */
GNUNET_MESH_peer_unblacklist (struct GNUNET_MESH_Tunnel *tunnel, const union GNUNET_MESH_ChannelInfo *
const struct GNUNET_PeerIdentity *peer); GNUNET_MESH_channel_get_info (struct GNUNET_MESH_Channel *channel,
enum GNUNET_MESH_ChannelOption option, ...);
/** /**
* Handle for a transmission request. * Handle for a transmission request.
*/ */
struct GNUNET_MESH_TransmitHandle; struct GNUNET_MESH_TransmitHandle;
/** /**
* Ask the mesh to call "notify" once it is ready to transmit the * Ask the mesh to call @a notify once it is ready to transmit the
* given number of bytes to the specified tunnel or target. * given number of bytes to the specified channel.
* Only one call can be active at any time, to issue another request, * Only one call can be active at any time, to issue another request,
* wait for the callback or cancel the current request. * wait for the callback or cancel the current request.
* *
* @param tunnel tunnel to use for transmission * @param channel channel to use for transmission
* @param cork is corking allowed for this transmission? * @param cork is corking allowed for this transmission?
* @param maxdelay how long can the message wait? * @param maxdelay how long can the message wait?
* @param target destination for the message
* NULL for multicast to all tunnel targets
* @param notify_size how many bytes of buffer space does notify want? * @param notify_size how many bytes of buffer space does notify want?
* @param notify function to call when buffer space is available; * @param notify function to call when buffer space is available;
* will be called with NULL on timeout or if the overall queue * will be called with NULL on timeout or if the overall queue
* for this peer is larger than queue_size and this is currently * for this peer is larger than queue_size and this is currently
* the message with the lowest priority * the message with the lowest priority
* @param notify_cls closure for notify * @param notify_cls closure for @a notify
* @return non-NULL if the notify callback was queued, * @return non-NULL if the notify callback was queued,
* NULL if we can not even queue the request (insufficient * NULL if we can not even queue the request (insufficient
* memory); if NULL is returned, "notify" will NOT be called. * memory); if NULL is returned, @a notify will NOT be called.
*/ */
struct GNUNET_MESH_TransmitHandle * struct GNUNET_MESH_TransmitHandle *
GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int c GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Channel *channel,
ork, int cork,
struct GNUNET_TIME_Relative maxdelay, struct GNUNET_TIME_Relative maxdelay,
const struct GNUNET_PeerIdentity *target ,
size_t notify_size, size_t notify_size,
GNUNET_CONNECTION_TransmitReadyNotify no tify, GNUNET_CONNECTION_TransmitReadyNotify no tify,
void *notify_cls); void *notify_cls);
/** /**
* Cancel the specified transmission-ready notification. * Cancel the specified transmission-ready notification.
* *
* @param th handle that was returned by "notify_transmit_ready". * @param th handle that was returned by "notify_transmit_ready".
*/ */
void void
GNUNET_MESH_notify_transmit_ready_cancel (struct GNUNET_MESH_TransmitHandle GNUNET_MESH_notify_transmit_ready_cancel (struct GNUNET_MESH_TransmitHandle
*th); *th);
/** /**
* Method called to retrieve information about each tunnel the mesh peer * Indicate readiness to receive the next message on a channel.
*
* Should only be called once per handler called.
*
* @param channel Channel that will be allowed to call another handler.
*/
void
GNUNET_MESH_receive_done (struct GNUNET_MESH_Channel *channel);
/**************************************************************************
****/
/******************** MONITORING /DEBUG API *********************
****/
/**************************************************************************
****/
/* The following calls are not useful for normal MESH operation, but for
*/
/* debug and monitoring of the mesh state. They can be safely ignored.
*/
/* The API can change at any point without notice.
*/
/* Please contact the developer if you consider any of this calls useful fo
r */
/* normal mesh applications.
*/
/**************************************************************************
****/
/**
* Method called to retrieve information about each channel the mesh peer
* is aware of. * is aware of.
* *
* @param cls Closure. * @param cls Closure.
* @param initiator Peer that started the tunnel (owner). * @param channel_number Channel number.
* @param tunnel_number Tunnel number. * @param origin that started the channel (owner).
* @param peers Array of peer identities that participate in the tunnel. * @param target other endpoint of the channel
* @param npeers Number of peers in peers. */
*/ typedef void (*GNUNET_MESH_ChannelsCB) (void *cls,
typedef void (*GNUNET_MESH_TunnelsCB) (void *cls, uint32_t channel_number,
const struct GNUNET_PeerIdentity *ow const struct GNUNET_PeerIdentity *o
ner, rigin,
unsigned int tunnel_number, const struct GNUNET_PeerIdentity *t
const struct GNUNET_PeerIdentity *pe arget);
ers,
unsigned int npeers);
/** /**
* Method called to retrieve information about a specific tunnel the mesh p eer * Method called to retrieve information about a specific channel the mesh peer
* is aware of, including all transit nodes. * is aware of, including all transit nodes.
* *
* @param cls Closure. * @param cls Closure.
* @param peer Peer in the tunnel's tree. * @param peer Peer in the channel's tree.
* @param parent Parent of the current peer. All 0 when peer is root. * @param parent Parent of the current peer. All 0 when peer is root.
*/ */
typedef void (*GNUNET_MESH_TunnelCB) (void *cls, typedef void (*GNUNET_MESH_ChannelCB) (void *cls,
const struct GNUNET_PeerIdentity *pee r, const struct GNUNET_PeerIdentity *pee r,
const struct GNUNET_PeerIdentity *par ent); const struct GNUNET_PeerIdentity *par ent);
/** /**
* Request information about the running mesh peer. * Request information about the running mesh peer.
* The callback will be called for every tunnel known to the service, * The callback will be called for every channel known to the service,
* listing all active peers that blong to the tunnel. * listing all active peers that belong to the channel.
* *
* If called again on the same handle, it will overwrite the previous * If called again on the same handle, it will overwrite the previous
* callback and cls. To retrieve the cls, monitor_cancel must be * callback and cls. To retrieve the cls, monitor_cancel must be
* called first. * called first.
* *
* WARNING: unstable API, likely to change in the future! * WARNING: unstable API, likely to change in the future!
* *
* @param h Handle to the mesh peer. * @param h Handle to the mesh peer.
* @param callback Function to call with the requested data. * @param callback Function to call with the requested data.
* @param callback_cls Closure for @c callback. * @param callback_cls Closure for @c callback.
*/ */
void void
GNUNET_MESH_get_tunnels (struct GNUNET_MESH_Handle *h, GNUNET_MESH_get_channels (struct GNUNET_MESH_Handle *h,
GNUNET_MESH_TunnelsCB callback, GNUNET_MESH_ChannelsCB callback,
void *callback_cls); void *callback_cls);
/** /**
* Request information about a specific tunnel of the running mesh peer. * Request information about a specific channel of the running mesh peer.
* *
* WARNING: unstable API, likely to change in the future! * WARNING: unstable API, likely to change in the future!
* *
* @param h Handle to the mesh peer. * @param h Handle to the mesh peer.
* @param initiator ID of the owner of the tunnel. * @param initiator ID of the owner of the channel.
* @param tunnel_number Tunnel number. * @param channel_number Channel number.
* @param callback Function to call with the requested data. * @param callback Function to call with the requested data.
* @param callback_cls Closure for @c callback. * @param callback_cls Closure for @c callback.
*/ */
void void
GNUNET_MESH_show_tunnel (struct GNUNET_MESH_Handle *h, GNUNET_MESH_show_channel (struct GNUNET_MESH_Handle *h,
struct GNUNET_PeerIdentity *initiator, struct GNUNET_PeerIdentity *initiator,
unsigned int tunnel_number, uint32_t channel_number,
GNUNET_MESH_TunnelCB callback, GNUNET_MESH_ChannelCB callback,
void *callback_cls); void *callback_cls);
/** /**
* Cancel a monitor request. The monitor callback will not be called. * Cancel a monitor request. The monitor callback will not be called.
* *
* WARNING: unstable API, likely to change in the future! * WARNING: unstable API, likely to change in the future!
* *
* @param h Mesh handle. * @param h Mesh handle.
* *
* @return Closure given to GNUNET_MESH_monitor, if any. * @return Closure given to GNUNET_MESH_monitor, if any.
*/ */
void * void *
GNUNET_MESH_get_tunnels_cancel (struct GNUNET_MESH_Handle *h); GNUNET_MESH_get_channels_cancel (struct GNUNET_MESH_Handle *h);
/** /**
* Transition API for tunnel ctx management * Create a message queue for a mesh channel.
* The message queue can only be used to transmit messages,
* not to receive them.
* *
* FIXME deprecated * @param channel the channel to create the message qeue for
* @return a message queue to messages over the channel
*/ */
void struct GNUNET_MQ_Handle *
GNUNET_MESH_tunnel_set_data (struct GNUNET_MESH_Tunnel *tunnel, void *data) GNUNET_MESH_mq_create (struct GNUNET_MESH_Channel *channel);
;
/**
* Transition API for tunnel ctx management
*
* FIXME deprecated
*/
void *
GNUNET_MESH_tunnel_get_data (struct GNUNET_MESH_Tunnel *tunnel);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* ifndef GNUNET_MESH_SERVICE_H */ /* ifndef GNUNET_MESH_SERVICE_H */
#endif #endif
 End of changes. 54 change blocks. 
319 lines changed or deleted 250 lines changed or added


 gnunet_namestore_plugin.h   gnunet_namestore_plugin.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2012 Christian Grothoff (and other contributing authors) (C) 2012, 2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 29 skipping to change at line 29
*/ */
/** /**
* @file include/gnunet_namestore_plugin.h * @file include/gnunet_namestore_plugin.h
* @brief plugin API for the namestore database backend * @brief plugin API for the namestore database backend
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_NAMESTORE_PLUGIN_H #ifndef GNUNET_NAMESTORE_PLUGIN_H
#define GNUNET_NAMESTORE_PLUGIN_H #define GNUNET_NAMESTORE_PLUGIN_H
#include "gnunet_common.h"
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_namestore_service.h" #include "gnunet_namestore_service.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/** /**
* Function called by for each matching record. * Function called by for each matching record.
* *
* @param cls closure * @param cls closure
* @param zone_key public key of the zone * @param zone_key private key of the zone
* @param expire when does the corresponding block in the DHT expire (until * @param label name that is being mapped (at most 255 characters long)
* when should we never do a DHT lookup for the same name aga * @param rd_count number of entries in @a rd array
in)?
* @param name name that is being mapped (at most 255 characters long)
* @param rd_count number of entries in 'rd' array
* @param rd array of records with data to store * @param rd array of records with data to store
* @param signature signature of the record block, NULL if signature is una
vailable (i.e.
* because the user queried for a particular record type only)
*/ */
typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls, typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls,
const struct GNUNET_CRYPTO_ const struct GNUNET_CRYPTO_
RsaPublicKeyBinaryEncoded *zone_key, EcdsaPrivateKey *private_key,
struct GNUNET_TIME_Absolute const char *label,
expire, unsigned int rd_count,
const char *name, const struct GNUNET_GNSRECO
unsigned int rd_len, RD_Data *rd);
const struct GNUNET_NAMESTO
RE_RecordData *rd,
const struct GNUNET_CRYPTO_
RsaSignature *signature);
/** /**
* @brief struct returned by the initialization function of the plugin * @brief struct returned by the initialization function of the plugin
*/ */
struct GNUNET_NAMESTORE_PluginFunctions struct GNUNET_NAMESTORE_PluginFunctions
{ {
/** /**
* Closure to pass to all plugin functions. * Closure to pass to all plugin functions.
*/ */
void *cls; void *cls;
/** /**
* Store a record in the datastore. Removes any existing record in the * Store a record in the datastore for which we are the authority.
* same zone with the same name. * Removes any existing record in the same zone with the same name.
* *
* @param cls closure (internal context for the plugin) * @param cls closure (internal context for the plugin)
* @param zone_key public key of the zone * @param zone private key of the zone
* @param expire when does the corresponding block in the DHT expire (unt * @param label name of the record in the zone
il * @param rd_count number of entries in @a rd array, 0 to delete all reco
* when should we never do a DHT lookup for the same name a rds
gain)?
* @param name name that is being mapped (at most 255 characters long)
* @param rd_count number of entries in 'rd' array
* @param rd array of records with data to store * @param rd array of records with data to store
* @param signature signature of the record block, NULL if signature is u * @return #GNUNET_OK on success, else #GNUNET_SYSERR
navailable (i.e.
* because the user queried for a particular record type only)
* @return GNUNET_OK on success, else GNUNET_SYSERR
*/ */
int (*put_records) (void *cls, int (*store_records) (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded * const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
zone_key, const char *label,
struct GNUNET_TIME_Absolute expire, unsigned int rd_count,
const char *name, const struct GNUNET_GNSRECORD_Data *rd);
unsigned int rd_len,
const struct GNUNET_NAMESTORE_RecordData *rd,
const struct GNUNET_CRYPTO_RsaSignature *signature);
/** /**
* Removes any existing record in the given zone with the same name. * Lookup records in the datastore for which we are the authority.
* *
* @param cls closure (internal context for the plugin) * @param cls closure (internal context for the plugin)
* @param zone hash of the public key of the zone * @param zone private key of the zone
* @param name name to remove (at most 255 characters long) * @param label name of the record in the zone
* @return GNUNET_OK on success * @param iter function to call with the result
* @param iter_cls closure for @a iter
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/ */
int (*remove_records) (void *cls, int (*lookup_records) (void *cls,
const struct GNUNET_CRYPTO_ShortHashCode *zone, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const char *name); const char *label,
GNUNET_NAMESTORE_RecordIterator iter, void *iter_cl
s);
/** /**
* Iterate over the results for a particular key and zone in the * Iterate over the results for a particular zone in the
* datastore. Will return at most one result to the iterator. * datastore. Will return at most one result to the iterator.
* *
* @param cls closure (internal context for the plugin) * @param cls closure (internal context for the plugin)
* @param zone hash of public key of the zone, NULL to iterate over all z * @param zone private key of the zone, NULL for all zones
ones
* @param name name as '\0' terminated string, NULL to iterate over all r
ecords of the zone
* @param offset offset in the list of all matching records * @param offset offset in the list of all matching records
* @param iter function to call with the result * @param iter function to call with the result
* @param iter_cls closure for iter * @param iter_cls closure for @a iter
* @return GNUNET_OK on success, GNUNET_NO if there were no results, GNUN * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #G
ET_SYSERR on error NUNET_SYSERR on error
* 'iter' will have been called unless the return value is 'GNUNET_
SYSERR'
*/ */
int (*iterate_records) (void *cls, int (*iterate_records) (void *cls,
const struct GNUNET_CRYPTO_ShortHashCode *zone, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const char *name,
uint64_t offset, uint64_t offset,
GNUNET_NAMESTORE_RecordIterator iter, void *iter_c ls); GNUNET_NAMESTORE_RecordIterator iter, void *iter_c ls);
/** /**
* Look for an existing PKEY delegation record for a given public key. * Look for an existing PKEY delegation record for a given public key.
* Returns at most one result to the iterator. * Returns at most one result to the iterator.
* *
* @param cls closure (internal context for the plugin) * @param cls closure (internal context for the plugin)
* @param zone hash of public key of the zone to look up in, never NULL * @param zone private key of the zone to look up in, never NULL
* @param value_zone hash of the public key of the target zone (value), n * @param value_zone public key of the target zone (value), never NULL
ever NULL
* @param iter function to call with the result * @param iter function to call with the result
* @param iter_cls closure for iter * @param iter_cls closure for @a iter
* @return GNUNET_OK on success, GNUNET_NO if there were no results, GNUN * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #G
ET_SYSERR on error NUNET_SYSERR on error
* 'iter' will have been called unless the return value is 'GNUNET_
SYSERR'
*/ */
int (*zone_to_name) (void *cls, int (*zone_to_name) (void *cls,
const struct GNUNET_CRYPTO_ShortHashCode *zone, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const struct GNUNET_CRYPTO_ShortHashCode *value_zone, const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone
,
GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) ; GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) ;
/**
* Delete an entire zone (all records). Not used in normal operation.
*
* @param cls closure (internal context for the plugin)
* @param zone zone to delete
*/
void (*delete_zone) (void *cls,
const struct GNUNET_CRYPTO_ShortHashCode *zone);
}; };
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* end of gnunet_namestore_plugin.h */ /* end of gnunet_namestore_plugin.h */
 End of changes. 21 change blocks. 
81 lines changed or deleted 48 lines changed or added


 gnunet_namestore_service.h   gnunet_namestore_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2012 Christian Grothoff (and other contributing authors) (C) 2012, 2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_namestore_service.h * @file include/gnunet_namestore_service.h
* @brief API that can be used to store naming information on a GNUnet node ; * @brief API that can be used to store naming information on a GNUnet node ;
* Naming information can either be records for which this peer/user
* is authoritative, or blocks which are cached, encrypted naming
* data from other peers.
* @author Christian Grothoff * @author Christian Grothoff
*
* Other functions we might want:
* - enumerate all known zones
*/ */
#ifndef GNUNET_NAMESTORE_SERVICE_H #ifndef GNUNET_NAMESTORE_SERVICE_H
#define GNUNET_NAMESTORE_SERVICE_H #define GNUNET_NAMESTORE_SERVICE_H
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_block_lib.h" #include "gnunet_block_lib.h"
#include "gnunet_gnsrecord_lib.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
/** /**
* Record type indicating any record/'*'
*/
#define GNUNET_NAMESTORE_TYPE_ANY 0
/**
* Record type for GNS zone transfer ("PKEY").
*/
#define GNUNET_NAMESTORE_TYPE_PKEY 65536
/**
* Record type for GNS zone transfer ("PSEU").
*/
#define GNUNET_NAMESTORE_TYPE_PSEU 65537
/**
* Record type for GNS legacy hostnames ("LEHO").
*/
#define GNUNET_NAMESTORE_TYPE_LEHO 65538
/**
* Record type for VPN resolution
*/
#define GNUNET_NAMESTORE_TYPE_VPN 65539
/**
* Record type for zone revocation
*/
#define GNUNET_NAMESTORE_TYPE_REV 65540
/**
* Entry in the queue. * Entry in the queue.
*/ */
struct GNUNET_NAMESTORE_QueueEntry; struct GNUNET_NAMESTORE_QueueEntry;
/** /**
* Handle to the namestore service. * Handle to the namestore service.
*/ */
struct GNUNET_NAMESTORE_Handle; struct GNUNET_NAMESTORE_Handle;
/** /**
* Handle to the namestore zone iterator. * Handle to the namestore zone iterator.
*/ */
struct GNUNET_NAMESTORE_ZoneIterator; struct GNUNET_NAMESTORE_ZoneIterator;
/** /**
* Maximum size of a value that can be stored in the namestore.
*/
#define GNUNET_NAMESTORE_MAX_VALUE_SIZE (63 * 1024)
/**
* Connect to the namestore service. * Connect to the namestore service.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @return handle to use to access the service * @return handle to use to access the service
*/ */
struct GNUNET_NAMESTORE_Handle * struct GNUNET_NAMESTORE_Handle *
GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
/** /**
* Disconnect from the namestore service (and free associated * Disconnect from the namestore service (and free associated
* resources). * resources). Must not be called from within operation callbacks of
* the API.
* *
* @param h handle to the namestore * @param h handle to the namestore
*/ */
void void
GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h); GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h);
/** /**
* Continuation called to notify client about result of the * Continuation called to notify client about result of the
* operation. * operation.
* *
* @param cls closure * @param cls closure
* @param success GNUNET_SYSERR on failure (including timeout/queue drop/fa * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/f
ilure to validate) ailure to validate)
* GNUNET_NO if content was already there or not found * #GNUNET_NO if content was already there or not found
* GNUNET_YES (or other positive value) on success * #GNUNET_YES (or other positive value) on success
* @param emsg NULL on success, otherwise an error message * @param emsg NULL on success, otherwise an error message
*/ */
typedef void (*GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls, typedef void (*GNUNET_NAMESTORE_ContinuationWithStatus) (void *cls,
int32_t success, int32_t success,
const char *emsg); const char *emsg);
/** /**
* Flags that can be set for a record.
*/
enum GNUNET_NAMESTORE_RecordFlags
{
/**
* No special options.
*/
GNUNET_NAMESTORE_RF_NONE = 0,
/**
* This peer is the authority for this record; it must thus
* not be deleted (other records can be deleted if we run
* out of space).
*/
GNUNET_NAMESTORE_RF_AUTHORITY = 1,
/**
* This is a private record of this peer and it should
* thus not be handed out to other peers.
*/
GNUNET_NAMESTORE_RF_PRIVATE = 2,
/**
* This record was added by the system
* and is pending user confimation
*/
GNUNET_NAMESTORE_RF_PENDING = 4,
/**
* This expiration time of the record is a relative
* time (not an absolute time).
*/
GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION = 8,
/**
* This record should not be used unless all (other) records with an abso
lute
* expiration time have expired.
*/
GNUNET_NAMESTORE_RF_SHADOW_RECORD = 16
/**
* When comparing flags for record equality for removal,
* which flags should must match (in addition to the type,
* name, expiration value and data of the record)? All flags
* that are not listed here will be ignored for this purpose.
* (for example, we don't expect that users will remember to
* pass the '--private' option when removing a record from
* the namestore, hence we don't require this particular option
* to match upon removal). See also
* 'GNUNET_NAMESTORE_records_cmp'.
*/
#define GNUNET_NAMESTORE_RF_RCMP_FLAGS (GNUNET_NAMESTORE_RF_RELATIVE_EXPIRA
TION)
};
/**
* A GNS record.
*/
struct GNUNET_NAMESTORE_RecordData
{
/**
* Binary value stored in the DNS record.
* FIXME: goofy API: sometimes 'data' is individually
* 'malloc'ed, sometimes it points into some existing
* data area (so sometimes this should be a 'void *',
* sometimes a 'const void *'). This is unclean.
*/
const void *data;
/**
* Expiration time for the DNS record. Can be relative
* or absolute, depending on 'flags'.
*/
uint64_t expiration_time;
/**
* Number of bytes in 'data'.
*/
size_t data_size;
/**
* Type of the GNS/DNS record.
*/
uint32_t record_type;
/**
* Flags for the record.
*/
enum GNUNET_NAMESTORE_RecordFlags flags;
};
/**
* Store an item in the namestore. If the item is already present, * Store an item in the namestore. If the item is already present,
* the expiration time is updated to the max of the existing time and * it is replaced with the new record. Use an empty array to
* the new time. This API is used when we cache signatures from other * remove all records under the given name.
* authorities.
* *
* @param h handle to the namestore * @param h handle to the namestore
* @param zone_key public key of the zone * @param pkey private key of the zone
* @param name name that is being mapped (at most 255 characters long) * @param label name that is being mapped
* @param freshness when does the corresponding block in the DHT expire (un * @param rd_count number of records in the 'rd' array
til
* when should we never do a DHT lookup for the same name aga
in)?
* @param rd_count number of entries in 'rd' array
* @param rd array of records with data to store * @param rd array of records with data to store
* @param signature signature for all the records in the zone under the giv en name
* @param cont continuation to call when done * @param cont continuation to call when done
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return handle to abort the request * @return handle to abort the request
*/ */
struct GNUNET_NAMESTORE_QueueEntry * struct GNUNET_NAMESTORE_QueueEntry *
GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEn const struct GNUNET_CRYPTO_EcdsaPrivateKey *
coded *zone_key, pkey,
const char *name, const char *label,
struct GNUNET_TIME_Absolute freshness, unsigned int rd_count,
unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd,
const struct GNUNET_NAMESTORE_RecordData *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont
const struct GNUNET_CRYPTO_RsaSignature *signat ,
ure, void *cont_cls);
GNUNET_NAMESTORE_ContinuationWithStatus cont,
void *cont_cls); /**
* Process a record that was stored in the namestore.
/** *
* Check if a signature is valid. This API is used by the GNS Block * @param cls closure
* to validate signatures received from the network. * @param zone private key of the zone; NULL on disconnect
* * @param label label of the records; NULL on disconnect
* @param public_key public key of the zone * @param rd_count number of entries in @a rd array, 0 if label was deleted
* @param freshness time set for block expiration
* @param name name that is being mapped (at most 255 characters long)
* @param rd_count number of entries in 'rd' array
* @param rd array of records with data to store * @param rd array of records with data to store
* @param signature signature for all the records in the zone under the giv
en name
* @return GNUNET_OK if the signature is valid
*/ */
int typedef void (*GNUNET_NAMESTORE_RecordMonitor) (void *cls,
GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyB const struct GNUNET_CRYPTO_E
inaryEncoded *public_key, cdsaPrivateKey *zone,
const struct GNUNET_TIME_Absolute freshn const char *label,
ess, unsigned int rd_count,
const char *name, const struct GNUNET_GNSRECOR
unsigned int rd_count, D_Data *rd);
const struct GNUNET_NAMESTORE_RecordData
*rd,
const struct GNUNET_CRYPTO_RsaSignature
*signature);
/** /**
* Store an item in the namestore. If the item is already present, * Set the desired nick name for a zone
* the expiration time is updated to the max of the existing time and
* the new time. This API is used by the authority of a zone.
* FIXME: consider allowing to pass multiple records in one call!
* *
* @param h handle to the namestore * @param h handle to the namestore
* @param pkey private key of the zone * @param pkey private key of the zone
* @param name name that is being mapped (at most 255 characters long) * @param nick the nick name to set
* @param rd record data to store
* @param cont continuation to call when done * @param cont continuation to call when done
* @param cont_cls closure for cont * @param cont_cls closure for 'cont'
* @return handle to abort the request * @return handle to abort the request
*/ */
struct GNUNET_NAMESTORE_QueueEntry * struct GNUNET_NAMESTORE_QueueEntry *
GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_RsaPrivateKey *p const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey
key, ,
const char *name, const char *nick,
const struct GNUNET_NAMESTORE_RecordData *r GNUNET_NAMESTORE_ContinuationWithStatus cont,
d, void *cont_cls);
GNUNET_NAMESTORE_ContinuationWithStatus con
t,
void *cont_cls);
/** /**
* Explicitly remove some content from the database. The * Lookup an item in the namestore.
* "cont"inuation will be called with status "GNUNET_OK" if content
* was removed, "GNUNET_NO" if no matching entry was found and
* "GNUNET_SYSERR" on all other types of errors.
* This API is used by the authority of a zone.
* *
* @param h handle to the namestore * @param h handle to the namestore
* @param pkey private key of the zone * @param pkey private key of the zone
* @param name name that is being mapped (at most 255 characters long) * @param label name that is being mapped
* @param rd record data, remove specific record, NULL to remove the name * @param rm function to call with the result (with 0 records if we don't h
and all records ave that label)
* @param cont continuation to call when done * @param rm_cls closure for @a rm
* @param cont_cls closure for cont
* @return handle to abort the request * @return handle to abort the request
*/ */
struct GNUNET_NAMESTORE_QueueEntry * struct GNUNET_NAMESTORE_QueueEntry *
GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_RsaPrivateKey *pk const struct GNUNET_CRYPTO_EcdsaPrivateKey
ey, *pkey,
const char *name, const char *label,
const struct GNUNET_NAMESTORE_RecordData *rd GNUNET_NAMESTORE_RecordMonitor rm,
, void *rm_cls);
GNUNET_NAMESTORE_ContinuationWithStatus cont
,
void *cont_cls);
/** /**
* Process a record that was stored in the namestore. * Look for an existing PKEY delegation record for a given public key.
* * Returns at most one result to the processor.
* @param cls closure
* @param zone_key public key of the zone
* @param freshness when does the corresponding block in the DHT expire (un
til
* when should we never do a DHT lookup for the same name aga
in)?;
* GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any t
ype in the namestore,
* or the expiration time of the block in the namestore (even
if there are zero
* records matching the desired record type)
* @param name name that is being mapped (at most 255 characters long)
* @param rd_count number of entries in 'rd' array
* @param rd array of records with data to store
* @param signature signature of the record block, NULL if signature is una
vailable (i.e.
* because the user queried for a particular record type only)
*/
typedef void (*GNUNET_NAMESTORE_RecordProcessor) (void *cls,
const struct GNUNET_CRYPTO
_RsaPublicKeyBinaryEncoded *zone_key,
struct GNUNET_TIME_Absolut
e freshness,
const char *name,
unsigned int rd_len,
const struct GNUNET_NAMEST
ORE_RecordData *rd,
const struct GNUNET_CRYPTO
_RsaSignature *signature);
/**
* Get a result for a particular key from the namestore. The processor
* will only be called once. When using this functions, relative expiratio
n
* times will be converted to absolute expiration times and a signature
* will be created if we are the authority. The record data and signature
* passed to 'proc' is thus always suitable for passing on to other peers
* (if we are the authority). If the record type is NOT set to 'ANY' and
* if we are NOT the authority, then non-matching records may be omitted
* from the result and no valid signature can be created; in this case,
* 'signature' will be NULL and the result cannot be given to other peers.
* *
* @param h handle to the namestore * @param h handle to the namestore
* @param zone zone to look up a record from * @param zone public key of the zone to look up in, never NULL
* @param name name to look up * @param value_zone public key of the target zone (value), never NULL
* @param record_type desired record type, 0 for all
* @param proc function to call on the matching records, or with * @param proc function to call on the matching records, or with
* NULL (rd_count == 0) if there are no matching records * NULL (rd_count == 0) if there are no matching records
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
* @return a handle that can be used to * @return a handle that can be used to
* cancel * cancel
*/ */
struct GNUNET_NAMESTORE_QueueEntry * struct GNUNET_NAMESTORE_QueueEntry *
GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_ShortHashCode *zo const struct GNUNET_CRYPTO_EcdsaPrivateKey *z
ne, one,
const char *name, const struct GNUNET_CRYPTO_EcdsaPublicKey *va
uint32_t record_type, lue_zone,
GNUNET_NAMESTORE_RecordProcessor proc, void GNUNET_NAMESTORE_RecordMonitor proc, void *pr
*proc_cls); oc_cls);
/** /**
* Look for an existing PKEY delegation record for a given public key. * Cancel a namestore operation. The final callback from the
* Returns at most one result to the processor. * operation must not have been done yet. Must be called on any
* namestore operation that has not yet completed prior to calling
* #GNUNET_NAMESTORE_disconnect.
* *
* @param h handle to the namestore * @param qe operation to cancel
* @param zone hash of public key of the zone to look up in, never NULL
* @param value_zone hash of the public key of the target zone (value), nev
er NULL
* @param proc function to call on the matching records, or with
* NULL (rd_count == 0) if there are no matching records
* @param proc_cls closure for proc
* @return a handle that can be used to
* cancel
*/ */
struct GNUNET_NAMESTORE_QueueEntry * void
GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe);
const struct GNUNET_CRYPTO_ShortHashCode *zon
e,
const struct GNUNET_CRYPTO_ShortHashCode *val
ue_zone,
GNUNET_NAMESTORE_RecordProcessor proc, void *
proc_cls);
/** /**
* Starts a new zone iteration (used to periodically PUT all of our * Starts a new zone iteration (used to periodically PUT all of our
* records into our DHT). "proc" will be called once immediately, and * records into our DHT). This MUST lock the struct GNUNET_NAMESTORE_Handle
* then again after "GNUNET_NAMESTORE_zone_iterator_next" is invoked. * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next and
* * #GNUNET_NAMESTORE_zone_iteration_stop. @a proc will be called once
* By specifying a 'zone' of NULL and setting 'GNUNET_NAMESTORE_RF_AUTHORIT * immediately, and then again after
Y' * #GNUNET_NAMESTORE_zone_iterator_next is invoked.
* in 'must_have_flags', we can iterate over all records for which we are
* the authority (the 'authority' flag will NOT be set in the returned
* records anyway).
*
* The 'GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION'
* bit in 'must_have_flags' has a special meaning:
*
* 0) If the bit is clear, all relative expriation times are converted to
* absolute expiration times. This is useful for performing DHT PUT
* operations (and zone transfers) of our zone. The generated signature
s
* will be valid for other peers.
* 1) if it is set, it means that relative expiration times should be
* preserved when returned (this is useful for the zone editor user
* interface). No signatures will be created in this case, as
* signatures must not cover records with relative expiration times.
*
* Note that not all queries against this interface are equally performant
* as for some combinations no efficient index may exist.
* *
* @param h handle to the namestore * @param h handle to the namestore
* @param zone zone to access, NULL for all zones * @param zone zone to access, NULL for all zones
* @param must_have_flags flags that must be set for the record to be retur
ned
* @param must_not_have_flags flags that must NOT be set for the record to
be returned
* @param proc function to call on each name from the zone; it * @param proc function to call on each name from the zone; it
* will be called repeatedly with a value (if available) * will be called repeatedly with a value (if available)
* and always once at the end with a name of NULL. * and always once at the end with a label of NULL.
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
* @return an iterator handle to use for iteration * @return an iterator handle to use for iteration
*/ */
struct GNUNET_NAMESTORE_ZoneIterator * struct GNUNET_NAMESTORE_ZoneIterator *
GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_ShortHashC const struct GNUNET_CRYPTO_EcdsaPriva
ode *zone, teKey *zone,
enum GNUNET_NAMESTORE_RecordFlags mus GNUNET_NAMESTORE_RecordMonitor proc,
t_have_flags,
enum GNUNET_NAMESTORE_RecordFlags mus
t_not_have_flags,
GNUNET_NAMESTORE_RecordProcessor proc
,
void *proc_cls); void *proc_cls);
/** /**
* Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_ start * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration _start
* for the next record. * for the next record.
* *
* @param it the iterator * @param it the iterator
*/ */
void void
GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator * it); GNUNET_NAMESTORE_zone_iterator_next (struct GNUNET_NAMESTORE_ZoneIterator * it);
/** /**
* Stops iteration and releases the namestore handle for further calls. Mu st * Stops iteration and releases the namestore handle for further calls. Mu st
* be called on any iteration that has not yet completed prior to calling * be called on any iteration that has not yet completed prior to calling
* 'GNUNET_NAMESTORE_disconnect'. * #GNUNET_NAMESTORE_disconnect.
* *
* @param it the iterator * @param it the iterator
*/ */
void void
GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it); GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it);
/** /**
* Cancel a namestore operation. The final callback from the * Handle for a monitoring activity.
* operation must not have been done yet. Must be called on any
* namestore operation that has not yet completed prior to calling
* 'GNUNET_NAMESTORE_disconnect'.
*
* @param qe operation to cancel
*/ */
void struct GNUNET_NAMESTORE_ZoneMonitor;
GNUNET_NAMESTORE_cancel (struct GNUNET_NAMESTORE_QueueEntry *qe);
/* convenience APIs for serializing / deserializing GNS records */
/** /**
* Calculate how many bytes we will need to serialize the given * Function called once the monitor has caught up with the current
* records. * state of the database. Will be called AGAIN after each disconnect
* * (record monitor called with 'NULL' for zone_key) once we're again
* @param rd_count number of records in the rd array * in sync.
* @param rd array of GNUNET_NAMESTORE_RecordData with rd_count elements
*
* @return the required size to serialize
* *
* @param cls closure
*/ */
size_t typedef void (*GNUNET_NAMESTORE_RecordsSynchronizedCallback)(void *cls);
GNUNET_NAMESTORE_records_get_size (unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData
*rd);
/**
* Serialize the given records to the given destination buffer.
*
* @param rd_count number of records in the rd array
* @param rd array of GNUNET_NAMESTORE_RecordData with rd_count elements
* @param dest_size size of the destination array
* @param dest where to write the result
*
* @return the size of serialized records, -1 if records do not fit
*/
ssize_t
GNUNET_NAMESTORE_records_serialize (unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData
*rd,
size_t dest_size,
char *dest);
/**
* Deserialize the given records to the given destination.
*
* @param len size of the serialized record data
* @param src the serialized record data
* @param rd_count number of records in the rd array
* @param dest where to put the data
*
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
GNUNET_NAMESTORE_records_deserialize (size_t len,
const char *src,
unsigned int rd_count,
struct GNUNET_NAMESTORE_RecordData *de
st);
/**
* Convert the 'value' of a record to a string.
*
* @param type type of the record
* @param data value in binary encoding
* @param data_size number of bytes in data
* @return NULL on error, otherwise human-readable representation of the va
lue
*/
char *
GNUNET_NAMESTORE_value_to_string (uint32_t type,
const void *data,
size_t data_size);
/**
* Convert human-readable version of a 'value' of a record to the binary
* representation.
*
* @param type type of the record
* @param s human-readable string
* @param data set to value in binary encoding (will be allocated)
* @param data_size set to number of bytes in data
* @return GNUNET_OK on success
*/
int
GNUNET_NAMESTORE_string_to_value (uint32_t type,
const char *s,
void **data,
size_t *data_size);
/**
* Convert a type name (i.e. "AAAA") to the corresponding number.
*
* @param typename name to convert
* @return corresponding number, UINT32_MAX on error
*/
uint32_t
GNUNET_NAMESTORE_typename_to_number (const char *typename);
/** /**
* Convert a type number (i.e. 1) to the corresponding type string (i.e. "A * Begin monitoring a zone for changes. Will first call the @a
") * monitor function on all existing records in the selected zone(s) if
* * @a iterate_first is #GNUNET_YES. In any case, we will then call @a
* @param type number of a type to convert * sync_cb, and then afterwards call the @a monitor whenever a record
* @return corresponding typestring, NULL on error * changes. If the namestore disconnects, the @a monitor function is
*/ * called with a disconnect event; if the connection is
const char * * re-established, the process begins from the start (depending on @a
GNUNET_NAMESTORE_number_to_typename (uint32_t type); * iterate_first, we first do all existing records, then @a sync, then
* updates).
*
* @param cfg configuration to use to connect to namestore
* @param zone zone to monitor, NULL for all zones
* @param iterate_first #GNUNET_YES to first iterate over all existing reco
rds,
* #GNUNET_NO to only return changes that happen from
now on
* @param monitor function to call on zone changes
* @param sync_cb function called when we're in sync with the namestore
* @param cls closure for @a monitor and @a sync_cb
* @return handle to stop monitoring
*/
struct GNUNET_NAMESTORE_ZoneMonitor *
GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Hand
le *cfg,
const struct GNUNET_CRYPTO_EcdsaPrivate
Key *zone,
int iterate_first,
GNUNET_NAMESTORE_RecordMonitor monitor,
GNUNET_NAMESTORE_RecordsSynchronizedCal
lback sync_cb,
void *cls);
/** /**
* Test if a given record is expired. * Stop monitoring a zone for changes.
* *
* @return GNUNET_YES if the record is expired, * @param zm handle to the monitor activity to stop
* GNUNET_NO if not
*/ */
int void
GNUNET_NAMESTORE_is_expired (const struct GNUNET_NAMESTORE_RecordData *rd); GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm
);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* end of gnunet_namestore_service.h */ /* end of gnunet_namestore_service.h */
#endif #endif
 End of changes. 47 change blocks. 
442 lines changed or deleted 137 lines changed or added


 gnunet_nat_lib.h   gnunet_nat_lib.h 
skipping to change at line 35 skipping to change at line 35
* *
* @author Milan Bouchet-Valat * @author Milan Bouchet-Valat
*/ */
#ifndef GNUNET_NAT_LIB_H #ifndef GNUNET_NAT_LIB_H
#define GNUNET_NAT_LIB_H #define GNUNET_NAT_LIB_H
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
/** /**
* Signature of the callback passed to GNUNET_NAT_register for * Signature of the callback passed to #GNUNET_NAT_register() for
* a function to call whenever our set of 'valid' addresses changes. * a function to call whenever our set of 'valid' addresses changes.
* *
* @param cls closure * @param cls closure
* @param add_remove GNUNET_YES to mean the new public IP address, GNUNET_N O to mean * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET _NO to mean
* the previous (now invalid) one * the previous (now invalid) one
* @param addr either the previous or the new public IP address * @param addr either the previous or the new public IP address
* @param addrlen actual lenght of the address * @param addrlen actual length of the @a addr
*/ */
typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove, typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove,
const struct sockaddr * addr, const struct sockaddr *addr,
socklen_t addrlen); socklen_t addrlen);
/** /**
* Signature of the callback passed to GNUNET_NAT_register * Signature of the callback passed to #GNUNET_NAT_register().
* for a function to call whenever someone asks us to do connection * for a function to call whenever someone asks us to do connection
* reversal. * reversal.
* *
* @param cls closure * @param cls closure
* @param addr public IP address of the other peer * @param addr public IP address of the other peer
* @param addrlen actual lenght of the address * @param addrlen actual lenght of the @a addr
*/ */
typedef void (*GNUNET_NAT_ReversalCallback) (void *cls, typedef void (*GNUNET_NAT_ReversalCallback) (void *cls,
const struct sockaddr * addr, const struct sockaddr *addr,
socklen_t addrlen); socklen_t addrlen);
/** /**
* Handle for active NAT registrations. * Handle for active NAT registrations.
*/ */
struct GNUNET_NAT_Handle; struct GNUNET_NAT_Handle;
/** /**
* Attempt to enable port redirection and detect public IP address contacti ng * Attempt to enable port redirection and detect public IP address contacti ng
* UPnP or NAT-PMP routers on the local network. Use addr to specify to whi ch * UPnP or NAT-PMP routers on the local network. Use addr to specify to whi ch
* of the local host's addresses should the external port be mapped. The po rt * of the local host's addresses should the external port be mapped. The po rt
* is taken from the corresponding sockaddr_in[6] field. The NAT module * is taken from the corresponding sockaddr_in[6] field. The NAT module
* should call the given callback for any 'plausible' external address. * should call the given callback for any 'plausible' external address.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param is_tcp GNUNET_YES for TCP, GNUNET_NO for UDP * @param is_tcp #GNUNET_YES for TCP, #GNUNET_NO for UDP
* @param adv_port advertised port (port we are either bound to or that our OS * @param adv_port advertised port (port we are either bound to or that our OS
* locally performs redirection from to our bound port). * locally performs redirection from to our bound port).
* @param num_addrs number of addresses in 'addrs' * @param num_addrs number of addresses in @a addrs
* @param addrs list of local addresses packets should be redirected to * @param addrs list of local addresses packets should be redirected to
* @param addrlens actual lengths of the addresses * @param addrlens actual lengths of the addresses in @a addrs
* @param address_callback function to call everytime the public IP address changes * @param address_callback function to call everytime the public IP address changes
* @param reversal_callback function to call if someone wants connection re versal from us, * @param reversal_callback function to call if someone wants connection re versal from us,
* NULL if connection reversal is not supported * NULL if connection reversal is not supported
* @param callback_cls closure for callback * @param callback_cls closure for callbacks
* @return NULL on error, otherwise handle that can be used to unregister * @return NULL on error, otherwise handle that can be used to unregister
*/ */
struct GNUNET_NAT_Handle * struct GNUNET_NAT_Handle *
GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
tcp, int is_tcp,
uint16_t adv_port, unsigned int num_addrs, uint16_t adv_port,
const struct sockaddr **addrs, const socklen_t * addrl unsigned int num_addrs,
ens, const struct sockaddr **addrs,
const socklen_t *addrlens,
GNUNET_NAT_AddressCallback address_callback, GNUNET_NAT_AddressCallback address_callback,
GNUNET_NAT_ReversalCallback reversal_callback, GNUNET_NAT_ReversalCallback reversal_callback,
void *callback_cls); void *callback_cls);
/** /**
* Test if the given address is (currently) a plausible IP address for this peer. * Test if the given address is (currently) a plausible IP address for this peer.
* *
* @param h the handle returned by register * @param h the handle returned by register
* @param addr IP address to test (IPv4 or IPv6) * @param addr IP address to test (IPv4 or IPv6)
* @param addrlen number of bytes in addr * @param addrlen number of bytes in @a addr
* @return GNUNET_YES if the address is plausible, * @return #GNUNET_YES if the address is plausible,
* GNUNET_NO if the address is not plausible, * #GNUNET_NO if the address is not plausible,
* GNUNET_SYSERR if the address is malformed * #GNUNET_SYSERR if the address is malformed
*/ */
int int
GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, const void *addr, GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h,
const void *addr,
socklen_t addrlen); socklen_t addrlen);
/** /**
* We learned about a peer (possibly behind NAT) so run the * We learned about a peer (possibly behind NAT) so run the
* gnunet-nat-client to send dummy ICMP responses to cause * gnunet-nat-client to send dummy ICMP responses to cause
* that peer to connect to us (connection reversal). * that peer to connect to us (connection reversal).
* *
* @param h handle (used for configuration) * @param h handle (used for configuration)
* @param sa the address of the peer (IPv4-only) * @param sa the address of the peer (IPv4-only)
* * @return #GNUNET_SYSERR on error, #GNUNET_NO if nat client is disabled,
* @return GNUNET_SYSERR on error, GNUNET_NO if nat client is disabled, * #GNUNET_OK otherwise
* GNUNET_OK otherwise
*/ */
int int
GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
const struct sockaddr_in *sa); const struct sockaddr_in *sa);
/** /**
* Stop port redirection and public IP address detection for the given hand * Stop port redirection and public IP address detection for the given
le. * handle. This frees the handle, after having sent the needed
* This frees the handle, after having sent the needed commands to close op * commands to close open ports.
en ports.
* *
* @param h the handle to stop * @param h the handle to stop
*/ */
void void
GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h); GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h);
/** /**
* Handle to a NAT test. * Handle to a NAT test.
*/ */
struct GNUNET_NAT_Test; struct GNUNET_NAT_Test;
/** /**
* Function called to report success or failure for * Function called to report success or failure for
* NAT configuration test. * NAT configuration test.
* *
* @param cls closure * @param cls closure
* @param success GNUNET_OK on success, GNUNET_NO on failure, * @param success #GNUNET_OK on success, #GNUNET_NO on failure,
* GNUNET_SYSERR if the test could not be * #GNUNET_SYSERR if the test could not be
* properly started (internal failure) * properly started (internal failure)
*/ */
typedef void (*GNUNET_NAT_TestCallback) (void *cls, int success); typedef void (*GNUNET_NAT_TestCallback) (void *cls, int success);
/** /**
* Start testing if NAT traversal works using the * Start testing if NAT traversal works using the
* given configuration (IPv4-only). * given configuration (IPv4-only).
* *
* @param cfg configuration for the NAT traversal * @param cfg configuration for the NAT traversal
* @param is_tcp GNUNET_YES to test TCP, GNUNET_NO to test UDP * @param is_tcp #GNUNET_YES to test TCP, #GNUNET_NO to test UDP
* @param bnd_port port to bind to, 0 for connection reversal * @param bnd_port port to bind to, 0 for connection reversal
* @param adv_port externally advertised port to use * @param adv_port externally advertised port to use
* @param report function to call with the result of the test * @param report function to call with the result of the test
* @param report_cls closure for report * @param report_cls closure for @a report
* @return handle to cancel NAT test * @return handle to cancel NAT test
*/ */
struct GNUNET_NAT_Test * struct GNUNET_NAT_Test *
GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
int is_tcp, uint16_t bnd_port, uint16_t adv_port, int is_tcp,
GNUNET_NAT_TestCallback report, void *report_cls); uint16_t bnd_port,
uint16_t adv_port,
GNUNET_NAT_TestCallback report,
void *report_cls);
/** /**
* Stop an active NAT test. * Stop an active NAT test.
* *
* @param tst test to stop. * @param tst test to stop.
*/ */
void void
GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst);
/** /**
* Signature of a callback that is given an IP address. * Signature of a callback that is given an IP address.
* *
* @param cls closure * @param cls closure
* @param addr the address, NULL on errors * @param addr the address, NULL on errors
*/ */
typedef void (*GNUNET_NAT_IPCallback) (void *cls, const struct in_addr * ad typedef void (*GNUNET_NAT_IPCallback) (void *cls,
dr); const struct in_addr * addr);
/** /**
* Opaque handle to cancel "GNUNET_NAT_mini_get_external_ipv4" operation. * Opaque handle to cancel #GNUNET_NAT_mini_get_external_ipv4() operation.
*/ */
struct GNUNET_NAT_ExternalHandle; struct GNUNET_NAT_ExternalHandle;
/** /**
* Try to get the external IPv4 address of this peer. * Try to get the external IPv4 address of this peer.
* *
* @param timeout when to fail * @param timeout when to fail
* @param cb function to call with result * @param cb function to call with result
* @param cb_cls closure for 'cb' * @param cb_cls closure for @a cb
* @return handle for cancellation (can only be used until 'cb' is called), * @return handle for cancellation (can only be used until @a cb is called)
NULL on error , NULL on error
*/ */
struct GNUNET_NAT_ExternalHandle * struct GNUNET_NAT_ExternalHandle *
GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout, GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout,
GNUNET_NAT_IPCallback cb, void *cb_cls); GNUNET_NAT_IPCallback cb,
void *cb_cls);
/** /**
* Cancel operation. * Cancel operation.
* *
* @param eh operation to cancel * @param eh operation to cancel
*/ */
void void
GNUNET_NAT_mini_get_external_ipv4_cancel (struct GNUNET_NAT_ExternalHandle *eh); GNUNET_NAT_mini_get_external_ipv4_cancel (struct GNUNET_NAT_ExternalHandle *eh);
/** /**
* Handle to a mapping created with upnpc. * Handle to a mapping created with upnpc.
*/ */
struct GNUNET_NAT_MiniHandle; struct GNUNET_NAT_MiniHandle;
/** /**
* Start mapping the given port using (mini)upnpc. This function * Start mapping the given port using (mini)upnpc. This function
* should typically not be used directly (it is used within the * should typically not be used directly (it is used within the
* general-purpose 'GNUNET_NAT_register' code). However, it can be * general-purpose #GNUNET_NAT_register() code). However, it can be
* used if specifically UPnP-based NAT traversal is to be used or * used if specifically UPnP-based NAT traversal is to be used or
* tested. * tested.
* *
* @param port port to map * @param port port to map
* @param is_tcp GNUNET_YES to map TCP, GNUNET_NO for UDP * @param is_tcp #GNUNET_YES to map TCP, #GNUNET_NO for UDP
* @param ac function to call with mapping result * @param ac function to call with mapping result
* @param ac_cls closure for 'ac' * @param ac_cls closure for @a ac
* @return NULL on error * @return NULL on error
*/ */
struct GNUNET_NAT_MiniHandle * struct GNUNET_NAT_MiniHandle *
GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp, GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp,
GNUNET_NAT_AddressCallback ac, void *ac_cls); GNUNET_NAT_AddressCallback ac,
void *ac_cls);
/** /**
* Remove a mapping created with (mini)upnpc. Calling * Remove a mapping created with (mini)upnpc. Calling
* this function will give 'upnpc' 1s to remove tha mapping, * this function will give 'upnpc' 1s to remove tha mapping,
* so while this function is non-blocking, a task will be * so while this function is non-blocking, a task will be
* left with the scheduler for up to 1s past this call. * left with the scheduler for up to 1s past this call.
* *
* @param mini the handle * @param mini the handle
*/ */
void void
skipping to change at line 260 skipping to change at line 270
*/ */
typedef void (*GNUNET_NAT_AutoResultCallback)(void *cls, typedef void (*GNUNET_NAT_AutoResultCallback)(void *cls,
const struct GNUNET_CONFIGURAT ION_Handle *diff); const struct GNUNET_CONFIGURAT ION_Handle *diff);
/** /**
* Start auto-configuration routine. The resolver service should * Start auto-configuration routine. The resolver service should
* be available when this function is called. * be available when this function is called.
* *
* @param cfg initial configuration * @param cfg initial configuration
* @param cb function to call with autoconfiguration result * @param cb function to call with autoconfiguration result
* @param cb_cls closure for cb * @param cb_cls closure for @a cb
* @return handle to cancel operation * @return handle to cancel operation
*/ */
struct GNUNET_NAT_AutoHandle * struct GNUNET_NAT_AutoHandle *
GNUNET_NAT_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NAT_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_NAT_AutoResultCallback cb, GNUNET_NAT_AutoResultCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Abort autoconfiguration. * Abort autoconfiguration.
* *
 End of changes. 29 change blocks. 
46 lines changed or deleted 51 lines changed or added


 gnunet_network_lib.h   gnunet_network_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_network_lib.h * @file include/gnunet_network_lib.h
* @brief basic low-level networking interface * @brief basic low-level networking interface
* @author Nils Durner * @author Nils Durner
*/ */
#ifndef GNUNET_NETWORK_LIB_H #ifndef GNUNET_NETWORK_LIB_H
#define GNUNET_NETWORK_LIB_H #define GNUNET_NETWORK_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
skipping to change at line 75 skipping to change at line 74
}; };
#include "gnunet_disk_lib.h" #include "gnunet_disk_lib.h"
#include "gnunet_time_lib.h" #include "gnunet_time_lib.h"
/** /**
* Test if the given protocol family is supported by this system. * Test if the given protocol family is supported by this system.
* *
* @param pf protocol family to test (PF_INET, PF_INET6, PF_UNIX) * @param pf protocol family to test (PF_INET, PF_INET6, PF_UNIX)
* @return GNUNET_OK if the PF is supported * @return #GNUNET_OK if the PF is supported
*/ */
int int
GNUNET_NETWORK_test_pf (int pf); GNUNET_NETWORK_test_pf (int pf);
/** /**
* Given a unixpath that is too long (larger than UNIX_PATH_MAX), * Given a unixpath that is too long (larger than UNIX_PATH_MAX),
* shorten it to an acceptable length while keeping it unique * shorten it to an acceptable length while keeping it unique
* and making sure it remains a valid filename (if possible). * and making sure it remains a valid filename (if possible).
* *
* @param unixpath long path, will be freed (or same pointer returned * @param unixpath long path, will be freed (or same pointer returned
skipping to change at line 105 skipping to change at line 104
* close-on-exec flag). * close-on-exec flag).
* *
* @param desc bound socket * @param desc bound socket
* @param address address of the connecting peer, may be NULL * @param address address of the connecting peer, may be NULL
* @param address_len length of address * @param address_len length of address
* @return client socket * @return client socket
*/ */
struct GNUNET_NETWORK_Handle * struct GNUNET_NETWORK_Handle *
GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
struct sockaddr *address, struct sockaddr *address,
socklen_t * address_len); socklen_t *address_len);
/** /**
* Box a native socket (and check that it is a socket). * Box a native socket (and check that it is a socket).
* *
* @param fd socket to box * @param fd socket to box
* @return NULL on error (including not supported on target platform) * @return NULL on error (including not supported on target platform)
*/ */
struct GNUNET_NETWORK_Handle * struct GNUNET_NETWORK_Handle *
GNUNET_NETWORK_socket_box_native (SOCKTYPE fd); GNUNET_NETWORK_socket_box_native (SOCKTYPE fd);
/** /**
* Bind to a connected socket * Set if a socket should use blocking or non-blocking IO.
*
* @param fd socket
* @param doBlock blocking mode
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd,
int doBlock);
/**
* Bind a socket to a particular address.
* *
* @param desc socket to bind * @param desc socket to bind
* @param address address to be bound * @param address address to be bound
* @param address_len length of address * @param address_len length of address
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
const struct sockaddr *address, const struct sockaddr *address,
socklen_t address_len); socklen_t address_len);
/** /**
* Close a socket. * Close a socket.
* *
* @param desc socket to close * @param desc socket to close
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc); GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc);
/** /**
* Connect a socket * Only free memory of a socket, keep the file descriptor untouched.
*
* @param desc socket
*/
void
GNUNET_NETWORK_socket_free_memory_only_ (struct GNUNET_NETWORK_Handle *desc
);
/**
* Connect a socket to some remote address.
* *
* @param desc socket to connect * @param desc socket to connect
* @param address peer address * @param address peer address
* @param address_len of address * @param address_len of address
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
const struct sockaddr *address, const struct sockaddr *address,
socklen_t address_len); socklen_t address_len);
/** /**
* Get socket options * Get socket options
* *
* @param desc socket to inspect * @param desc socket to inspect
* @param level protocol level of the option * @param level protocol level of the option
* @param optname identifier of the option * @param optname identifier of the option
* @param optval options * @param optval options
* @param optlen length of optval * @param optlen length of optval
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc,
int level, int optname, void *optval, int level, int optname, void *optval,
socklen_t * optlen); socklen_t * optlen);
/** /**
* Listen on a socket * Listen on a socket
* *
* @param desc socket to start listening on * @param desc socket to start listening on
* @param backlog length of the listen queue * @param backlog length of the listen queue
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc,
int backlog); int backlog);
/** /**
* How much data is available to be read on this descriptor? * How much data is available to be read on this descriptor?
*
* @param desc socket * @param desc socket
* @returns #GNUNET_NO if no data is available, or on error!
*/ */
ssize_t ssize_t
GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle
*desc); *desc);
/** /**
* Read data from a connected socket (always non-blocking). * Read data from a socket (always non-blocking).
*
* @param desc socket * @param desc socket
* @param buffer buffer * @param buffer buffer
* @param length length of buffer * @param length length of buffer
* @param src_addr either the source to recv from, or all zeroes * @param src_addr either the source to recv from, or all zeroes
* to be filled in by recvfrom * to be filled in by recvfrom
* @param addrlen length of the addr * @param addrlen length of the addr
*/ */
ssize_t ssize_t
GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle *desc,
void *buffer, size_t length, void *buffer, size_t length,
skipping to change at line 217 skipping to change at line 238
ssize_t ssize_t
GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc,
void *buffer, size_t length); void *buffer, size_t length);
/** /**
* Check if sockets meet certain conditions * Check if sockets meet certain conditions
* @param rfds set of sockets to be checked for readability * @param rfds set of sockets to be checked for readability
* @param wfds set of sockets to be checked for writability * @param wfds set of sockets to be checked for writability
* @param efds set of sockets to be checked for exceptions * @param efds set of sockets to be checked for exceptions
* @param timeout relative value when to return * @param timeout relative value when to return
* @return number of selected sockets, GNUNET_SYSERR on error * @return number of selected sockets, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
struct GNUNET_NETWORK_FDSet *wfds, struct GNUNET_NETWORK_FDSet *wfds,
struct GNUNET_NETWORK_FDSet *efds, struct GNUNET_NETWORK_FDSet *efds,
struct GNUNET_TIME_Relative timeout); struct GNUNET_TIME_Relative timeout);
/** /**
* Send data (always non-blocking). * Send data (always non-blocking).
* *
* @param desc socket * @param desc socket
* @param buffer data to send * @param buffer data to send
* @param length size of the buffer * @param length size of the buffer
* @return number of bytes sent, GNUNET_SYSERR on error * @return number of bytes sent, #GNUNET_SYSERR on error
*/ */
ssize_t ssize_t
GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc,
const void *buffer, size_t length); const void *buffer, size_t length);
/** /**
* Send data to a particular destination (always non-blocking). * Send data to a particular destination (always non-blocking).
* This function only works for UDP sockets. * This function only works for UDP sockets.
* *
* @param desc socket * @param desc socket
* @param message data to send * @param message data to send
* @param length size of the data * @param length size of the data
* @param dest_addr destination address * @param dest_addr destination address
* @param dest_len length of address * @param dest_len length of address
* @return number of bytes sent, GNUNET_SYSERR on error * @return number of bytes sent, #GNUNET_SYSERR on error
*/ */
ssize_t ssize_t
GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc, GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc,
const void *message, size_t length, const void *message, size_t length,
const struct sockaddr *dest_addr, const struct sockaddr *dest_addr,
socklen_t dest_len); socklen_t dest_len);
/** /**
* Set socket option * Set socket option
* *
* @param fd socket * @param fd socket
* @param level protocol level of the option * @param level protocol level of the option
* @param option_name option identifier * @param option_name option identifier
* @param option_value value to set * @param option_value value to set
* @param option_len size of option_value * @param option_len size of option_value
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, int lev el, GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, int lev el,
int option_name, const void *option_value , int option_name, const void *option_value ,
socklen_t option_len); socklen_t option_len);
/** /**
* Shut down socket operations * Shut down socket operations
* *
* @param desc socket * @param desc socket
* @param how type of shutdown * @param how type of shutdown
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int how ); GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int how );
/** /**
* Disable the "CORK" feature for communication with the given socket, * Disable the "CORK" feature for communication with the given socket,
* forcing the OS to immediately flush the buffer on transmission * forcing the OS to immediately flush the buffer on transmission
* instead of potentially buffering multiple messages. Essentially * instead of potentially buffering multiple messages. Essentially
* reduces the OS send buffers to zero. * reduces the OS send buffers to zero.
* *
* @param desc socket * @param desc socket
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc); GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc);
/** /**
* Create a new socket. Configure it for non-blocking IO and * Create a new socket. Configure it for non-blocking IO and
* mark it as non-inheritable to child processes (set the * mark it as non-inheritable to child processes (set the
* close-on-exec flag). * close-on-exec flag).
* *
* @param domain domain of the socket * @param domain domain of the socket
skipping to change at line 314 skipping to change at line 335
/** /**
* Reset FD set (clears all file descriptors). * Reset FD set (clears all file descriptors).
* *
* @param fds fd set to clear * @param fds fd set to clear
*/ */
void void
GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds); GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds);
/** /**
* Add a socket to the FD set * Add a socket to the FD set
*
* @param fds fd set * @param fds fd set
* @param desc socket to add * @param desc socket to add
*/ */
void void
GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds, GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds,
const struct GNUNET_NETWORK_Handle *desc); const struct GNUNET_NETWORK_Handle *desc);
#if WINDOWS #if WINDOWS
/** /**
* Add a W32 file handle to the fd set * Add a W32 file handle to the fd set
*
* @param fds fd set * @param fds fd set
* @param h the file handle to add * @param h the file handle to add
*/ */
void void
GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct GNUNET_NETWORK_FD Set GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct GNUNET_NETWORK_FD Set
*fds, HANDLE h); *fds, HANDLE h);
#endif #endif
/** /**
* Check whether a socket is part of the fd set * Check whether a socket is part of the fd set
*
* @param fds fd set * @param fds fd set
* @param desc socket * @param desc socket
* @return GNUNET_YES if the socket is in the set * @return #GNUNET_YES if the socket is in the set
*/ */
int int
GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds, GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds,
const struct GNUNET_NETWORK_Handle *desc); const struct GNUNET_NETWORK_Handle *desc);
/** /**
* Add one fd set to another * Add one fd set to another (computes the union).
*
* @param dst the fd set to add to * @param dst the fd set to add to
* @param src the fd set to add from * @param src the fd set to add from
*/ */
void void
GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
const struct GNUNET_NETWORK_FDSet *src); const struct GNUNET_NETWORK_FDSet *src);
/** /**
* Copy one fd set to another * Copy one fd set to another
*
* @param to destination * @param to destination
* @param from source * @param from source
*/ */
void void
GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to, GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
const struct GNUNET_NETWORK_FDSet *from); const struct GNUNET_NETWORK_FDSet *from);
/** /**
* Return file descriptor for this network handle * Return file descriptor for this network handle
* *
skipping to change at line 388 skipping to change at line 414
/** /**
* Return sockaddr length for this network handle * Return sockaddr length for this network handle
* *
* @param desc wrapper to process * @param desc wrapper to process
* @return socklen_t for sockaddr * @return socklen_t for sockaddr
*/ */
socklen_t socklen_t
GNUNET_NETWORK_get_addrlen (struct GNUNET_NETWORK_Handle *desc); GNUNET_NETWORK_get_addrlen (struct GNUNET_NETWORK_Handle *desc);
/** /**
* Copy a native fd set * Copy a native fd set into the GNUnet representation.
*
* @param to destination * @param to destination
* @param from native source set * @param from native source set
* @param nfds the biggest socket number in from + 1 * @param nfds the biggest socket number in from + 1
*/ */
void void
GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to,
const fd_set * from, int nfds); const fd_set *from, int nfds);
/** /**
* Set a native fd in a set * Set a native fd in a set
* *
* @param to destination * @param to destination
* @param nfd native FD to set * @param nfd native FD to set
*/ */
void void
GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, int nfd); GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, int nfd);
skipping to change at line 419 skipping to change at line 446
* @param to set to test, NULL for empty set * @param to set to test, NULL for empty set
* @param nfd native FD to test, -1 for none * @param nfd native FD to test, -1 for none
* @return GNUNET_YES if to contains nfd * @return GNUNET_YES if to contains nfd
*/ */
int int
GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to, GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to,
int nfd); int nfd);
/** /**
* Add a file handle to the fd set * Add a file handle to the fd set
*
* @param fds fd set * @param fds fd set
* @param h the file handle to add * @param h the file handle to add
*/ */
void void
GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
const struct GNUNET_DISK_FileHandle *h); const struct GNUNET_DISK_FileHandle *h);
/** /**
* Check if a file handle is part of an fd set * Check if a file handle is part of an fd set
* @param fds fd set * @param fds fd set
* @param h file handle * @param h file handle
* @return GNUNET_YES if the file handle is part of the set * @return #GNUNET_YES if the file handle is part of the set
*/ */
int int
GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
const struct GNUNET_DISK_FileHandle *h); const struct GNUNET_DISK_FileHandle *h);
/** /**
* Checks if two fd sets overlap * Checks if two fd sets overlap
*
* @param fds1 first fd set * @param fds1 first fd set
* @param fds2 second fd set * @param fds2 second fd set
* @return GNUNET_YES if they do overlap, GNUNET_NO otherwise * @return #GNUNET_YES if they do overlap, #GNUNET_NO otherwise
*/ */
int int
GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
const struct GNUNET_NETWORK_FDSet *fds2); const struct GNUNET_NETWORK_FDSet *fds2);
/** /**
* Creates an fd set * Creates an fd set
*
* @return a new fd set * @return a new fd set
*/ */
struct GNUNET_NETWORK_FDSet * struct GNUNET_NETWORK_FDSet *
GNUNET_NETWORK_fdset_create (void); GNUNET_NETWORK_fdset_create (void);
/** /**
* Releases the associated memory of an fd set * Releases the associated memory of an fd set
*
* @param fds fd set * @param fds fd set
*/ */
void void
GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds); GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
 End of changes. 35 change blocks. 
25 lines changed or deleted 57 lines changed or added


 gnunet_nse_service.h   gnunet_nse_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2011 Christian Grothoff (and other contributing authors) (C) 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 29 skipping to change at line 29
*/ */
#ifndef GNUNET_NSE_SERVICE_H_ #ifndef GNUNET_NSE_SERVICE_H_
#define GNUNET_NSE_SERVICE_H_ #define GNUNET_NSE_SERVICE_H_
/** /**
* @file include/gnunet_nse_service.h * @file include/gnunet_nse_service.h
* @brief API to retrieve the current network size estimate, * @brief API to retrieve the current network size estimate,
* also to register for notifications whenever a new * also to register for notifications whenever a new
* network size estimate is calculated. * network size estimate is calculated.
*
* @author Nathan Evans * @author Nathan Evans
* @defgroup nse network size estimation service
* @{
*/ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h" #include "gnunet_util_lib.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_scheduler_lib.h"
/** /**
* Version of the network size estimation API. * Version of the network size estimation API.
*/ */
#define GNUNET_NSE_VERSION 0x00000000 #define GNUNET_NSE_VERSION 0x00000000
/** /**
* Handle for the network size estimation service. * Handle for the network size estimation service.
*/ */
struct GNUNET_NSE_Handle; struct GNUNET_NSE_Handle;
skipping to change at line 82 skipping to change at line 81
* @param loge logarithmic estimate * @param loge logarithmic estimate
* @return absolute number of peers in the network (estimated) * @return absolute number of peers in the network (estimated)
*/ */
#define GNUNET_NSE_log_estimate_to_n(loge) pow(2.0, (loge)) #define GNUNET_NSE_log_estimate_to_n(loge) pow(2.0, (loge))
/** /**
* Connect to the network size estimation service. * Connect to the network size estimation service.
* *
* @param cfg the configuration to use * @param cfg the configuration to use
* @param func funtion to call with network size estimate * @param func funtion to call with network size estimate
* @param func_cls closure to pass for network size estimate callback * @param func_cls closure to pass to @a func
* * @return handle to use in #GNUNET_NSE_disconnect to stop NSE from invokin
* @return handle to use g the callbacks
*/ */
struct GNUNET_NSE_Handle * struct GNUNET_NSE_Handle *
GNUNET_NSE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_NSE_Callback func, void *func_cls); GNUNET_NSE_Callback func, void *func_cls);
/** /**
* Disconnect from network size estimation service * Disconnect from network size estimation service
* *
* @param h handle to destroy * @param h handle to destroy
*
*/ */
void void
GNUNET_NSE_disconnect (struct GNUNET_NSE_Handle *h); GNUNET_NSE_disconnect (struct GNUNET_NSE_Handle *h);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group nse */
#endif /* GNUNET_NSE_SERVICE_H_ */ #endif /* GNUNET_NSE_SERVICE_H_ */
 End of changes. 7 change blocks. 
9 lines changed or deleted 9 lines changed or added


 gnunet_os_lib.h   gnunet_os_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2011 Christian Grothoff (and o ther contributing authors) (C) 2001, 2002, 2003, 2004, 2005, 2006, 2011 Christian Grothoff (and o ther contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 193 skipping to change at line 193
GNUNET_OS_PROCESS_EXITED, GNUNET_OS_PROCESS_EXITED,
/** /**
* The process was killed by a signal. * The process was killed by a signal.
*/ */
GNUNET_OS_PROCESS_SIGNALED GNUNET_OS_PROCESS_SIGNALED
}; };
/** /**
* Get the path to a specific GNUnet installation directory or, with * Get the path to a specific GNUnet installation directory or, with
* GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation * #GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation
* directory. * directory.
* *
* @param dirkind what kind of directory is desired? * @param dirkind what kind of directory is desired?
* @return a pointer to the dir path (to be freed by the caller) * @return a pointer to the dir path (to be freed by the caller)
*/ */
char * char *
GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkin d); GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkin d);
/** /**
* Given the name of a gnunet-helper, gnunet-service or gnunet-daemon * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon
skipping to change at line 221 skipping to change at line 221
GNUNET_OS_get_libexec_binary_path (const char *progname); GNUNET_OS_get_libexec_binary_path (const char *progname);
/** /**
* Callback function invoked for each interface found. * Callback function invoked for each interface found.
* *
* @param cls closure * @param cls closure
* @param name name of the interface (can be NULL for unknown) * @param name name of the interface (can be NULL for unknown)
* @param isDefault is this presumably the default interface * @param isDefault is this presumably the default interface
* @param addr address of this interface (can be NULL for unknown or unassi gned) * @param addr address of this interface (can be NULL for unknown or unassi gned)
* @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned)
* @param netmask the network mask (can be NULL for unknown or unassigned)) * @param netmask the network mask (can be NULL for unknown or unassigned)
* @param addrlen length of the address * @param addrlen length of the address
* @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort
*/ */
typedef int (*GNUNET_OS_NetworkInterfaceProcessor) (void *cls, const char * typedef int (*GNUNET_OS_NetworkInterfaceProcessor) (void *cls,
name, const char *name,
int isDefault, int isDefault,
const struct sockaddr * const struct sockaddr *
addr, addr,
const struct sockaddr * const struct sockaddr *
broadcast_addr, broadcast_addr,
const struct sockaddr * const struct sockaddr *
netmask, socklen_t addr netmask,
len); socklen_t addrlen);
/** /**
* @brief Enumerate all network interfaces * @brief Enumerate all network interfaces
*
* @param proc the callback function * @param proc the callback function
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
*/ */
void void
GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc , GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc ,
void *proc_cls); void *proc_cls);
/** /**
* @brief Get maximum string length returned by gethostname() * @brief Get maximum string length returned by gethostname()
*/ */
#if HAVE_SYSCONF && defined(_SC_HOST_NAME_MAX) #if HAVE_SYSCONF && defined(_SC_HOST_NAME_MAX)
#define GNUNET_OS_get_hostname_max_length() ({ int __sc_tmp = sysconf(_SC_H OST_NAME_MAX); __sc_tmp <= 0 ? 255 : __sc_tmp; }) #define GNUNET_OS_get_hostname_max_length() ({ int __sc_tmp = sysconf(_SC_H OST_NAME_MAX); __sc_tmp <= 0 ? 255 : __sc_tmp; })
skipping to change at line 294 skipping to change at line 294
* Get the pid of the process in question * Get the pid of the process in question
* *
* @param proc the process to get the pid of * @param proc the process to get the pid of
* *
* @return the current process id * @return the current process id
*/ */
pid_t pid_t
GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc); GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc);
/** /**
* Set process priority
*
* @param proc pointer to process structure
* @param prio priority value
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
enum GNUNET_SCHEDULER_Priority prio);
/**
* Start a process. * Start a process.
* *
* @param pipe_control should a pipe be used to send signals to the child? * @param pipe_control should a pipe be used to send signals to the child?
* @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags
* @param pipe_stdin pipe to use to send input to child process (or NULL) * @param pipe_stdin pipe to use to send input to child process (or NULL)
* @param pipe_stdout pipe to use to get output from child process (or NULL ) * @param pipe_stdout pipe to use to get output from child process (or NULL )
* @param filename name of the binary * @param filename name of the binary
* @param argv NULL-terminated array of arguments to the process * @param argv NULL-terminated array of arguments to the process
* @return pointer to process structure of the new process, NULL on error * @return pointer to process structure of the new process, NULL on error
*/ */
skipping to change at line 379 skipping to change at line 368
* @return pointer to process structure of the new process, NULL on error * @return pointer to process structure of the new process, NULL on error
*/ */
struct GNUNET_OS_Process * struct GNUNET_OS_Process *
GNUNET_OS_start_process_v (int pipe_control, GNUNET_OS_start_process_v (int pipe_control,
enum GNUNET_OS_InheritStdioFlags std_inheritance , enum GNUNET_OS_InheritStdioFlags std_inheritance ,
const SOCKTYPE *lsocks, const SOCKTYPE *lsocks,
const char *filename, const char *filename,
char *const argv[]); char *const argv[]);
/** /**
* Start a process. This function is similar to the GNUNET_OS_start_proces
s_*
* except that the filename and arguments can have whole strings which cont
ain
* the arguments. These arguments are to be separated by spaces and are pa
rsed
* in the order they appear. Arguments containing spaces can be used by
* quoting them with @em ".
*
* @param pipe_control should a pipe be used to send signals to the child?
* @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags
* @param lsocks array of listen sockets to dup systemd-style (or NULL);
* must be NULL on platforms where dup is not supported
* @param filename name of the binary. It is valid to have the arguments
* in this string when they are separated by spaces.
* @param ... more arguments. Should be of type `char *`. It is valid
* to have the arguments in these strings when they are separated b
y
* spaces. The last argument MUST be NULL.
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
GNUNET_OS_start_process_s (int pipe_control,
unsigned int std_inheritance,
const SOCKTYPE * lsocks,
const char *filename, ...);
/**
* Handle to a command action. * Handle to a command action.
*/ */
struct GNUNET_OS_CommandHandle; struct GNUNET_OS_CommandHandle;
/** /**
* Type of a function to process a line of output. * Type of a function to process a line of output.
* *
* @param cls closure * @param cls closure
* @param line line of output from a command, NULL for the end * @param line line of output from a command, NULL for the end
*/ */
skipping to change at line 422 skipping to change at line 435
struct GNUNET_TIME_Relative timeout, const char *bin ary, struct GNUNET_TIME_Relative timeout, const char *bin ary,
...); ...);
/** /**
* Retrieve the status of a process, waiting on him if dead. * Retrieve the status of a process, waiting on him if dead.
* Nonblocking version. * Nonblocking version.
* *
* @param proc pointer to process structure * @param proc pointer to process structure
* @param type status type * @param type status type
* @param code return code/signal number * @param code return code/signal number
* @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_NO if the process is still runnin g, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
enum GNUNET_OS_ProcessStatusType *type, enum GNUNET_OS_ProcessStatusType *type,
unsigned long *code); unsigned long *code);
/** /**
* Wait for a process to terminate. The return code is discarded. * Wait for a process to terminate. The return code is discarded.
* You must not use 'GNUNET_OS_process_status' on the same process * You must not use 'GNUNET_OS_process_status' on the same process
* after calling this function! This function is blocking and should * after calling this function! This function is blocking and should
* thus only be used if the child process is known to have terminated * thus only be used if the child process is known to have terminated
* or to terminate very soon. * or to terminate very soon.
* *
* @param proc pointer to process structure of the process to wait for * @param proc pointer to process structure of the process to wait for
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/ */
int int
GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc); GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc);
/** /**
* Connects this process to its parent via pipe; * Connects this process to its parent via pipe;
* essentially, the parent control handler will read signal numbers * essentially, the parent control handler will read signal numbers
* from the 'GNUNET_OS_CONTROL_PIPE' (as given in an environment * from the 'GNUNET_OS_CONTROL_PIPE' (as given in an environment
* variable) and raise those signals. * variable) and raise those signals.
* *
skipping to change at line 462 skipping to change at line 475
GNUNET_OS_install_parent_control_handler (void *cls, GNUNET_OS_install_parent_control_handler (void *cls,
const struct const struct
GNUNET_SCHEDULER_TaskContext *tc) ; GNUNET_SCHEDULER_TaskContext *tc) ;
/** /**
* Check whether an executable exists and possibly * Check whether an executable exists and possibly
* if the suid bit is set on the file. * if the suid bit is set on the file.
* Attempts to find the file using the current * Attempts to find the file using the current
* PATH environment variable as a search path. * PATH environment variable as a search path.
* *
* @param binary the name of the file to check * @param binary the name of the file to check.
* @return GNUNET_YES if the file is SUID, * W32: must not have an .exe suffix.
* GNUNET_NO if not SUID (but binary exists) * @param check_suid input true if the binary should be checked for SUID (*
* GNUNET_SYSERR on error (no such binary or not executable) nix)
* W32: checks if the program has sufficient privileges by executing
this
* binary with the -d flag. -d omits a programs main loop and o
nly
* executes all privileged operations in an binary.
* @param params parameters used for w32 privilege checking (can be NULL fo
r != w32, or when not checking for suid/permissions )
* @return #GNUNET_YES if the file is SUID (*nix) or can be executed with c
urrent privileges (W32),
* #GNUNET_NO if not SUID (but binary exists),
* #GNUNET_SYSERR on error (no such binary or not executable)
*/ */
int int
GNUNET_OS_check_helper_binary (const char *binary); GNUNET_OS_check_helper_binary (const char *binary, int check_suid, const ch ar * params);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* ifndef GNUNET_OS_LIB_H */ /* ifndef GNUNET_OS_LIB_H */
#endif #endif
 End of changes. 14 change blocks. 
32 lines changed or deleted 61 lines changed or added


 gnunet_peer_lib.h   gnunet_peer_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2006, 2009 Christian Grothoff (and other contributing authors) (C) 2006, 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gnunet_peerinfo_service.h   gnunet_peerinfo_service.h 
skipping to change at line 138 skipping to change at line 138
peer, peer,
const struct GNUNET_HELLO_Messag e * const struct GNUNET_HELLO_Messag e *
hello, const char *err_msg); hello, const char *err_msg);
/** /**
* Handle for cancellation of iteration over peers. * Handle for cancellation of iteration over peers.
*/ */
struct GNUNET_PEERINFO_IteratorContext; struct GNUNET_PEERINFO_IteratorContext;
/** /**
* Call a method for each known matching host to get its HELLO. * Call a method for each known matching host. The callback method
* The callback method will be invoked once for each matching * will be invoked once for each matching host and then finally once
* host and then finally once with a NULL pointer. After that final * with a NULL pointer. After that final invocation, the iterator
* invocation, the iterator context must no longer be used. * context must no longer be used.
* *
* Instead of calling this function with 'peer == NULL' * Instead of calling this function with 'peer == NULL' it is often
* it is often better to use 'GNUNET_PEERINFO_notify'. * better to use 'GNUNET_PEERINFO_notify'.
* *
* @param h handle to the peerinfo service * @param h handle to the peerinfo service
* @param include_friend_only include HELLO messages for friends only
* @param peer restrict iteration to this peer only (can be NULL) * @param peer restrict iteration to this peer only (can be NULL)
* @param timeout how long to wait until timing out * @param timeout how long to wait until timing out
* @param callback the method to call for each peer * @param callback the method to call for each peer
* @param callback_cls closure for callback * @param callback_cls closure for callback
* @return NULL on error (in this case, 'callback' is never called!), * @return iterator context
* otherwise an iterator context
*/ */
struct GNUNET_PEERINFO_IteratorContext * struct GNUNET_PEERINFO_IteratorContext *
GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
int include_friend_only,
const struct GNUNET_PeerIdentity *peer, const struct GNUNET_PeerIdentity *peer,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_PEERINFO_Processor callback, GNUNET_PEERINFO_Processor callback, void *callback
void *callback_cls); _cls);
/** /**
* Cancel an iteration over peer information. * Cancel an iteration over peer information.
* *
* @param ic context of the iterator to cancel * @param ic context of the iterator to cancel
*/ */
void void
GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic) ; GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic) ;
/** /**
* Handle for notifications about changes to the set of known peers. * Handle for notifications about changes to the set of known peers.
*/ */
struct GNUNET_PEERINFO_NotifyContext; struct GNUNET_PEERINFO_NotifyContext;
/** /**
* Call a method whenever our known information about peers * Call a method whenever our known information about peers
* changes. Initially calls the given function for all known * changes. Initially calls the given function for all known
* peers and then only signals changes. Note that it is * peers and then only signals changes.
* possible (i.e. on disconnects) that the callback is called *
* twice with the same peer information. * If include_friend_only is set to GNUNET_YES peerinfo will include HELLO
* messages which are intended for friend to friend mode and which do not
* have to be gossiped. Otherwise these messages are skipped.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param include_friend_only include HELLO messages for friends only
* @param callback the method to call for each peer * @param callback the method to call for each peer
* @param callback_cls closure for callback * @param callback_cls closure for callback
* @return NULL on error * @return NULL on error
*/ */
struct GNUNET_PEERINFO_NotifyContext * struct GNUNET_PEERINFO_NotifyContext *
GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
int include_friend_only,
GNUNET_PEERINFO_Processor callback, void *callback_ cls); GNUNET_PEERINFO_Processor callback, void *callback_ cls);
/** /**
* Stop notifying about changes. * Stop notifying about changes.
* *
* @param nc context to stop notifying * @param nc context to stop notifying
*/ */
void void
GNUNET_PEERINFO_notify_cancel (struct GNUNET_PEERINFO_NotifyContext *nc); GNUNET_PEERINFO_notify_cancel (struct GNUNET_PEERINFO_NotifyContext *nc);
 End of changes. 9 change blocks. 
13 lines changed or deleted 18 lines changed or added


 gnunet_plugin_lib.h   gnunet_plugin_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other c ontributing authors) (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other c ontributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 58 skipping to change at line 58
*/ */
typedef void *(*GNUNET_PLUGIN_Callback) (void *arg); typedef void *(*GNUNET_PLUGIN_Callback) (void *arg);
/** /**
* Test if a plugin exists. * Test if a plugin exists.
* *
* Note that the library must export a symbol called * Note that the library must export a symbol called
* "library_name_init" for the test to succeed. * "library_name_init" for the test to succeed.
* *
* @param library_name name of the plugin to test if it is installed * @param library_name name of the plugin to test if it is installed
* @return GNUNET_YES if the plugin exists, GNUNET_NO if not * @return #GNUNET_YES if the plugin exists, #GNUNET_NO if not
*/ */
int int
GNUNET_PLUGIN_test (const char *library_name); GNUNET_PLUGIN_test (const char *library_name);
/** /**
* Setup plugin (runs the "init" callback and returns whatever "init" * Setup plugin (runs the "init" callback and returns whatever "init"
* returned). If "init" returns NULL, the plugin is unloaded. * returned). If "init" returns NULL, the plugin is unloaded.
* *
* Note that the library must export symbols called * Note that the library must export symbols called
* "library_name_init" and "library_name_done". These will be called * "library_name_init" and "library_name_done". These will be called
skipping to change at line 83 skipping to change at line 83
* @return whatever the initialization function returned, NULL on error * @return whatever the initialization function returned, NULL on error
*/ */
void * void *
GNUNET_PLUGIN_load (const char *library_name, void *arg); GNUNET_PLUGIN_load (const char *library_name, void *arg);
/** /**
* Signature of a function called by 'GNUNET_PLUGIN_load_all'. * Signature of a function called by 'GNUNET_PLUGIN_load_all'.
* *
* @param cls closure * @param cls closure
* @param library_name full name of the library (to be used with * @param library_name full name of the library (to be used with
* 'GNUNET_PLUGIN_unload') * #GNUNET_PLUGIN_unload)
* @param lib_ret return value from the initialization function * @param lib_ret return value from the initialization function
* of the library (same as what 'GNUNET_PLUGIN_load' would * of the library (same as what #GNUNET_PLUGIN_load would
* have returned for the given library name) * have returned for the given library name)
*/ */
typedef void (*GNUNET_PLUGIN_LoaderCallback) (void *cls, typedef void (*GNUNET_PLUGIN_LoaderCallback) (void *cls,
const char *library_name, const char *library_name,
void *lib_ret); void *lib_ret);
/** /**
* Load all compatible plugins with the given base name. * Load all compatible plugins with the given base name.
* *
* Note that the library must export symbols called * Note that the library must export symbols called
* "basename_ANYTHING_init" and "basename_ANYTHING__done". These will * "basename_ANYTHING_init" and "basename_ANYTHING__done". These will
* be called when the library is loaded and unloaded respectively. * be called when the library is loaded and unloaded respectively.
* *
* @param basename basename of the plugins to load * @param basename basename of the plugins to load
* @param arg argument to the plugin initialization function * @param arg argument to the plugin initialization function
* @param cb function to call for each plugin found * @param cb function to call for each plugin found
* @param cb_cls closure for 'cb' * @param cb_cls closure for @a cb
*/ */
void void
GNUNET_PLUGIN_load_all (const char *basename, void *arg, GNUNET_PLUGIN_load_all (const char *basename, void *arg,
GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls); GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls);
/** /**
* Unload plugin (runs the "done" callback and returns whatever "done" * Unload plugin (runs the "done" callback and returns whatever "done"
* returned). The plugin is then unloaded. * returned). The plugin is then unloaded.
* *
* @param library_name name of the plugin to unload * @param library_name name of the plugin to unload
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 gnunet_postgres_lib.h   gnunet_postgres_lib.h 
skipping to change at line 99 skipping to change at line 99
* @return GNUNET_OK on success * @return GNUNET_OK on success
*/ */
#define GNUNET_POSTGRES_exec(dbh,sql) GNUNET_POSTGRES_exec_(dbh,sql,__FILE_ _,__LINE__) #define GNUNET_POSTGRES_exec(dbh,sql) GNUNET_POSTGRES_exec_(dbh,sql,__FILE_ _,__LINE__)
/** /**
* Prepare SQL statement. * Prepare SQL statement.
* *
* @param dbh database handle * @param dbh database handle
* @param name name for the prepared SQL statement * @param name name for the prepared SQL statement
* @param sql SQL code to prepare * @param sql SQL code to prepare
* @param nparms number of parameters in sql * @param nparams number of parameters in sql
* @param filename filename for error reporting * @param filename filename for error reporting
* @param line code line for error reporting * @param line code line for error reporting
* @return GNUNET_OK on success * @return GNUNET_OK on success
*/ */
int int
GNUNET_POSTGRES_prepare_ (PGconn *dbh, const char *name, const char *sql, GNUNET_POSTGRES_prepare_ (PGconn *dbh, const char *name, const char *sql,
int nparms, int nparams,
const char *filename, int line); const char *filename, int line);
/** /**
* Prepare SQL statement. * Prepare SQL statement.
* *
* @param dbh database handle * @param dbh database handle
* @param name name for the prepared SQL statement * @param name name for the prepared SQL statement
* @param sql SQL code to prepare * @param sql SQL code to prepare
* @param nparams number of parameters in sql * @param nparams number of parameters in sql
* @return GNUNET_OK on success * @return GNUNET_OK on success
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 gnunet_program_lib.h   gnunet_program_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_program_lib.h * @file include/gnunet_program_lib.h
* @brief functions related to starting programs * @brief functions related to starting programs
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup program functions for writing command-line programs
* @{
*/ */
#ifndef GNUNET_PROGRAM_LIB_H #ifndef GNUNET_PROGRAM_LIB_H
#define GNUNET_PROGRAM_LIB_H #define GNUNET_PROGRAM_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
skipping to change at line 59 skipping to change at line 61
*/ */
typedef void (*GNUNET_PROGRAM_Main) (void *cls, char *const *args, typedef void (*GNUNET_PROGRAM_Main) (void *cls, char *const *args,
const char *cfgfile, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Hand le * const struct GNUNET_CONFIGURATION_Hand le *
cfg); cfg);
/** /**
* Run a standard GNUnet command startup sequence (initialize loggers * Run a standard GNUnet command startup sequence (initialize loggers
* and configuration, parse options). * and configuration, parse options).
* *
* @param argc number of command line arguments * @param argc number of command line arguments in @a argv
* @param argv command line arguments * @param argv command line arguments
* @param binaryName our expected name * @param binaryName our expected name
* @param binaryHelp help text for the program * @param binaryHelp help text for the program
* @param options command line options * @param options command line options
* @param task main function to run * @param task main function to run
* @param task_cls closure for task * @param task_cls closure for @a task
* @param run_without_scheduler GNUNET_NO start the scheduler, GNUNET_YES d * @param run_without_scheduler #GNUNET_NO start the scheduler,
o not * #GNUNET_YES do not start the scheduler just run the main task
* start the scheduler just run the main task * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
* @return GNUNET_SYSERR on error, GNUNET_OK on success
*/ */
int int
GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName, GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName,
const char *binaryHelp, const char *binaryHelp,
const struct GNUNET_GETOPT_CommandLineOption *options, const struct GNUNET_GETOPT_CommandLineOption *options,
GNUNET_PROGRAM_Main task, void *task_cls, GNUNET_PROGRAM_Main task, void *task_cls,
int run_without_scheduler); int run_without_scheduler);
/** /**
* Run a standard GNUnet command startup sequence (initialize loggers * Run a standard GNUnet command startup sequence (initialize loggers
* and configuration, parse options). * and configuration, parse options).
* *
* @param argc number of command line arguments * @param argc number of command line arguments
* @param argv command line arguments * @param argv command line arguments
* @param binaryName our expected name * @param binaryName our expected name
* @param binaryHelp helptext for "-h" option (about the app) * @param binaryHelp helptext for "-h" option (about the app)
* @param options command line options * @param options command line options
* @param task main function to run * @param task main function to run
* @param task_cls closure for task * @param task_cls closure for @a task
* @return GNUNET_SYSERR on error, GNUNET_OK on success * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/ */
int int
GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName,
const char *binaryHelp, const char *binaryHelp,
const struct GNUNET_GETOPT_CommandLineOption *options, const struct GNUNET_GETOPT_CommandLineOption *options,
GNUNET_PROGRAM_Main task, void *task_cls); GNUNET_PROGRAM_Main task, void *task_cls);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group program */
/* ifndef GNUNET_PROGRAM_LIB_H */ /* ifndef GNUNET_PROGRAM_LIB_H */
#endif #endif
/* end of gnunet_program_lib.h */ /* end of gnunet_program_lib.h */
 End of changes. 7 change blocks. 
10 lines changed or deleted 13 lines changed or added


 gnunet_protocols.h   gnunet_protocols.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 Christian Gro thoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_protocols.h * @file include/gnunet_protocols.h
* @brief constants for network protocols * @brief constants for network protocols
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup protocols Types of messages used in GNUnet
* @{
*/ */
/**************************************************************************
*****
* TODO: we need a way to register message types centrally (via some webpag
e).
* For now: unofficial extensions should start at 48k, internal extensions
* defined here should leave some room (4-10 additional messages to the pre
vious
* extension).
**************************************************************************
****/
#ifndef GNUNET_PROTOCOLS_H #ifndef GNUNET_PROTOCOLS_H
#define GNUNET_PROTOCOLS_H #define GNUNET_PROTOCOLS_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
skipping to change at line 81 skipping to change at line 90
* Request to ARM to start a service. * Request to ARM to start a service.
*/ */
#define GNUNET_MESSAGE_TYPE_ARM_START 8 #define GNUNET_MESSAGE_TYPE_ARM_START 8
/** /**
* Request to ARM to stop a service. * Request to ARM to stop a service.
*/ */
#define GNUNET_MESSAGE_TYPE_ARM_STOP 9 #define GNUNET_MESSAGE_TYPE_ARM_STOP 9
/** /**
* Request ARM service itself to shutdown. * Response from ARM.
*/ */
#define GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN 10 #define GNUNET_MESSAGE_TYPE_ARM_RESULT 10
/** /**
* Response from ARM. * Status update from ARM.
*/ */
#define GNUNET_MESSAGE_TYPE_ARM_RESULT 11 #define GNUNET_MESSAGE_TYPE_ARM_STATUS 11
/** /**
* Request to ARM to list all currently running services * Request to ARM to list all currently running services
*/ */
#define GNUNET_MESSAGE_TYPE_ARM_LIST 12 #define GNUNET_MESSAGE_TYPE_ARM_LIST 12
/** /**
* Response from ARM for listing currently running services * Response from ARM for listing currently running services
*/ */
#define GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT 13 #define GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT 13
/**
* Request to ARM to notify client of service status changes
*/
#define GNUNET_MESSAGE_TYPE_ARM_MONITOR 14
/************************************************************************** ***** /************************************************************************** *****
* HELLO message types * HELLO message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* HELLO message used for communicating peer addresses. * Previously used for HELLO messages used for communicating peer addresses
.
* Managed by libgnunethello.
*/
#define GNUNET_MESSAGE_TYPE_HELLO_LEGACY 16
/**
* HELLO message with friend only flag used for communicating peer addresse
s.
* Managed by libgnunethello. * Managed by libgnunethello.
*/ */
#define GNUNET_MESSAGE_TYPE_HELLO 16
#define GNUNET_MESSAGE_TYPE_HELLO 17
/************************************************************************** ***** /************************************************************************** *****
* FRAGMENTATION message types * FRAGMENTATION message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* FRAGMENT of a larger message. * FRAGMENT of a larger message.
* Managed by libgnunetfragment. * Managed by libgnunetfragment.
*/ */
#define GNUNET_MESSAGE_TYPE_FRAGMENT 18 #define GNUNET_MESSAGE_TYPE_FRAGMENT 18
skipping to change at line 164 skipping to change at line 185
/************************************************************************** ***** /************************************************************************** *****
* Transport-DV message types * Transport-DV message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* DV service to DV Plugin message, when a message is * DV service to DV Plugin message, when a message is
* unwrapped by the DV service and handed to the plugin * unwrapped by the DV service and handed to the plugin
* for processing * for processing
*/ */
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECEIVE 44 #define GNUNET_MESSAGE_TYPE_DV_RECV 44
/** /**
* DV Plugin to DV service message, indicating a message * DV Plugin to DV service message, indicating a message
* should be sent out. * should be sent out.
*/ */
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND 45 #define GNUNET_MESSAGE_TYPE_DV_SEND 45
/** /**
* DV service to DV api message, containing a confirmation * DV service to DV api message, containing a confirmation
* or failure of a DV_SEND message. * or failure of a DV_SEND message.
*/ */
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND_RESULT 46 #define GNUNET_MESSAGE_TYPE_DV_SEND_ACK 46
/** /**
* P2P DV message encapsulating some real message * P2P DV message encapsulating some real message
*/ */
#define GNUNET_MESSAGE_TYPE_DV_DATA 47 #define GNUNET_MESSAGE_TYPE_DV_ROUTE 47
/** /**
* P2P DV message gossipping peer information * DV Plugin to DV service message, indicating
* startup.
*/ */
#define GNUNET_MESSAGE_TYPE_DV_GOSSIP 48 #define GNUNET_MESSAGE_TYPE_DV_START 48
/** /**
* DV Plugin to DV service message, indicating * P2P DV message telling plugin that a peer connected
* startup.
*/ */
#define GNUNET_MESSAGE_TYPE_DV_START 49 #define GNUNET_MESSAGE_TYPE_DV_CONNECT 49
/** /**
* P2P DV message notifying connected peers of a disconnect * P2P DV message telling plugin that a peer disconnected
*/ */
#define GNUNET_MESSAGE_TYPE_DV_DISCONNECT 50 #define GNUNET_MESSAGE_TYPE_DV_DISCONNECT 50
/**
* P2P DV message telling plugin that a message transmission failed (negati
ve ACK)
*/
#define GNUNET_MESSAGE_TYPE_DV_SEND_NACK 51
/**
* P2P DV message telling plugin that our distance to a peer changed
*/
#define GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED 52
/**
* DV message box for boxing multiple messages.
*/
#define GNUNET_MESSAGE_TYPE_DV_BOX 53
/************************************************************************** ***** /************************************************************************** *****
* Transport-UDP message types * Transport-UDP message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Normal UDP message type. * Normal UDP message type.
*/ */
#define GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE 56 #define GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE 56
/** /**
skipping to change at line 309 skipping to change at line 345
* Request for peer iteration from CORE service. * Request for peer iteration from CORE service.
*/ */
#define GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS 78 #define GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS 78
/** /**
* Last reply from core to request for peer iteration from CORE service. * Last reply from core to request for peer iteration from CORE service.
*/ */
#define GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END 79 #define GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END 79
/** /**
* Check whether a given peer is currently connected to CORE.
*/
#define GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED 80
/**
* Session key exchange between peers.
*/
#define GNUNET_MESSAGE_TYPE_CORE_SET_KEY 81
/**
* Encapsulation for an encrypted message between peers. * Encapsulation for an encrypted message between peers.
*/ */
#define GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE 82 #define GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE 82
/** /**
* Check that other peer is alive (challenge). * Check that other peer is alive (challenge).
*/ */
#define GNUNET_MESSAGE_TYPE_CORE_PING 83 #define GNUNET_MESSAGE_TYPE_CORE_PING 83
/** /**
skipping to change at line 348 skipping to change at line 374
/** /**
* gzip-compressed type map of the sender * gzip-compressed type map of the sender
*/ */
#define GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP 86 #define GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP 86
/** /**
* uncompressed type map of the sender * uncompressed type map of the sender
*/ */
#define GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP 87 #define GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP 87
/**
* Session key exchange between peers.
*/
#define GNUNET_MESSAGE_TYPE_CORE_EPHEMERAL_KEY 88
/************************************************************************** ***** /************************************************************************** *****
* DATASTORE message types * DATASTORE message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Message sent by datastore client on join. * Message sent by datastore client on join.
*/ */
#define GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE 92 #define GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE 92
/** /**
skipping to change at line 484 skipping to change at line 515
* used between the service and clients (in response to START_SEARCH). * used between the service and clients (in response to START_SEARCH).
*/ */
#define GNUNET_MESSAGE_TYPE_FS_PUT 138 #define GNUNET_MESSAGE_TYPE_FS_PUT 138
/** /**
* Peer asks us to stop migrating content towards it for a while. * Peer asks us to stop migrating content towards it for a while.
*/ */
#define GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP 139 #define GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP 139
/** /**
* P2P request for content (one FS to another via a stream). * P2P request for content (one FS to another via a mesh).
*/ */
#define GNUNET_MESSAGE_TYPE_FS_STREAM_QUERY 140 #define GNUNET_MESSAGE_TYPE_FS_MESH_QUERY 140
/** /**
* P2P answer for content (one FS to another via a stream). * P2P answer for content (one FS to another via a mesh).
*/ */
#define GNUNET_MESSAGE_TYPE_FS_STREAM_REPLY 141 #define GNUNET_MESSAGE_TYPE_FS_MESH_REPLY 141
/************************************************************************** ***** /************************************************************************** *****
* DHT message types * DHT message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Client wants to store item in DHT. * Client wants to store item in DHT.
*/ */
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT 142 #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT 142
skipping to change at line 743 skipping to change at line 774
*/ */
#define GNUNET_MESSAGE_TYPE_MESH 215 #define GNUNET_MESSAGE_TYPE_MESH 215
/** /**
* Type of message used to send another peer which messages we want to rece ive * Type of message used to send another peer which messages we want to rece ive
* through a mesh-tunnel (LEGACY) * through a mesh-tunnel (LEGACY)
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_HELLO 216 #define GNUNET_MESSAGE_TYPE_MESH_HELLO 216
/** /**
* Request the creation of a path * Request the creation of a connection
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE 256 #define GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE 256
/** /**
* Request the modification of an existing path * Send origin an ACK that the connection is complete
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGE 257 #define GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK 257
/** /**
* Notify that a connection of a path is no longer valid * Notify that a connection is no longer valid
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN 258 #define GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN 258
/** /**
* At some point, the route will spontaneously change * At some point, the route will spontaneously change TODO
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED 259 #define GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED 259
/** /**
* Transport data in the mesh (origin->end) unicast * Payload data (usually inside a encrypted tunnel).
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_UNICAST 260 #define GNUNET_MESSAGE_TYPE_MESH_DATA 260
/** /**
* Transport data to all peers in a tunnel * Confirm payload data end-to-end.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_MULTICAST 261 #define GNUNET_MESSAGE_TYPE_MESH_DATA_ACK 261
/** /**
* Transport data back in the mesh (end->origin) * Key exchange encapsulation.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN 262 #define GNUNET_MESSAGE_TYPE_MESH_KX 262
/** /**
* Send origin an ACK that the path is complete * New ephemeral key.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_PATH_ACK 263 #define GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL 263
/** /**
* Avoid path timeouts * Challenge to test peer's session key.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE 264 #define GNUNET_MESSAGE_TYPE_MESH_KX_PING 264
/** /**
* Request the destuction of a path * Answer to session key challenge.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY 265 #define GNUNET_MESSAGE_TYPE_MESH_KX_PONG 265
/** /**
* Request the destruction of a whole tunnel * Request the destuction of a connection
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY 266 #define GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY 266
/** /**
* ACK for a data packet. * Hop-by-hop, connection dependent ACK.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_ACK 267 #define GNUNET_MESSAGE_TYPE_MESH_ACK 268
/**
* Poll for an ACK.
*/
#define GNUNET_MESSAGE_TYPE_MESH_POLL 268
/**
* Connect to the mesh service, specifying subscriptions
*/
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 272
/** /**
* Ask the mesh service to create a new tunnel * Poll for a hop-by-hop ACK.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE 273 #define GNUNET_MESSAGE_TYPE_MESH_POLL 269
/** /**
* Ask the mesh service to destroy a tunnel * Announce connection is still alive (direction sensitive).
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY 274 #define GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE 270
/** /**
* Ask the mesh service to add a peer to an existing tunnel * Connect to the mesh service, specifying subscriptions
*/
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD 275
/**
* Ask the mesh service to remove a peer from a tunnel
*/
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL 276
/**
* Ask the mesh service to add a peer offering a service to an existing tun
nel
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_TYPE 277 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 272
/** /**
* Ask the mesh service to add a peer described by a service string * Ask the mesh service to create a new channel.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX 278 #define GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE 273
/** /**
* Ask the mesh service to add a peer described by a service string * Ask the mesh service to destroy a channel.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING 279 #define GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY 274
/** /**
* Ask the mesh service to add a peer to the blacklist of an existing tunne l * Confirm the creation of a channel
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_BLACKLIST 280 #define GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK 275
/** /**
* Ask the mesh service to remove a peer from the blacklist of a tunnel * Reject the creation of a channel
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST 281 #define GNUNET_MESSAGE_TYPE_MESH_CHANNEL_NACK 276
/** /**
* Set tunnel speed to slowest peer * Encrypted data. (Payload, channel management, keepalive)
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN 282 #define GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED 280
/** /**
* Set tunnel speed to fastest peer * Payload client <-> service
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX 283 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA 285
/** /**
* Set tunnel buffering on. * Local ACK for data.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_BUFFER 284 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK 286
/** /**
* Set tunnel buffering off. * Local NACK for rejected channels.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOBUFFER 285 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_NACK 287
/** /**
* Local ACK for data. * Local information about all tunnels of service. DEPRECATED
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK 286 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS 287
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS 287
/** /**
* Local information about all tunnels of service. * Local information of service about a specific tunnel. DEPRECATED
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS 287 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL 288
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL 288
/** /**
* Local information of service about a specific tunnel. * Traffic (net-cat style) used by the Command Line Interface.
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL 288 #define GNUNET_MESSAGE_TYPE_MESH_CLI 298
/** /**
* 640kb should be enough for everybody * 640kb should be enough for everybody
*/ */
#define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 299 #define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 299
/************************************************************************** ***** /************************************************************************** *****
* CHAT message types START * CHAT message types START
************************************************************************** ****/ ************************************************************************** ****/
skipping to change at line 1115 skipping to change at line 1128
* to request information about addresses * to request information about addresses
*/ */
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST 354 #define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST 354
/** /**
* Type of the 'struct AddressListResponseMessage' sent by ATS to client * Type of the 'struct AddressListResponseMessage' sent by ATS to client
* with information about addresses * with information about addresses
*/ */
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE 355 #define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE 355
/**
* Type of the 'struct ChangePreferenceMessage' sent by clients to ATS
* to ask for allocation preference changes.
*/
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK 356
/************************************************************************** ***** /************************************************************************** *****
* TRANSPORT message types * TRANSPORT message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Message from the core saying that the transport * Message from the core saying that the transport
* server should start giving it messages. This * server should start giving it messages. This
* should automatically trigger the transmission of * should automatically trigger the transmission of
* a HELLO message. * a HELLO message.
*/ */
skipping to change at line 1255 skipping to change at line 1274
/** /**
* Request to iterate over all known addresses. * Request to iterate over all known addresses.
*/ */
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE 383 #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE 383
/** /**
* Message send by a peer to notify the other to keep the session alive. * Message send by a peer to notify the other to keep the session alive.
*/ */
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON 384 #define GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON 384
/**************************************************************************
*****
* STREAM messages types
**************************************************************************
****/
/**
* Message containing data exchanged between stream end-points over mesh.
*/
#define GNUNET_MESSAGE_TYPE_STREAM_DATA 400
/**
* ACK message
*/
#define GNUNET_MESSAGE_TYPE_STREAM_ACK 401
/**
* Handshake hello message
*/
#define GNUNET_MESSAGE_TYPE_STREAM_HELLO 402
/**
* Handshake hello acknowledgement message
*/
#define GNUNET_MESSAGE_TYPE_STREAM_HELLO_ACK 403
/**
* Reset message
*/
#define GNUNET_MESSAGE_TYPE_STREAM_RESET 404
/** /**
* Transmit close message (data transmission no longer possible after this * Message containing traffic metrics for transport service
* message)
*/ */
#define GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE 405 #define GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC 385
/**
* Transmit close acknowledgement message
*/
#define GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE_ACK 406
/**
* Receive close message (data is no loger read by the receiver after this
* message)
*/
#define GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE 407
/**
* Receive close acknowledgement message
*/
#define GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE_ACK 408
/**
* Stream close message (data is no longer sent or read after this message)
*/
#define GNUNET_MESSAGE_TYPE_STREAM_CLOSE 409
/**
* Close acknowledgement message
*/
#define GNUNET_MESSAGE_TYPE_STREAM_CLOSE_ACK 410
/************************************************************************** ***** /************************************************************************** *****
* FS-PUBLISH-HELPER IPC Messages * FS-PUBLISH-HELPER IPC Messages
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Progress information from the helper: found a file * Progress information from the helper: found a file
*/ */
#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE 420 #define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE 420
skipping to change at line 1356 skipping to change at line 1319
* Extracted meta data from the helper. * Extracted meta data from the helper.
*/ */
#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA 425 #define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA 425
/** /**
* Signal that helper is done. * Signal that helper is done.
*/ */
#define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED 426 #define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED 426
/************************************************************************** ***** /************************************************************************** *****
* NAMESTORE message types * NAMECACHE message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Client to service: register. * Client to service: lookup block
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_START 430 #define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK 431
/** /**
* Client to service: lookup name * Service to client: result of block lookup
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME 431 #define GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE 432
/** /**
* Service to client: result of name lookup * Client to service: cache a block
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE 432 #define GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE 433
/** /**
* Client to service: put records (for caching) * Service to client: result of block cache request
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT 433 #define GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE 434
/** /**************************************************************************
* Service to client: result of put operation. *****
*/ * NAMESTORE message types
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE 434 **************************************************************************
****/
/** /**
* Client to service: create record as authority * Client to service: store records (as authority)
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE 435 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE 435
/** /**
* Service to client: result of record creation request * Service to client: result of store operation.
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE 436 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE 436
/** /**
* Client to service: remove record(s) * Client to service: lookup label
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE 437 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP 437
/** /**
* Service to client: result of removal request. * Service to client: lookup label
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE 438 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE 438
/** /**
* Client to service: "reverse" lookup for zone name based on zone key * Client to service: "reverse" lookup for zone name based on zone key
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME 439 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME 439
/** /**
* Service to client: result of zone-to-name lookup. * Service to client: result of zone-to-name lookup.
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440
/** /**
* Client to service: please start iteration * Client to service: start monitoring (yields sequence of
* "ZONE_ITERATION_RESPONSES" --- forever).
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445 #define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START 441
/** /**
* Service to client: current record in iteration (or end of list). * Service to client: you're now in sync.
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 446 #define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC 442
/**
* Service to client: here is a (plaintext) record you requested.
*/
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT 443
/**
* Client to service: please start iteration; receives
* "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE" messages in return.
*/
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445
/** /**
* Client to service: next record in iteration please. * Client to service: next record in iteration please.
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447
/** /**
* Client to service: stop iterating. * Client to service: stop iterating.
*/ */
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
skipping to change at line 1465 skipping to change at line 1439
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Initial message from a client to a testing control service * Initial message from a client to a testing control service
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_INIT 460 #define GNUNET_MESSAGE_TYPE_TESTBED_INIT 460
/** /**
* Message to add host * Message to add host
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST 461 #define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST 461
/** /**
* Message to signal that a add host succeeded * Message to signal that a add host succeeded
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM 462 #define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS 462
/**
* Message to configure a service to be shared among peers
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE 463
/** /**
* Message to link delegated controller to slave controller * Message to link delegated controller to slave controller
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS 464 #define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS 463
/** /**
* Message to create a peer at a host * Message to create a peer at a host
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER 465 #define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER 464
/** /**
* Message to reconfigure a peer * Message to reconfigure a peer
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_PEERRECONF 466 #define GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER 465
/** /**
* Message to start a peer at a host * Message to start a peer at a host
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER 467 #define GNUNET_MESSAGE_TYPE_TESTBED_START_PEER 466
/** /**
* Message to stop a peer at a host * Message to stop a peer at a host
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER 468 #define GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER 467
/** /**
* Message to destroy a peer * Message to destroy a peer
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER 469 #define GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER 468
/** /**
* Configure underlay link message * Configure underlay link message
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_CONFIGULLINK 470 #define GNUNET_MESSAGE_TYPE_TESTBED_CONFIGURE_UNDERLAY_LINK 469
/** /**
* Message to connect peers in a overlay * Message to connect peers in a overlay
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT 471 #define GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT 470
/** /**
* Message for peer events * Message for peer events
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT 472 #define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT 471
/** /**
* Message for peer connect events * Message for peer connect events
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT 473 #define GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT 472
/** /**
* Message for operation events * Message for operation events
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT 474 #define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT 473
/** /**
* Message to signal successful peer creation * Message to signal successful peer creation
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS 475 #define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS 474
/** /**
* Message to signal a generic operation has been successful * Message to signal a generic operation has been successful
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS 476 #define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS 475
/** /**
* Message to get the configuration of a peer * Message to get a peer's information
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG 477 #define GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION 476
/** /**
* Message containing the peer configuration * Message containing the peer's information
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG 478 #define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION 477
/** /**
* Message to request a controller to make one of its peer to connect to an other * Message to request a controller to make one of its peer to connect to an other
* peer using the contained HELLO * peer using the contained HELLO
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT 479 #define GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT 478
/** /**
* Message to cancel a REQUESTCONNECT request * Message to request configuration of a slave controller
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECTCANCEL 480 #define GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION 479
/** /**
* Message to request configuration of a slave controller * Message which contains the configuration of slave controller
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_GETSLAVECONFIG 481 #define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION 480
/** /**
* Message which contains the configuration of slave controller * Message to signal the result of GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROL
LERS request
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT 481
/**
* A controller receiving this message floods it to its directly-connected
* sub-controllers and then stops and destroys all peers
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG 482 #define GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS 482
/**
* Message to start/stop a service of a peer
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE 483
/**
* Message to initialise a barrier. Messages of these type are flooded to
all
* sub-controllers
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT 484
/**
* Message to cancel a barrier. This message is flooded to all sub-control
lers
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL 485
/**
* Message for signalling status of a barrier
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS 486
/**
* Message sent by a peer when it has reached a barrier and is waiting for
it to
* be crossed
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT 487
/** /**
* Not really a message, but for careful checks on the testbed messages; Sh ould * Not really a message, but for careful checks on the testbed messages; Sh ould
* always be the maximum and never be used to send messages with this type * always be the maximum and never be used to send messages with this type
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_MAX 483 #define GNUNET_MESSAGE_TYPE_TESTBED_MAX 488
/** /**
* The initialization message towards gnunet-testbed-helper * The initialization message towards gnunet-testbed-helper
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT 495 #define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT 495
/** /**
* The reply message from gnunet-testbed-helper * The reply message from gnunet-testbed-helper
*/ */
#define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY 496 #define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY 496
/**************************************************************************
****
* GNS.
**************************************************************************
***/
/** /**
* GNS. FIXME: document! * Client would like to resolve a name.
*/ */
#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP 500 #define GNUNET_MESSAGE_TYPE_GNS_LOOKUP 500
/**
* Service response to name resolution request from client.
*/
#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT 501 #define GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT 501
#define GNUNET_MESSAGE_TYPE_GNS_SHORTEN 502
#define GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT 503
#define GNUNET_MESSAGE_TYPE_GNS_GET_AUTH 504
#define GNUNET_MESSAGE_TYPE_GNS_GET_AUTH_RESULT 505
/************************************************************************** ***** /************************************************************************** *****
* CONSENSUS message types * CONSENSUS message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Join a consensus session. Sent by client to service as first message. * Join a consensus session. Sent by client to service as first message.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN 520 #define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN 520
/** /**
skipping to change at line 1640 skipping to change at line 1641
* Sent by client to service in order to start the consensus conclusion. * Sent by client to service in order to start the consensus conclusion.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE 524 #define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE 524
/** /**
* Sent by service to client in order to signal a completed consensus concl usion. * Sent by service to client in order to signal a completed consensus concl usion.
* Last message sent in a consensus session. * Last message sent in a consensus session.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE 525 #define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE 525
/* message types 526-539 reserved for consensus client/service messages */
/** /**
* Sent by client to service, telling whether a received element should * Sent by client to service, telling whether a received element should
* be accepted and propagated further or not. * be accepted and propagated further or not.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_ACK 527 #define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_ACK 540
/**
* Strata estimator.
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_DELTA_ESTIMATE 541
/**
* IBF containing all elements of a peer.
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_DIFFERENCE_DIGEST 542
/** /**
* Update another peer's consensus set with new elements. * One or more elements that are sent from peer to peer.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS 528 #define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS 543
/** /**
* Request elements (by their hash) from another peer. * Elements, and requests for further elements
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_REQUEST_ELEMENTS 529 #define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS_REQUEST 544
/**
* Elements that a peer reports to be missing at the remote peer.
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS_REPORT 545
/*
* Initialization message for consensus p2p communication.
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_HELLO 546
/**
* Report that the peer is synced with the partner after successfuly decodi
ng the invertible bloom filter.
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_SYNCED 547
/**
* Interaction os over, got synched and reported all elements
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_FIN 548
/**
* Abort a round, don't send requested elements anymore
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ABORT 548
/**
* Abort a round, don't send requested elements anymore
*/
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT 547
/**************************************************************************
*****
* SET message types
**************************************************************************
****/
#define GNUNET_MESSAGE_TYPE_SET_REJECT 569
/**
* Cancel a set operation
*/
#define GNUNET_MESSAGE_TYPE_SET_CANCEL 570
/**
* Acknowledge result from iteration
*/
#define GNUNET_MESSAGE_TYPE_SET_ITER_ACK 571
/**
* Create an empty set
*/
#define GNUNET_MESSAGE_TYPE_SET_RESULT 572
/**
* Add element to set
*/
#define GNUNET_MESSAGE_TYPE_SET_ADD 573
/**
* Remove element from set
*/
#define GNUNET_MESSAGE_TYPE_SET_REMOVE 574
/**
* Listen for operation requests
*/
#define GNUNET_MESSAGE_TYPE_SET_LISTEN 575
/**
* Accept a set request
*/
#define GNUNET_MESSAGE_TYPE_SET_ACCEPT 576
/**
* Evaluate a set operation
*/
#define GNUNET_MESSAGE_TYPE_SET_EVALUATE 577
/**
* Start a set operation with the given set
*/
#define GNUNET_MESSAGE_TYPE_SET_CONCLUDE 578
/**
* Notify the client of a request from a remote peer
*/
#define GNUNET_MESSAGE_TYPE_SET_REQUEST 579
/**
* Create a new local set
*/
#define GNUNET_MESSAGE_TYPE_SET_CREATE 580
/**
* Request a set operation from a remote peer.
*/
#define GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST 581
/** /**
* Strata estimator. * Strata estimator.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_STRATA 530 #define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE 582
/** /**
* IBF containing all elements of a peer. * Invertible bloom filter.
*/
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF 583
/**
* Actual set elements.
*/
#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS 584
/**
* Requests for the elements with the given hashes.
*/
#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS 585
/**
* Operation is done.
*/
#define GNUNET_MESSAGE_TYPE_SET_P2P_DONE 586
/**
* Start iteration over set elements.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_IBF 531 #define GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST 587
/** /**
* Request reconcilliation with another peer. * Element result for the iterating client.
*/ */
#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_RECONCILE 532 #define GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT 588
/** /**
* Next available: 570 * Iteration end marker for the client.
*/ */
#define GNUNET_MESSAGE_TYPE_SET_ITER_DONE 589
/**
* Information about the element count for intersection
*/
#define GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO 591
/**
* Bloom filter message for intersection exchange started by Bob.
*/
#define GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF 592
/**
* Bloom filter message for intersection exchange started by Bob.
*/
#define GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF_PART 593
/************************************************************************** ***** /************************************************************************** *****
* TODO: we need a way to register message types centrally (via some webpag * TESTBED LOGGER message types
e). **************************************************************************
* For now: unofficial extensions should start at 48k, internal extensions ****/
* define here should leave some room (4-10 additional messages to the prev
ious /**
* extension). * Message for TESTBED LOGGER
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG 600
/**
* Message for TESTBED LOGGER acknowledgement
*/
#define GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_ACK 601
/**************************************************************************
*****
* EXPERIMENTATION message types
**************************************************************************
****/
/**
* Message for experimentation request
*/
#define GNUNET_MESSAGE_TYPE_EXPERIMENTATION_REQUEST 610
/**
* Message for experimentation response
*/
#define GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE 611
/**
* Message for experimentation response
*/
#define GNUNET_MESSAGE_TYPE_EXPERIMENTATION_START 612
/**
* Message for experimentation response
*/
#define GNUNET_MESSAGE_TYPE_EXPERIMENTATION_START_ACK 613
/**
* Message for experimentation response
*/
#define GNUNET_MESSAGE_TYPE_EXPERIMENTATION_STOP 614
/**
* Advertise regex capability.
*/
#define GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE 620
/**
* Search for peer with matching capability.
*/
#define GNUNET_MESSAGE_TYPE_REGEX_SEARCH 621
/**
* Result in response to regex search.
*/
#define GNUNET_MESSAGE_TYPE_REGEX_RESULT 622
/**************************************************************************
*****
* IDENTITY message types
**************************************************************************
****/
/**
* First message send from identity client to service (to subscribe to
* updates).
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_START 624
/**
* Generic response from identity service with success and/or error message
.
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE 625
/**
* Update about identity status from service to clients.
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE 626
/**
* Client requests to know default identity for a subsystem.
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT 627
/**
* Client sets default identity; or service informs about default identity.
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT 628
/**
* Create new identity (client->service).
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE 629
/**
* Rename existing identity (client->service).
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME 630
/**
* Delete identity (client->service).
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE 631
/**************************************************************************
*****
* REVOCATION message types
**************************************************************************
****/
/**
* Client to service: was this key revoked?
*/
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY 636
/**
* Service to client: answer if key was revoked!
*/
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE 637
/**
* Client to service OR peer-to-peer: revoke this key!
*/
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE 638
/**
* Service to client: revocation confirmed
*/
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE 639
/**************************************************************************
*****
* SCALARPRODUCT message types
**************************************************************************
****/
/**
* Client -> Vector-Product Service request message
*/
#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE 640
/**
* Client -> Vector-Product Service request message
*/
#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB 641
/**
* Vector-Product Service request -> remote VP Service
*/
#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB 642
/**
* Vector-Product Service request -> remote VP Service Multipart
*/
#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB_MULTIPART 643
/**
* remote Vector-Product Service response -> requesting VP Service
*/
#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE 644
/**
* remote Vector-Product Service response -> requesting VP Service Multipar
t
*/
#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE_MULTIPART 645
/**
* Vector-Product Service response -> Client
*/
#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SERVICE_TO_CLIENT 646
/**************************************************************************
*****
* PSYCSTORE message types
**************************************************************************
****/
/**
* Store a membership event.
*/
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE 650
/**
* Test for membership of a member at a particular point in time.
*/
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST 651
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE 652
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET 653
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET 654
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET_FRAGMENT 655
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_COUNTERS_GET 656
/* 657 */
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY 658
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC 659
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_RESET 660
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE 661
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_GET 662
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_GET_PREFIX 663
/**
* Generic response from PSYCstore service with success and/or error messag
e.
*/
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE 664
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_FRAGMENT 665
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS 666
#define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_STATE 667
/**************************************************************************
*****
* PSYC message types
**************************************************************************
****/
#define GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE 680
#define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START 681
#define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK 682
#define GNUNET_MESSAGE_TYPE_PSYC_MASTER_STOP 683
#define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN 684
#define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 685
#define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_PART 686
#define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687
#define GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION 688
#define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD 689
#define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690
#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 691
#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 692
#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 693
#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 694
#define GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK 695
#define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701
#define GNUNET_MESSAGE_TYPE_PSYC_STORY_RESPONSE 702
#define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET 703
#define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX 704
#define GNUNET_MESSAGE_TYPE_PSYC_STATE_RESPONSE 705
#define GNUNET_MESSAGE_TYPE_PSYC_STATE_MODIFIER 706
#define GNUNET_MESSAGE_TYPE_PSYC_STATE_MOD_CONT 707
/**************************************************************************
*****
* CONVERSATION message types
**************************************************************************
****/
/**
* Message to transmit the audio between helper and speaker/microphone libr
ary.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO 730
/**
* Client -> Server message register a phone.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER 731
/**
* Client -> Server message to reject/hangup a call
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP 732
/**
* Client -> Server message to reject/hangup a call
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP 733
/**
* Client <- Server message to indicate a ringing phone
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL 734
/**
* Client <- Server message to indicate a ringing phone
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING 735
/**
* Client <-> Server message to suspend connection.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND 736
/**
* Client <-> Server message to resume connection.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME 737
/**
* Client <-> Server message to send audio data.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP 738
/**
* Client <-> Server message to send audio data.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO 739
/**
* Mesh: call initiation
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING 740
/**
* Mesh: hang up / refuse call
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_HANG_UP 741
/**
* Mesh: pick up phone (establish audio channel)
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_PICK_UP 742
/**
* Mesh: phone suspended.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_SUSPEND 743
/**
* Mesh: phone resumed.
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RESUME 744
/**
* Mesh: audio data
*/
#define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_AUDIO 745
/**************************************************************************
*****
* MULTICAST message types
**************************************************************************
****/
/* WIP: no numbers assigned yet */
/**
* Multicast message from the origin to all members.
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE 750
/**
* A unicast message from a group member to the origin.
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST
/**
* A peer wants to join the group.
*
* Unicast message to the origin or another group member.
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST
/**
* Response to a join request.
*
* Unicast message from a group member to the peer wanting to join.
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
/**
* A peer wants to part the group.
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST
/**
* Acknowledgement sent in response to a part request.
*
* Unicast message from a group member to the peer wanting to part.
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_ACK
/**
* Group terminated.
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_GROUP_END
/**
*
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_REQUEST
/**
*
*/
#define GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_REQUEST_CANCEL
/**************************************************************************
*****
* SECRETSHARING message types
**************************************************************************
****/
/**
* Establish a new session.
*/
#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE 780
/**
* Request the decryption of a ciphertext.
*/
#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT 781
/**
* The service succeeded in decrypting a ciphertext.
*/
#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_DECRYPT_DONE 782
/**
* The cryptosystem has been established.
* Contains the peer's share.
*/
#define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY 783
/**
* Next available: 800
*/
/**************************************************************************
*****
* PSYC message types
**************************************************************************
****/
/**************************************************************************
*****
* PSYCSTORE message types
**************************************************************************
****/
/**************************************************************************
*****
* SOCIAL message types
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Type used to match 'all' message types. * Type used to match 'all' message types.
*/ */
#define GNUNET_MESSAGE_TYPE_ALL 65535 #define GNUNET_MESSAGE_TYPE_ALL 65535
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group protocols */
/* ifndef GNUNET_PROTOCOLS_H */ /* ifndef GNUNET_PROTOCOLS_H */
#endif #endif
/* end of gnunet_protocols.h */ /* end of gnunet_protocols.h */
 End of changes. 150 change blocks. 
247 lines changed or deleted 875 lines changed or added


 gnunet_resolver_service.h   gnunet_resolver_service.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_resolver_service.h * @file include/gnunet_resolver_service.h
* @brief functions related to doing DNS lookups * @brief functions related to doing DNS lookups
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup resolver asynchronous standard DNS lookups
* @{
*/ */
#ifndef GNUNET_RESOLVER_SERVICE_H #ifndef GNUNET_RESOLVER_SERVICE_H
#define GNUNET_RESOLVER_SERVICE_H #define GNUNET_RESOLVER_SERVICE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
skipping to change at line 47 skipping to change at line 49
#include "gnunet_configuration_lib.h" #include "gnunet_configuration_lib.h"
#include "gnunet_scheduler_lib.h" #include "gnunet_scheduler_lib.h"
#include "gnunet_time_lib.h" #include "gnunet_time_lib.h"
/** /**
* Function called by the resolver for each address obtained from DNS. * Function called by the resolver for each address obtained from DNS.
* *
* @param cls closure * @param cls closure
* @param addr one of the addresses of the host, NULL for the last address * @param addr one of the addresses of the host, NULL for the last address
* @param addrlen length of the address * @param addrlen length of @a addr
*/ */
typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls, typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls,
const struct sockaddr * ad dr, const struct sockaddr *add r,
socklen_t addrlen); socklen_t addrlen);
/** /**
* Handle to a request given to the resolver. Can be used to cancel * Handle to a request given to the resolver. Can be used to cancel
* the request prior to the timeout or successful execution. * the request prior to the timeout or successful execution.
*/ */
struct GNUNET_RESOLVER_RequestHandle; struct GNUNET_RESOLVER_RequestHandle;
/** /**
* Create the connection to the resolver service. * Create the connection to the resolver service.
skipping to change at line 79 skipping to change at line 81
*/ */
void void
GNUNET_RESOLVER_disconnect (void); GNUNET_RESOLVER_disconnect (void);
/** /**
* Convert a string to one or more IP addresses. * Convert a string to one or more IP addresses.
* *
* @param hostname the hostname to resolve * @param hostname the hostname to resolve
* @param af AF_INET or AF_INET6; use AF_UNSPEC for "any" * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
* @param callback function to call with addresses * @param callback function to call with addresses
* @param callback_cls closure for callback * @param callback_cls closure for @a callback
* @param timeout how long to try resolving * @param timeout how long to try resolving
* @return handle that can be used to cancel the request, NULL on error * @return handle that can be used to cancel the request, NULL on error
*/ */
struct GNUNET_RESOLVER_RequestHandle * struct GNUNET_RESOLVER_RequestHandle *
GNUNET_RESOLVER_ip_get (const char *hostname, int af, GNUNET_RESOLVER_ip_get (const char *hostname, int af,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_RESOLVER_AddressCallback callback, GNUNET_RESOLVER_AddressCallback callback,
void *callback_cls); void *callback_cls);
/** /**
* Resolve our hostname to an IP address. * Resolve our hostname to an IP address.
* *
* @param af AF_INET or AF_INET6; use AF_UNSPEC for "any" * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
* @param callback function to call with addresses * @param callback function to call with addresses
* @param cls closure for callback * @param cls closure for @a callback
* @param timeout how long to try resolving * @param timeout how long to try resolving
* @return handle that can be used to cancel the request, NULL on error * @return handle that can be used to cancel the request, NULL on error
*/ */
struct GNUNET_RESOLVER_RequestHandle * struct GNUNET_RESOLVER_RequestHandle *
GNUNET_RESOLVER_hostname_resolve (int af, GNUNET_RESOLVER_hostname_resolve (int af,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_RESOLVER_AddressCallback callback, GNUNET_RESOLVER_AddressCallback callback,
void *cls); void *cls);
/** /**
skipping to change at line 126 skipping to change at line 128
* *
* @return local hostname, caller must free * @return local hostname, caller must free
*/ */
char * char *
GNUNET_RESOLVER_local_fqdn_get (void); GNUNET_RESOLVER_local_fqdn_get (void);
/** /**
* Perform a reverse DNS lookup. * Perform a reverse DNS lookup.
* *
* @param sa host address * @param sa host address
* @param salen length of host address * @param salen length of @a sa
* @param do_resolve use GNUNET_NO to return numeric hostname * @param do_resolve use #GNUNET_NO to return numeric hostname
* @param timeout how long to try resolving * @param timeout how long to try resolving
* @param callback function to call with hostnames * @param callback function to call with hostnames
* @param cls closure for callback * @param cls closure for @a callback
* @return handle that can be used to cancel the request, NULL on error * @return handle that can be used to cancel the request, NULL on error
*/ */
struct GNUNET_RESOLVER_RequestHandle * struct GNUNET_RESOLVER_RequestHandle *
GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen, GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen,
int do_resolve, int do_resolve,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_RESOLVER_HostnameCallback callback, GNUNET_RESOLVER_HostnameCallback callback,
void *cls); void *cls);
/** /**
skipping to change at line 158 skipping to change at line 160
void void
GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh); GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group resolver */
/* ifndef GNUNET_RESOLVER_SERVICE_H */ /* ifndef GNUNET_RESOLVER_SERVICE_H */
#endif #endif
/* end of gnunet_resolver_service.h */ /* end of gnunet_resolver_service.h */
 End of changes. 10 change blocks. 
9 lines changed or deleted 13 lines changed or added


 gnunet_scheduler_lib.h   gnunet_scheduler_lib.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2009, 2011 Christian Grothoff (and other contributing authors) (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_scheduler_lib.h * @file include/gnunet_scheduler_lib.h
* @brief API to schedule computations using continuation passing style * @brief API to schedule computations using continuation passing style
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup scheduler Event loop (scheduler)
* @{
*/ */
#ifndef GNUNET_SCHEDULER_LIB_H #ifndef GNUNET_SCHEDULER_LIB_H
#define GNUNET_SCHEDULER_LIB_H #define GNUNET_SCHEDULER_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
skipping to change at line 196 skipping to change at line 198
* *
* @param cls closure * @param cls closure
* @param tc context information (why was this task triggered now) * @param tc context information (why was this task triggered now)
*/ */
typedef void (*GNUNET_SCHEDULER_Task) (void *cls, typedef void (*GNUNET_SCHEDULER_Task) (void *cls,
const struct GNUNET_SCHEDULER_TaskCo ntext const struct GNUNET_SCHEDULER_TaskCo ntext
* tc); * tc);
/** /**
* Signature of the select function used by the scheduler. * Signature of the select function used by the scheduler.
* GNUNET_NETWORK_socket_select matches it. * #GNUNET_NETWORK_socket_select matches it.
* *
* @param cls closure * @param cls closure
* @param rfds set of sockets to be checked for readability * @param rfds set of sockets to be checked for readability
* @param wfds set of sockets to be checked for writability * @param wfds set of sockets to be checked for writability
* @param efds set of sockets to be checked for exceptions * @param efds set of sockets to be checked for exceptions
* @param timeout relative value when to return * @param timeout relative value when to return
* @return number of selected sockets, GNUNET_SYSERR on error * @return number of selected sockets, #GNUNET_SYSERR on error
*/ */
typedef int (*GNUNET_SCHEDULER_select) (void *cls, typedef int (*GNUNET_SCHEDULER_select) (void *cls,
struct GNUNET_NETWORK_FDSet * rfds, struct GNUNET_NETWORK_FDSet *rfds,
struct GNUNET_NETWORK_FDSet * wfds, struct GNUNET_NETWORK_FDSet *wfds,
struct GNUNET_NETWORK_FDSet * efds, struct GNUNET_NETWORK_FDSet *efds,
struct GNUNET_TIME_Relative timeout ); struct GNUNET_TIME_Relative timeout );
/** /**
* Initialize and run scheduler. This function will return when all * Initialize and run scheduler. This function will return when all
* tasks have completed. On systems with signals, receiving a SIGTERM * tasks have completed. On systems with signals, receiving a SIGTERM
* (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown" * (and other similar signals) will cause #GNUNET_SCHEDULER_shutdown
* to be run after the active task is complete. As a result, SIGTERM * to be run after the active task is complete. As a result, SIGTERM
* causes all active tasks to be scheduled with reason * causes all active tasks to be scheduled with reason
* "GNUNET_SCHEDULER_REASON_SHUTDOWN". (However, tasks added * #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added
* afterwards will execute normally!). Note that any particular * afterwards will execute normally!). Note that any particular
* signal will only shut down one scheduler; applications should * signal will only shut down one scheduler; applications should
* always only create a single scheduler. * always only create a single scheduler.
* *
* @param task task to run first (and immediately) * @param task task to run first (and immediately)
* @param task_cls closure of task * @param task_cls closure of task
*/ */
void void
GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls); GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls);
skipping to change at line 244 skipping to change at line 246
*/ */
void void
GNUNET_SCHEDULER_shutdown (void); GNUNET_SCHEDULER_shutdown (void);
/** /**
* Get information about the current load of this scheduler. Use this * Get information about the current load of this scheduler. Use this
* function to determine if an elective task should be added or simply * function to determine if an elective task should be added or simply
* dropped (if the decision should be made based on the number of * dropped (if the decision should be made based on the number of
* tasks ready to run). * tasks ready to run).
* *
* * @param p priority-level to query, use KEEP to query the level * @param p priority-level to query, use KEEP to query the level
* of the current task, use COUNT to get the sum over * of the current task, use COUNT to get the sum over
* all priority levels * all priority levels
* @return number of tasks pending right now * @return number of tasks pending right now
*/ */
unsigned int unsigned int
GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p); GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p);
/** /**
* Obtain the reason code for why the current task was * Obtain the reason code for why the current task was
* started. Will return the same value as * started. Will return the same value as
* the GNUNET_SCHEDULER_TaskContext's reason field. * the GNUNET_SCHEDULER_TaskContext's reason field.
* *
* * @return reason(s) why the current task is run * @return reason(s) why the current task is run
*/ */
enum GNUNET_SCHEDULER_Reason enum GNUNET_SCHEDULER_Reason
GNUNET_SCHEDULER_get_reason (void); GNUNET_SCHEDULER_get_reason (void);
/** /**
* Cancel the task with the specified identifier. * Cancel the task with the specified identifier.
* The task must not yet have run. * The task must not yet have run.
* *
* * @param task id of the task to cancel * @param task id of the task to cancel
* @return the closure of the callback of the cancelled task * @return the closure of the callback of the cancelled task
*/ */
void * void *
GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task); GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task);
/** /**
* Continue the current execution with the given function. This is * Continue the current execution with the given function. This is
* similar to the other "add" functions except that there is no delay * similar to the other "add" functions except that there is no delay
* and the reason code can be specified. * and the reason code can be specified.
* *
* * @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of task
* @param reason reason for task invocation * @param reason reason for task invocation
*/ */
void void
GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_c ls, GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_c ls,
enum GNUNET_SCHEDULER_Reason reason); enum GNUNET_SCHEDULER_Reason reason);
/** /**
* Continue the current execution with the given function. This is * Continue the current execution with the given function. This is
* similar to the other "add" functions except that there is no delay * similar to the other "add" functions except that there is no delay
* and the reason code can be specified. * and the reason code can be specified.
* *
* @param task main function of the task * @param task main function of the task
* @param task_cls closure for 'main' * @param task_cls closure for @a task
* @param reason reason for task invocation * @param reason reason for task invocation
* @param priority priority to use for the task * @param priority priority to use for the task
*/ */
void void
GNUNET_SCHEDULER_add_continuation_with_priority (GNUNET_SCHEDULER_Task task , void *task_cls, GNUNET_SCHEDULER_add_continuation_with_priority (GNUNET_SCHEDULER_Task task , void *task_cls,
enum GNUNET_SCHEDULER_Reaso n reason, enum GNUNET_SCHEDULER_Reaso n reason,
enum GNUNET_SCHEDULER_Prior ity priority); enum GNUNET_SCHEDULER_Prior ity priority);
/** /**
* Schedule a new task to be run with a specified priority. * Schedule a new task to be run with a specified priority.
* *
* * @param prio how important is the new task? * @param prio how important is the new task?
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio,
GNUNET_SCHEDULER_Task task, void *task_ cls); GNUNET_SCHEDULER_Task task, void *task_ cls);
/** /**
* Schedule a new task to be run as soon as possible. The task * Schedule a new task to be run as soon as possible. Note that this
* will be run with the DEFAULT priority. * does not guarantee that this will be the next task that is being
* run, as other tasks with higher priority (or that are already ready
* to run) might get to run first. Just as with delays, clients must
* not rely on any particular order of execution between tasks
* scheduled concurrently.
* *
* * @param task main function of the task * The task will be run with the DEFAULT priority.
* @param task_cls closure of task *
* @param task main function of the task
* @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, void *task_cls); GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, void *task_cls);
/** /**
* Schedule a new task to be run as soon as possible with the * Schedule a new task to be run as soon as possible with the
* (transitive) ignore-shutdown flag either explicitly set or * (transitive) ignore-shutdown flag either explicitly set or
* explicitly enabled. This task (and all tasks created from it, * explicitly enabled. This task (and all tasks created from it,
* other than by another call to this function) will either count or * other than by another call to this function) will either count or
* not count for the 'lifeness' of the process. This API is only * not count for the 'lifeness' of the process. This API is only
* useful in a few special cases. * useful in a few special cases.
* *
* @param lifeness GNUNET_YES if the task counts for lifeness, GNUNET_NO if not. * @param lifeness #GNUNET_YES if the task counts for lifeness, #GNUNET_NO if not.
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness,
GNUNET_SCHEDULER_Task task, GNUNET_SCHEDULER_Task task,
void *task_cls); void *task_cls);
/** /**
* Schedule a new task to be run with a specified delay. The task * Schedule a new task to be run with a specified delay. The task
* will be scheduled for execution once the delay has expired. It * will be scheduled for execution once the delay has expired. It
* will be run with the DEFAULT priority. * will be run with the DEFAULT priority.
* *
* * @param delay when should this operation time out? Use * * @param delay when should this operation time out? Use
* GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay,
GNUNET_SCHEDULER_Task task, void *task_cls); GNUNET_SCHEDULER_Task task, void *task_cls);
/** /**
* Schedule a new task to be run with a specified delay. The task * Schedule a new task to be run with a specified delay. The task
* will be scheduled for execution once the delay has expired. * will be scheduled for execution once the delay has expired.
* *
* @param delay when should this operation time out? Use * @param delay when should this operation time out? Use
* GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param priority priority to use for the task * @param priority priority to use for the task
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative del ay, GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative del ay,
enum GNUNET_SCHEDULER_Priority p riority, enum GNUNET_SCHEDULER_Priority p riority,
GNUNET_SCHEDULER_Task task, void *task_cls); GNUNET_SCHEDULER_Task task, void *task_cls);
/** /**
* Schedule a new task to be run with a specified delay or when the * Schedule a new task to be run with a specified delay or when the
* specified file descriptor is ready for reading. The delay can be * specified file descriptor is ready for reading. The delay can be
* used as a timeout on the socket being ready. The task will be * used as a timeout on the socket being ready. The task will be
* scheduled for execution once either the delay has expired or the * scheduled for execution once either the delay has expired or the
* socket operation is ready. It will be run with the DEFAULT priority. * socket operation is ready. It will be run with the DEFAULT priority.
* *
* * @param delay when should this operation time out? Use * * @param delay when should this operation time out? Use
* GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param rfd read file-descriptor * @param rfd read file-descriptor
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay,
struct GNUNET_NETWORK_Handle *rfd, struct GNUNET_NETWORK_Handle *rfd,
GNUNET_SCHEDULER_Task task, void *task_cls); GNUNET_SCHEDULER_Task task, void *task_cls);
/** /**
* Schedule a new task to be run with a specified priority and to be * Schedule a new task to be run with a specified priority and to be
* run after the specified delay or when the specified file descriptor * run after the specified delay or when the specified file descriptor
* is ready for reading. The delay can be used as a timeout on the * is ready for reading. The delay can be used as a timeout on the
* socket being ready. The task will be scheduled for execution once * socket being ready. The task will be scheduled for execution once
* either the delay has expired or the socket operation is ready. It * either the delay has expired or the socket operation is ready. It
* will be run with the DEFAULT priority. * will be run with the DEFAULT priority.
* *
* @param delay when should this operation time out? Use * @param delay when should this operation time out? Use
* GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param priority priority to use for the task * @param priority priority to use for the task
* @param rfd read file-descriptor * @param rfd read file-descriptor
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative de lay, GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative de lay,
enum GNUNET_SCHEDULER_Priority priority, enum GNUNET_SCHEDULER_Priority priority,
struct GNUNET_NETWORK_Handle *r fd, struct GNUNET_NETWORK_Handle *r fd,
GNUNET_SCHEDULER_Task task, voi d *task_cls); GNUNET_SCHEDULER_Task task, voi d *task_cls);
/** /**
* Schedule a new task to be run with a specified delay or when the * Schedule a new task to be run with a specified delay or when the
* specified file descriptor is ready for writing. The delay can be * specified file descriptor is ready for writing. The delay can be
* used as a timeout on the socket being ready. The task will be * used as a timeout on the socket being ready. The task will be
* scheduled for execution once either the delay has expired or the * scheduled for execution once either the delay has expired or the
* socket operation is ready. It will be run with the DEFAULT priority. * socket operation is ready. It will be run with the DEFAULT priority.
* *
* * @param delay when should this operation time out? Use * * @param delay when should this operation time out? Use
* GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param wfd write file-descriptor * @param wfd write file-descriptor
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay,
struct GNUNET_NETWORK_Handle *wfd, struct GNUNET_NETWORK_Handle *wfd,
GNUNET_SCHEDULER_Task task, void *task_cls) ; GNUNET_SCHEDULER_Task task, void *task_cls) ;
/** /**
* Schedule a new task to be run with a specified delay or when the * Schedule a new task to be run with a specified delay or when the
* specified file descriptor is ready. The delay can be
* used as a timeout on the socket being ready. The task will be
* scheduled for execution once either the delay has expired or the
* socket operation is ready.
*
* @param delay when should this operation time out? Use
* #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param priority priority of the task
* @param fd file-descriptor
* @param on_read whether to poll the file-descriptor for readability
* @param on_write whether to poll the file-descriptor for writability
* @param task main function of the task
* @param task_cls closure of @a task
* @return unique task identifier for the job
* only valid until "task" is started!
*/
GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay,
enum GNUNET_SCHEDULER_Priority pri
ority,
struct GNUNET_NETWORK_Handle *fd,
int on_read, int on_write,
GNUNET_SCHEDULER_Task task, void *
task_cls);
/**
* Schedule a new task to be run with a specified delay or when the
* specified file descriptor is ready for reading. The delay can be * specified file descriptor is ready for reading. The delay can be
* used as a timeout on the socket being ready. The task will be * used as a timeout on the socket being ready. The task will be
* scheduled for execution once either the delay has expired or the * scheduled for execution once either the delay has expired or the
* socket operation is ready. It will be run with the DEFAULT priority. * socket operation is ready. It will be run with the DEFAULT priority.
* *
* * @param delay when should this operation time out? Use * * @param delay when should this operation time out? Use
* GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param rfd read file-descriptor * @param rfd read file-descriptor
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until "task" is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay,
const struct GNUNET_DISK_FileHandle *rfd, const struct GNUNET_DISK_FileHandle *rfd,
GNUNET_SCHEDULER_Task task, void *task_cls) ; GNUNET_SCHEDULER_Task task, void *task_cls) ;
/** /**
* Schedule a new task to be run with a specified delay or when the * Schedule a new task to be run with a specified delay or when the
* specified file descriptor is ready for writing. The delay can be * specified file descriptor is ready for writing. The delay can be
* used as a timeout on the socket being ready. The task will be * used as a timeout on the socket being ready. The task will be
* scheduled for execution once either the delay has expired or the * scheduled for execution once either the delay has expired or the
* socket operation is ready. It will be run with the DEFAULT priority. * socket operation is ready. It will be run with the DEFAULT priority.
* *
* * @param delay when should this operation time out? Use * * @param delay when should this operation time out? Use
* GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param wfd write file-descriptor * @param wfd write file-descriptor
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until @a task is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay,
const struct GNUNET_DISK_FileHandle *wfd, const struct GNUNET_DISK_FileHandle *wfd,
GNUNET_SCHEDULER_Task task, void *task_cls ); GNUNET_SCHEDULER_Task task, void *task_cls );
/** /**
* Schedule a new task to be run with a specified delay or when the
* specified file descriptor is ready. The delay can be
* used as a timeout on the socket being ready. The task will be
* scheduled for execution once either the delay has expired or the
* socket operation is ready.
*
* @param delay when should this operation time out? Use
* #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
* @param priority priority of the task
* @param fd file-descriptor
* @param on_read whether to poll the file-descriptor for readability
* @param on_write whether to poll the file-descriptor for writability
* @param task main function of the task
* @param task_cls closure of @a task
* @return unique task identifier for the job
* only valid until @a task is started!
*/
GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay,
enum GNUNET_SCHEDULER_Priority pri
ority,
const struct GNUNET_DISK_FileHandl
e *fd,
int on_read, int on_write,
GNUNET_SCHEDULER_Task task, void *
task_cls);
/**
* Schedule a new task to be run with a specified delay or when any of * Schedule a new task to be run with a specified delay or when any of
* the specified file descriptor sets is ready. The delay can be used * the specified file descriptor sets is ready. The delay can be used
* as a timeout on the socket(s) being ready. The task will be * as a timeout on the socket(s) being ready. The task will be
* scheduled for execution once either the delay has expired or any of * scheduled for execution once either the delay has expired or any of
* the socket operations is ready. This is the most general * the socket operations is ready. This is the most general
* function of the "add" family. Note that the "prerequisite_task" * function of the "add" family. Note that the "prerequisite_task"
* must be satisfied in addition to any of the other conditions. In * must be satisfied in addition to any of the other conditions. In
* other words, the task will be started when * other words, the task will be started when
* <code> * <code>
* (prerequisite-run) * (prerequisite-run)
* && (delay-ready * && (delay-ready
* || any-rs-ready * || any-rs-ready
* || any-ws-ready * || any-ws-ready
* || shutdown-active) * || shutdown-active)
* </code> * </code>
* *
* @param prio how important is this task? * @param prio how important is this task?
* @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL f or "forever", * @param delay how long should we wait? Use #GNUNET_TIME_UNIT_FOREVER_REL for "forever",
* which means that the task will only be run after we receive SIGTE RM * which means that the task will only be run after we receive SIGTE RM
* @param rs set of file descriptors we want to read (can be NULL) * @param rs set of file descriptors we want to read (can be NULL)
* @param ws set of file descriptors we want to write (can be NULL) * @param ws set of file descriptors we want to write (can be NULL)
* @param task main function of the task * @param task main function of the task
* @param task_cls closure of task * @param task_cls closure of @a task
* @return unique task identifier for the job * @return unique task identifier for the job
* only valid until "task" is started! * only valid until "task" is started!
*/ */
GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_TaskIdentifier
GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
struct GNUNET_TIME_Relative delay, struct GNUNET_TIME_Relative delay,
const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *rs,
const struct GNUNET_NETWORK_FDSet *ws, const struct GNUNET_NETWORK_FDSet *ws,
GNUNET_SCHEDULER_Task task, void *task_cls); GNUNET_SCHEDULER_Task task, void *task_cls);
/** /**
* Sets the select function to use in the scheduler (scheduler_select). * Sets the select function to use in the scheduler (scheduler_select).
* *
* @param new_select new select function to use (NULL to reset to default) * @param new_select new select function to use (NULL to reset to default)
* @param new_select_cls closure for 'new_select' * @param new_select_cls closure for 'new_select'
*/ */
void void
GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select, GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select,
void *new_select_cls); void *new_select_cls);
/** @} */ /* end of group scheduler */
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 47 change blocks. 
47 lines changed or deleted 112 lines changed or added


 gnunet_server_lib.h   gnunet_server_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009, 2010 Christian Grothoff (and other contributing authors) (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_server_lib.h * @file include/gnunet_server_lib.h
* @brief library for building GNUnet network servers * @brief library for building GNUnet network servers
*
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup server functions for a server that communicates with clients
* @{
*/ */
#ifndef GNUNET_SERVER_LIB_H #ifndef GNUNET_SERVER_LIB_H
#define GNUNET_SERVER_LIB_H #define GNUNET_SERVER_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h" #include "gnunet_common.h"
#include "gnunet_connection_lib.h" #include "gnunet_connection_lib.h"
/** /**
* Largest supported message. * Largest supported message (to be precise, one byte more
* than the largest possible message, so tests involving
* this value should check for messages being smaller than
* this value).
*/ */
#define GNUNET_SERVER_MAX_MESSAGE_SIZE 65536 #define GNUNET_SERVER_MAX_MESSAGE_SIZE 65536
/** /**
* Smallest supported message. * Smallest supported message.
*/ */
#define GNUNET_SERVER_MIN_BUFFER_SIZE sizeof (struct GNUNET_MessageHeader) #define GNUNET_SERVER_MIN_BUFFER_SIZE sizeof (struct GNUNET_MessageHeader)
/** /**
* @brief handle for a server * @brief handle for a server
skipping to change at line 76 skipping to change at line 80
/** /**
* Functions with this signature are called whenever a message is * Functions with this signature are called whenever a message is
* received. * received.
* *
* @param cls closure * @param cls closure
* @param client identification of the client * @param client identification of the client
* @param message the actual message * @param message the actual message
*/ */
typedef void (*GNUNET_SERVER_MessageCallback) (void *cls, typedef void (*GNUNET_SERVER_MessageCallback) (void *cls,
struct GNUNET_SERVER_Client struct GNUNET_SERVER_Client
* *client,
client,
const struct GNUNET_MessageH eader const struct GNUNET_MessageH eader
* message); *message);
/** /**
* Message handler. Each struct specifies how to handle on particular * Message handler. Each struct specifies how to handle on particular
* type of message received. * type of message received.
*/ */
struct GNUNET_SERVER_MessageHandler struct GNUNET_SERVER_MessageHandler
{ {
/** /**
* Function to call for messages of "type". * Function to call for messages of "type".
*/ */
GNUNET_SERVER_MessageCallback callback; GNUNET_SERVER_MessageCallback callback;
/** /**
* Closure argument for "callback". * Closure argument for @e callback.
*/ */
void *callback_cls; void *callback_cls;
/** /**
* Type of the message this handler covers. * Type of the message this handler covers.
*/ */
uint16_t type; uint16_t type;
/** /**
* Expected size of messages of this type. Use 0 for * Expected size of messages of this type. Use 0 for
skipping to change at line 116 skipping to change at line 119
* if they do not have the right size. * if they do not have the right size.
*/ */
uint16_t expected_size; uint16_t expected_size;
}; };
/** /**
* Create a new server. * Create a new server.
* *
* @param access function for access control * @param access function for access control
* @param access_cls closure for access * @param access_cls closure for @a access
* @param lsocks NULL-terminated array of listen sockets * @param lsocks NULL-terminated array of listen sockets
* @param idle_timeout after how long should we timeout idle connections? * @param idle_timeout after how long should we timeout idle connections?
* @param require_found if YES, connections sending messages of unknown typ e * @param require_found if #GNUNET_YES, connections sending messages of unk nown type
* will be closed * will be closed
* @return handle for the new server, NULL on error * @return handle for the new server, NULL on error
* (typically, "port" already in use) * (typically, "port" already in use)
*/ */
struct GNUNET_SERVER_Handle * struct GNUNET_SERVER_Handle *
GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access,
void *access_cls, void *access_cls,
struct GNUNET_NETWORK_Handle **lsocks, struct GNUNET_NETWORK_Handle **lsocks,
struct GNUNET_TIME_Relative idle_timeout , struct GNUNET_TIME_Relative idle_timeout ,
int require_found); int require_found);
/** /**
* Create a new server. * Create a new server.
* *
* @param access function for access control * @param access function for access control
* @param access_cls closure for access * @param access_cls closure for @a access
* @param serverAddr address toes listen on (including port), NULL terminat * @param server_addr address toes listen on (including port), NULL termina
ed array ted array
* @param socklen lengths of respective serverAddr * @param socklen lengths of respective @a server_addr
* @param idle_timeout after how long should we timeout idle connections? * @param idle_timeout after how long should we timeout idle connections?
* @param require_found if YES, connections sending messages of unknown typ e * @param require_found if #GNUNET_YES, connections sending messages of unk nown type
* will be closed * will be closed
* @return handle for the new server, NULL on error * @return handle for the new server, NULL on error
* (typically, "port" already in use) * (typically, "port" already in use)
*/ */
struct GNUNET_SERVER_Handle * struct GNUNET_SERVER_Handle *
GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cl s, GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cl s,
struct sockaddr *const *serverAddr, struct sockaddr *const *server_addr,
const socklen_t * socklen, const socklen_t * socklen,
struct GNUNET_TIME_Relative idle_timeout, struct GNUNET_TIME_Relative idle_timeout,
int require_found); int require_found);
/** /**
* Suspend accepting connections from the listen socket temporarily. * Suspend accepting connections from the listen socket temporarily.
* Resume activity using #GNUNET_SERVER_resume.
* *
* @param server server to stop accepting connections. * @param server server to stop accepting connections.
*/ */
void void
GNUNET_SERVER_suspend (struct GNUNET_SERVER_Handle *server); GNUNET_SERVER_suspend (struct GNUNET_SERVER_Handle *server);
/** /**
* Resume accepting connections from the listen socket. * Resume accepting connections from the listen socket.
* *
* @param server server to stop accepting connections. * @param server server to resume accepting connections.
*/ */
void void
GNUNET_SERVER_resume (struct GNUNET_SERVER_Handle *server); GNUNET_SERVER_resume (struct GNUNET_SERVER_Handle *server);
/** /**
* Stop the listen socket and get ready to shutdown the server * Stop the listen socket and get ready to shutdown the server once
* once only 'monitor' clients are left. * only clients marked using #GNUNET_SERVER_client_mark_monitor are
* left.
* *
* @param server server to stop listening on * @param server server to stop listening on
*/ */
void void
GNUNET_SERVER_stop_listening (struct GNUNET_SERVER_Handle *server); GNUNET_SERVER_stop_listening (struct GNUNET_SERVER_Handle *server);
/** /**
* Free resources held by this server. * Free resources held by this server.
* *
* @param server server to destroy * @param server server to destroy
skipping to change at line 199 skipping to change at line 204
* incoming messages; the last entry must * incoming messages; the last entry must
* have "NULL" for the "callback"; multiple * have "NULL" for the "callback"; multiple
* entries for the same type are allowed, * entries for the same type are allowed,
* they will be called in order of occurence. * they will be called in order of occurence.
* These handlers can be removed later; * These handlers can be removed later;
* the handlers array must exist until removed * the handlers array must exist until removed
* (or server is destroyed). * (or server is destroyed).
*/ */
void void
GNUNET_SERVER_add_handlers (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_add_handlers (struct GNUNET_SERVER_Handle *server,
const struct GNUNET_SERVER_MessageHandler const struct GNUNET_SERVER_MessageHandler *hand
*handlers); lers);
/** /**
* Notify us when the server has enough space to transmit * Notify us when the server has enough space to transmit
* a message of the given size to the given client. * a message of the given size to the given client.
* *
* @param client client to transmit message to * @param client client to transmit message to
* @param size requested amount of buffer space * @param size requested amount of buffer space
* @param timeout after how long should we give up (and call * @param timeout after how long should we give up (and call
* notify with buf NULL and size 0)? * notify with buf NULL and size 0)?
* @param callback function to call when space is available * @param callback function to call when space is available
* @param callback_cls closure for callback * @param callback_cls closure for @a callback
* @return non-NULL if the notify callback was queued; can be used * @return non-NULL if the notify callback was queued; can be used
* to cancel the request using * to cancel the request using
* GNUNET_SERVER_notify_transmit_ready_cancel. * #GNUNET_SERVER_notify_transmit_ready_cancel.
* NULL if we are already going to notify someone else (busy) * NULL if we are already going to notify someone else (busy)
*/ */
struct GNUNET_SERVER_TransmitHandle * struct GNUNET_SERVER_TransmitHandle *
GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client, GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
size_t size, size_t size,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_CONNECTION_TransmitReadyNotify GNUNET_CONNECTION_TransmitReadyNotify
callback, void *callback_cls); callback,
void *callback_cls);
/** /**
* Abort transmission request. * Abort transmission request.
* *
* @param th request to abort * @param th request to abort
*/ */
void void
GNUNET_SERVER_notify_transmit_ready_cancel (struct GNUNET_SERVER_TransmitHa ndle *th); GNUNET_SERVER_notify_transmit_ready_cancel (struct GNUNET_SERVER_TransmitHa ndle *th);
/** /**
* Set the 'monitor' flag on this client. Clients which have been * Set the 'monitor' flag on this client. Clients which have been
* marked as 'monitors' won't prevent the server from shutting down * marked as 'monitors' won't prevent the server from shutting down
* once 'GNUNET_SERVER_stop_listening' has been invoked. The idea is * once #GNUNET_SERVER_stop_listening has been invoked. The idea is
* that for "normal" clients we likely want to allow them to process * that for "normal" clients we likely want to allow them to process
* their requests; however, monitor-clients are likely to 'never' * their requests; however, monitor-clients are likely to 'never'
* disconnect during shutdown and thus will not be considered when * disconnect during shutdown and thus will not be considered when
* determining if the server should continue to exist after * determining if the server should continue to exist after
* 'GNUNET_SERVER_destroy' has been called. * #GNUNET_SERVER_destroy has been called.
* *
* @param client the client to set the 'monitor' flag on * @param client the client to set the 'monitor' flag on
*/ */
void void
GNUNET_SERVER_client_mark_monitor (struct GNUNET_SERVER_Client *client); GNUNET_SERVER_client_mark_monitor (struct GNUNET_SERVER_Client *client);
/** /**
* Set the persistent flag on this client, used to setup client connection * Set the persistent flag on this client, used to setup client
* to only be killed when the service it's connected to is actually dead. * connection to only be killed when the process of the service it's
* connected to is actually dead. This API is used during shutdown
* signalling within ARM, and it is not expected that typical users
* of the API would need this function.
* *
* @param client the client to set the persistent flag on * @param client the client to set the persistent flag on
*/ */
void void
GNUNET_SERVER_client_persist_ (struct GNUNET_SERVER_Client *client); GNUNET_SERVER_client_persist_ (struct GNUNET_SERVER_Client *client);
/** /**
* Resume receiving from this client, we are done processing the * Resume receiving from this client, we are done processing the
* current request. This function must be called from within each * current request. This function must be called from within each
* GNUNET_SERVER_MessageCallback (or its respective continuations). * #GNUNET_SERVER_MessageCallback (or its respective continuations).
* *
* @param client client we were processing a message of * @param client client we were processing a message of
* @param success GNUNET_OK to keep the connection open and * @param success #GNUNET_OK to keep the connection open and
* continue to receive * continue to receive
* GNUNET_NO to close the connection (normal behavior) * #GNUNET_NO to close the connection (normal behavior)
* GNUNET_SYSERR to close the connection (signal * #GNUNET_SYSERR to close the connection (signal
* serious error) * serious error)
*/ */
void void
GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int succes GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client,
s); int success);
/** /**
* Change the timeout for a particular client. Decreasing the timeout * Change the timeout for a particular client. Decreasing the timeout
* may not go into effect immediately (only after the previous timeout * may not go into effect immediately (only after the previous timeout
* times out or activity happens on the socket). * times out or activity happens on the socket).
* *
* @param client the client to update * @param client the client to update
* @param timeout new timeout for activities on the socket * @param timeout new timeout for activities on the socket
*/ */
void void
GNUNET_SERVER_client_set_timeout (struct GNUNET_SERVER_Client *client, GNUNET_SERVER_client_set_timeout (struct GNUNET_SERVER_Client *client,
struct GNUNET_TIME_Relative timeout); struct GNUNET_TIME_Relative timeout);
/** /**
* Return user context associated with the given client.
* Note: you should probably use the macro (call without the underscore).
*
* @param client client to query
* @param size number of bytes in user context struct (for verification onl
y)
* @return pointer to user context
*/
void *
GNUNET_SERVER_client_get_user_context_ (struct GNUNET_SERVER_Client *client
,
size_t size);
/**
* Set user context to be associated with the given client.
* Note: you should probably use the macro (call without the underscore).
*
* @param client client to query
* @param ptr pointer to user context
* @param size number of bytes in user context struct (for verification onl
y)
*/
void
GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client
,
void *ptr,
size_t size);
/**
* Return user context associated with the given client.
*
* @param client client to query
* @param type expected return type (i.e. 'struct Foo')
* @return pointer to user context of type 'type *'.
*/
#define GNUNET_SERVER_client_get_user_context(client,type) \
(type *) GNUNET_SERVER_client_get_user_context_ (client, sizeof (type))
/**
* Set user context to be associated with the given client.
*
* @param client client to query
* @param value pointer to user context
*/
#define GNUNET_SERVER_client_set_user_context(client,value) \
GNUNET_SERVER_client_set_user_context_ (client, value, sizeof (*value))
/**
* Disable the warning the server issues if a message is not acknowledged * Disable the warning the server issues if a message is not acknowledged
* in a timely fashion. Use this call if a client is intentionally delayed * in a timely fashion. Use this call if a client is intentionally delayed
* for a while. Only applies to the current message. * for a while. Only applies to the current message.
* *
* @param client client for which to disable the warning * @param client client for which to disable the warning
*/ */
void void
GNUNET_SERVER_disable_receive_done_warning (struct GNUNET_SERVER_Client GNUNET_SERVER_disable_receive_done_warning (struct GNUNET_SERVER_Client
*client); *client);
/** /**
* Inject a message into the server, pretend it came * Inject a message into the server, pretend it came
* from the specified client. Delivery of the message * from the specified client. Delivery of the message
* will happen instantly (if a handler is installed; * will happen instantly (if a handler is installed;
* otherwise the call does nothing). * otherwise the call does nothing).
* *
* @param server the server receiving the message * @param server the server receiving the message
* @param sender the "pretended" sender of the message * @param sender the "pretended" sender of the message
* can be NULL! * can be NULL!
* @param message message to transmit * @param message message to transmit
* @return GNUNET_OK if the message was OK and the * @return #GNUNET_OK if the message was OK and the
* connection can stay open * connection can stay open
* GNUNET_SYSERR if the connection to the * #GNUNET_SYSERR if the connection to the
* client should be shut down * client should be shut down
*/ */
int int
GNUNET_SERVER_inject (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_inject (struct GNUNET_SERVER_Handle *server,
struct GNUNET_SERVER_Client *sender, struct GNUNET_SERVER_Client *sender,
const struct GNUNET_MessageHeader *message); const struct GNUNET_MessageHeader *message);
/** /**
* Add a TCP socket-based connection to the set of handles managed by * Add a TCP socket-based connection to the set of handles managed by
* this server. Use this function for outgoing (P2P) connections that * this server. Use this function for outgoing (P2P) connections that
* we initiated (and where this server should process incoming * we initiated (and where this server should process incoming
* messages). * messages).
* *
* @param server the server to use * @param server the server to use
* @param connection the connection to manage (client must * @param connection the connection to manage (client must
* stop using this connection from now on) * stop using this connection from now on)
* @return the client handle (client should call * @return the client handle (client should call
* "client_drop" on the return value eventually) * #GNUNET_SERVER_client_drop on the return value eventually)
*/ */
struct GNUNET_SERVER_Client * struct GNUNET_SERVER_Client *
GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server,
struct GNUNET_CONNECTION_Handle *connection); struct GNUNET_CONNECTION_Handle *connection);
/** /**
* Notify the server that the given client handle should * Notify the server that the given client handle should
* be kept (keeps the connection up if possible, increments * be kept (keeps the connection up if possible, increments
* the internal reference counter). * the internal reference counter).
* *
skipping to change at line 356 skipping to change at line 408
* @param client the client to drop * @param client the client to drop
*/ */
void void
GNUNET_SERVER_client_drop (struct GNUNET_SERVER_Client *client); GNUNET_SERVER_client_drop (struct GNUNET_SERVER_Client *client);
/** /**
* Obtain the network address of the other party. * Obtain the network address of the other party.
* *
* @param client the client to get the address for * @param client the client to get the address for
* @param addr where to store the address * @param addr where to store the address
* @param addrlen where to store the length of the address * @param addrlen where to store the length of @a addr
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_SERVER_client_get_address (struct GNUNET_SERVER_Client *client, GNUNET_SERVER_client_get_address (struct GNUNET_SERVER_Client *client,
void **addr, size_t * addrlen); void **addr, size_t *addrlen);
/** /**
* Functions with this signature are called whenever a client * Functions with this signature are called whenever a client
* is disconnected on the network level. * is disconnected on the network level.
* *
* @param cls closure * @param cls closure
* @param client identification of the client; NULL * @param client identification of the client; NULL
* for the last call when the server is destroyed * for the last call when the server is destroyed
*/ */
typedef void (*GNUNET_SERVER_DisconnectCallback) (void *cls, typedef void (*GNUNET_SERVER_DisconnectCallback) (void *cls,
struct GNUNET_SERVER_Clie struct GNUNET_SERVER_Clie
nt * nt *client);
client);
/**
* Functions with this signature are called whenever a client
* is connected on the network level.
*
* @param cls closure
* @param client identification of the client
*/
typedef void (*GNUNET_SERVER_ConnectCallback) (void *cls,
struct GNUNET_SERVER_Client *
client);
/** /**
* Ask the server to notify us whenever a client disconnects. * Ask the server to notify us whenever a client disconnects.
* This function is called whenever the actual network connection * This function is called whenever the actual network connection
* is closed; the reference count may be zero or larger than zero * is closed; the reference count may be zero or larger than zero
* at this point. If the server is destroyed before this * at this point. If the server is destroyed before this
* notification is explicitly cancelled, the 'callback' will * notification is explicitly cancelled, the 'callback' will
* once be called with a 'client' argument of NULL to indicate * once be called with a 'client' argument of NULL to indicate
* that the server itself is now gone (and that the callback * that the server itself is now gone (and that the callback
* won't be called anymore and also can no longer be cancelled). * won't be called anymore and also can no longer be cancelled).
* *
* @param server the server manageing the clients * @param server the server manageing the clients
* @param callback function to call on disconnect * @param callback function to call on disconnect
* @param callback_cls closure for callback * @param callback_cls closure for @a callback
*/ */
void void
GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server,
GNUNET_SERVER_DisconnectCallback callback, GNUNET_SERVER_DisconnectCallback callback,
void *callback_cls); void *callback_cls);
/** /**
* Ask the server to notify us whenever a client connects.
* This function is called whenever the actual network connection
* is opened. If the server is destroyed before this
* notification is explicitly cancelled, the @a callback will
* once be called with a 'client' argument of NULL to indicate
* that the server itself is now gone (and that the callback
* won't be called anymore and also can no longer be cancelled).
*
* @param server the server manageing the clients
* @param callback function to call on sconnect
* @param callback_cls closure for @a callback
*/
void
GNUNET_SERVER_connect_notify (struct GNUNET_SERVER_Handle *server,
GNUNET_SERVER_ConnectCallback callback,
void *callback_cls);
/**
* Ask the server to stop notifying us whenever a client disconnects. * Ask the server to stop notifying us whenever a client disconnects.
* Arguments must match exactly those given to
* #GNUNET_SERVER_disconnect_notify. It is not necessary to call this
* function during shutdown of the server; in fact, most applications
* will never use this function.
* *
* @param server the server manageing the clients * @param server the server manageing the clients
* @param callback function to call on disconnect * @param callback function to call on disconnect
* @param callback_cls closure for callback * @param callback_cls closure for @a callback
*/ */
void void
GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server , GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server ,
GNUNET_SERVER_DisconnectCallback GNUNET_SERVER_DisconnectCallback ca
callback, void *callback_cls); llback,
void *callback_cls);
/**
* Ask the server to stop notifying us whenever a client connects.
* Arguments must match exactly those given to
* #GNUNET_SERVER_connect_notify. It is not necessary to call this
* function during shutdown of the server; in fact, most applications
* will never use this function.
*
* @param server the server manageing the clients
* @param callback function to call on connect
* @param callback_cls closure for @a callback
*/
void
GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server,
GNUNET_SERVER_ConnectCallback callback,
void *callback_cls);
/** /**
* Ask the server to disconnect from the given client. * Ask the server to disconnect from the given client. This is the
* This is the same as returning GNUNET_SYSERR from a message * same as passing #GNUNET_SYSERR to #GNUNET_SERVER_receive_done,
* handler, except that it allows dropping of a client even * except that it allows dropping of a client even when not handling a
* when not handling a message from that client. * message from that client.
* *
* @param client the client to disconnect from * @param client the client to disconnect from
*/ */
void void
GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client); GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client);
/** /**
* Disable the "CORK" feature for communication with the given client, * Disable the "CORK" feature for communication with the given client,
* forcing the OS to immediately flush the buffer on transmission * forcing the OS to immediately flush the buffer on transmission
* instead of potentially buffering multiple messages. * instead of potentially buffering multiple messages.
* *
* @param client handle to the client * @param client handle to the client
* @return GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
GNUNET_SERVER_client_disable_corking (struct GNUNET_SERVER_Client *client); GNUNET_SERVER_client_disable_corking (struct GNUNET_SERVER_Client *client);
/** /**
* The tansmit context is the key datastructure for a conveniance API * The tansmit context is the key datastructure for a conveniance API
* used for transmission of complex results to the client followed * used for transmission of complex results to the client followed
* ONLY by signaling receive_done with success or error * ONLY by signaling receive_done with success or error
*/ */
struct GNUNET_SERVER_TransmitContext; struct GNUNET_SERVER_TransmitContext;
/** /**
* Create a new transmission context for the * Create a new transmission context for the given client.
* given client.
* *
* @param client client to create the context for. * @param client client to create the context for.
* @return NULL on error * @return NULL on error
*/ */
struct GNUNET_SERVER_TransmitContext * struct GNUNET_SERVER_TransmitContext *
GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client) ; GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client) ;
/** /**
* Append a message to the transmission context. * Append a message to the transmission context.
* All messages in the context will be sent by * All messages in the context will be sent by
* the transmit_context_run method. * the #GNUNET_SERVER_transmit_context_run method.
* *
* @param tc context to use * @param tc context to use
* @param data what to append to the result message * @param data what to append to the result message
* @param length length of data * @param length length of @a data
* @param type type of the message * @param type type of the message
*/ */
void void
GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitCo GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitCo
ntext ntext *tc,
*tc, const void *data, const void *data,
size_t length, uint16_t type); size_t length, uint16_t type);
/** /**
* Append a message to the transmission context. * Append a message to the transmission context.
* All messages in the context will be sent by * All messages in the context will be sent by
* the transmit_context_run method. * the transmit_context_run method.
* *
* @param tc context to use * @param tc context to use
* @param msg message to append * @param msg message to append
*/ */
void void
GNUNET_SERVER_transmit_context_append_message (struct GNUNET_SERVER_transmit_context_append_message (struct GNUNET_SERVER_Transmi
GNUNET_SERVER_TransmitContex tContext *tc,
t const struct GNUNET_MessageH
*tc, eader *msg);
const struct GNUNET_MessageH
eader
*msg);
/** /**
* Execute a transmission context. If there is an error in the * Execute a transmission context. If there is an error in the
* transmission, the receive_done method will be called with an error * transmission, the receive_done method will be called with an error
* code (GNUNET_SYSERR), otherwise with GNUNET_OK. * code (#GNUNET_SYSERR), otherwise with #GNUNET_OK.
* *
* @param tc transmission context to use * @param tc transmission context to use
* @param timeout when to time out and abort the transmission * @param timeout when to time out and abort the transmission
*/ */
void void
GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *t c, GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *t c,
struct GNUNET_TIME_Relative timeout); struct GNUNET_TIME_Relative timeout);
/** /**
* Destroy a transmission context. This function must not be called * Destroy a transmission context. This function must not be called
* after 'GNUNET_SERVER_transmit_context_run'. * after #GNUNET_SERVER_transmit_context_run.
* *
* @param tc transmission context to destroy * @param tc transmission context to destroy
* @param success code to give to 'GNUNET_SERVER_receive_done' for * @param success code to give to #GNUNET_SERVER_receive_done for
* the client: GNUNET_OK to keep the connection open and * the client: #GNUNET_OK to keep the connection open and
* continue to receive * continue to receive
* GNUNET_NO to close the connection (normal behavior) * #GNUNET_NO to close the connection (normal behavior)
* GNUNET_SYSERR to close the connection (signal * #GNUNET_SYSERR to close the connection (signal
* serious error) * serious error)
*/ */
void void
GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContex GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContex
t t *tc,
*tc, int success); int success);
/** /**
* The notification context is the key datastructure for a conveniance * The notification context is the key datastructure for a conveniance
* API used for transmission of notifications to the client until the * API used for transmission of notifications to the client until the
* client disconnects or is disconnected (or the notification context * client disconnects or is disconnected (or the notification context
* is destroyed, in which case we disconnect these clients). * is destroyed, in which case we disconnect these clients).
* Essentially, all (notification) messages are queued up until the * Essentially, all (notification) messages are queued up until the
* client is able to read them. * client is able to read them.
*/ */
struct GNUNET_SERVER_NotificationContext; struct GNUNET_SERVER_NotificationContext;
skipping to change at line 532 skipping to change at line 627
struct GNUNET_SERVER_NotificationContext * struct GNUNET_SERVER_NotificationContext *
GNUNET_SERVER_notification_context_create (struct GNUNET_SERVER_Handle *ser ver, GNUNET_SERVER_notification_context_create (struct GNUNET_SERVER_Handle *ser ver,
unsigned int queue_length); unsigned int queue_length);
/** /**
* Destroy the context, force disconnect for all clients. * Destroy the context, force disconnect for all clients.
* *
* @param nc context to destroy. * @param nc context to destroy.
*/ */
void void
GNUNET_SERVER_notification_context_destroy (struct GNUNET_SERVER_notification_context_destroy (struct GNUNET_SERVER_Notificati
GNUNET_SERVER_NotificationConte onContext *nc);
xt
*nc);
/** /**
* Add a client to the notification context. * Add a client to the notification context.
* *
* @param nc context to modify * @param nc context to modify
* @param client client to add * @param client client to add
*/ */
void void
GNUNET_SERVER_notification_context_add (struct GNUNET_SERVER_NotificationCo GNUNET_SERVER_notification_context_add (struct GNUNET_SERVER_NotificationCo
ntext ntext *nc,
*nc,
struct GNUNET_SERVER_Client *client ); struct GNUNET_SERVER_Client *client );
/** /**
* Send a message to a particular client; must have * Send a message to a particular client; must have
* already been added to the notification context. * already been added to the notification context.
* *
* @param nc context to modify * @param nc context to modify
* @param client client to transmit to * @param client client to transmit to
* @param msg message to send * @param msg message to send
* @param can_drop can this message be dropped due to queue length limitati ons * @param can_drop can this message be dropped due to queue length limitati ons
*/ */
void void
GNUNET_SERVER_notification_context_unicast (struct GNUNET_SERVER_notification_context_unicast (struct GNUNET_SERVER_Notificati
GNUNET_SERVER_NotificationConte onContext *nc,
xt
*nc,
struct GNUNET_SERVER_Client *cl ient, struct GNUNET_SERVER_Client *cl ient,
const struct GNUNET_MessageHead const struct GNUNET_MessageHead
er er *msg,
*msg, int can_drop); int can_drop);
/** /**
* Send a message to all clients of this context. * Send a message to all clients of this context.
* *
* @param nc context to modify * @param nc context to modify
* @param msg message to send * @param msg message to send
* @param can_drop can this message be dropped due to queue length limitati ons * @param can_drop can this message be dropped due to queue length limitati ons
*/ */
void void
GNUNET_SERVER_notification_context_broadcast (struct GNUNET_SERVER_notification_context_broadcast (struct GNUNET_SERVER_Notifica
GNUNET_SERVER_NotificationCon tionContext *nc,
text const struct GNUNET_MessageHe
*nc, ader *msg,
const struct GNUNET_MessageHe int can_drop);
ader
*msg, int can_drop);
/** /**
* Handle to a message stream tokenizer. * Handle to a message stream tokenizer.
*/ */
struct GNUNET_SERVER_MessageStreamTokenizer; struct GNUNET_SERVER_MessageStreamTokenizer;
/** /**
* Functions with this signature are called whenever a * Functions with this signature are called whenever a
* complete message is received by the tokenizer. * complete message is received by the tokenizer.
* *
* Do not call GNUNET_SERVER_mst_destroy in callback * Do not call #GNUNET_SERVER_mst_destroy from within
* the scope of this callback.
* *
* @param cls closure * @param cls closure
* @param client identification of the client * @param client identification of the client
* @param message the actual message * @param message the actual message
* * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
* @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing
*/ */
typedef int (*GNUNET_SERVER_MessageTokenizerCallback) (void *cls, void *cli ent, typedef int (*GNUNET_SERVER_MessageTokenizerCallback) (void *cls, void *cli ent,
const struct const struct GNUNET_
GNUNET_MessageHeade MessageHeader *message);
r *
message);
/** /**
* Create a message stream tokenizer. * Create a message stream tokenizer.
* *
* @param cb function to call on completed messages * @param cb function to call on completed messages
* @param cb_cls closure for cb * @param cb_cls closure for @a cb
* @return handle to tokenizer * @return handle to tokenizer
*/ */
struct GNUNET_SERVER_MessageStreamTokenizer * struct GNUNET_SERVER_MessageStreamTokenizer *
GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb, GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Add incoming data to the receive buffer and call the * Add incoming data to the receive buffer and call the
* callback for all complete messages. * callback for all complete messages.
* *
* @param mst tokenizer to use * @param mst tokenizer to use
* @param client_identity ID of client for which this is a buffer, * @param client_identity ID of client for which this is a buffer,
* can be NULL (will be passed back to 'cb') * can be NULL (will be passed back to 'cb')
* @param buf input data to add * @param buf input data to add
* @param size number of bytes in buf * @param size number of bytes in @a buf
* @param purge should any excess bytes in the buffer be discarded * @param purge should any excess bytes in the buffer be discarded
* (i.e. for packet-based services like UDP) * (i.e. for packet-based services like UDP)
* @param one_shot only call callback once, keep rest of message in buffer * @param one_shot only call callback once, keep rest of message in buffer
* @return GNUNET_OK if we are done processing (need more data) * @return #GNUNET_OK if we are done processing (need more data)
* GNUNET_NO if one_shot was set and we have another message ready * #GNUNET_NO if one_shot was set and we have another message ready
* GNUNET_SYSERR if the data stream is corrupt * #GNUNET_SYSERR if the data stream is corrupt
*/ */
int int
GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst , GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst ,
void *client_identity, const char *buf, size_t s void *client_identity,
ize, const char *buf, size_t size,
int purge, int one_shot); int purge, int one_shot);
/** /**
* Destroys a tokenizer. * Destroys a tokenizer.
* *
* @param mst tokenizer to destroy * @param mst tokenizer to destroy
*/ */
void void
GNUNET_SERVER_mst_destroy (struct GNUNET_SERVER_MessageStreamTokenizer *mst ); GNUNET_SERVER_mst_destroy (struct GNUNET_SERVER_MessageStreamTokenizer *mst );
/** /**
* Signature of a function to create a custom tokenizer. * Signature of a function to create a custom tokenizer.
* *
* @param cls closure from 'GNUNET_SERVER_set_callbacks' * @param cls closure from #GNUNET_SERVER_set_callbacks
* @param client handle to client the tokenzier will be used for * @param client handle to client the tokenzier will be used for
* @return handle to custom tokenizer ('mst') * @return handle to custom tokenizer ('mst')
*/ */
typedef void* (*GNUNET_SERVER_MstCreateCallback) (void *cls, typedef void* (*GNUNET_SERVER_MstCreateCallback) (void *cls,
struct GNUNET_SERVER_Clie nt *client); struct GNUNET_SERVER_Clie nt *client);
/** /**
* Signature of a function to destroy a custom tokenizer. * Signature of a function to destroy a custom tokenizer.
* *
* @param cls closure from 'GNUNET_SERVER_set_callbacks' * @param cls closure from #GNUNET_SERVER_set_callbacks
* @param mst custom tokenizer handle * @param mst custom tokenizer handle
*/ */
typedef void (*GNUNET_SERVER_MstDestroyCallback) (void *cls, void *mst); typedef void (*GNUNET_SERVER_MstDestroyCallback) (void *cls, void *mst);
/** /**
* Signature of a function to destroy a custom tokenizer. * Signature of a function to receive data for a custom tokenizer.
* *
* @param cls closure from 'GNUNET_SERVER_set_callbacks' * @param cls closure from #GNUNET_SERVER_set_callbacks
* @param mst custom tokenizer handle * @param mst custom tokenizer handle
* @param client_identity ID of client for which this is a buffer, * @param client_identity ID of client for which this is a buffer,
* can be NULL (will be passed back to 'cb') * can be NULL (will be passed back to 'cb')
* @param buf input data to add * @param buf input data to add
* @param size number of bytes in buf * @param size number of bytes in @a buf
* @param purge should any excess bytes in the buffer be discarded * @param purge should any excess bytes in the buffer be discarded
* (i.e. for packet-based services like UDP) * (i.e. for packet-based services like UDP)
* @param one_shot only call callback once, keep rest of message in buffer * @param one_shot only call callback once, keep rest of message in buffer
* @return GNUNET_OK if we are done processing (need more data) * @return #GNUNET_OK if we are done processing (need more data)
* GNUNET_NO if one_shot was set and we have another message ready * #GNUNET_NO if one_shot was set and we have another message ready
* GNUNET_SYSERR if the data stream is corrupt * #GNUNET_SYSERR if the data stream is corrupt
*/ */
typedef int (*GNUNET_SERVER_MstReceiveCallback) (void *cls, void *mst, typedef int (*GNUNET_SERVER_MstReceiveCallback) (void *cls, void *mst,
struct GNUNET_SERVER_Clien t *client, struct GNUNET_SERVER_Clien t *client,
const char *buf, size_t si ze, const char *buf, size_t si ze,
int purge, int one_shot); int purge, int one_shot);
/** /**
* Change functions used by the server to tokenize the message stream. * Change functions used by the server to tokenize the message stream.
* (very rarely used). * (very rarely used).
* *
* @param server server to modify * @param server server to modify
* @param create new tokenizer initialization function * @param create new tokenizer initialization function
* @param destroy new tokenizer destruction function * @param destroy new tokenizer destruction function
* @param receive new tokenizer receive function * @param receive new tokenizer receive function
* @param cls closure for 'create', 'receive', 'destroy' * @param cls closure for @a create, @a receive and @a destroy
*/ */
void void
GNUNET_SERVER_set_callbacks (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_set_callbacks (struct GNUNET_SERVER_Handle *server,
GNUNET_SERVER_MstCreateCallback create, GNUNET_SERVER_MstCreateCallback create,
GNUNET_SERVER_MstDestroyCallback destroy, GNUNET_SERVER_MstDestroyCallback destroy,
GNUNET_SERVER_MstReceiveCallback receive, GNUNET_SERVER_MstReceiveCallback receive,
void *cls); void *cls);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group server */
/* ifndef GNUNET_SERVER_LIB_H */ /* ifndef GNUNET_SERVER_LIB_H */
#endif #endif
/* end of gnunet_server_lib.h */ /* end of gnunet_server_lib.h */
 End of changes. 71 change blocks. 
121 lines changed or deleted 216 lines changed or added


 gnunet_service_lib.h   gnunet_service_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_service_lib.h * @file include/gnunet_service_lib.h
* @brief functions related to starting services * @brief functions related to starting services
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup service generic functions for implementing service processes
* @{
*/ */
#ifndef GNUNET_SERVICE_LIB_H #ifndef GNUNET_SERVICE_LIB_H
#define GNUNET_SERVICE_LIB_H #define GNUNET_SERVICE_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
skipping to change at line 51 skipping to change at line 53
/** /**
* Get the list of addresses that a server for the given service * Get the list of addresses that a server for the given service
* should bind to. * should bind to.
* *
* @param service_name name of the service * @param service_name name of the service
* @param cfg configuration (which specifies the addresses) * @param cfg configuration (which specifies the addresses)
* @param addrs set (call by reference) to an array of pointers to the * @param addrs set (call by reference) to an array of pointers to the
* addresses the server should bind to and listen on; the * addresses the server should bind to and listen on; the
* array will be NULL-terminated (on success) * array will be NULL-terminated (on success)
* @param addr_lens set (call by reference) to an array of the lengths * @param addr_lens set (call by reference) to an array of the lengths
* of the respective 'struct sockaddr' struct in the 'addrs' * of the respective 'struct sockaddr' struct in the @a addrs
* array (on success) * array (on success)
* @return number of addresses found on success, * @return number of addresses found on success,
* GNUNET_SYSERR if the configuration * #GNUNET_SYSERR if the configuration
* did not specify reasonable finding information or * did not specify reasonable finding information or
* if it specified a hostname that could not be resolved; * if it specified a hostname that could not be resolved;
* GNUNET_NO if the number of addresses configured is * #GNUNET_NO if the number of addresses configured is
* zero (in this case, '*addrs' and '*addr_lens' will be * zero (in this case, '* @a addrs' and '* @a addr_lens' will
be
* set to NULL). * set to NULL).
*/ */
int int
GNUNET_SERVICE_get_server_addresses (const char *service_name, GNUNET_SERVICE_get_server_addresses (const char *service_name,
const struct GNUNET_CONFIGURATION_Hand le const struct GNUNET_CONFIGURATION_Hand le
*cfg, struct sockaddr ***addrs, *cfg, struct sockaddr ***addrs,
socklen_t ** addr_lens); socklen_t **addr_lens);
/** /**
* Function called by the service's run * Function called by the service's run
* method to run service-specific setup code. * method to run service-specific setup code.
* *
* @param cls closure * @param cls closure
* @param server the initialized server * @param server the initialized server
* @param cfg configuration to use * @param cfg configuration to use
*/ */
typedef void (*GNUNET_SERVICE_Main) (void *cls, typedef void (*GNUNET_SERVICE_Main) (void *cls,
struct GNUNET_SERVER_Handle * server, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Hand const struct GNUNET_CONFIGURATION_Hand
le * le *cfg);
cfg);
/** /**
* Options for the service (bitmask). * Options for the service (bitmask).
*/ */
enum GNUNET_SERVICE_Options enum GNUNET_SERVICE_Options
{ {
/** /**
* Use defaults. * Use defaults.
*/ */
GNUNET_SERVICE_OPTION_NONE = 0, GNUNET_SERVICE_OPTION_NONE = 0,
skipping to change at line 107 skipping to change at line 108
* Trigger a SOFT server shutdown on signals, allowing active * Trigger a SOFT server shutdown on signals, allowing active
* non-monitor clients to complete their transactions. * non-monitor clients to complete their transactions.
*/ */
GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2 GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2
}; };
/** /**
* Run a standard GNUnet service startup sequence (initialize loggers * Run a standard GNUnet service startup sequence (initialize loggers
* and configuration, parse options). * and configuration, parse options).
* *
* @param argc number of command line arguments * @param argc number of command line arguments in @a argv
* @param argv command line arguments * @param argv command line arguments
* @param service_name our service name * @param service_name our service name
* @param options service options * @param options service options
* @param task main task of the service * @param task main task of the service
* @param task_cls closure for task * @param task_cls closure for @a task
* @return GNUNET_SYSERR on error, GNUNET_OK * @return #GNUNET_SYSERR on error, #GNUNET_OK
* if we shutdown nicely * if we shutdown nicely
*/ */
int int
GNUNET_SERVICE_run (int argc, char *const *argv, const char *service_name, GNUNET_SERVICE_run (int argc, char *const *argv,
enum GNUNET_SERVICE_Options options, GNUNET_SERVICE_Mai const char *service_name,
n task, enum GNUNET_SERVICE_Options options,
void *task_cls); GNUNET_SERVICE_Main task,
void *task_cls);
/** /**
* Opaque handle for a service. * Opaque handle for a service.
*/ */
struct GNUNET_SERVICE_Context; struct GNUNET_SERVICE_Context;
/** /**
* Run a service startup sequence within an existing * Run a service startup sequence within an existing
* initialized system. * initialized system.
* *
skipping to change at line 151 skipping to change at line 154
* Obtain the server used by a service. Note that the server must NOT * Obtain the server used by a service. Note that the server must NOT
* be destroyed by the caller. * be destroyed by the caller.
* *
* @param ctx the service context returned from the start function * @param ctx the service context returned from the start function
* @return handle to the server for this service, NULL if there is none * @return handle to the server for this service, NULL if there is none
*/ */
struct GNUNET_SERVER_Handle * struct GNUNET_SERVER_Handle *
GNUNET_SERVICE_get_server (struct GNUNET_SERVICE_Context *ctx); GNUNET_SERVICE_get_server (struct GNUNET_SERVICE_Context *ctx);
/** /**
* Stop a service that was started with "GNUNET_SERVICE_start". * Stop a service that was started with #GNUNET_SERVICE_start.
* *
* @param sctx the service context returned from the start function * @param sctx the service context returned from the start function
*/ */
void void
GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx); GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group service */
/* ifndef GNUNET_SERVICE_LIB_H */ /* ifndef GNUNET_SERVICE_LIB_H */
#endif #endif
/* end of gnunet_service_lib.h */ /* end of gnunet_service_lib.h */
 End of changes. 13 change blocks. 
19 lines changed or deleted 24 lines changed or added


 gnunet_signal_lib.h   gnunet_signal_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 74 skipping to change at line 74
/** /**
* Uninstall a previously installed signal hander. * Uninstall a previously installed signal hander.
* *
* @param ctx context that was returned when the * @param ctx context that was returned when the
* signal handler was installed * signal handler was installed
*/ */
void void
GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx); GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx);
/**
* Raise the given signal by calling the installed signal handlers. This w
ill
* not use the @em raise() system call but only calls the handlers register
ed
* through GNUNET_SIGNAL_handler_install().
*
* @param sig the signal to raise
*/
void
GNUNET_SIGNAL_raise (const int sig);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* ifndef GNUNET_SIGNAL_LIB_H */ /* ifndef GNUNET_SIGNAL_LIB_H */
#endif #endif
/* end of gnunet_signal_lib.h */ /* end of gnunet_signal_lib.h */
 End of changes. 2 change blocks. 
1 lines changed or deleted 13 lines changed or added


 gnunet_signatures.h   gnunet_signatures.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 56 skipping to change at line 56
* Signature for confirming that this peer uses a particular address. * Signature for confirming that this peer uses a particular address.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN 1 #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN 1
/** /**
* Signature for confirming that this peer intends to disconnect. * Signature for confirming that this peer intends to disconnect.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DISCONNECT 2 #define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DISCONNECT 2
/** /**
* Purpose is to set a session key. * Signature for confirming a key revocation.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_SET_KEY 3 #define GNUNET_SIGNATURE_PURPOSE_REVOCATION 3
/** /**
* Signature for a namespace/pseudonym advertisement (by * Signature for a namespace/pseudonym advertisement (by
* the namespace owner). * the namespace owner).
*/ */
#define GNUNET_SIGNATURE_PURPOSE_NAMESPACE_ADVERTISEMENT 4 #define GNUNET_SIGNATURE_PURPOSE_NAMESPACE_ADVERTISEMENT 4
/** /**
* Signature by which a peer affirms that it is * Signature by which a peer affirms that it is
* providing a certain bit of content (used * providing a certain bit of content (used
* in LOCation URIs). * in LOCation URIs).
*/ */
#define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT 5 #define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT 5
/** /**
* Signature in a KBlock of the FS module. * Obsolete, legacy value.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK 6 #define GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK 6
/** /**
* Signature of content URI placed into a namespace. * Obsolete, legacy value.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK 7 #define GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK 7
/** /**
* Signature of advertisment for a namespace. * Obsolete, legacy value.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK 8 #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK 8
/** /**
* Keyword-based signature of advertisment for a namespace. * Obsolete, legacy value.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG 9 #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG 9
/** /**
* *
*/ */
#define GNUNET_SIGNATURE_PURPOSE_RESOLVER_RESPONSE 10 #define GNUNET_SIGNATURE_PURPOSE_RESOLVER_RESPONSE 10
/** /**
* Signature of an GNUNET_DNS_Record * Signature of an GNUNET_DNS_Advertisement
*/ */
#define GNUNET_SIGNATURE_PURPOSE_DNS_RECORD 11 #define GNUNET_SIGNATURE_PURPOSE_DNS_RECORD 11
/** /**
* Signature of a chat message. * Signature of a chat message.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE 12 #define GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE 12
/** /**
* Signature of confirmation receipt for a chat message. * Signature of confirmation receipt for a chat message.
skipping to change at line 123 skipping to change at line 123
/** /**
* Signature of a network size estimate message. * Signature of a network size estimate message.
*/ */
#define GNUNET_SIGNATURE_PURPOSE_NSE_SEND 14 #define GNUNET_SIGNATURE_PURPOSE_NSE_SEND 14
/** /**
* Signature of a gnunet naming system record block * Signature of a gnunet naming system record block
*/ */
#define GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN 15 #define GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN 15
/**
* Purpose is to set a session key.
*/
#define GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY 16
/**
* UBlock Signature, done using DSS, not ECC
*/
#define GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK 17
/**
* Accept state in regex DFA. Peer affirms that
* he offers the matching service.
*/
#define GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT 18
/**
* Signature of a multicast message.
*/
#define GNUNET_SIGNATURE_PURPOSE_MULTICAST_MESSAGE 19
/**
* Signature of a conversation ring.
*/
#define GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING 20
/**
* Key exchange in MESH
*/
#define GNUNET_SIGNATURE_PURPOSE_MESH_KX 21
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* ifndef GNUNET_SIGNATURES_H */ /* ifndef GNUNET_SIGNATURES_H */
#endif #endif
/* end of gnunet_signatures.h */ /* end of gnunet_signatures.h */
 End of changes. 9 change blocks. 
8 lines changed or deleted 39 lines changed or added


 gnunet_statistics_service.h   gnunet_statistics_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2009, 2010 Christian Grothoff (and other contributing authors) (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_statistics_service.h * @file include/gnunet_statistics_service.h
* @brief API to create, modify and access statistics about * @brief API to create, modify and access statistics about
* the operation of GNUnet; all statistical values * the operation of GNUnet; all statistical values
* must be of type "unsigned long long". * must be of type `unsigned long long`.
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup statistics track statistics or provide access to statistics
* @{
*/ */
#ifndef GNUNET_STATISTICS_SERVICE_H #ifndef GNUNET_STATISTICS_SERVICE_H
#define GNUNET_STATISTICS_SERVICE_H #define GNUNET_STATISTICS_SERVICE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h" #include "gnunet_util_lib.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_scheduler_lib.h"
/** /**
* Version of the statistics API. * Version of the statistics API.
*/ */
#define GNUNET_STATISTICS_VERSION 0x00000000 #define GNUNET_STATISTICS_VERSION 0x00000000
/** /**
* Opaque handle for the statistics service. * Opaque handle for the statistics service.
*/ */
struct GNUNET_STATISTICS_Handle; struct GNUNET_STATISTICS_Handle;
/** /**
* Callback function to process statistic values. * Callback function to process statistic values.
* *
* @param cls closure * @param cls closure
* @param subsystem name of subsystem that created the statistic * @param subsystem name of subsystem that created the statistic
* @param name the name of the datum * @param name the name of the datum
* @param value the current value * @param value the current value
* @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO
not if not
* @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/ */
typedef int (*GNUNET_STATISTICS_Iterator) (void *cls, const char *subsystem typedef int (*GNUNET_STATISTICS_Iterator) (void *cls,
, const char *subsystem,
const char *name, uint64_t value const char *name,
, uint64_t value,
int is_persistent); int is_persistent);
/** /**
* Get handle for the statistics service. * Get handle for the statistics service.
* *
* @param subsystem name of subsystem using the service * @param subsystem name of subsystem using the service
* @param cfg services configuration in use * @param cfg services configuration in use
* @return handle to use * @return handle to use
*/ */
struct GNUNET_STATISTICS_Handle * struct GNUNET_STATISTICS_Handle *
GNUNET_STATISTICS_create (const char *subsystem, GNUNET_STATISTICS_create (const char *subsystem,
const struct GNUNET_CONFIGURATION_Handle *cfg); const struct GNUNET_CONFIGURATION_Handle *cfg);
/** /**
* Destroy a handle (free all state associated with * Destroy a handle (free all state associated with
* it). * it).
* *
* @param h statistics handle to destroy * @param h statistics handle to destroy
* @param sync_first set to GNUNET_YES if pending SET requests should * @param sync_first set to #GNUNET_YES if pending SET requests should
* be completed * be completed
*/ */
void void
GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_fir GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h,
st); int sync_first);
/** /**
* Watch statistics from the peer (be notified whenever they change). * Watch statistics from the peer (be notified whenever they change).
* *
* @param handle identification of the statistics service * @param handle identification of the statistics service
* @param subsystem limit to the specified subsystem, never NULL * @param subsystem limit to the specified subsystem, never NULL
* @param name name of the statistic value, never NULL * @param name name of the statistic value, never NULL
* @param proc function to call on each value * @param proc function to call on each value
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle,
const char *subsystem, const char *name, const char *subsystem,
GNUNET_STATISTICS_Iterator proc, void *proc_cls); const char *name,
GNUNET_STATISTICS_Iterator proc,
void *proc_cls);
/** /**
* Stop watching statistics from the peer. * Stop watching statistics from the peer.
* *
* @param handle identification of the statistics service * @param handle identification of the statistics service
* @param subsystem limit to the specified subsystem, never NULL * @param subsystem limit to the specified subsystem, never NULL
* @param name name of the statistic value, never NULL * @param name name of the statistic value, never NULL
* @param proc function to call on each value * @param proc function to call on each value
* @param proc_cls closure for proc * @param proc_cls closure for @a proc
* @return GNUNET_OK on success, GNUNET_SYSERR on error (no such watch) * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (no such watch)
*/ */
int int
GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle,
const char *subsystem, const char *name, const char *subsystem,
GNUNET_STATISTICS_Iterator proc, void *proc_ const char *name,
cls); GNUNET_STATISTICS_Iterator proc,
void *proc_cls);
/** /**
* Continuation called by the "get_all" and "get" functions. * Continuation called by #GNUNET_STATISTICS_get functions.
* *
* @param cls closure * @param cls closure
* @param success GNUNET_OK if statistics were * @param success #GNUNET_OK if statistics were
* successfully obtained, GNUNET_SYSERR if not. * successfully obtained, #GNUNET_SYSERR if not.
*/ */
typedef void (*GNUNET_STATISTICS_Callback) (void *cls, int success); typedef void (*GNUNET_STATISTICS_Callback) (void *cls,
int success);
/** /**
* Handle that can be used to cancel a statistics 'get' operation. * Handle that can be used to cancel a statistics 'get' operation.
*/ */
struct GNUNET_STATISTICS_GetHandle; struct GNUNET_STATISTICS_GetHandle;
/** /**
* Get statistic from the peer. * Get statistic from the peer.
* *
* @param handle identification of the statistics service * @param handle identification of the statistics service
* @param subsystem limit to the specified subsystem, NULL for our subsyste m * @param subsystem limit to the specified subsystem, NULL for all subsyste ms
* @param name name of the statistic value, NULL for all values * @param name name of the statistic value, NULL for all values
* @param timeout after how long should we give up (and call * @param timeout after how long should we give up (and call
* notify with buf NULL and size 0)? * notify with buf NULL and size 0)?
* @param cont continuation to call when done (can be NULL) * @param cont continuation to call when done (can be NULL)
* This callback CANNOT destroy the statistics handle in the same ca ll. * This callback CANNOT destroy the statistics handle in the same ca ll.
* @param proc function to call on each value * @param proc function to call on each value
* @param cls closure for proc and cont * @param cls closure for @a proc and @a cont
* @return NULL on error * @return NULL on error
*/ */
struct GNUNET_STATISTICS_GetHandle * struct GNUNET_STATISTICS_GetHandle *
GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle,
const char *subsystem, const char *name, const char *subsystem,
const char *name,
struct GNUNET_TIME_Relative timeout, struct GNUNET_TIME_Relative timeout,
GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Callback cont,
GNUNET_STATISTICS_Iterator proc, void *cls); GNUNET_STATISTICS_Iterator proc, void *cls);
/** /**
* Cancel a 'get' request. Must be called before the 'cont' * Cancel a #GNUNET_STATISTICS_get request. Must be called before the 'con t'
* function is called. * function is called.
* *
* @param gh handle of the request to cancel * @param gh handle of the request to cancel
*/ */
void void
GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh); GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh);
/** /**
* Set statistic value for the peer. Will always use our * Set statistic value for the peer. Will always use our
* subsystem (the argument used when "handle" was created). * subsystem (the argument used when @a handle was created).
* *
* @param handle identification of the statistics service * @param handle identification of the statistics service
* @param name name of the statistic value * @param name name of the statistic value
* @param value new value to set * @param value new value to set
* @param make_persistent should the value be kept across restarts? * @param make_persistent should the value be kept across restarts?
*/ */
void void
GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
const char *name, uint64_t value, int make_persisten const char *name,
t); uint64_t value,
int make_persistent);
/** /**
* Set statistic value for the peer. Will always use our * Set statistic value for the peer. Will always use our
* subsystem (the argument used when "handle" was created). * subsystem (the argument used when @a handle was created).
* *
* @param handle identification of the statistics service * @param handle identification of the statistics service
* @param name name of the statistic value * @param name name of the statistic value
* @param delta change in value (added to existing value) * @param delta change in value (added to existing value)
* @param make_persistent should the value be kept across restarts? * @param make_persistent should the value be kept across restarts?
*/ */
void void
GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
const char *name, int64_t delta, int make_persist const char *name,
ent); int64_t delta,
int make_persistent);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group statistics */
#endif #endif
 End of changes. 25 change blocks. 
39 lines changed or deleted 48 lines changed or added


 gnunet_strings_lib.h   gnunet_strings_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 Christian Gro thoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 57 skipping to change at line 57
#endif #endif
#endif #endif
#include "gnunet_time_lib.h" #include "gnunet_time_lib.h"
/** /**
* Convert a given fancy human-readable size to bytes. * Convert a given fancy human-readable size to bytes.
* *
* @param fancy_size human readable string (i.e. 1 MB) * @param fancy_size human readable string (i.e. 1 MB)
* @param size set to the size in bytes * @param size set to the size in bytes
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
unsigned long long *size); unsigned long long *size);
/** /**
* Convert a given fancy human-readable time to our internal * Convert a given fancy human-readable time to our internal
* representation. * representation.
* *
* @param fancy_time human readable string (i.e. 1 minute) * @param fancy_time human readable string (i.e. 1 minute)
* @param rtime set to the relative time * @param rtime set to the relative time
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time,
struct GNUNET_TIME_Relative *rtime); struct GNUNET_TIME_Relative *rtime);
/** /**
* @ingroup time
* Convert a given fancy human-readable time to our internal * Convert a given fancy human-readable time to our internal
* representation. * representation. The human-readable time is expected to be
* in local time, whereas the returned value will be in UTC.
* *
* @param fancy_time human readable string (i.e. %Y-%m-%d %H:%M:%S) * @param fancy_time human readable string (i.e. %Y-%m-%d %H:%M:%S)
* @param atime set to the absolute time * @param atime set to the absolute time
* @return GNUNET_OK on success, GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
int int
GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
struct GNUNET_TIME_Absolute *atime); struct GNUNET_TIME_Absolute *atime);
/** /**
* Convert a given filesize into a fancy human-readable format. * Convert a given filesize into a fancy human-readable format.
* *
* @param size number of bytes * @param size number of bytes
* @return fancy representation of the size (possibly rounded) for humans * @return fancy representation of the size (possibly rounded) for humans
*/ */
char * char *
GNUNET_STRINGS_byte_size_fancy (unsigned long long size); GNUNET_STRINGS_byte_size_fancy (unsigned long long size);
/** /**
* Convert the len characters long character sequence * Convert the len characters long character sequence
* given in input that is in the given input charset * given in input that is in the given input charset
* to a string in given output charset. * to a string in given output charset.
*
* @param input input string
* @param len number of bytes in @a input
* @param input_charset character set used for @a input
* @param output_charset desired character set for the return value
* @return the converted string (0-terminated), * @return the converted string (0-terminated),
* if conversion fails, a copy of the orignal * if conversion fails, a copy of the orignal
* string is returned. * string is returned.
*/ */
char * char *
GNUNET_STRINGS_conv (const char *input, size_t len, GNUNET_STRINGS_conv (const char *input, size_t len,
const char *input_charset, const char *input_charset,
const char *output_charset); const char *output_charset);
/** /**
* Convert the len characters long character sequence * Convert the len characters long character sequence
* given in input that is in the given charset * given in input that is in the given charset
* to UTF-8. * to UTF-8.
* *
* @param input the input string (not necessarily 0-terminated) * @param input the input string (not necessarily 0-terminated)
* @param len the number of bytes in the input * @param len the number of bytes in the @a input
* @param charset character set to convert from * @param charset character set to convert from
* @return the converted string (0-terminated) * @return the converted string (0-terminated)
*/ */
char * char *
GNUNET_STRINGS_to_utf8 (const char *input, GNUNET_STRINGS_to_utf8 (const char *input,
size_t len, size_t len,
const char *charset); const char *charset);
/** /**
* Convert the len bytes-long UTF-8 string * Convert the len bytes-long UTF-8 string
* given in input to the given charset. * given in input to the given charset.
*
* @param input the input string (not necessarily 0-terminated)
* @param len the number of bytes in the @a input
* @param charset character set to convert to
* @return the converted string (0-terminated), * @return the converted string (0-terminated),
* if conversion fails, a copy of the orignal * if conversion fails, a copy of the orignal
* string is returned. * string is returned.
*/ */
char * char *
GNUNET_STRINGS_from_utf8 (const char *input, GNUNET_STRINGS_from_utf8 (const char *input,
size_t len, size_t len,
const char *charset); const char *charset);
/** /**
* Convert the utf-8 input string to lowercase * Convert the utf-8 input string to lower case.
* Output needs to be allocated appropriately * Output needs to be allocated appropriately.
* *
* @param input input string * @param input input string
* @param output output buffer * @param output output buffer
*/ */
void void
GNUNET_STRINGS_utf8_tolower (const char* input, GNUNET_STRINGS_utf8_tolower (const char *input,
char** output); char *output);
/** /**
* Convert the utf-8 input string to lowercase * Convert the utf-8 input string to upper case.
* Output needs to be allocated appropriately * Output needs to be allocated appropriately.
* *
* @param input input string * @param input input string
* @param output output buffer * @param output output buffer
*/ */
void void
GNUNET_STRINGS_utf8_toupper (const char* input, GNUNET_STRINGS_utf8_toupper (const char *input,
char** output); char *output);
/** /**
* Complete filename (a la shell) from abbrevition. * Complete filename (a la shell) from abbrevition.
* *
* @param fil the name of the file, may contain ~/ or * @param fil the name of the file, may contain ~/ or
* be relative to the current directory * be relative to the current directory
* @return the full file name, * @return the full file name,
* NULL is returned on error * NULL is returned on error
*/ */
char * char *
skipping to change at line 201 skipping to change at line 211
size_t size, size_t size,
unsigned int count, unsigned int count,
...); ...);
/** /**
* Given a buffer of a given size, find "count" 0-terminated strings * Given a buffer of a given size, find "count" 0-terminated strings
* in the buffer and assign the count (varargs) of type "const char**" * in the buffer and assign the count (varargs) of type "const char**"
* to the locations of the respective strings in the buffer. * to the locations of the respective strings in the buffer.
* *
* @param buffer the buffer to parse * @param buffer the buffer to parse
* @param size size of the buffer * @param size size of the @a buffer
* @param count number of strings to locate * @param count number of strings to locate
* @param ... pointers to where to store the strings * @param ... pointers to where to store the strings
* @return offset of the character after the last 0-termination * @return offset of the character after the last 0-termination
* in the buffer, or 0 on error. * in the buffer, or 0 on error.
*/ */
unsigned int unsigned int
GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size, GNUNET_STRINGS_buffer_tokenize (const char *buffer,
size_t size,
unsigned int count, ...); unsigned int count, ...);
/** /**
* "asctime", except for GNUnet time. * @ingroup time
* This is one of the very few calls in the entire API that is * Like `asctime`, except for GNUnet time. Converts a GNUnet internal
* NOT reentrant! * absolute time (which is in UTC) to a string in local time.
* Note that the returned value will be overwritten if this function
* is called again.
* *
* @param t the absolute time to convert * @param t the absolute time to convert
* @return timestamp in human-readable form * @return timestamp in human-readable form in local time
*/ */
const char * const char *
GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t); GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t);
/** /**
* @ingroup time
* Give relative time in human-readable fancy format. * Give relative time in human-readable fancy format.
* This is one of the very few calls in the entire API that is * This is one of the very few calls in the entire API that is
* NOT reentrant! * NOT reentrant!
* *
* @param delta time in milli seconds * @param delta time in milli seconds
* @param do_round are we allowed to round a bit? * @param do_round are we allowed to round a bit?
* @return string in human-readable form * @return string in human-readable form
*/ */
const char * const char *
GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta,
skipping to change at line 265 skipping to change at line 279
* it should be placed, if needed. * it should be placed, if needed.
* *
* @param data data to encode * @param data data to encode
* @param size size of data (in bytes) * @param size size of data (in bytes)
* @param out buffer to fill * @param out buffer to fill
* @param out_size size of the buffer. Must be large enough to hold * @param out_size size of the buffer. Must be large enough to hold
* ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5 * ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5
* @return pointer to the next byte in 'out' or NULL on error. * @return pointer to the next byte in 'out' or NULL on error.
*/ */
char * char *
GNUNET_STRINGS_data_to_string (const unsigned char *data, GNUNET_STRINGS_data_to_string (const void *data,
size_t size, size_t size,
char *out, char *out,
size_t out_size); size_t out_size);
/** /**
* Convert ASCII encoding back to data * Convert ASCII encoding back to data
* out_size must match exactly the size of the data before it was encoded. * out_size must match exactly the size of the data before it was encoded.
* *
* @param enc the encoding * @param enc the encoding
* @param enclen number of characters in 'enc' (without 0-terminator, which can be missing) * @param enclen number of characters in 'enc' (without 0-terminator, which can be missing)
* @param out location where to store the decoded data * @param out location where to store the decoded data
* @param out_size sizeof the output buffer * @param out_size size of the output buffer @a out
* @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong enco * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong en
ding coding
*/ */
int int
GNUNET_STRINGS_string_to_data (const char *enc, GNUNET_STRINGS_string_to_data (const char *enc,
size_t enclen, size_t enclen,
unsigned char *out, void *out,
size_t out_size); size_t out_size);
/** /**
* Encode into Base64.
*
* @param data the data to encode
* @param len the length of the input
* @param output where to write the output (*output should be NULL,
* is allocated)
* @return the size of the output
*/
size_t
GNUNET_STRINGS_base64_encode (const char *data, size_t len, char **output);
/**
* Decode from Base64.
*
* @param data the data to encode
* @param len the length of the input
* @param output where to write the output (*output should be NULL,
* is allocated)
* @return the size of the output
*/
size_t
GNUNET_STRINGS_base64_decode (const char *data, size_t len, char **output);
/**
* Parse a path that might be an URI. * Parse a path that might be an URI.
* *
* @param path path to parse. Must be NULL-terminated. * @param path path to parse. Must be NULL-terminated.
* @param scheme_part a pointer to 'char *' where a pointer to a string tha t * @param scheme_part a pointer to 'char *' where a pointer to a string tha t
* represents the URI scheme will be stored. Can be NULL. The string is * represents the URI scheme will be stored. Can be NULL. The string is
* allocated by the function, and should be freed by GNUNET_free() w hen * allocated by the function, and should be freed by GNUNET_free() w hen
* it is no longer needed. * it is no longer needed.
* @param path_part a pointer to 'const char *' where a pointer to the path * @param path_part a pointer to 'const char *' where a pointer to the path
* part of the URI will be stored. Can be NULL. Points to the same b lock * part of the URI will be stored. Can be NULL. Points to the same b lock
* of memory as 'path', and thus must not be freed. Might point to ' \0', * of memory as 'path', and thus must not be freed. Might point to ' \0',
* if path part is zero-length. * if path part is zero-length.
* @return GNUNET_YES if it's an URI, GNUNET_NO otherwise. If 'path' is not * @return #GNUNET_YES if it's an URI, #GNUNET_NO otherwise. If 'path' is n ot
* an URI, '* scheme_part' and '*path_part' will remain unchanged * an URI, '* scheme_part' and '*path_part' will remain unchanged
* (if they weren't NULL). * (if they weren't NULL).
*/ */
int int
GNUNET_STRINGS_parse_uri (const char *path, GNUNET_STRINGS_parse_uri (const char *path,
char **scheme_part, char **scheme_part,
const char **path_part); const char **path_part);
/** /**
* Check whether filename is absolute or not, and if it's an URI * Check whether filename is absolute or not, and if it's an URI
* *
* @param filename filename to check * @param filename filename to check
* @param can_be_uri GNUNET_YES to check for being URI, GNUNET_NO - to * @param can_be_uri #GNUNET_YES to check for being URI, #GNUNET_NO - to
* assume it's not URI * assume it's not URI
* @param r_is_uri a pointer to an int that is set to GNUNET_YES if 'filena me' * @param r_is_uri a pointer to an int that is set to #GNUNET_YES if 'filen ame'
* is URI and to GNUNET_NO otherwise. Can be NULL. If 'can_be_uri' i s * is URI and to GNUNET_NO otherwise. Can be NULL. If 'can_be_uri' i s
* not GNUNET_YES, *r_is_uri is set to GNUNET_NO. * not #GNUNET_YES, *r_is_uri is set to #GNUNET_NO.
* @param r_uri_scheme a pointer to a char * that is set to a pointer to UR I scheme. * @param r_uri_scheme a pointer to a char * that is set to a pointer to UR I scheme.
* The string is allocated by the function, and should be freed with * The string is allocated by the function, and should be freed with
* GNUNET_free (). Can be NULL. * GNUNET_free (). Can be NULL.
* @return GNUNET_YES if 'filename' is absolute, GNUNET_NO otherwise. * @return #GNUNET_YES if 'filename' is absolute, #GNUNET_NO otherwise.
*/ */
int int
GNUNET_STRINGS_path_is_absolute (const char *filename, GNUNET_STRINGS_path_is_absolute (const char *filename,
int can_be_uri, int can_be_uri,
int *r_is_uri, int *r_is_uri,
char **r_uri_scheme); char **r_uri_scheme);
/** /**
* Flags for what we should check a file for. * Flags for what we should check a file for.
*/ */
skipping to change at line 354 skipping to change at line 392
*/ */
GNUNET_STRINGS_CHECK_IS_LINK = 0x00000004, GNUNET_STRINGS_CHECK_IS_LINK = 0x00000004,
/** /**
* Check that the path is an absolute path. * Check that the path is an absolute path.
*/ */
GNUNET_STRINGS_CHECK_IS_ABSOLUTE = 0x00000008 GNUNET_STRINGS_CHECK_IS_ABSOLUTE = 0x00000008
}; };
/** /**
* Perform checks on 'filename'. FIXME: some duplication with * Perform checks on @a filename. FIXME: some duplication with
* "GNUNET_DISK_"-APIs. We should unify those. * "GNUNET_DISK_"-APIs. We should unify those.
* *
* @param filename file to check * @param filename file to check
* @param checks checks to perform * @param checks checks to perform
* @return GNUNET_YES if all checks pass, GNUNET_NO if at least one of them * @return #GNUNET_YES if all checks pass, #GNUNET_NO if at least one of th
* fails, GNUNET_SYSERR when a check can't be performed em
* fails, #GNUNET_SYSERR when a check can't be performed
*/ */
int int
GNUNET_STRINGS_check_filename (const char *filename, GNUNET_STRINGS_check_filename (const char *filename,
enum GNUNET_STRINGS_FilenameCheck checks); enum GNUNET_STRINGS_FilenameCheck checks);
/** /**
* Tries to convert 'zt_addr' string to an IPv6 address. * Tries to convert @a zt_addr string to an IPv6 address.
* The string is expected to have the format "[ABCD::01]:80". * The string is expected to have the format "[ABCD::01]:80".
* *
* @param zt_addr 0-terminated string. May be mangled by the function. * @param zt_addr 0-terminated string. May be mangled by the function.
* @param addrlen length of zt_addr (not counting 0-terminator). * @param addrlen length of zt_addr (not counting 0-terminator).
* @param r_buf a buffer to fill. Initially gets filled with zeroes, * @param r_buf a buffer to fill. Initially gets filled with zeroes,
* then its sin6_port, sin6_family and sin6_addr are set appropriate ly. * then its sin6_port, sin6_family and sin6_addr are set appropriate ly.
* @return GNUNET_OK if conversion succeded. GNUNET_SYSERR otherwise, in wh ich * @return #GNUNET_OK if conversion succeded. #GNUNET_SYSERR otherwise, in which
* case the contents of r_buf are undefined. * case the contents of r_buf are undefined.
*/ */
int int
GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
uint16_t addrlen, uint16_t addrlen,
struct sockaddr_in6 *r_buf); struct sockaddr_in6 *r_buf);
/** /**
* Tries to convert 'zt_addr' string to an IPv4 address. * Tries to convert @a zt_addr string to an IPv4 address.
* The string is expected to have the format "1.2.3.4:80". * The string is expected to have the format "1.2.3.4:80".
* *
* @param zt_addr 0-terminated string. May be mangled by the function. * @param zt_addr 0-terminated string. May be mangled by the function.
* @param addrlen length of zt_addr (not counting 0-terminator). * @param addrlen length of zt_addr (not counting 0-terminator).
* @param r_buf a buffer to fill. * @param r_buf a buffer to fill.
* @return GNUNET_OK if conversion succeded. GNUNET_SYSERR otherwise, in wh ich case * @return #GNUNET_OK if conversion succeded. #GNUNET_SYSERR otherwise, in which case
* the contents of r_buf are undefined. * the contents of r_buf are undefined.
*/ */
int int
GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
uint16_t addrlen, uint16_t addrlen,
struct sockaddr_in *r_buf); struct sockaddr_in *r_buf);
/** /**
* Tries to convert 'addr' string to an IP (v4 or v6) address. * Tries to convert @a addr string to an IP (v4 or v6) address.
* Will automatically decide whether to treat 'addr' as v4 or v6 address. * Will automatically decide whether to treat 'addr' as v4 or v6 address.
* *
* @param addr a string, may not be 0-terminated. * @param addr a string, may not be 0-terminated.
* @param addrlen number of bytes in addr (if addr is 0-terminated, * @param addrlen number of bytes in @a addr (if addr is 0-terminated,
* 0-terminator should not be counted towards addrlen). * 0-terminator should not be counted towards addrlen).
* @param r_buf a buffer to fill. * @param r_buf a buffer to fill.
* @return GNUNET_OK if conversion succeded. GNUNET_SYSERR otherwise, in wh ich * @return #GNUNET_OK if conversion succeded. #GNUNET_SYSERR otherwise, in which
* case the contents of r_buf are undefined. * case the contents of r_buf are undefined.
*/ */
int int
GNUNET_STRINGS_to_address_ip (const char *addr, GNUNET_STRINGS_to_address_ip (const char *addr,
uint16_t addrlen, uint16_t addrlen,
struct sockaddr_storage *r_buf); struct sockaddr_storage *r_buf);
/** /**
* Returns utf-8 encoded arguments. * Returns utf-8 encoded arguments. Does nothing (returns a copy of
* Does nothing (returns a copy of argc and argv) on any platform * @a argc and @a argv) on any platform other than W32. Returned @a
* other than W32. * argv has `u8argv[u8argc] == NULL`. Returned @a argv is a single
* Returned argv has u8argv[u8argc] == NULL. * memory block, and can be freed with a single GNUNET_free() call.
* Returned argv is a single memory block, and can be freed with a single
* GNUNET_free () call.
* *
* @param argc argc (as given by main()) * @param argc argc (as given by main())
* @param argv argv (as given by main()) * @param argv argv (as given by main())
* @param u8argc a location to store new argc in (though it's th same as ar gc) * @param u8argc a location to store new argc in (though it's th same as ar gc)
* @param u8argv a location to store new argv in * @param u8argv a location to store new argv in
* @return GNUNET_OK on success, GNUNET_SYSERR on failure * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/ */
int int
GNUNET_STRINGS_get_utf8_args (int argc, GNUNET_STRINGS_get_utf8_args (int argc,
char *const *argv, char *const *argv,
int *u8argc, int *u8argc,
char *const **u8argv); char *const **u8argv);
/* ***************** IPv4/IPv6 parsing ****************** */
struct GNUNET_STRINGS_PortPolicy
{
/**
* Starting port range (0 if none given).
*/
uint16_t start_port;
/**
* End of port range (0 if none given).
*/
uint16_t end_port;
/**
* #GNUNET_YES if the port range should be negated
* ("!" in policy).
*/
int negate_portrange;
};
/**
* @brief IPV4 network in CIDR notation.
*/
struct GNUNET_STRINGS_IPv4NetworkPolicy
{
/**
* IPv4 address.
*/
struct in_addr network;
/**
* IPv4 netmask.
*/
struct in_addr netmask;
/**
* Policy for port access.
*/
struct GNUNET_STRINGS_PortPolicy pp;
};
/**
* @brief network in CIDR notation for IPV6.
*/
struct GNUNET_STRINGS_IPv6NetworkPolicy
{
/**
* IPv6 address.
*/
struct in6_addr network;
/**
* IPv6 netmask.
*/
struct in6_addr netmask;
/**
* Policy for port access.
*/
struct GNUNET_STRINGS_PortPolicy pp;
};
/**
* Parse an IPv4 network policy. The argument specifies a list of
* subnets. The format is <tt>(network[/netmask][:[!]SPORT-DPORT];)*</tt>
* (no whitespace, must be terminated with a semicolon). The network
* must be given in dotted-decimal notation. The netmask can be given
* in CIDR notation (/16) or in dotted-decimal (/255.255.0.0).
*
* @param routeListX a string specifying the IPv4 subnets
* @return the converted list, terminated with all zeros;
* NULL if the synatx is flawed
*/
struct GNUNET_STRINGS_IPv4NetworkPolicy *
GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX);
/**
* Parse an IPv6 network policy. The argument specifies a list of
* subnets. The format is <tt>(network[/netmask[:[!]SPORT[-DPORT]]];)*</tt>
* (no whitespace, must be terminated with a semicolon). The network
* must be given in colon-hex notation. The netmask must be given in
* CIDR notation (/16) or can be omitted to specify a single host.
* Note that the netmask is mandatory if ports are specified.
*
* @param routeListX a string specifying the policy
* @return the converted list, 0-terminated, NULL if the synatx is flawed
*/
struct GNUNET_STRINGS_IPv6NetworkPolicy *
GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* ifndef GNUNET_UTIL_STRING_H */ /* ifndef GNUNET_UTIL_STRING_H */
#endif #endif
/* end of gnunet_util_string.h */ /* end of gnunet_util_string.h */
 End of changes. 40 change blocks. 
49 lines changed or deleted 181 lines changed or added


 gnunet_testbed_service.h   gnunet_testbed_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2008, 2009, 2012 Christian Grothoff (and other contributing autho rs) (C) 2008--2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
skipping to change at line 76 skipping to change at line 76
* controllers can interact with each other (in a P2P fashion); those * controllers can interact with each other (in a P2P fashion); those
* links are established via TCP/IP on the controller's service port. * links are established via TCP/IP on the controller's service port.
*/ */
struct GNUNET_TESTBED_Controller; struct GNUNET_TESTBED_Controller;
/** /**
* Create a host to run peers and controllers on. * Create a host to run peers and controllers on.
* *
* @param hostname name of the host, use "NULL" for localhost * @param hostname name of the host, use "NULL" for localhost
* @param username username to use for the login; may be NULL * @param username username to use for the login; may be NULL
* @param cfg the configuration to use as a template while starting a contr
oller
* on this host. Operation queue sizes specific to a host are als
o
* read from this configuration handle
* @param port port number to use for ssh; use 0 to let ssh decide * @param port port number to use for ssh; use 0 to let ssh decide
* @return handle to the host, NULL on error * @return handle to the host, NULL on error
*/ */
struct GNUNET_TESTBED_Host * struct GNUNET_TESTBED_Host *
GNUNET_TESTBED_host_create (const char *hostname, GNUNET_TESTBED_host_create (const char *hostname,
const char *username, const char *username,
const struct GNUNET_CONFIGURATION_Handle *cfg,
uint16_t port); uint16_t port);
/** /**
* Create a host to run peers and controllers on. This function is used * Create a host to run peers and controllers on. This function is used
* if a peer learns about a host via IPC between controllers (and thus * if a peer learns about a host via IPC between controllers (and thus
* some higher-level controller has already determined the unique IDs). * some higher-level controller has already determined the unique IDs).
* *
* @param id global host ID assigned to the host; 0 is * @param id global host ID assigned to the host; 0 is
* reserved to always mean 'localhost' * reserved to always mean 'localhost'
* @param hostname name of the host, use "NULL" for localhost * @param hostname name of the host, use "NULL" for localhost
* @param username username to use for the login; may be NULL * @param username username to use for the login; may be NULL
* @param cfg the configuration to use as a template while starting a contr
oller
* on this host. Operation queue sizes specific to a host are als
o
* read from this configuration handle
* @param port port number to use for ssh; use 0 to let ssh decide * @param port port number to use for ssh; use 0 to let ssh decide
* @return handle to the host, NULL on error * @return handle to the host, NULL on error
*/ */
struct GNUNET_TESTBED_Host * struct GNUNET_TESTBED_Host *
GNUNET_TESTBED_host_create_with_id (uint32_t id, GNUNET_TESTBED_host_create_with_id (uint32_t id,
const char *hostname, const char *hostname,
const char *username, const char *username,
const struct GNUNET_CONFIGURATION_Handl
e
*cfg,
uint16_t port); uint16_t port);
/** /**
* Load a set of hosts from a configuration file. * Load a set of hosts from a configuration file. The hostfile format is
* specified at https://gnunet.org/content/hosts-file-format
* *
* @param filename file with the host specification * @param filename file with the host specification
* @param cfg the configuration to use as a template while starting a contr
oller
* on any of the loaded hosts. Operation queue sizes specific to
a host
* are also read from this configuration handle
* @param hosts set to the hosts found in the file; caller must free this i f * @param hosts set to the hosts found in the file; caller must free this i f
* number of hosts returned is greater than 0 * number of hosts returned is greater than 0
* @return number of hosts returned in 'hosts', 0 on error * @return number of hosts returned in 'hosts', 0 on error
*/ */
unsigned int unsigned int
GNUNET_TESTBED_hosts_load_from_file (const char *filename, GNUNET_TESTBED_hosts_load_from_file (const char *filename,
const struct GNUNET_CONFIGURATION_Hand
le
*cfg,
struct GNUNET_TESTBED_Host ***hosts); struct GNUNET_TESTBED_Host ***hosts);
/** /**
* Loads the set of host allocated by the LoadLeveler Job Scheduler. This
* function is only available when compiled with support for LoadLeveler an
d is
* used for running on the SuperMUC
*
* @param cfg the configuration to use as a template while starting a contr
oller
* on any of the loaded hosts. Operation queue sizes specific to
a host
* are also read from this configuration handle
* @param hosts set to the hosts found in the file; caller must free this i
f
* number of hosts returned is greater than 0
* @return number of hosts returned in 'hosts', 0 on error
*/
unsigned int
GNUNET_TESTBED_hosts_load_from_loadleveler (const struct
GNUNET_CONFIGURATION_Handle *cf
g,
struct GNUNET_TESTBED_Host
***hosts);
/**
* Destroy a host handle. Must only be called once everything * Destroy a host handle. Must only be called once everything
* running on that host has been stopped. * running on that host has been stopped.
* *
* @param host handle to destroy * @param host handle to destroy
*/ */
void void
GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host); GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
/** /**
* The handle for whether a host is habitable or not * The handle for whether a host is habitable or not
skipping to change at line 165 skipping to change at line 198
struct GNUNET_TESTBED_HostHabitableCheckHandle * struct GNUNET_TESTBED_HostHabitableCheckHandle *
GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
const struct GNUNET_CONFIGURATION_Handle const struct GNUNET_CONFIGURATION_Handle
*config, *config,
GNUNET_TESTBED_HostHabitableCallback cb, GNUNET_TESTBED_HostHabitableCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Function to cancel a request started using GNUNET_TESTBED_is_host_habita ble() * Function to cancel a request started using GNUNET_TESTBED_is_host_habita ble()
* *
* @param struct handle the habitability check handle * @param handle the habitability check handle
*/ */
void void
GNUNET_TESTBED_is_host_habitable_cancel (struct GNUNET_TESTBED_is_host_habitable_cancel (struct
GNUNET_TESTBED_HostHabitableCheckH andle GNUNET_TESTBED_HostHabitableCheckH andle
*handle); *handle);
/** /**
* Obtain the host's hostname. * Obtain the host's hostname.
* *
* @param host handle to the host, NULL means 'localhost' * @param host handle to the host, NULL means 'localhost'
skipping to change at line 212 skipping to change at line 245
/** /**
* A connection between two peers was torn down. * A connection between two peers was torn down.
*/ */
GNUNET_TESTBED_ET_DISCONNECT = 3, GNUNET_TESTBED_ET_DISCONNECT = 3,
/** /**
* A requested testbed operation has been completed. * A requested testbed operation has been completed.
*/ */
GNUNET_TESTBED_ET_OPERATION_FINISHED = 4, GNUNET_TESTBED_ET_OPERATION_FINISHED = 4,
/**
* The 'GNUNET_TESTBED_run' operation has been completed
*/
GNUNET_TESTBED_ET_TESTBED_ONLINE = 5
}; };
/** /**
* Types of information that can be requested about a peer. * Types of information that can be requested about a peer.
*/ */
enum GNUNET_TESTBED_PeerInformationType enum GNUNET_TESTBED_PeerInformationType
{ {
/** /**
* Special value (not valid for requesting information) * Special value (not valid for requesting information)
skipping to change at line 264 skipping to change at line 292
*/ */
struct GNUNET_TESTBED_EventInformation struct GNUNET_TESTBED_EventInformation
{ {
/** /**
* Type of the event. * Type of the event.
*/ */
enum GNUNET_TESTBED_EventType type; enum GNUNET_TESTBED_EventType type;
/** /**
* Handle for the corresponding operation that generated this event
*/
struct GNUNET_TESTBED_Operation *op;
/**
* Closure given while creating the above operation
*/
void *op_cls;
/**
* Details about the event. * Details about the event.
*/ */
union union
{ {
/** /**
* Details about peer start event. * Details about peer start event.
*/ */
struct struct
{ {
skipping to change at line 339 skipping to change at line 377
*/ */
struct GNUNET_TESTBED_Peer *peer2; struct GNUNET_TESTBED_Peer *peer2;
} peer_disconnect; } peer_disconnect;
/** /**
* Details about an operation finished event. * Details about an operation finished event.
*/ */
struct struct
{ {
/**
* Handle for the operation that was finished.
*/
struct GNUNET_TESTBED_Operation *operation;
/**
* Closure that was passed in when the event was
* requested.
*/
void *op_cls;
/** /**
* Error message for the operation, NULL on success. * Error message for the operation, NULL on success.
*/ */
const char *emsg; const char *emsg;
/** /**
* No result (NULL pointer) or generic result * No result (NULL pointer) or generic result
* (whatever the GNUNET_TESTBED_ConnectAdapter returned). * (whatever the GNUNET_TESTBED_ConnectAdapter returned).
*/ */
void *generic; void *generic;
} operation_finished; } operation_finished;
/**
* Details about an testbed run completed event.
*/
struct
{
/**
* Error message for the operation, NULL on success.
*/
const char *emsg;
/**
* Array of peers now running (valid until
* 'GNUNET_TESTBED_testbed_stop' is called). Note that it is
* not allowed to call 'GNUNET_TESTBED_peer_destroy' on peers
* from this array.
*/
struct GNUNET_TESTBED_Peer **peers;
/**
* Size of the 'peers' array.
*/
unsigned int num_peers;
} testbed_run_finished;
} details; } details;
}; };
/** /**
* Signature of the event handler function called by the * Signature of the event handler function called by the
* respective event controller. * respective event controller.
* *
* @param cls closure * @param cls closure
* @param event information about the event * @param event information about the event
skipping to change at line 423 skipping to change at line 423
* @param cfg the configuration with which the controller has been started; * @param cfg the configuration with which the controller has been started;
* NULL if status is not GNUNET_OK * NULL if status is not GNUNET_OK
* @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
* GNUNET_TESTBED_controller_stop() shouldn't be called in this ca se * GNUNET_TESTBED_controller_stop() shouldn't be called in this ca se
*/ */
typedef void (*GNUNET_TESTBED_ControllerStatusCallback) (void *cls, typedef void (*GNUNET_TESTBED_ControllerStatusCallback) (void *cls,
const struct GNUNET _CONFIGURATION_Handle *cfg, const struct GNUNET _CONFIGURATION_Handle *cfg,
int status); int status);
/** /**
* Starts a controller process at the given host. * Starts a controller process at the given host. The given host's configr
ation
* is used as a Template configuration to use for the remote controller; th
e
* remote controller will be started with a slightly modified configuration
* (port numbers, unix domain sockets and service home values are changed a
s per
* TESTING library on the remote host). The modified configuration replace
s the
* host's existing configuration before signalling success through the
* GNUNET_TESTBED_ControllerStatusCallback()
* *
* @param trusted_ip the ip address of the controller which will be set as TRUSTED * @param trusted_ip the ip address of the controller which will be set as TRUSTED
* HOST(all connections form this ip are permitted by the testbed) when * HOST(all connections form this ip are permitted by the testbed) when
* starting testbed controller at host. This can either be a singl e ip * starting testbed controller at host. This can either be a singl e ip
* address or a network address in CIDR notation. * address or a network address in CIDR notation.
* @param host the host where the controller has to be started; NULL for * @param host the host where the controller has to be started. CANNOT be
* localhost NULL.
* @param cfg template configuration to use for the remote controller; the
* remote controller will be started with a slightly modified
* configuration (port numbers, unix domain sockets and service ho
me
* values are changed as per TESTING library on the remote host)
* @param cb function called when the controller is successfully started or * @param cb function called when the controller is successfully started or
* dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be * dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be
* called if cb is called with GNUNET_SYSERR as status. Will never be * called if cb is called with GNUNET_SYSERR as status. Will never be
* called in the same task as 'GNUNET_TESTBED_controller_start' * called in the same task as 'GNUNET_TESTBED_controller_start'
* (synchronous errors will be signalled by returning NULL). This * (synchronous errors will be signalled by returning NULL). This
* parameter cannot be NULL. * parameter cannot be NULL.
* @param cls closure for above callbacks * @param cls closure for above callbacks
* @return the controller process handle, NULL on errors * @return the controller process handle, NULL on errors
*/ */
struct GNUNET_TESTBED_ControllerProc * struct GNUNET_TESTBED_ControllerProc *
GNUNET_TESTBED_controller_start (const char *trusted_ip, GNUNET_TESTBED_controller_start (const char *trusted_ip,
struct GNUNET_TESTBED_Host *host, struct GNUNET_TESTBED_Host *host,
const struct GNUNET_CONFIGURATION_Handle * cfg,
GNUNET_TESTBED_ControllerStatusCallback cb , GNUNET_TESTBED_ControllerStatusCallback cb ,
void *cls); void *cls);
/** /**
* Stop the controller process (also will terminate all peers and controlle rs * Stop the controller process (also will terminate all peers and controlle rs
* dependent on this controller). This function blocks until the testbed h as * dependent on this controller). This function blocks until the testbed h as
* been fully terminated (!). The controller status cb from * been fully terminated (!). The controller status cb from
* GNUNET_TESTBED_controller_start() will not be called. * GNUNET_TESTBED_controller_start() will not be called.
* *
* @param cproc the controller process handle * @param cproc the controller process handle
*/ */
void void
GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc ); GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc );
/** /**
* Connect to a controller process using the given configuration at the * Connect to a controller process. The configuration to use for the conne
* given host. ction
* is retreived from the given host where a controller is started using
* GNUNET_TESTBED_controller_start().
* *
* @param cfg configuration to use
* @param host host to run the controller on; This should be the same host if * @param host host to run the controller on; This should be the same host if
* the controller was previously started with * the controller was previously started with
* GNUNET_TESTBED_controller_start; NULL for localhost * GNUNET_TESTBED_controller_start()
* @param host host where this controller is being run;
* @param event_mask bit mask with set of events to call 'cc' for; * @param event_mask bit mask with set of events to call 'cc' for;
* or-ed values of "1LL" shifted by the * or-ed values of "1LL" shifted by the
* respective 'enum GNUNET_TESTBED_EventType' * respective 'enum GNUNET_TESTBED_EventType'
* (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...") * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
* @param cc controller callback to invoke on events * @param cc controller callback to invoke on events
* @param cc_cls closure for cc * @param cc_cls closure for cc
* @return handle to the controller * @return handle to the controller
*/ */
struct GNUNET_TESTBED_Controller * struct GNUNET_TESTBED_Controller *
GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
*cfg,
struct GNUNET_TESTBED_Host *host,
uint64_t event_mask, uint64_t event_mask,
GNUNET_TESTBED_ControllerCallback cc, GNUNET_TESTBED_ControllerCallback cc,
void *cc_cls); void *cc_cls);
/** /**
* Configure shared services at a controller. Using this function,
* you can specify that certain services (such as "resolver")
* should not be run for each peer but instead be shared
* across N peers on the specified host. This function
* must be called before any peers are created at the host.
*
* @param controller controller to configure
* @param service_name name of the service to share
* @param num_peers number of peers that should share one instance
* of the specified service (1 for no sharing is the default),
* use 0 to disable the service
*/
void
GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controll
er *controller,
const char *service_name,
uint32_t num_peers);
/**
* Stop the given controller (also will terminate all peers and * Stop the given controller (also will terminate all peers and
* controllers dependent on this controller). This function * controllers dependent on this controller). This function
* blocks until the testbed has been fully terminated (!). * blocks until the testbed has been fully terminated (!).
* *
* @param controller handle to controller to stop * @param c handle to controller to stop
*/ */
void void
GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *con troller); GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c);
/** /**
* Opaque handle for host registration * Opaque handle for host registration
*/ */
struct GNUNET_TESTBED_HostRegistrationHandle; struct GNUNET_TESTBED_HostRegistrationHandle;
/** /**
* Callback which will be called to after a host registration succeeded or failed * Callback which will be called to after a host registration succeeded or failed
* *
* @param cls the closure * @param cls the closure
skipping to change at line 590 skipping to change at line 570
* slave controller will then route it to the delegated controller. The * slave controller will then route it to the delegated controller. The
* configuration of the delegated controller is given and is used to either * configuration of the delegated controller is given and is used to either
* create the delegated controller or to connect to an existing controller. Note * create the delegated controller or to connect to an existing controller. Note
* that while starting the delegated controller the configuration will be * that while starting the delegated controller the configuration will be
* modified to accommodate available free ports. the 'is_subordinate' spec ifies * modified to accommodate available free ports. the 'is_subordinate' spec ifies
* if the given delegated controller should be started and managed by the s lave * if the given delegated controller should be started and managed by the s lave
* controller, or if the delegated controller already has a master and the slave * controller, or if the delegated controller already has a master and the slave
* controller connects to it as a non master controller. The success or fai lure * controller connects to it as a non master controller. The success or fai lure
* of this operation will be signalled through the * of this operation will be signalled through the
* GNUNET_TESTBED_ControllerCallback() with an event of type * GNUNET_TESTBED_ControllerCallback() with an event of type
* GNUNET_TESTBED_ET_OPERATION_FINISHED * #GNUNET_TESTBED_ET_OPERATION_FINISHED
* *
* @param op_cls the operation closure for the event which is generated to * @param op_cls the operation closure for the event which is generated to
* signal success or failure of this operation * signal success or failure of this operation
* @param master handle to the master controller who creates the associatio n * @param master handle to the master controller who creates the associatio n
* @param delegated_host requests to which host should be delegated; cannot be NULL * @param delegated_host requests to which host should be delegated; cannot be NULL
* @param slave_host which host is used to run the slave controller; use NU LL to * @param slave_host which host is used to run the slave controller; use NU LL to
* make the master controller connect to the delegated host * make the master controller connect to the delegated host
* @param slave_cfg configuration to use for the slave controller * @param is_subordinate #GNUNET_YES if the controller at delegated_host sh
* @param is_subordinate GNUNET_YES if the controller at delegated_host sho ould
uld * be started by the slave controller; #GNUNET_NO if the slave
* be started by the slave controller; GNUNET_NO if the slave
* controller has to connect to the already started delegated * controller has to connect to the already started delegated
* controller via TCP/IP * controller via TCP/IP
* @return the operation handle * @return the operation handle
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_controller_link (void *op_cls, GNUNET_TESTBED_controller_link (void *op_cls,
struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Controller *master,
struct GNUNET_TESTBED_Host *delegated_host, struct GNUNET_TESTBED_Host *delegated_host,
struct GNUNET_TESTBED_Host *slave_host, struct GNUNET_TESTBED_Host *slave_host,
const struct GNUNET_CONFIGURATION_Handle
*slave_cfg,
int is_subordinate); int is_subordinate);
/** /**
* Same as the GNUNET_TESTBED_controller_link, however expects configuratio
n in
* serialized and compressed
*
* @param op_cls the operation closure for the event which is generated to
* signal success or failure of this operation
* @param master handle to the master controller who creates the associatio
n
* @param delegated_host requests to which host should be delegated; cannot
be NULL
* @param slave_host which host is used to run the slave controller; use NU
LL to
* make the master controller connect to the delegated host
* @param sxcfg serialized and compressed configuration
* @param sxcfg_size the size sxcfg
* @param scfg_size the size of uncompressed serialized configuration
* @param is_subordinate GNUNET_YES if the controller at delegated_host sho
uld
* be started by the slave controller; GNUNET_NO if the slave
* controller has to connect to the already started delegated
* controller via TCP/IP
* @return the operation handle
*/
struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_controller_link_2 (void *op_cls,
struct GNUNET_TESTBED_Controller *master,
struct GNUNET_TESTBED_Host *delegated_hos
t,
struct GNUNET_TESTBED_Host *slave_host,
const char *sxcfg,
size_t sxcfg_size,
size_t scfg_size,
int is_subordinate);
/**
* Function to acquire the configuration of a running slave controller. The * Function to acquire the configuration of a running slave controller. The
* completion of the operation is signalled through the controller_cb from * completion of the operation is signalled through the controller_cb from
* GNUNET_TESTBED_controller_connect(). If the operation is successful the * GNUNET_TESTBED_controller_connect(). If the operation is successful the
* handle to the configuration is available in the generic pointer of * handle to the configuration is available in the generic pointer of
* operation_finished field of struct GNUNET_TESTBED_EventInformation. * operation_finished field of `struct GNUNET_TESTBED_EventInformation`.
* *
* @param op_cls the closure for the operation * @param op_cls the closure for the operation
* @param master the handle to master controller * @param master the handle to master controller
* @param slave_host the host where the slave controller is running; the ha ndle * @param slave_host the host where the slave controller is running; the ha ndle
* to the slave_host should remain valid until this operation is * to the slave_host should remain valid until this operation is
* cancelled or marked as finished * cancelled or marked as finished
* @return the operation handle; NULL if the slave_host is not registered a t * @return the operation handle; NULL if the slave_host is not registered a t
* master * master
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
skipping to change at line 688 skipping to change at line 636
* controller. If the given controller is not running on the target * controller. If the given controller is not running on the target
* host, it should find or create a controller at the target host and * host, it should find or create a controller at the target host and
* delegate creating the peer. Explicit delegation paths can be setup * delegate creating the peer. Explicit delegation paths can be setup
* using 'GNUNET_TESTBED_controller_link'. If no explicit delegation * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
* path exists, a direct link with a subordinate controller is setup * path exists, a direct link with a subordinate controller is setup
* for the first delegated peer to a particular host; the subordinate * for the first delegated peer to a particular host; the subordinate
* controller is then destroyed once the last peer that was delegated * controller is then destroyed once the last peer that was delegated
* to the remote host is stopped. * to the remote host is stopped.
* *
* Creating the peer only creates the handle to manipulate and further * Creating the peer only creates the handle to manipulate and further
* configure the peer; use "GNUNET_TESTBED_peer_start" and * configure the peer; use #GNUNET_TESTBED_peer_start and
* "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's * #GNUNET_TESTBED_peer_stop to actually start/stop the peer's
* processes. * processes.
* *
* Note that the given configuration will be adjusted by the * Note that the given configuration will be adjusted by the
* controller to avoid port/path conflicts with other peers. * controller to avoid port/path conflicts with other peers.
* The "final" configuration can be obtained using * The "final" configuration can be obtained using
* 'GNUNET_TESTBED_peer_get_information'. * #GNUNET_TESTBED_peer_get_information.
* *
* @param controller controller process to use * @param controller controller process to use
* @param host host to run the peer on; cannot be NULL * @param host host to run the peer on; cannot be NULL
* @param cfg Template configuration to use for the peer. Should exist unti l * @param cfg Template configuration to use for the peer. Should exist unti l
* operation is cancelled or GNUNET_TESTBED_operation_done() is ca lled * operation is cancelled or GNUNET_TESTBED_operation_done() is ca lled
* @param cb the callback to call when the peer has been created * @param cb the callback to call when the peer has been created
* @param cls the closure to the above callback * @param cls the closure to the above callback
* @return the operation handle * @return the operation handle
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
skipping to change at line 725 skipping to change at line 673
* *
* @param cls the closure from GNUNET_TESTBED_peer_start/stop() * @param cls the closure from GNUNET_TESTBED_peer_start/stop()
* @param emsg NULL on success; otherwise an error description * @param emsg NULL on success; otherwise an error description
*/ */
typedef void (*GNUNET_TESTBED_PeerChurnCallback) (void *cls, typedef void (*GNUNET_TESTBED_PeerChurnCallback) (void *cls,
const char *emsg); const char *emsg);
/** /**
* Start the given peer. * Start the given peer.
* *
* @param op_cls the closure for this operation; will be set in * @param op_cls the closure for this operation; will be set in the event
* event->details.operation_finished.op_cls when this operation fa * information
ils.
* @param peer peer to start * @param peer peer to start
* @param pcc function to call upon completion * @param pcc function to call upon completion
* @param pcc_cls closure for 'pcc' * @param pcc_cls closure for 'pcc'
* @return handle to the operation * @return handle to the operation
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_peer_start (void *op_cls, GNUNET_TESTBED_peer_start (void *op_cls,
struct GNUNET_TESTBED_Peer *peer, struct GNUNET_TESTBED_Peer *peer,
GNUNET_TESTBED_PeerChurnCallback pcc, GNUNET_TESTBED_PeerChurnCallback pcc,
void *pcc_cls); void *pcc_cls);
/** /**
* Stop the given peer. The handle remains valid (use * Stop the given peer. The handle remains valid (use
* "GNUNET_TESTBED_peer_destroy" to fully clean up the * #GNUNET_TESTBED_peer_destroy to fully clean up the
* state of the peer). * state of the peer).
* *
* @param op_cls the closure for this operation; will be set in the event
* information
* @param peer peer to stop * @param peer peer to stop
* @param pcc function to call upon completion * @param pcc function to call upon completion
* @param pcc_cls closure for 'pcc' * @param pcc_cls closure for 'pcc'
* @return handle to the operation * @return handle to the operation
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_peer_stop (void *op_cls,
struct GNUNET_TESTBED_Peer *peer,
GNUNET_TESTBED_PeerChurnCallback pcc, GNUNET_TESTBED_PeerChurnCallback pcc,
void *pcc_cls); void *pcc_cls);
/** /**
* Data returned from GNUNET_TESTBED_peer_get_information * Data returned from GNUNET_TESTBED_peer_get_information
*/ */
struct GNUNET_TESTBED_PeerInformation struct GNUNET_TESTBED_PeerInformation
{ {
/** /**
* Peer information type; captures which of the types * Peer information type; captures which of the types
skipping to change at line 783 skipping to change at line 734
/** /**
* The identity of the peer * The identity of the peer
*/ */
struct GNUNET_PeerIdentity *id; struct GNUNET_PeerIdentity *id;
} result; } result;
}; };
/** /**
* Callback to be called when the requested peer information is available * Callback to be called when the requested peer information is available
* The peer information in the callback is valid until the operation 'op' i s canceled.
* *
* @param cb_cls the closure from GNUNET_TETSBED_peer_get_information() * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
* @param op the operation this callback corresponds to * @param op the operation this callback corresponds to
* @param pinfo the result; will be NULL if the operation has failed * @param pinfo the result; will be NULL if the operation has failed
* @param emsg error message if the operation has failed; will be NULL if t he * @param emsg error message if the operation has failed; will be NULL if t he
* operation is successfull * operation is successfull
*/ */
typedef void (*GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls, typedef void (*GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls,
struct GNUNET_TESTBED_Oper ation struct GNUNET_TESTBED_Oper ation
*op, *op,
const struct const struct
GNUNET_TESTBED_PeerInforma tion GNUNET_TESTBED_PeerInforma tion
*pinfo, *pinfo,
const char *emsg); const char *emsg);
/** /**
* Request information about a peer. The controller callback will not be ca lled * Request information about a peer. The controller callback will not be ca lled
* with event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for thi s * with event type #GNUNET_TESTBED_ET_OPERATION_FINISHED when result for th is
* operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() w ill * operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() w ill
* be called. * be called.
* The peer information in the callback is valid until the operation is can celed.
* *
* @param peer peer to request information about * @param peer peer to request information about
* @param pit desired information * @param pit desired information
* @param cb the convenience callback to be called when results for this * @param cb the convenience callback to be called when results for this
* operation are available * operation are available
* @param cb_cls the closure for the above callback * @param cb_cls the closure for @a cb
* @return handle to the operation * @return handle to the operation
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
enum GNUNET_TESTBED_PeerInformationTyp e enum GNUNET_TESTBED_PeerInformationTyp e
pit, pit,
GNUNET_TESTBED_PeerInfoCallback cb, GNUNET_TESTBED_PeerInfoCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Change peer configuration. Must only be called while the * Change @a peer configuration. Ports and paths cannot be changed this
* peer is stopped. Ports and paths cannot be changed this
* way. * way.
* *
* @param peer peer to change configuration for * @param peer peer to change configuration for
* @param cfg new configuration (differences to existing * @param cfg new configuration
* configuration only)
* @return handle to the operation * @return handle to the operation
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
const struct GNUNET_CONFIGURATION _Handle *cfg); const struct GNUNET_CONFIGURATION _Handle *cfg);
/** /**
* Destroy the given peer; the peer should have been * Destroy the given peer; the peer should have been
* stopped first (if it was started). * stopped first (if it was started).
* *
* @param peer peer to stop * @param peer peer to stop
* @return handle to the operation * @return handle to the operation
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer); GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer);
/** /**
* Start or stop given service at a peer. This should not be called to
* start/stop the peer's ARM service. Use GNUNET_TESTBED_peer_start(),
* GNUNET_TESTBED_peer_stop() for starting/stopping peer's ARM service. Su
ccess
* or failure of the generated operation is signalled through the controlle
r
* event callback and/or operation completion callback.
*
* @param op_cls the closure for the operation
* @param peer the peer whose service is to be started/stopped
* @param service_name the name of the service
* @param cb the operation completion callback
* @param cb_cls the closure for @a cb
* @param start 1 to start the service; 0 to stop the service
* @return an operation handle; NULL upon error (peer not running)
*/
struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_peer_manage_service (void *op_cls,
struct GNUNET_TESTBED_Peer *peer,
const char *service_name,
GNUNET_TESTBED_OperationCompletionCallb
ack cb,
void *cb_cls,
unsigned int start);
/**
* Stops and destroys all peers. Is equivalent of calling
* GNUNET_TESTBED_peer_stop() and GNUNET_TESTBED_peer_destroy() on all peer
s,
* except that the peer stop event and operation finished event correspondi
ng to
* the respective functions are not generated. This function should be cal
led
* when there are no other pending operations. If there are pending operat
ions,
* it will return NULL
*
* @param c the controller to send this message to
* @param op_cls closure for the operation
* @param cb the callback to call when all peers are stopped and destroyed
* @param cb_cls the closure for the callback
* @return operation handle on success; NULL if any pending operations are
* present
*/
struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c,
void *op_cls,
GNUNET_TESTBED_OperationCompletionCallback c
b,
void *cb_cls);
/**
* Options for peer connections. * Options for peer connections.
*/ */
enum GNUNET_TESTBED_ConnectOption enum GNUNET_TESTBED_ConnectOption
{ {
/** /**
* No option (not valid as an argument). * No option (not valid as an argument).
*/ */
GNUNET_TESTBED_CO_NONE = 0, GNUNET_TESTBED_CO_NONE = 0,
/** /**
* Allow or disallow a connection between the specified peers. * Allow or disallow a connection between the specified peers.
* Followed by GNUNET_NO (int) if a connection is disallowed * Followed by #GNUNET_NO (int) if a connection is disallowed
* or GNUNET_YES if a connection is allowed. Note that the * or #GNUNET_YES if a connection is allowed. Note that the
* default (all connections allowed or disallowed) is * default (all connections allowed or disallowed) is
* specified in the configuration of the controller. * specified in the configuration of the controller.
*/ */
GNUNET_TESTBED_CO_ALLOW = 1, GNUNET_TESTBED_CO_ALLOW = 1,
/** /**
* FIXME: add (and implement) options to limit connection to * FIXME: add (and implement) options to limit connection to
* particular transports, force simulation of particular latencies * particular transports, force simulation of particular latencies
* or message loss rates, or set bandwidth limitations. * or message loss rates, or set bandwidth limitations.
*/ */
skipping to change at line 954 skipping to change at line 949
GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
/** /**
* Certain percentage of peers are unable to communicate directly * Certain percentage of peers are unable to communicate directly
* replicating NAT conditions. Followed by the fraction of * replicating NAT conditions. Followed by the fraction of
* NAT'ed peers (float). * NAT'ed peers (float).
*/ */
GNUNET_TESTBED_TOPOLOGY_INTERNAT, GNUNET_TESTBED_TOPOLOGY_INTERNAT,
/** /**
* Scale free topology. No options. * Scale free topology. It is generated according to the method describe
d in
* "Emergence of Scaling in Random Networks." Science 286, 509-512, 1999.
*
* This options takes two arguments in the following order: an uint16_t t
o
* determine the maximum number of edges a peer is permitted to have whil
e
* generating scale free topology, a good value for this argument is 70;
and
* an uint8_t to determine the number of edges to be established when add
ing a
* new node to the scale free network, a good value for this argument is
4.
*/ */
GNUNET_TESTBED_TOPOLOGY_SCALE_FREE, GNUNET_TESTBED_TOPOLOGY_SCALE_FREE,
/** /**
* Straight line topology. No options. * Straight line topology. No options.
*/ */
GNUNET_TESTBED_TOPOLOGY_LINE, GNUNET_TESTBED_TOPOLOGY_LINE,
/** /**
* Read a topology from a given file. Followed by the name of the file ( const char *). * Read a topology from a given file. Followed by the name of the file ( const char *).
skipping to change at line 984 skipping to change at line 986
* The options should always end with this * The options should always end with this
*/ */
GNUNET_TESTBED_TOPOLOGY_OPTION_END, GNUNET_TESTBED_TOPOLOGY_OPTION_END,
/* The following are not topologies but influence how the topology has to be /* The following are not topologies but influence how the topology has to be
setup. These options should follow the topology specific options (if setup. These options should follow the topology specific options (if
required by the chosen topology). Note that these should be given befo re required by the chosen topology). Note that these should be given befo re
GNUNET_TESTBED_TOPOLOGY_OPTION_END */ GNUNET_TESTBED_TOPOLOGY_OPTION_END */
/** /**
* Disable automatic retrying for failed overlay connections. The default * How many times should the failed overlay connect operations be retried
is * before giving up. The default if this option is not specified is to r
* to always retry failed overlay connections. This parameter takes no op etry
tions. * 3 times. This option takes and unsigned integer as a parameter. Use
this
* option with parameter 0 to disable retrying of failed overlay connect
* operations.
*/ */
GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY GNUNET_TESTBED_TOPOLOGY_RETRY_CNT
}; };
/** /**
* Configure overall network topology to have a particular shape. * Configure overall network topology to have a particular shape.
* *
* @param op_cls closure argument to give with the operation event * @param op_cls closure argument to give with the operation event
* @param num_peers number of peers in 'peers' * @param num_peers number of peers in 'peers'
* @param peers array of 'num_peers' with the peers to configure * @param peers array of 'num_peers' with the peers to configure
* @param topo desired underlay topology to use * @param topo desired underlay topology to use
* @param ap topology-specific options * @param ap topology-specific options
skipping to change at line 1028 skipping to change at line 1033
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_underlay_configure_topology (void *op_cls, GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
unsigned int num_peers, unsigned int num_peers,
struct GNUNET_TESTBED_Peer **pe ers, struct GNUNET_TESTBED_Peer **pe ers,
enum GNUNET_TESTBED_TopologyOpt ion topo, enum GNUNET_TESTBED_TopologyOpt ion topo,
...); ...);
/** /**
* Both peers must have been started before calling this function. * Both peers must have been started before calling this function.
* This function then obtains a HELLO from 'p1', gives it to 'p2' * This function then obtains a HELLO from @a p1, gives it to @a p2
* and asks 'p2' to connect to 'p1'. * and asks @a p2 to connect to @a p1.
* *
* @param op_cls closure argument to give with the operation event * @param op_cls closure argument to give with the operation event
* @param cb the callback to call when this operation has finished * @param cb the callback to call when this operation has finished
* @param cb_cls the closure for the above callback * @param cb_cls the closure for @a cb
* @param p1 first peer * @param p1 first peer
* @param p2 second peer * @param p2 second peer
* @return handle to the operation, NULL if connecting these two * @return handle to the operation, NULL if connecting these two
* peers is fundamentally not possible at this time (peers * peers is fundamentally not possible at this time (peers
* not running or underlay disallows) * not running or underlay disallows)
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_overlay_connect (void *op_cls, GNUNET_TESTBED_overlay_connect (void *op_cls,
GNUNET_TESTBED_OperationCompletionCallback cb, GNUNET_TESTBED_OperationCompletionCallback cb,
void *cb_cls, void *cb_cls,
struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p1,
struct GNUNET_TESTBED_Peer *p2); struct GNUNET_TESTBED_Peer *p2);
/** /**
* Callbacks of this type are called when topology configuration is complet
ed
*
* @param cls the operation closure given to
* GNUNET_TESTBED_overlay_configure_topology_va() and
* GNUNET_TESTBED_overlay_configure() calls
* @param nsuccess the number of successful overlay connects
* @param nfailures the number of overlay connects which failed
*/
typedef void (*GNUNET_TESTBED_TopologyCompletionCallback) (void *cls,
unsigned int nsuc
cess,
unsigned int nfai
lures);
/**
* All peers must have been started before calling this function. * All peers must have been started before calling this function.
* This function then connects the given peers in the P2P overlay * This function then connects the given peers in the P2P overlay
* using the given topology. * using the given topology.
* *
* @param op_cls closure argument to give with the operation event * @param op_cls closure argument to give with the peer connect operation e
vents
* generated through this function
* @param num_peers number of peers in 'peers' * @param num_peers number of peers in 'peers'
* @param peers array of 'num_peers' with the peers to configure * @param peers array of 'num_peers' with the peers to configure
* @param max_connections the maximums number of overlay connections that w ill * @param max_connections the maximums number of overlay connections that w ill
* be made to achieve the given topology * be made to achieve the given topology
* @param comp_cb the completion callback to call when the topology generat
ion
* is completed
* @param comp_cb_cls closure for the @a comp_cb
* @param topo desired underlay topology to use * @param topo desired underlay topology to use
* @param va topology-specific options * @param va topology-specific options
* @return handle to the operation, NULL if connecting these * @return handle to the operation, NULL if connecting these
* peers is fundamentally not possible at this time (peers * peers is fundamentally not possible at this time (peers
* not running or underlay disallows) or if num_peers is less than 2 * not running or underlay disallows) or if num_peers is less than 2
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
unsigned int num_peers, unsigned int num_peers,
struct GNUNET_TESTBED_Peer ** peers, struct GNUNET_TESTBED_Peer ** peers,
unsigned int *max_connections , unsigned int *max_connections ,
GNUNET_TESTBED_TopologyComple
tionCallback
comp_cb,
void *comp_cb_cls,
enum GNUNET_TESTBED_TopologyO ption topo, enum GNUNET_TESTBED_TopologyO ption topo,
va_list va); va_list va);
/** /**
* All peers must have been started before calling this function. * All peers must have been started before calling this function.
* This function then connects the given peers in the P2P overlay * This function then connects the given peers in the P2P overlay
* using the given topology. * using the given topology.
* *
* @param op_cls closure argument to give with the operation event * @param op_cls closure argument to give with the peer connect operation e
vents
* generated through this function
* @param num_peers number of peers in 'peers' * @param num_peers number of peers in 'peers'
* @param peers array of 'num_peers' with the peers to configure * @param peers array of 'num_peers' with the peers to configure
* @param max_connections the maximums number of overlay connections that w ill * @param max_connections the maximums number of overlay connections that w ill
* be made to achieve the given topology * be made to achieve the given topology
* @param comp_cb the completion callback to call when the topology generat
ion
* is completed
* @param comp_cb_cls closure for the above completion callback
* @param topo desired underlay topology to use * @param topo desired underlay topology to use
* @param ... topology-specific options * @param ... topology-specific options
* @return handle to the operation, NULL if connecting these * @return handle to the operation, NULL if connecting these
* peers is fundamentally not possible at this time (peers * peers is fundamentally not possible at this time (peers
* not running or underlay disallows) or if num_peers is less than 2 * not running or underlay disallows) or if num_peers is less than 2
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_overlay_configure_topology (void *op_cls, GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
unsigned int num_peers, unsigned int num_peers,
struct GNUNET_TESTBED_Peer **pee rs, struct GNUNET_TESTBED_Peer **pee rs,
unsigned int *max_connections, unsigned int *max_connections,
GNUNET_TESTBED_TopologyCompletio
nCallback
comp_cb,
void *comp_cb_cls,
enum GNUNET_TESTBED_TopologyOpti on topo, enum GNUNET_TESTBED_TopologyOpti on topo,
...); ...);
/** /**
* Ask the testbed controller to write the current overlay topology to * Ask the testbed controller to write the current overlay topology to
* a file. Naturally, the file will only contain a snapshot as the * a file. Naturally, the file will only contain a snapshot as the
* topology may evolve all the time. * topology may evolve all the time.
* FIXME: needs continuation!? * FIXME: needs continuation!?
* *
* @param controller overlay controller to inspect * @param controller overlay controller to inspect
skipping to change at line 1155 skipping to change at line 1187
void void
*ca_result , *ca_result ,
const char const char
*emsg ); *emsg );
/** /**
* Connect to a service offered by the given peer. Will ensure that * Connect to a service offered by the given peer. Will ensure that
* the request is queued to not overwhelm our ability to create and * the request is queued to not overwhelm our ability to create and
* maintain connections with other systems. The actual service * maintain connections with other systems. The actual service
* handle is then returned via the 'op_result' member in the event * handle is then returned via the 'op_result' member in the event
* callback. The 'ca' callback is used to create the connection * callback. The @a ca callback is used to create the connection
* when the time is right; the 'da' callback will be used to * when the time is right; the @a da callback will be used to
* destroy the connection (upon 'GNUNET_TESTBED_operation_done'). * destroy the connection (upon #GNUNET_TESTBED_operation_done).
* 'GNUNET_TESTBED_operation_cancel' can be used to abort this * #GNUNET_TESTBED_operation_done can be used to abort this
* operation until the event callback has been called. * operation until the event callback has been called.
* *
* @param op_cls closure to pass in operation event * @param op_cls closure to pass in operation event // FIXME: didn't we say we'd no longer use the global callback for these? -CG
* @param peer peer that runs the service * @param peer peer that runs the service
* @param service_name name of the service to connect to * @param service_name name of the service to connect to
* @param cb the callback to call when this operation finishes * @param cb the callback to call when this operation is ready (that is,
* @param cb_cls closure for the above callback * right after the connect adapter returns)
* @param cb_cls closure for @a cb
* @param ca helper function to establish the connection * @param ca helper function to establish the connection
* @param da helper function to close the connection * @param da helper function to close the connection
* @param cada_cls closure for ca and da * @param cada_cls closure for @a ca and @a da
* @return handle for the operation * @return handle for the operation
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_service_connect (void *op_cls, GNUNET_TESTBED_service_connect (void *op_cls,
struct GNUNET_TESTBED_Peer *peer, struct GNUNET_TESTBED_Peer *peer,
const char *service_name, const char *service_name,
GNUNET_TESTBED_ServiceConnectCompletionCall back cb, GNUNET_TESTBED_ServiceConnectCompletionCall back cb,
void *cb_cls, void *cb_cls,
GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_ConnectAdapter ca,
GNUNET_TESTBED_DisconnectAdapter da, GNUNET_TESTBED_DisconnectAdapter da,
skipping to change at line 1229 skipping to change at line 1262
const char *name, const char *name,
uint64_t value, uint64_t value,
int is_persistent); int is_persistent);
/** /**
* Convenience method that iterates over all (running) peers * Convenience method that iterates over all (running) peers
* and retrieves all statistics from each peer. * and retrieves all statistics from each peer.
* *
* @param num_peers number of peers to iterate over * @param num_peers number of peers to iterate over
* @param peers array of peers to iterate over * @param peers array of peers to iterate over
* @param subsystem limit to the specified subsystem, NULL for all subsyste
ms
* @param name name of the statistic value, NULL for all values
* @param proc processing function for each statistic retrieved * @param proc processing function for each statistic retrieved
* @param cont continuation to call once call is completed(?) * @param cont continuation to call once call is completed. The completion
of this
* operation is *ONLY* signalled through this callback -- no
* GNUNET_TESTBED_ET_OPERATION_FINISHED is generated
* @param cls closure to pass to proc and cont * @param cls closure to pass to proc and cont
* @return operation handle to cancel the operation * @return operation handle to cancel the operation
*/ */
struct GNUNET_TESTBED_Operation * struct GNUNET_TESTBED_Operation *
GNUNET_TESTBED_get_statistics (unsigned int num_peers, GNUNET_TESTBED_get_statistics (unsigned int num_peers,
struct GNUNET_TESTBED_Peer **peers, struct GNUNET_TESTBED_Peer **peers,
const char *subsystem, const char *name,
GNUNET_TESTBED_StatisticsIterator proc, GNUNET_TESTBED_StatisticsIterator proc,
GNUNET_TESTBED_OperationCompletionCallback c ont, GNUNET_TESTBED_OperationCompletionCallback c ont,
void *cls); void *cls);
/** /**
* Handle for testbed run helper funtions
*/
struct GNUNET_TESTBED_RunHandle;
/**
* Signature of a main function for a testcase. * Signature of a main function for a testcase.
* *
* @param cls closure * @param cls closure
* @param h the run handle
* @param num_peers number of peers in 'peers' * @param num_peers number of peers in 'peers'
* @param peers handle to peers run in the testbed * @param peers handle to peers run in the testbed. NULL upon timeout (see
* GNUNET_TESTBED_test_run()).
* @param links_succeeded the number of overlay link connection attempts th
at
* succeeded
* @param links_failed the number of overlay link connection attempts that
* failed
* @see GNUNET_TESTBED_test_run()
*/ */
typedef void (*GNUNET_TESTBED_TestMaster)(void *cls, typedef void (*GNUNET_TESTBED_TestMaster)(void *cls,
struct GNUNET_TESTBED_RunHandle * h,
unsigned int num_peers, unsigned int num_peers,
struct GNUNET_TESTBED_Peer **peer struct GNUNET_TESTBED_Peer **peer
s); s,
unsigned int links_succeeded,
unsigned int links_failed);
/** /**
* Convenience method for running a testbed with * Convenience method for running a testbed with
* a single call. Underlay and overlay topology * a single call. Underlay and overlay topology
* are configured using the "UNDERLAY" and "OVERLAY" * are configured using the "UNDERLAY" and "OVERLAY"
* options in the "[testbed]" section of the configuration\ * options in the "[testbed]" section of the configuration\
* (with possible options given in "UNDERLAY_XXX" and/or * (with possible options given in "UNDERLAY_XXX" and/or
* "OVERLAY_XXX"). * "OVERLAY_XXX").
* *
* The test_master callback will be called once the testbed setup is finish
ed or
* upon a timeout. This timeout is given through the configuration file by
* setting the option "SETUP_TIMEOUT" in "[TESTBED]" section.
*
* The testbed is to be terminated using a call to * The testbed is to be terminated using a call to
* "GNUNET_SCHEDULER_shutdown". * "GNUNET_SCHEDULER_shutdown".
* *
* @param host_filename name of the file with the 'hosts', NULL * @param host_filename name of the file with the 'hosts', NULL
* to run everything on 'localhost' * to run everything on 'localhost'
* @param cfg configuration to use (for testbed, controller and peers) * @param cfg configuration to use (for testbed, controller and peers)
* @param num_peers number of peers to start; FIXME: maybe put that ALSO in to * @param num_peers number of peers to start; FIXME: maybe put that ALSO in to
* cfg?; should be greater than 0 * cfg?; should be greater than 0
* @param event_mask bit mask with set of events to call 'cc' for; * @param event_mask bit mask with set of events to call 'cc' for;
* or-ed values of "1LL" shifted by the * or-ed values of "1LL" shifted by the
* respective 'enum GNUNET_TESTBED_EventType' * respective 'enum GNUNET_TESTBED_EventType'
* (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...") * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
* @param cc controller callback to invoke on events; This callback is call ed * @param cc controller callback to invoke on events; This callback is call ed
* for all peer start events even if GNUNET_TESTBED_ET_PEER_START is n't * for all peer start events even if GNUNET_TESTBED_ET_PEER_START is n't
* set in the event_mask as this is the only way get access to the * set in the event_mask as this is the only way get access to the
* handle of each peer * handle of each peer
* @param cc_cls closure for cc * @param cc_cls closure for cc
* @param test_master this callback will be called once the test is ready * @param test_master this callback will be called once the test is ready o
r
* upon timeout
* @param test_master_cls closure for 'test_master'. * @param test_master_cls closure for 'test_master'.
*/ */
void void
GNUNET_TESTBED_run (const char *host_filename, GNUNET_TESTBED_run (const char *host_filename,
const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CONFIGURATION_Handle *cfg,
unsigned int num_peers, unsigned int num_peers,
uint64_t event_mask, uint64_t event_mask,
GNUNET_TESTBED_ControllerCallback cc, GNUNET_TESTBED_ControllerCallback cc,
void *cc_cls, void *cc_cls,
GNUNET_TESTBED_TestMaster test_master, GNUNET_TESTBED_TestMaster test_master,
void *test_master_cls); void *test_master_cls);
/** /**
* Convenience method for running a "simple" test on the local system * Convenience method for running a "simple" test on the local system
* with a single call from 'main'. Underlay and overlay topology are * with a single call from 'main'. Underlay and overlay topology are
* configured using the "UNDERLAY" and "OVERLAY" options in the * configured using the "UNDERLAY" and "OVERLAY" options in the
* "[testbed]" section of the configuration (with possible options * "[TESTBED]" section of the configuration (with possible options
* given in "UNDERLAY_XXX" and/or "OVERLAY_XXX"). * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
* *
* The test_master callback will be called once the testbed setup is finish
ed or
* upon a timeout. This timeout is given through the configuration file by
* setting the option "SETUP_TIMEOUT" in "[TESTBED]" section.
*
* The test is to be terminated using a call to * The test is to be terminated using a call to
* "GNUNET_SCHEDULER_shutdown". If starting the test fails, * "GNUNET_SCHEDULER_shutdown". If starting the test fails,
* the program is stopped without 'master' ever being run. * the program is stopped without 'master' ever being run.
* *
* NOTE: this function should be called from 'main', NOT from * NOTE: this function should be called from 'main', NOT from
* within a GNUNET_SCHEDULER-loop. This function will initialze * within a GNUNET_SCHEDULER-loop. This function will initialze
* the scheduler loop, the testbed and then pass control to * the scheduler loop, the testbed and then pass control to
* 'master'. * 'master'.
* *
* @param testname name of the testcase (to configure logging, etc.) * @param testname name of the testcase (to configure logging, etc.)
skipping to change at line 1318 skipping to change at line 1380
* (for testbed, controller and peers) * (for testbed, controller and peers)
* @param num_peers number of peers to start; should be greter than 0 * @param num_peers number of peers to start; should be greter than 0
* @param event_mask bit mask with set of events to call 'cc' for; * @param event_mask bit mask with set of events to call 'cc' for;
* or-ed values of "1LL" shifted by the * or-ed values of "1LL" shifted by the
* respective 'enum GNUNET_TESTBED_EventType' * respective 'enum GNUNET_TESTBED_EventType'
* (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...") * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
* @param cc controller callback to invoke on events; This callback is call ed * @param cc controller callback to invoke on events; This callback is call ed
* for all peer start events even if GNUNET_TESTBED_ET_PEER_START is n't * for all peer start events even if GNUNET_TESTBED_ET_PEER_START is n't
* set in the event_mask as this is the only way get access to the * set in the event_mask as this is the only way get access to the
* handle of each peer * handle of each peer
* @param cc_cls closure for cc * @param cc_cls closure for @a cc
* @param test_master this callback will be called once the test is ready * @param test_master this callback will be called once the test is ready o
* @param test_master_cls closure for 'test_master'. r
* @param GNUNET_SYSERR on error, GNUNET_OK on success * upon timeout
* @param test_master_cls closure for @a test_master.
* @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/ */
int int
GNUNET_TESTBED_test_run (const char *testname, GNUNET_TESTBED_test_run (const char *testname,
const char *cfg_filename, const char *cfg_filename,
unsigned int num_peers, unsigned int num_peers,
uint64_t event_mask, uint64_t event_mask,
GNUNET_TESTBED_ControllerCallback cc, GNUNET_TESTBED_ControllerCallback cc,
void *cc_cls, void *cc_cls,
GNUNET_TESTBED_TestMaster test_master, GNUNET_TESTBED_TestMaster test_master,
void *test_master_cls); void *test_master_cls);
/**
* Obtain handle to the master controller from a testbed run. The handle
* returned should not be disconnected.
*
* @param h the testbed run handle
* @return handle to the master controller
*/
struct GNUNET_TESTBED_Controller *
GNUNET_TESTBED_run_get_controller_handle (struct GNUNET_TESTBED_RunHandle *
h);
/**
* Opaque handle for barrier
*/
struct GNUNET_TESTBED_Barrier;
/**
* Status of a barrier
*/
enum GNUNET_TESTBED_BarrierStatus
{
/**
* Barrier initialised successfully
*/
GNUNET_TESTBED_BARRIERSTATUS_INITIALISED = 1,
/**
* Barrier is crossed
*/
GNUNET_TESTBED_BARRIERSTATUS_CROSSED,
/**
* Error status
*/
GNUNET_TESTBED_BARRIERSTATUS_ERROR,
};
/**
* Functions of this type are to be given as callback argument to
* GNUNET_TESTBED_barrier_init(). The callback will be called when status
* information is available for the barrier.
*
* @param cls the closure given to GNUNET_TESTBED_barrier_init()
* @param name the name of the barrier
* @param barrier the barrier handle
* @param status status of the barrier; GNUNET_OK if the barrier is crossed
;
* GNUNET_SYSERR upon error
* @param emsg if the status were to be GNUNET_SYSERR, this parameter has t
he
* error messsage
*/
typedef void (*GNUNET_TESTBED_barrier_status_cb) (void *cls,
const char *name,
struct GNUNET_TESTBED_Bar
rier
*barrier,
enum GNUNET_TESTBED_Barri
erStatus status,
const char *emsg);
/**
* Initialise a barrier and call the given callback when the required perce
ntage
* of peers (quorum) reach the barrier.
*
* @param controller the handle to the controller
* @param name identification name of the barrier
* @param quorum the percentage of peers that is required to reach the barr
ier.
* Peers signal reaching a barrier by calling
* GNUNET_TESTBED_barrier_reached().
* @param cb the callback to call when the barrier is reached or upon error
.
* Cannot be NULL.
* @param cls closure for the above callback
* @return barrier handle
*/
struct GNUNET_TESTBED_Barrier *
GNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller,
const char *name,
unsigned int quorum,
GNUNET_TESTBED_barrier_status_cb cb, void *cls
);
/**
* Cancel a barrier.
*
* @param barrier the barrier handle
*/
void
GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier);
/**
* Opaque handle for barrier wait
*/
struct GNUNET_TESTBED_BarrierWaitHandle;
/**
* Functions of this type are to be given as acallback argumetn to
* GNUNET_TESTBED_barrier_wait(). The callback will be called when the bar
rier
* corresponding given in GNUNET_TESTBED_barrier_wait() is crossed or cance
lled.
*
* @param cls closure pointer given to GNUNET_TESTBED_barrier_wait()
* @param name the barrier name
* @param status GNUNET_SYSERR in case of error while waiting for the barri
er;
* GNUNET_OK if the barrier is crossed
*/
typedef void (*GNUNET_TESTBED_barrier_wait_cb) (void *cls,
const char *name,
int status);
/**
* Wait for a barrier to be crossed. This function should be called by the
* peers which have been started by the testbed. If the peer is not starte
d by
* testbed this function may return error
*
* @param name the name of the barrier
* @param cb the barrier wait callback
* @param cls the closure for the above callback
* @return barrier wait handle which can be used to cancel the waiting at
* anytime before the callback is called. NULL upon error.
*/
struct GNUNET_TESTBED_BarrierWaitHandle *
GNUNET_TESTBED_barrier_wait (const char *name,
GNUNET_TESTBED_barrier_wait_cb cb,
void *cls);
/**
* Cancel a barrier wait handle. Should not be called in or after the call
back
* given to GNUNET_TESTBED_barrier_wait() has been called.
*
* @param h the barrier wait handle
*/
void
GNUNET_TESTBED_barrier_wait_cancel (struct GNUNET_TESTBED_BarrierWaitHandle
*h);
/**
* Model for configuring underlay links of a peer
* @ingroup underlay
*/
struct GNUNET_TESTBED_UnderlayLinkModel;
/**
* The type of GNUNET_TESTBED_UnderlayLinkModel
* @ingroup underlay
*/
enum GNUNET_TESTBED_UnderlayLinkModelType
{
/**
* The model is based on white listing of peers to which underlay connect
ions
* are permitted. Underlay connections to all other peers will not be
* permitted.
*/
GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST,
/**
* The model is based on black listing of peers to which underlay connect
ions
* are not permitted. Underlay connections to all other peers will be
* permitted
*/
GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_WHITELIST
};
/**
* Create a GNUNET_TESTBED_UnderlayLinkModel for the given peer. A peer ca
n
* have ONLY ONE model and it can be either a blacklist or whitelist based
one.
*
* @ingroup underlay
* @param peer the peer for which the model has to be created
* @param type the type of the model
* @return the model
*/
struct GNUNET_TESTBED_UnderlayLinkModel *
GNUNET_TESTBED_underlaylinkmodel_create (struct GNUNET_TESTBED_Peer *peer,
enum GNUNET_TESTBED_UnderlayLinkMo
delType type);
/**
* Add a peer to the given model. Underlay connections to the given peer w
ill
* be permitted if the model is whitelist based; otherwise they will not be
* permitted.
*
* @ingroup underlay
* @param model the model
* @param peer the peer to add
*/
void
GNUNET_TESTBED_underlaylinkmodel_add_peer (struct GNUNET_TESTBED_UnderlayLi
nkModel *model,
struct GNUNET_TESTBED_Peer *peer
);
/**
* Set the metrics for a link to the given peer in the underlay model. The
link
* SHOULD be permittable according to the given model.
*
* @ingroup underlay
* @param model the model
* @param peer the other end peer of the link
* @param latency latency of the link in microseconds
* @param loss data loss of the link expressed as a percentage
* @param bandwidth bandwidth of the link in kilobytes per second [kB/s]
*/
void
GNUNET_TESTBED_underlaylinkmodel_set_link (struct GNUNET_TESTBED_UnderlayLi
nkModel *model,
struct GNUNET_TESTBED_Peer *peer
,
uint32_t latency,
uint32_t loss,
uint32_t bandwidth);
/**
* Commit the model. The model is freed in this function(!).
*
* @ingroup underlay
* @param model the model to commit
*/
void
GNUNET_TESTBED_underlaylinkmodel_commit (struct GNUNET_TESTBED_UnderlayLink
Model *model);
/**
* Free the resources of the model. Use this function only if the model ha
s not
* be committed and has to be unallocated. The peer can then have another
model
* created.
*
* @ingroup underlay
* @param model the model to unallocate
*/
void
GNUNET_TESTBED_underlaylinkmodel_free (struct GNUNET_TESTBED_UnderlayLinkMo
del *model);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 73 change blocks. 
172 lines changed or deleted 524 lines changed or added


 gnunet_testing_lib.h   gnunet_testing_lib.h 
skipping to change at line 38 skipping to change at line 38
* P2P connection, topology management or distributed * P2P connection, topology management or distributed
* testbed maintenance (those are in gnunet_testbed_service.h) * testbed maintenance (those are in gnunet_testbed_service.h)
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef GNUNET_TESTING_LIB_H #ifndef GNUNET_TESTING_LIB_H
#define GNUNET_TESTING_LIB_H #define GNUNET_TESTING_LIB_H
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h" #include "gnunet_statistics_service.h"
#include "gnunet_arm_service.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#define GNUNET_TESTING_HOSTKEYFILESIZE 914 /**
* Size of each hostkey in the hostkey file (in BYTES).
*/
#define GNUNET_TESTING_HOSTKEYFILESIZE sizeof (struct GNUNET_CRYPTO_EddsaPr
ivateKey)
/**
* The environmental variable, if set, that dictates where testing should p
lace
* generated peer configurations
*/
#define GNUNET_TESTING_PREFIX "GNUNET_TESTING_PREFIX"
/** /**
* Handle for a system on which GNUnet peers are executed; * Handle for a system on which GNUnet peers are executed;
* a system is used for reserving unique paths and ports. * a system is used for reserving unique paths and ports.
*/ */
struct GNUNET_TESTING_System; struct GNUNET_TESTING_System;
/** /**
* Handle for a GNUnet peer controlled by testing. * Handle for a GNUnet peer controlled by testing.
*/ */
struct GNUNET_TESTING_Peer; struct GNUNET_TESTING_Peer;
/** /**
* Specification of a service that is to be shared among peers
*/
struct GNUNET_TESTING_SharedService
{
/**
* The name of the service.
*/
const char *service;
/**
* The configuration template for the service. Cannot be NULL
*/
const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* The number of peers which share an instance of the service. 0 for sha
ring
* among all peers
*/
unsigned int share;
};
/**
* Create a system handle. There must only be one system handle per operat ing * Create a system handle. There must only be one system handle per operat ing
* system. Uses a default range for allowed ports. Ports are still tested for * system. Uses a default range for allowed ports. Ports are still tested for
* availability. * availability.
* *
* @param testdir only the directory name without any path. This is used fo r all * @param testdir only the directory name without any path. This is used fo r all
* service homes; the directory will be created in a temporary loc ation * service homes; the directory will be created in a temporary loc ation
* depending on the underlying OS * depending on the underlying OS. This variable will be
* overridden with the value of the environmental variable
* GNUNET_TESTING_PREFIX, if it exists.
* @param trusted_ip the ip address which will be set as TRUSTED HOST in al l * @param trusted_ip the ip address which will be set as TRUSTED HOST in al l
* service configurations generated to allow control connections f rom * service configurations generated to allow control connections f rom
* this ip. This can either be a single ip address or a network ad dress * this ip. This can either be a single ip address or a network ad dress
* in CIDR notation. * in CIDR notation.
* @param hostname the hostname of the system we are using for testing; NUL L for * @param hostname the hostname of the system we are using for testing; NUL L for
* localhost * localhost
* @param shared_services NULL terminated array describing services that ar
e to
* be shared among peers
* @return handle to this system, NULL on error * @return handle to this system, NULL on error
*/ */
struct GNUNET_TESTING_System * struct GNUNET_TESTING_System *
GNUNET_TESTING_system_create (const char *testdir, GNUNET_TESTING_system_create (const char *testdir,
const char *trusted_ip, const char *trusted_ip,
const char *hostname); const char *hostname,
const struct GNUNET_TESTING_SharedService *
shared_services);
/** /**
* Create a system handle. There must only be one system * Create a system handle. There must only be one system
* handle per operating system. Use this function directly * handle per operating system. Use this function directly
* if multiple system objects are created for the same host * if multiple system objects are created for the same host
* (only really useful when testing --- or to make the port * (only really useful when testing --- or to make the port
* range configureable). * range configureable).
* *
* @param testdir only the directory name without any path. This is used fo r * @param testdir only the directory name without any path. This is used fo r
* all service homes; the directory will be created in a temporary * all service homes; the directory will be created in a temporary
* location depending on the underlying OS * location depending on the underlying OS. This variable will be
* overridden with the value of the environmental variable
* GNUNET_TESTING_PREFIX, if it exists.
* @param trusted_ip the ip address which will be set as TRUSTED HOST in al l * @param trusted_ip the ip address which will be set as TRUSTED HOST in al l
* service configurations generated to allow control connections f rom * service configurations generated to allow control connections f rom
* this ip. This can either be a single ip address or a network ad dress * this ip. This can either be a single ip address or a network ad dress
* in CIDR notation. * in CIDR notation.
* @param controller hostname of the controlling host,
* service configurations are modified to allow
* control connections from this host; can be NULL
* @param hostname the hostname of the system we are using for testing; NUL L for * @param hostname the hostname of the system we are using for testing; NUL L for
* localhost * localhost
* @param shared_services NULL terminated array describing services that ar
e to
* be shared among peers
* @param lowport lowest port number this system is allowed to allocate (in clusive) * @param lowport lowest port number this system is allowed to allocate (in clusive)
* @param highport highest port number this system is allowed to allocate ( exclusive) * @param highport highest port number this system is allowed to allocate ( exclusive)
* @return handle to this system, NULL on error * @return handle to this system, NULL on error
*/ */
struct GNUNET_TESTING_System * struct GNUNET_TESTING_System *
GNUNET_TESTING_system_create_with_portrange (const char *testdir, GNUNET_TESTING_system_create_with_portrange (const char *testdir,
const char *trusted_ip, const char *trusted_ip,
const char *hostname, const char *hostname,
const struct
GNUNET_TESTING_SharedService *
shared_services,
uint16_t lowport, uint16_t lowport,
uint16_t highport); uint16_t highport);
/** /**
* Free system resources. * Free system resources.
* *
* @param system system to be freed * @param system system to be freed
* @param remove_paths should the 'testdir' and all subdirectories * @param remove_paths should the 'testdir' and all subdirectories
* be removed (clean up on shutdown)? * be removed (clean up on shutdown)?
*/ */
skipping to change at line 139 skipping to change at line 181
* *
* This is primarily a helper function used internally * This is primarily a helper function used internally
* by 'GNUNET_TESTING_peer_configure'. * by 'GNUNET_TESTING_peer_configure'.
* *
* @param system the testing system handle * @param system the testing system handle
* @param key_number desired pre-created hostkey to obtain * @param key_number desired pre-created hostkey to obtain
* @param id set to the peer's identity (hash of the public * @param id set to the peer's identity (hash of the public
* key; if NULL, GNUNET_SYSERR is returned immediately * key; if NULL, GNUNET_SYSERR is returned immediately
* @return NULL on error (not enough keys) * @return NULL on error (not enough keys)
*/ */
struct GNUNET_CRYPTO_RsaPrivateKey * struct GNUNET_CRYPTO_EddsaPrivateKey *
GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
uint32_t key_number, uint32_t key_number,
struct GNUNET_PeerIdentity *id); struct GNUNET_PeerIdentity *id);
/** /**
* Reserve a TCP or UDP port for a peer. * Reserve a port for a peer.
* *
* @param system system to use for reservation tracking * @param system system to use for reservation tracking
* @param is_tcp GNUNET_YES for TCP ports, GNUNET_NO for UDP
* @return 0 if no free port was available * @return 0 if no free port was available
*/ */
uint16_t uint16_t
GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system, GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system);
int is_tcp);
/** /**
* Release reservation of a TCP or UDP port for a peer * Release reservation of a TCP or UDP port for a peer
* (used during GNUNET_TESTING_peer_destroy). * (used during GNUNET_TESTING_peer_destroy).
* *
* @param system system to use for reservation tracking * @param system system to use for reservation tracking
* @param is_tcp GNUNET_YES for TCP ports, GNUNET_NO for UDP
* @param port reserved port to release * @param port reserved port to release
*/ */
void void
GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system, GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
int is_tcp,
uint16_t port); uint16_t port);
/** /**
* Create a new configuration using the given configuration as a template; * Create a new configuration using the given configuration as a template;
* ports and paths will be modified to select available ports on the local * ports and paths will be modified to select available ports on the local
* system. The default configuration will be available in PATHS section und er * system. The default configuration will be available in PATHS section und er
* the option DEFAULTCONFIG after the call. SERVICE_HOME is also set in PAT HS * the option DEFAULTCONFIG after the call. SERVICE_HOME is also set in PAT HS
* section to the temporary directory specific to this configuration. If we run * section to the temporary directory specific to this configuration. If we run
* out of "*port" numbers, return SYSERR. * out of "*port" numbers, return SYSERR.
* *
skipping to change at line 216 skipping to change at line 254
struct GNUNET_PeerIdentity *id, struct GNUNET_PeerIdentity *id,
char **emsg); char **emsg);
/** /**
* Obtain the peer identity from a peer handle. * Obtain the peer identity from a peer handle.
* *
* @param peer peer handle for which we want the peer's identity * @param peer peer handle for which we want the peer's identity
* @param id identifier for the daemon, will be set * @param id identifier for the daemon, will be set
*/ */
void void
GNUNET_TESTING_peer_get_identity (const struct GNUNET_TESTING_Peer *peer, GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
struct GNUNET_PeerIdentity *id); struct GNUNET_PeerIdentity *id);
/** /**
* Start the peer. * Start the peer.
* *
* @param peer peer to start * @param peer peer to start
* @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running) * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running)
*/ */
int int
GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer); GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer);
/** /**
* Stop the peer. * Stop the peer. This call is blocking as it kills the peer's main ARM pro
cess
* by sending a SIGTERM and waits on it. For asynchronous shutdown of peer
, see
* GNUNET_TESTING_peer_stop_async().
* *
* @param peer peer to stop * @param peer peer to stop
* @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer not runn ing) * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer not runn ing)
*/ */
int int
GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer); GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer);
/** /**
* Destroy the peer. Releases resources locked during peer configuration. * Destroy the peer. Releases resources locked during peer configuration.
* If the peer is still running, it will be stopped AND a warning will be * If the peer is still running, it will be stopped AND a warning will be
skipping to change at line 268 skipping to change at line 308
* Waits for a peer to terminate. The peer's main process will also be dest royed. * Waits for a peer to terminate. The peer's main process will also be dest royed.
* *
* @param peer the handle to the peer * @param peer the handle to the peer
* @return GNUNET_OK if successful; GNUNET_SYSERR if the main process is NU LL * @return GNUNET_OK if successful; GNUNET_SYSERR if the main process is NU LL
* or upon any error while waiting * or upon any error while waiting
*/ */
int int
GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer); GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer);
/** /**
* Callback to inform whether the peer is running or stopped.
*
* @param cls the closure given to GNUNET_TESTING_peer_stop_async()
* @param peer the respective peer whose status is being reported
* @param success GNUNET_YES if the peer is stopped; GNUNET_SYSERR upon any
* error
*/
typedef void (*GNUNET_TESTING_PeerStopCallback) (void *cls,
struct GNUNET_TESTING_Peer
*
peer,
int success);
/**
* Stop a peer asynchronously using ARM API. Peer's shutdown is signaled
* through the GNUNET_TESTING_PeerStopCallback().
*
* @param peer the peer to stop
* @param cb the callback to signal peer shutdown
* @param cb_cls closure for the above callback
* @return GNUNET_OK upon successfully giving the request to the ARM API (t
his
* does not mean that the peer is successfully stopped); GNUNET_S
YSERR
* upon any error.
*/
int
GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer,
GNUNET_TESTING_PeerStopCallback cb,
void *cb_cls);
/**
* Cancel a previous asynchronous peer stop request.
* GNUNET_TESTING_peer_stop_async() should have been called before on the g
iven
* peer. It is an error to call this function if the peer stop callback wa
s
* already called
*
* @param peer the peer on which GNUNET_TESTING_peer_stop_async() was calle
d
* before.
*/
void
GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer);
/**
* Signature of the 'main' function for a (single-peer) testcase that * Signature of the 'main' function for a (single-peer) testcase that
* is run using 'GNUNET_TESTING_peer_run'. * is run using 'GNUNET_TESTING_peer_run'.
* *
* @param cls closure * @param cls closure
* @param cfg configuration of the peer that was started * @param cfg configuration of the peer that was started
* @param peer identity of the peer that was created * @param peer identity of the peer that was created
*/ */
typedef void (*GNUNET_TESTING_TestMain)(void *cls, typedef void (*GNUNET_TESTING_TestMain) (void *cls,
const struct GNUNET_CONFIGURATION_Ha const struct GNUNET_CONFIGURATION_
ndle *cfg, Handle *cfg,
struct GNUNET_TESTING_Peer *peer); struct GNUNET_TESTING_Peer *peer);
/** /**
* Start a single peer and run a test using the testing library. * Start a single peer and run a test using the testing library.
* Starts a peer using the given configuration and then invokes the * Starts a peer using the given configuration and then invokes the
* given callback. This function ALSO initializes the scheduler loop * given callback. This function ALSO initializes the scheduler loop
* and should thus be called directly from "main". The testcase * and should thus be called directly from "main". The testcase
* should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'.
* *
* @param testdir only the directory name without any path. This is used fo r * @param testdir only the directory name without any path. This is used fo r
* all service homes; the directory will be created in a temporary * all service homes; the directory will be created in a temporary
 End of changes. 20 change blocks. 
20 lines changed or deleted 114 lines changed or added


 gnunet_time_lib.h   gnunet_time_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. Boston, MA 02111-1307, USA.
*/ */
/** /**
* @file include/gnunet_time_lib.h * @file include/gnunet_time_lib.h
* @brief functions related to time * @brief functions related to time
*
* @author Christian Grothoff * @author Christian Grothoff
* @defgroup time Time and time calculations
* @{
*/ */
#ifndef GNUNET_TIME_LIB_H #ifndef GNUNET_TIME_LIB_H
#define GNUNET_TIME_LIB_H #define GNUNET_TIME_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h" #include "gnunet_common.h"
/** /**
* Time for absolute times used by GNUnet, in milliseconds. * Time for absolute times used by GNUnet, in microseconds.
*/ */
struct GNUNET_TIME_Absolute struct GNUNET_TIME_Absolute
{ {
/** /**
* The actual value. * The actual value.
*/ */
uint64_t abs_value; uint64_t abs_value_us;
}; };
/** /**
* Time for relative time used by GNUnet, in milliseconds. * Time for relative time used by GNUnet, in microseconds.
* Always positive, so we can only refer to future time. * Always positive, so we can only refer to future time.
*/ */
struct GNUNET_TIME_Relative struct GNUNET_TIME_Relative
{ {
/** /**
* The actual value. * The actual value.
*/ */
uint64_t rel_value; uint64_t rel_value_us;
}; };
GNUNET_NETWORK_STRUCT_BEGIN GNUNET_NETWORK_STRUCT_BEGIN
/** /**
* Time for relative time used by GNUnet, in milliseconds and in network by te order. * Time for relative time used by GNUnet, in microseconds and in network by te order.
*/ */
struct GNUNET_TIME_RelativeNBO struct GNUNET_TIME_RelativeNBO
{ {
/** /**
* The actual value (in network byte order). * The actual value (in network byte order).
*/ */
uint64_t rel_value__ GNUNET_PACKED; uint64_t rel_value_us__ GNUNET_PACKED;
}; };
/** /**
* Time for absolute time used by GNUnet, in milliseconds and in network by te order. * Time for absolute time used by GNUnet, in microseconds and in network by te order.
*/ */
struct GNUNET_TIME_AbsoluteNBO struct GNUNET_TIME_AbsoluteNBO
{ {
/** /**
* The actual value (in network byte order). * The actual value (in network byte order).
*/ */
uint64_t abs_value__ GNUNET_PACKED; uint64_t abs_value_us__ GNUNET_PACKED;
}; };
GNUNET_NETWORK_STRUCT_END GNUNET_NETWORK_STRUCT_END
/** /**
* Relative time zero. * Relative time zero.
*/ */
#define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero_() #define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero_()
/** /**
* Absolute time zero. * Absolute time zero.
*/ */
#define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero_() #define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero_()
/** /**
* One millisecond, our basic time unit. * One microsecond, our basic time unit.
*/
#define GNUNET_TIME_UNIT_MICROSECONDS GNUNET_TIME_relative_get_unit_()
/**
* One millisecond.
*/ */
#define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit_() #define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_millisecond_ ()
/** /**
* One second. * One second.
*/ */
#define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_get_second_() #define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_get_second_()
/** /**
* One minute. * One minute.
*/ */
#define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_get_minute_() #define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_get_minute_()
skipping to change at line 157 skipping to change at line 163
* will be treated specially in all time operations. * will be treated specially in all time operations.
*/ */
#define GNUNET_TIME_UNIT_FOREVER_ABS GNUNET_TIME_absolute_get_forever_ () #define GNUNET_TIME_UNIT_FOREVER_ABS GNUNET_TIME_absolute_get_forever_ ()
/** /**
* Threshold after which exponential backoff should not increase (15 m). * Threshold after which exponential backoff should not increase (15 m).
*/ */
#define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD GNUNET_TIME_relative_ multiply (GNUNET_TIME_UNIT_MINUTES, 15) #define GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD GNUNET_TIME_relative_ multiply (GNUNET_TIME_UNIT_MINUTES, 15)
/** /**
* Perform our standard exponential back-off calculation, starting at 1mst * Perform our standard exponential back-off calculation, starting at 1 ms
* and then going by a factor of 2 up unto a maximum of 1s. * and then going by a factor of 2 up unto a maximum of 15 m.
* *
* @param r current backoff time, initially zero * @param r current backoff time, initially zero
*/ */
#define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min (GNUNET_TIME_ST D_EXPONENTIAL_BACKOFF_THRESHOLD, \ #define GNUNET_TIME_STD_BACKOFF(r) GNUNET_TIME_relative_min (GNUNET_TIME_ST D_EXPONENTIAL_BACKOFF_THRESHOLD, \
GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_max (GNUNET_TIME_UNI T_MILLISECONDS, (r)), 2)); GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_max (GNUNET_TIME_UNI T_MILLISECONDS, (r)), 2));
/** /**
* Return relative time of 0ms. * Return relative time of 0ms.
*/ */
struct GNUNET_TIME_Relative struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_zero_ (void); GNUNET_TIME_relative_get_zero_ (void);
/** /**
* Return absolute time of 0ms. * Return absolute time of 0ms.
*/ */
struct GNUNET_TIME_Absolute struct GNUNET_TIME_Absolute
GNUNET_TIME_absolute_get_zero_ (void); GNUNET_TIME_absolute_get_zero_ (void);
/** /**
* Return relative time of 1ms. * Return relative time of 1 microsecond.
*/ */
struct GNUNET_TIME_Relative struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_unit_ (void); GNUNET_TIME_relative_get_unit_ (void);
/** /**
* Return relative time of 1ms.
*/
struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_millisecond_ (void);
/**
* Return relative time of 1s. * Return relative time of 1s.
*/ */
struct GNUNET_TIME_Relative struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_second_ (void); GNUNET_TIME_relative_get_second_ (void);
/** /**
* Return relative time of 1 minute. * Return relative time of 1 minute.
*/ */
struct GNUNET_TIME_Relative struct GNUNET_TIME_Relative
GNUNET_TIME_relative_get_minute_ (void); GNUNET_TIME_relative_get_minute_ (void);
skipping to change at line 434 skipping to change at line 446
GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a); GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a);
/** /**
* Set the timestamp offset for this instance. * Set the timestamp offset for this instance.
* *
* @param offset the offset to skew the locale time by * @param offset the offset to skew the locale time by
*/ */
void void
GNUNET_TIME_set_offset (long long offset); GNUNET_TIME_set_offset (long long offset);
/**
* Get the timestamp offset for this instance.
*
* @return the offset we currently skew the locale time by
*/
long long
GNUNET_TIME_get_offset (void);
/**
* Return the current year (i.e. '2011').
*/
unsigned int
GNUNET_TIME_get_current_year (void);
/**
* Convert a year to an expiration time of January 1st of that year.
*
* @param year a year (after 1970, please ;-)).
* @return absolute time for January 1st of that year.
*/
struct GNUNET_TIME_Absolute
GNUNET_TIME_year_to_time (unsigned int year);
/**
* Convert an expiration time to the respective year (rounds)
*
* @param at absolute time
* @return year a year (after 1970), 0 on error
*/
unsigned int
GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at);
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /* end of group time */
/* ifndef GNUNET_TIME_LIB_H */ /* ifndef GNUNET_TIME_LIB_H */
#endif #endif
/* end of gnunet_time_lib.h */ /* end of gnunet_time_lib.h */
 End of changes. 19 change blocks. 
16 lines changed or deleted 62 lines changed or added


 gnunet_transport_plugin.h   gnunet_transport_plugin.h 
skipping to change at line 38 skipping to change at line 38
* and is expected to return a NULL pointer. * and is expected to return a NULL pointer.
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef PLUGIN_TRANSPORT_H #ifndef PLUGIN_TRANSPORT_H
#define PLUGIN_TRANSPORT_H #define PLUGIN_TRANSPORT_H
#include "gnunet_configuration_lib.h" #include "gnunet_configuration_lib.h"
#include "gnunet_scheduler_lib.h" #include "gnunet_scheduler_lib.h"
#include "gnunet_statistics_service.h" #include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h" #include "gnunet_transport_service.h"
#include "gnunet_ats_service.h"
#define TRANSPORT_SESSION_INBOUND_STRING "<inbound>"
/** /**
* Opaque pointer that plugins can use to distinguish specific * Opaque pointer that plugins can use to distinguish specific
* connections to a given peer. Typically used by stateful plugins to * connections to a given peer. Typically used by stateful plugins to
* allow the service to refer to specific streams instead of a more * allow the service to refer to specific streams instead of a more
* general notion of "some connection" to the given peer. This is * general notion of "some connection" to the given peer. This is
* useful since sometimes (i.e. for inbound TCP connections) a * useful since sometimes (i.e. for inbound TCP connections) a
* connection may not have an address that can be used for meaningful * connection may not have an address that can be used for meaningful
* distinction between sessions to the same peer. * distinction between sessions to the same peer.
* *
skipping to change at line 59 skipping to change at line 62
* of the peer the session is for (which will be used for some error * of the peer the session is for (which will be used for some error
* checking by the ATS code). * checking by the ATS code).
*/ */
struct Session; struct Session;
/** /**
* Every 'struct Session' must begin with this header. * Every 'struct Session' must begin with this header.
*/ */
struct SessionHeader struct SessionHeader
{ {
/* empty, for now */
/**
* Cached signature for PONG generation for the session. Do not use
* in the plugin!
*/
struct GNUNET_CRYPTO_RsaSignature pong_signature;
/**
* Expiration time for signature. Do not use in the plugin!
*/
struct GNUNET_TIME_Absolute pong_sig_expires;
}; };
/** /**
* Function that will be called whenever the plugin internally * Function that will be called whenever the plugin internally
* cleans up a session pointer and hence the service needs to * cleans up a session pointer and hence the service needs to
* discard all of those sessions as well. Plugins that do not * discard all of those sessions as well. Plugins that do not
* use sessions can simply omit calling this function and always * use sessions can simply omit calling this function and always
* use NULL wherever a session pointer is needed. This function * use NULL wherever a session pointer is needed. This function
* should be called BEFORE a potential "TransmitContinuation" * should be called BEFORE a potential "TransmitContinuation"
* from the "TransmitFunction". * from the "TransmitFunction".
* *
* @param cls closure * @param cls closure
* @param peer which peer was the session for * @param peer which peer was the session for
* @param session which session is being destoyed * @param session which session is being destroyed
*/ */
typedef void (*GNUNET_TRANSPORT_SessionEnd) (void *cls, typedef void
const struct GNUNET_PeerIdenti (*GNUNET_TRANSPORT_SessionEnd) (void *cls,
ty * const struct GNUNET_PeerIdentity *peer,
peer, struct Session * session struct Session *session);
);
/**
* Function that will be called whenever the plugin internally
* creates a new session and hence transport need to tell ATS.
* This happens when we have a inbound connection we did not
* initiate.
*
* @param cls closure
* @param peer peer
* @param plugin plugin
* @param address address
* @param address_len length of the @a address
* @param session session
* @param ats ATS information
* @param ats_count number of entries in @a ats array
*/
typedef void
(*GNUNET_TRANSPORT_SessionStart) (void *cls,
const struct GNUNET_PeerIdentity *peer,
const char *plugin,
const void *address,
uint16_t address_len,
struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count);
/** /**
* Function called by the transport for each received message. * Function called by the transport for each received message.
* This function should also be called with "NULL" for the * This function should also be called with "NULL" for the
* message to signal that the other peer disconnected. * message to signal that the other peer disconnected.
* *
* @param cls closure * @param cls closure
* @param peer (claimed) identity of the other peer * @param peer (claimed) identity of the other peer
* @param message the message, NULL if we only care about * @param message the message, NULL if we only care about
* learning about the delay until we should receive again * learning about the delay until we should receive again
* @param session identifier used for this session (NULL for plugins * @param session identifier used for this session (NULL for plugins
* that do not offer bi-directional communication to the sen der * that do not offer bi-directional communication to the sen der
* using the same "connection") * using the same "connection")
* @param sender_address binary address of the sender (if we established th e * @param sender_address binary address of the sender (if we established th e
* connection or are otherwise sure of it; should be NULL * connection or are otherwise sure of it; should be NULL
* for inbound TCP/UDP connections since it it not clear * for inbound TCP/UDP connections since it it not clear
* that we could establish ourselves a connection to that * that we could establish ourselves a connection to that
* IP address and get the same system) * IP address and get the same system)
* @param sender_address_len number of bytes in sender_address * @param sender_address_len number of bytes in @a sender_address
* @return how long the plugin should wait until receiving more data * @return how long the plugin should wait until receiving more data;
* (plugins that do not support this, can ignore the return value) * returning #GNUNET_TIME_UNIT_FOREVER_REL means that the
*/ * connection should be closed
typedef struct */
GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *c typedef struct GNUNET_TIME_Relative
ls, (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
const s const struct GNUNET_PeerIdentity
truct *peer,
GNUNET_ const struct GNUNET_MessageHeade
PeerIdentity r *message,
* peer, struct Session *session,
const s const char *sender_address,
truct uint16_t sender_address_len);
GNUNET_
MessageHeader
* messa
ge,
const s
truct
GNUNET_
ATS_Information
* ats,
uint32_
t
ats_cou
nt,
struct
Session
*
session
,
const c
har
*sender
_address,
uint16_
t
sender_
address_len);
/** /**
* Function that will be called to figure if an address is an loopback, * Function that will be called to figure if an address is an loopback,
* LAN, WAN etc. address * LAN, WAN etc. address
* *
* @param cls closure * @param cls closure
* @param addr binary address * @param addr binary address
* @param addrlen length of the address * @param addrlen length of the @a addr
* @return ATS Information containing the network type * @return ATS Information containing the network type
*/ */
typedef struct GNUNET_ATS_Information typedef struct GNUNET_ATS_Information
(*GNUNET_TRANSPORT_AddressToType) (void *cls, (*GNUNET_TRANSPORT_AddressToType) (void *cls,
const struct sockaddr *addr, const struct sockaddr *addr,
size_t addrlen); size_t addrlen);
/** /**
* Function called when quality properties of an address change.
*
* @param cls closure
* @param peer peer
* @param address address
* @param address_len length of the @a address
* @param session session
* @param ats ATS information
* @param ats_count number entries in the @a ats array
*/
typedef void
(*GNUNET_TRANSPORT_UpdateAddressMetrics) (void *cls,
const struct GNUNET_PeerIdentity *
peer,
const void *address,
uint16_t address_len,
struct Session *session,
const struct GNUNET_ATS_Informatio
n *ats,
uint32_t ats_count);
/**
* Function that will be called for each address the transport * Function that will be called for each address the transport
* is aware that it might be reachable under. * is aware that it might be reachable under.
* *
* @param cls closure * @param cls closure
* @param add_remove should the address added (YES) or removed (NO) from th e * @param add_remove should the address added (#GNUNET_YES) or removed (#GN UNET_NO) from the
* set of valid addresses? * set of valid addresses?
* @param addr one of the addresses of the host * @param addr one of the addresses of the host
* the specific address format depends on the transport * the specific address format depends on the transport
* @param addrlen length of the address * @param addrlen length of the @a addr
* @param dest_plugin plugin to use this address with * @param dest_plugin plugin to use this address with
*/ */
typedef void (*GNUNET_TRANSPORT_AddressNotification) (void *cls, int add_re typedef void
move, (*GNUNET_TRANSPORT_AddressNotification) (void *cls,
const void *addr, int add_remove,
size_t addrlen, const void *addr,
const char *dest_plug size_t addrlen,
in); const char *dest_plugin);
/** /**
* Function that will be called whenever the plugin receives data over * Function that will be called whenever the plugin receives data over
* the network and wants to determine how long it should wait until * the network and wants to determine how long it should wait until
* the next time it reads from the given peer. Note that some plugins * the next time it reads from the given peer. Note that some plugins
* (such as UDP) may not be able to wait (for a particular peer), so * (such as UDP) may not be able to wait (for a particular peer), so
* the waiting part is optional. Plugins that can wait should call * the waiting part is optional. Plugins that can wait should call
* this function, sleep the given amount of time, and call it again * this function, sleep the given amount of time, and call it again
* (with zero bytes read) UNTIL it returns zero and only then read. * (with zero bytes read) UNTIL it returns zero and only then read.
* *
* @param cls closure * @param cls closure
* @param peer which peer did we read data from * @param peer which peer did we read data from
* @param amount_recved number of bytes read (can be zero) * @param amount_recved number of bytes read (can be zero)
* @return how long to wait until reading more from this peer * @return how long to wait until reading more from this peer
* (to enforce inbound quotas) * (to enforce inbound quotas); returning #GNUNET_TIME_UNIT_FOREVER
_REL
* means that the connection should be closed
*/ */
typedef struct GNUNET_TIME_Relative (*GNUNET_TRANSPORT_TrafficReport) (void typedef struct GNUNET_TIME_Relative
*cls (*GNUNET_TRANSPORT_TrafficReport) (void *cls,
, const struct GNUNET_PeerIdentity *peer,
cons size_t amount_recved);
t
stru
ct
GNUN
ET_PeerIdentity
* pe
er,
size
_t
amou
nt_recved);
/** /**
* Function that returns a HELLO message. * Function that returns a HELLO message.
*/ */
typedef const struct GNUNET_MessageHeader * typedef const struct GNUNET_MessageHeader *
(*GNUNET_TRANSPORT_GetHelloCallback) (void); (*GNUNET_TRANSPORT_GetHelloCallback) (void);
/** /**
* The transport service will pass a pointer to a struct * The transport service will pass a pointer to a struct
* of this type as the first and only argument to the * of this type as the first and only argument to the
* entry point of each transport plugin. * entry point of each transport plugin.
*/ */
struct GNUNET_TRANSPORT_PluginEnvironment struct GNUNET_TRANSPORT_PluginEnvironment
{ {
/** /**
* Configuration to use. * Configuration to use.
skipping to change at line 249 skipping to change at line 274
*/ */
GNUNET_TRANSPORT_AddressNotification notify_address; GNUNET_TRANSPORT_AddressNotification notify_address;
/** /**
* Function that must be called by the plugin when a non-NULL * Function that must be called by the plugin when a non-NULL
* session handle stops being valid (is destroyed). * session handle stops being valid (is destroyed).
*/ */
GNUNET_TRANSPORT_SessionEnd session_end; GNUNET_TRANSPORT_SessionEnd session_end;
/** /**
* Function called by the plugin when a new (incoming) session was create
d
* not explicitly created using the the get_session function
*/
GNUNET_TRANSPORT_SessionStart session_start;
/**
* Function that will be called to figure if an address is an loopback, * Function that will be called to figure if an address is an loopback,
* LAN, WAN etc. address * LAN, WAN etc. address
*/ */
GNUNET_TRANSPORT_AddressToType get_address_type; GNUNET_TRANSPORT_AddressToType get_address_type;
/** /**
* Function that will be called to figure if an address is an loopback,
* LAN, WAN etc. address
*/
GNUNET_TRANSPORT_UpdateAddressMetrics update_address_metrics;
/**
* What is the maximum number of connections that this transport * What is the maximum number of connections that this transport
* should allow? Transports that do not have sessions (such as * should allow? Transports that do not have sessions (such as
* UDP) can ignore this value. * UDP) can ignore this value.
*/ */
uint32_t max_connections; uint32_t max_connections;
}; };
/** /**
* Function called by the GNUNET_TRANSPORT_TransmitFunction * Function called by the #GNUNET_TRANSPORT_TransmitFunction
* upon "completion". In the case that a peer disconnects, * upon "completion". In the case that a peer disconnects,
* this function must be called for each pending request * this function must be called for each pending request
* (with a 'failure' indication) AFTER notifying the service * (with a 'failure' indication) AFTER notifying the service
* about the disconnect event (so that the service won't try * about the disconnect event (so that the service won't try
* to transmit more messages, believing the connection still * to transmit more messages, believing the connection still
* exists...). * exists...).
* *
* @param cls closure * @param cls closure
* @param target who was the recipient of the message? * @param target who was the recipient of the message?
* @param result GNUNET_OK on success * @param result #GNUNET_OK on success
* GNUNET_SYSERR if the target disconnected; * #GNUNET_SYSERR if the target disconnected;
* disconnect will ALSO be signalled using * disconnect will ALSO be signalled using
* the ReceiveCallback. * the ReceiveCallback.
* @param size_payload bytes of payload from transport service in message * @param size_payload bytes of payload from transport service in message
* @param size_on_wire bytes required on wire for transmission, * @param size_on_wire bytes required on wire for transmission,
* 0 if result == GNUNET_SYSERR * 0 if result == #GNUNET_SYSERR
*/ */
typedef void (*GNUNET_TRANSPORT_TransmitContinuation) (void *cls, typedef void
const struct (*GNUNET_TRANSPORT_TransmitContinuation) (void *cls,
GNUNET_PeerIdentity const struct GNUNET_PeerIdentity
* *target,
target, int result,
int result, size_t size_payload,
size_t size_payload, size_t size_on_wire);
size_t size_on_wire)
;
/** /**
* The new send function with just the session and no address * The new send function with just the session and no address
* *
* Function that can be used by the transport service to transmit * Function that can be used by the transport service to transmit
* a message using the plugin. Note that in the case of a * a message using the plugin. Note that in the case of a
* peer disconnecting, the continuation MUST be called * peer disconnecting, the continuation MUST be called
* prior to the disconnect notification itself. This function * prior to the disconnect notification itself. This function
* will be called with this peer's HELLO message to initiate * will be called with this peer's HELLO message to initiate
* a fresh connection to another peer. * a fresh connection to another peer.
* *
* @param cls closure * @param cls closure
* @param session which session must be used * @param session which session must be used
* @param msgbuf the message to transmit * @param msgbuf the message to transmit
* @param msgbuf_size number of bytes in 'msgbuf' * @param msgbuf_size number of bytes in @a msgbuf
* @param priority how important is the message (most plugins will * @param priority how important is the message (most plugins will
* ignore message priority and just FIFO) * ignore message priority and just FIFO)
* @param timeout how long to wait at most for the transmission (does not * @param to how long to wait at most for the transmission (does not
* require plugins to discard the message after the timeout, * require plugins to discard the message after the timeout,
* just advisory for the desired delay; most plugins will ig nore * just advisory for the desired delay; most plugins will ig nore
* this as well) * this as well)
* @param cont continuation to call once the message has * @param cont continuation to call once the message has
* been transmitted (or if the transport is ready * been transmitted (or if the transport is ready
* for the next transmission call; or if the * for the next transmission call; or if the
* peer disconnected...); can be NULL * peer disconnected...); can be NULL
* @param cont_cls closure for cont * @param cont_cls closure for @a cont
* @return number of bytes used (on the physical network, with overheads); * @return number of bytes used (on the physical network, with overheads);
* -1 on hard errors (i.e. address invalid); 0 is a legal value * -1 on hard errors (i.e. address invalid); 0 is a legal value
* and does NOT mean that the message was not transmitted (DV) * and does NOT mean that the message was not transmitted (DV)
*/ */
typedef ssize_t (*GNUNET_TRANSPORT_TransmitFunction) (void *cls, typedef ssize_t
struct Session *sessio (*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
n, struct Session *session,
const char *msgbuf, si const char *msgbuf,
ze_t msgbuf_size, size_t msgbuf_size,
unsigned int priority, unsigned int priority,
struct GNUNET_TIME_Rel struct GNUNET_TIME_Relative to,
ative to, GNUNET_TRANSPORT_TransmitContinuation
GNUNET_TRANSPORT_Trans cont,
mitContinuation cont, void *cont_cls);
void *cont_cls);
/**
* Function that can be called to force a disconnect from the
* specified neighbour for the given session only. . This should
* also cancel all previously scheduled transmissions for this
* session. Obviously the transmission may have been partially
* completed already, which is OK. The plugin is supposed to close
* the connection (if applicable).
*
* @param cls closure with the `struct Plugin`
* @param session session to destroy
* @return #GNUNET_OK on success
*/
typedef int
(*GNUNET_TRANSPORT_DisconnectSessionFunction) (void *cls,
struct Session *session);
/**
* Function that is called to get the keepalive factor.
* GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
* calculate the interval between keepalive packets.
*
* @param cls closure with the `struct Plugin`
* @return keepalive factor
*/
typedef unsigned int
(*GNUNET_TRANSPORT_QueryKeepaliveFactorFunction) (void *cls);
/** /**
* Function that can be called to force a disconnect from the * Function that can be called to force a disconnect from the
* specified neighbour. This should also cancel all previously * specified neighbour. This should also cancel all previously
* scheduled transmissions. Obviously the transmission may have been * scheduled transmissions. Obviously the transmission may have been
* partially completed already, which is OK. The plugin is supposed * partially completed already, which is OK. The plugin is supposed
* to close the connection (if applicable) and no longer call the * to close the connection (if applicable) and no longer call the
* transmit continuation(s). * transmit continuation(s).
* *
* Finally, plugin MUST NOT call the services's receive function to
* notify the service that the connection to the specified target was
* closed after a getting this call.
*
* @param cls closure * @param cls closure
* @param target peer for which the last transmission is * @param target peer for which the last transmission is
* to be cancelled * to be cancelled
*/ */
typedef void (*GNUNET_TRANSPORT_DisconnectFunction) (void *cls, typedef void
const struct (*GNUNET_TRANSPORT_DisconnectPeerFunction) (void *cls,
GNUNET_PeerIdentity * const struct GNUNET_PeerIdentit
target); y *target);
/** /**
* Function called by the pretty printer for the resolved address for * Function called by the pretty printer for the resolved address for
* each human-readable address obtained. * each human-readable address obtained.
* *
* @param cls closure * @param cls closure
* @param hostname one of the names for the host, NULL * @param address one of the names for the host, NULL
* on the last call to the callback * on the last call to the callback
*/ */
typedef void (*GNUNET_TRANSPORT_AddressStringCallback) (void *cls, typedef void
const char *address (*GNUNET_TRANSPORT_AddressStringCallback) (void *cls,
); const char *address);
/** /**
* Convert the transports address to a nice, human-readable * Convert the transports address to a nice, human-readable
* format. * format.
* *
* @param cls closure * @param cls closure
* @param name name of the transport that generated the address * @param type name of the transport that generated the address
* @param addr one of the addresses of the host, NULL for the last address * @param addr one of the addresses of the host, NULL for the last address
* the specific address format depends on the transport * the specific address format depends on the transport
* @param addrlen length of the address * @param addrlen length of the @a addr
* @param numeric should (IP) addresses be displayed in numeric form? * @param numeric should (IP) addresses be displayed in numeric form?
* @param timeout after how long should we give up? * @param timeout after how long should we give up?
* @param asc function to call on each string * @param asc function to call on each string
* @param asc_cls closure for asc * @param asc_cls closure for @a asc
*/ */
typedef void (*GNUNET_TRANSPORT_AddressPrettyPrinter) (void *cls, typedef void
const char *type, (*GNUNET_TRANSPORT_AddressPrettyPrinter) (void *cls,
const void *addr, const char *type,
size_t addrlen, const void *addr,
int numeric, size_t addrlen,
struct int numeric,
GNUNET_TIME_Relative struct GNUNET_TIME_Relative timeo
timeout, ut,
GNUNET_TRANSPORT_Add GNUNET_TRANSPORT_AddressStringCal
ressStringCallback lback asc,
asc, void *asc_cls); void *asc_cls);
/** /**
* Another peer has suggested an address for this peer and transport * Another peer has suggested an address for this peer and transport
* plugin. Check that this could be a valid address. This function * plugin. Check that this could be a valid address. This function
* is not expected to 'validate' the address in the sense of trying to * is not expected to 'validate' the address in the sense of trying to
* connect to it but simply to see if the binary format is technically * connect to it but simply to see if the binary format is technically
* legal for establishing a connection to this peer (and make sure that * legal for establishing a connection to this peer (and make sure that
* the address really corresponds to our network connection/settings * the address really corresponds to our network connection/settings
* and not some potential man-in-the-middle). * and not some potential man-in-the-middle).
* *
* @param addr pointer to the address * @param addr pointer to the address
* @param addrlen length of addr * @param addrlen length of @a addr
* @return GNUNET_OK if this is a plausible address for this peer * @return #GNUNET_OK if this is a plausible address for this peer
* and transport, GNUNET_SYSERR if not * and transport, #GNUNET_SYSERR if not
*/ */
typedef int (*GNUNET_TRANSPORT_CheckAddress) (void *cls, const void *addr, typedef int
size_t addrlen); (*GNUNET_TRANSPORT_CheckAddress) (void *cls,
const void *addr,
size_t addrlen);
/** /**
* Create a new session to transmit data to the target * Create a new session to transmit data to the target
* This session will used to send data to this peer and the plugin will * This session will used to send data to this peer and the plugin will
* notify us by calling the env->session_end function * notify us by calling the env->session_end function
* *
* @param cls the plugin * @param cls the plugin
* @param target the neighbour id * @param address the hello address
* @param addr pointer to the address
* @param addrlen length of addr
* @return the session if the address is valid, NULL otherwise * @return the session if the address is valid, NULL otherwise
*/ */
typedef struct Session * (*GNUNET_TRANSPORT_CreateSession) (void *cls, typedef struct Session *
const struct GNUNET_HELLO_Address *address); (*GNUNET_TRANSPORT_CreateSession) (void *cls,
const struct GNUNET_HELLO_Address *addre
ss);
/**
* Function that will be called whenever the transport service wants to
* notify the plugin that a session is still active and in use and
* therefore the session timeout for this session has to be updated
*
* @param cls closure
* @param peer which peer was the session for
* @param session which session is being updated
*/
typedef void
(*GNUNET_TRANSPORT_UpdateSessionTimeout) (void *cls,
const struct GNUNET_PeerIdentity
*peer,
struct Session *session);
/** /**
* Function called for a quick conversion of the binary address to * Function called for a quick conversion of the binary address to
* a numeric address. Note that the caller must not free the * a numeric address. Note that the caller must not free the
* address and that the next call to this function is allowed * address and that the next call to this function is allowed
* to override the address again. * to override the address again.
* *
* @param cls closure * @param cls closure
* @param addr binary address * @param addr binary address
* @param addr_len length of the address * @param addr_len length of the @a addr
* @return string representing the same address * @return string representing the same address
*/ */
typedef const char *(*GNUNET_TRANSPORT_AddressToString) (void *cls, typedef const char *
const void *addr, (*GNUNET_TRANSPORT_AddressToString) (void *cls,
size_t addrlen); const void *addr,
size_t addrlen);
/** /**
* Function called to convert a string address to * Function called to convert a string address to
* a binary address. * a binary address.
* *
* @param cls closure ('struct Plugin*') * @param cls closure (`struct Plugin*`)
* @param addr string address * @param addr string address
* @param addrlen length of the address including \0 termination * @param addrlen length of the @a addr including \0 termination
* @param buf location to store the buffer * @param buf location to store the buffer
* If the function returns GNUNET_SYSERR, its contents are undefined . * If the function returns #GNUNET_SYSERR, its contents are undefine d.
* @param added length of created address * @param added length of created address
* @return GNUNET_OK on success, GNUNET_SYSERR on failure * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/ */
typedef int (*GNUNET_TRANSPORT_StringToAddress) (void *cls, typedef int
const char *addr, (*GNUNET_TRANSPORT_StringToAddress) (void *cls,
uint16_t addrlen, const char *addr,
void **buf, uint16_t addrlen,
size_t *added); void **buf,
size_t *added);
/**
* Function to obtain the network type for a session
*
* @param cls closure ('struct Plugin*')
* @param session the session
* @return the network type
*/
typedef enum GNUNET_ATS_Network_Type
(*GNUNET_TRANSPORT_GetNetworkType) (void *cls,
struct Session *session);
/** /**
* Each plugin is required to return a pointer to a struct of this * Each plugin is required to return a pointer to a struct of this
* type as the return value from its entry point. * type as the return value from its entry point.
*/ */
struct GNUNET_TRANSPORT_PluginFunctions struct GNUNET_TRANSPORT_PluginFunctions
{ {
/** /**
* Closure for all of the callbacks. * Closure for all of the callbacks.
skipping to change at line 474 skipping to change at line 562
* continuation with success or error before notifying us about the * continuation with success or error before notifying us about the
* target having disconnected. * target having disconnected.
*/ */
GNUNET_TRANSPORT_TransmitFunction send; GNUNET_TRANSPORT_TransmitFunction send;
/** /**
* Function that can be used to force the plugin to disconnect from * Function that can be used to force the plugin to disconnect from
* the given peer and cancel all previous transmissions (and their * the given peer and cancel all previous transmissions (and their
* continuations). * continuations).
*/ */
GNUNET_TRANSPORT_DisconnectFunction disconnect; GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer;
/**
* Function that can be used to force the plugin to disconnect from
* the given peer and cancel all previous transmissions (and their
* continuations).
*/
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session;
/**
* Function that will be called whenever the transport service wants to
* notify the plugin that a session is still active and in use and
* therefore the session timeout for this session has to be updated
*/
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout;
/**
* Function that is used to query keepalive factor.
* GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
* calculate the interval between keepalive packets.
*/
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor;
/** /**
* Function to pretty-print addresses. NOTE: this function is not * Function to pretty-print addresses. NOTE: this function is not
* yet used by transport-service, but will be used in the future * yet used by transport-service, but will be used in the future
* once the transport-API has been completed. * once the transport-API has been completed.
*/ */
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer; GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer;
/** /**
* Function that will be called to check if a binary address * Function that will be called to check if a binary address
skipping to change at line 511 skipping to change at line 620
* Function that will be called to convert a string address * Function that will be called to convert a string address
* to binary (numeric conversion only). * to binary (numeric conversion only).
*/ */
GNUNET_TRANSPORT_StringToAddress string_to_address; GNUNET_TRANSPORT_StringToAddress string_to_address;
/** /**
* Function that will be called tell the plugin to create a session * Function that will be called tell the plugin to create a session
* object * object
*/ */
GNUNET_TRANSPORT_CreateSession get_session; GNUNET_TRANSPORT_CreateSession get_session;
/**
* Function to obtain the network type for a session
*/
GNUNET_TRANSPORT_GetNetworkType get_network;
}; };
#endif #endif
 End of changes. 43 change blocks. 
162 lines changed or deleted 254 lines changed or added


 gnunet_transport_service.h   gnunet_transport_service.h 
skipping to change at line 60 skipping to change at line 60
* @param peer (claimed) identity of the other peer * @param peer (claimed) identity of the other peer
* @param message the message * @param message the message
* @param ats performance data * @param ats performance data
* @param ats_count number of entries in ats * @param ats_count number of entries in ats
*/ */
typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls, typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
const struct const struct
GNUNET_PeerIdentity * pee r, GNUNET_PeerIdentity * pee r,
const struct const struct
GNUNET_MessageHeader * GNUNET_MessageHeader *
message, message);
const struct
GNUNET_ATS_Information *
ats,
uint32_t ats_count);
/** /**
* Opaque handle to the service. * Opaque handle to the service.
*/ */
struct GNUNET_TRANSPORT_Handle; struct GNUNET_TRANSPORT_Handle;
/** /**
* Function called to notify transport users that another * Function called to notify transport users that another
* peer connected to us. * peer connected to us.
* *
* @param cls closure * @param cls closure
* @param peer the peer that connected * @param peer the peer that connected
* @param ats performance data * @param ats performance data
* @param ats_count number of entries in ats (excluding 0-termination) * @param ats_count number of entries in ats (excluding 0-termination)
*/ */
typedef void (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, typedef void (*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
const struct GNUNET_PeerIde ntity const struct GNUNET_PeerIde ntity
* peer, * peer);
const struct
GNUNET_ATS_Information * at
s,
uint32_t ats_count);
/** /**
* Function called to notify transport users that another * Function called to notify transport users that another
* peer disconnected from us. * peer disconnected from us.
* *
* @param cls closure * @param cls closure
* @param peer the peer that disconnected * @param peer the peer that disconnected
*/ */
typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls,
const struct const struct
skipping to change at line 144 skipping to change at line 138
address); address);
/** /**
* Connect to the transport service. Note that the connection may * Connect to the transport service. Note that the connection may
* complete (or fail) asynchronously. * complete (or fail) asynchronously.
* *
* @param cfg configuration to use * @param cfg configuration to use
* @param self our own identity (API should check that it matches * @param self our own identity (API should check that it matches
* the identity found by transport), or NULL (no check) * the identity found by transport), or NULL (no check)
* @param cls closure for the callbacks * @param cls closure for the callbacks
* @param rec receive function to call * @param rec receive function to call, or NULL
* @param nc function to call on connect events * @param nc function to call on connect events, or NULL
* @param nd function to call on disconnect events * @param nd function to call on disconnect events, or NULL
* @return NULL on error * @return NULL on error
*/ */
struct GNUNET_TRANSPORT_Handle * struct GNUNET_TRANSPORT_Handle *
GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_PeerIdentity *self, void *cls , const struct GNUNET_PeerIdentity *self, void *cls ,
GNUNET_TRANSPORT_ReceiveCallback rec, GNUNET_TRANSPORT_ReceiveCallback rec,
GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd); GNUNET_TRANSPORT_NotifyDisconnect nd);
/** /**
skipping to change at line 256 skipping to change at line 250
const struct const struct
GNUNET_MessageHeader * GNUNET_MessageHeader *
hello); hello);
/** /**
* Handle to cancel a 'GNUNET_TRANSPORT_get_hello' operation. * Handle to cancel a 'GNUNET_TRANSPORT_get_hello' operation.
*/ */
struct GNUNET_TRANSPORT_GetHelloHandle; struct GNUNET_TRANSPORT_GetHelloHandle;
/** /**
* Obtain updates on changes to the HELLO message for this peer. * Checks if a given peer is connected to us
*
* @param handle connection to transport service
* @param peer the peer to check
* @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected)
*/
int
GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *hand
le,
const struct GNUNET_PeerIdentit
y *peer);
/**
* Set transport metrics for a peer and a direction
*
* @param handle transport handle
* @param peer the peer to set the metric for
* @param inbound set inbound direction (GNUNET_YES or GNUNET_NO)
* @param outbound set outbound direction (GNUNET_YES or GNUNET_NO)
* @param ats the metric as ATS information
* @param ats_count the number of metrics
*
* Supported ATS values:
* GNUNET_ATS_QUALITY_NET_DELAY (value in ms)
* GNUNET_ATS_QUALITY_NET_DISTANCE (value in count(hops))
*
* Example
* To enforce a delay of 10 ms for peer p1 in sending direction use:
*
* struct GNUNET_ATS_Information ats;
* ats.type = ntohl (GNUNET_ATS_QUALITY_NET_DELAY);
* ats.value = ntohl (10);
* GNUNET_TRANSPORT_set_traffic_metric (th, p1, TM_SEND, &ats, 1);
*
* Note:
* Delay restrictions in receiving direction will be enforced with
* 1 message delay.
*/
void
GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle
,
const struct GNUNET_PeerIdentity *peer,
int inbound,
int outbound,
const struct GNUNET_ATS_Information *at
s,
size_t ats_count);
/**
* Obtain updates on changes to the HELLO message for this peer. The callba
ck
* given in this function is never called synchronously.
* *
* @param handle connection to transport service * @param handle connection to transport service
* @param rec function to call with the HELLO * @param rec function to call with the HELLO
* @param rec_cls closure for rec * @param rec_cls closure for rec
* @return handle to cancel the operation * @return handle to cancel the operation
*/ */
struct GNUNET_TRANSPORT_GetHelloHandle * struct GNUNET_TRANSPORT_GetHelloHandle *
GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
GNUNET_TRANSPORT_HelloUpdateCallback rec, GNUNET_TRANSPORT_HelloUpdateCallback rec,
void *rec_cls); void *rec_cls);
 End of changes. 4 change blocks. 
14 lines changed or deleted 57 lines changed or added


 gnunet_tun_lib.h   gnunet_tun_lib.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2010, 2011, 2012 Christian Grothoff (C) 2010-2013 Christian Grothoff
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
skipping to change at line 47 skipping to change at line 47
#define ETH_P_IPV4 0x0800 #define ETH_P_IPV4 0x0800
#endif #endif
#ifndef ETH_P_IPV6 #ifndef ETH_P_IPV6
/** /**
* Number for IPv6 * Number for IPv6
*/ */
#define ETH_P_IPV6 0x86DD #define ETH_P_IPV6 0x86DD
#endif #endif
/**
* Maximum regex string length for use with #GNUNET_TUN_ipv4toregexsearch.
*
* 8 bytes for IPv4, 4 bytes for port, 1 byte for "4", 2 bytes for "-",
* one byte for 0-termination.
*/
#define GNUNET_TUN_IPV4_REGEXLEN 16
/**
* Maximum regex string length for use with #GNUNET_TUN_ipv6toregexsearch
*
* 32 bytes for IPv4, 4 bytes for port, 1 byte for "4", 2 bytes for "-",
* one byte for 0-termination.
*/
#define GNUNET_TUN_IPV6_REGEXLEN 40
GNUNET_NETWORK_STRUCT_BEGIN GNUNET_NETWORK_STRUCT_BEGIN
/** /**
* Header from Linux TUN interface. * Header from Linux TUN interface.
*/ */
struct GNUNET_TUN_Layer2PacketHeader struct GNUNET_TUN_Layer2PacketHeader
{ {
/** /**
* Some flags (unused). * Some flags (unused).
*/ */
skipping to change at line 169 skipping to change at line 185
* Destination of the packet. * Destination of the packet.
*/ */
struct in6_addr destination_address GNUNET_PACKED; struct in6_addr destination_address GNUNET_PACKED;
} GNUNET_GCC_STRUCT_LAYOUT; } GNUNET_GCC_STRUCT_LAYOUT;
/** /**
* TCP packet header. * TCP packet header.
*/ */
struct GNUNET_TUN_TcpHeader struct GNUNET_TUN_TcpHeader
{ {
/**
* Source port (in NBO).
*/
uint16_t source_port GNUNET_PACKED; uint16_t source_port GNUNET_PACKED;
/**
* Destination port (in NBO).
*/
uint16_t destination_port GNUNET_PACKED; uint16_t destination_port GNUNET_PACKED;
/** /**
* Sequence number. * Sequence number.
*/ */
uint32_t seq GNUNET_PACKED; uint32_t seq GNUNET_PACKED;
/** /**
* Acknowledgement number. * Acknowledgement number.
*/ */
skipping to change at line 229 skipping to change at line 252
* Urgent pointer. * Urgent pointer.
*/ */
uint16_t urgent_pointer GNUNET_PACKED; uint16_t urgent_pointer GNUNET_PACKED;
} GNUNET_GCC_STRUCT_LAYOUT; } GNUNET_GCC_STRUCT_LAYOUT;
/** /**
* UDP packet header. * UDP packet header.
*/ */
struct GNUNET_TUN_UdpHeader struct GNUNET_TUN_UdpHeader
{ {
/**
* Source port (in NBO).
*/
uint16_t source_port GNUNET_PACKED; uint16_t source_port GNUNET_PACKED;
/**
* Destination port (in NBO).
*/
uint16_t destination_port GNUNET_PACKED; uint16_t destination_port GNUNET_PACKED;
/**
* Number of bytes of payload.
*/
uint16_t len GNUNET_PACKED; uint16_t len GNUNET_PACKED;
/**
* Checksum.
*/
uint16_t crc GNUNET_PACKED; uint16_t crc GNUNET_PACKED;
}; };
/** /**
* A few common DNS classes (ok, only one is common, but I list a
* couple more to make it clear what we're talking about here).
*/
#define GNUNET_TUN_DNS_CLASS_INTERNET 1
#define GNUNET_TUN_DNS_CLASS_CHAOS 3
#define GNUNET_TUN_DNS_CLASS_HESIOD 4
#define GNUNET_TUN_DNS_OPCODE_QUERY 0
#define GNUNET_TUN_DNS_OPCODE_INVERSE_QUERY 1
#define GNUNET_TUN_DNS_OPCODE_STATUS 2
/**
* RFC 1035 codes.
*/
#define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR 0
#define GNUNET_TUN_DNS_RETURN_CODE_FORMAT_ERROR 1
#define GNUNET_TUN_DNS_RETURN_CODE_SERVER_FAILURE 2
#define GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR 3
#define GNUNET_TUN_DNS_RETURN_CODE_NOT_IMPLEMENTED 4
#define GNUNET_TUN_DNS_RETURN_CODE_REFUSED 5
/**
* RFC 2136 codes
*/
#define GNUNET_TUN_DNS_RETURN_CODE_YXDOMAIN 6
#define GNUNET_TUN_DNS_RETURN_CODE_YXRRSET 7
#define GNUNET_TUN_DNS_RETURN_CODE_NXRRSET 8
#define GNUNET_TUN_DNS_RETURN_CODE_NOT_AUTH 9
#define GNUNET_TUN_DNS_RETURN_CODE_NOT_ZONE 10
/**
* DNS flags (largely RFC 1035 / RFC 2136).
*/
struct GNUNET_TUN_DnsFlags
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
/**
* Set to 1 if recursion is desired (client -> server)
*/
unsigned int recursion_desired : 1 GNUNET_PACKED;
/**
* Set to 1 if message is truncated
*/
unsigned int message_truncated : 1 GNUNET_PACKED;
/**
* Set to 1 if this is an authoritative answer
*/
unsigned int authoritative_answer : 1 GNUNET_PACKED;
/**
* See GNUNET_TUN_DNS_OPCODE_ defines.
*/
unsigned int opcode : 4 GNUNET_PACKED;
/**
* query:0, response:1
*/
unsigned int query_or_response : 1 GNUNET_PACKED;
/**
* See GNUNET_TUN_DNS_RETURN_CODE_ defines.
*/
unsigned int return_code : 4 GNUNET_PACKED;
/**
* See RFC 4035.
*/
unsigned int checking_disabled : 1 GNUNET_PACKED;
/**
* Response has been cryptographically verified, RFC 4035.
*/
unsigned int authenticated_data : 1 GNUNET_PACKED;
/**
* Always zero.
*/
unsigned int zero : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is available (server -> client)
*/
unsigned int recursion_available : 1 GNUNET_PACKED;
#elif __BYTE_ORDER == __BIG_ENDIAN
/**
* query:0, response:1
*/
unsigned int query_or_response : 1 GNUNET_PACKED;
/**
* See GNUNET_TUN_DNS_OPCODE_ defines.
*/
unsigned int opcode : 4 GNUNET_PACKED;
/**
* Set to 1 if this is an authoritative answer
*/
unsigned int authoritative_answer : 1 GNUNET_PACKED;
/**
* Set to 1 if message is truncated
*/
unsigned int message_truncated : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is desired (client -> server)
*/
unsigned int recursion_desired : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is available (server -> client)
*/
unsigned int recursion_available : 1 GNUNET_PACKED;
/**
* Always zero.
*/
unsigned int zero : 1 GNUNET_PACKED;
/**
* Response has been cryptographically verified, RFC 4035.
*/
unsigned int authenticated_data : 1 GNUNET_PACKED;
/**
* See RFC 4035.
*/
unsigned int checking_disabled : 1 GNUNET_PACKED;
/**
* See GNUNET_TUN_DNS_RETURN_CODE_ defines.
*/
unsigned int return_code : 4 GNUNET_PACKED;
#else
#error byteorder undefined
#endif
} GNUNET_GCC_STRUCT_LAYOUT;
/**
* DNS header. * DNS header.
*/ */
struct GNUNET_TUN_DnsHeader struct GNUNET_TUN_DnsHeader
{ {
/**
* Unique identifier for the request/response.
*/
uint16_t id GNUNET_PACKED; uint16_t id GNUNET_PACKED;
uint16_t flags GNUNET_PACKED;
uint16_t qdcount GNUNET_PACKED; /**
uint16_t ancount GNUNET_PACKED; * Flags.
uint16_t nscount GNUNET_PACKED; */
uint16_t arcount GNUNET_PACKED; struct GNUNET_TUN_DnsFlags flags;
/**
* Number of queries.
*/
uint16_t query_count GNUNET_PACKED;
/**
* Number of answers.
*/
uint16_t answer_rcount GNUNET_PACKED;
/**
* Number of authoritative answers.
*/
uint16_t authority_rcount GNUNET_PACKED;
/**
* Number of additional records.
*/
uint16_t additional_rcount GNUNET_PACKED;
};
/**
* Payload of DNS SOA record (header).
*/
struct GNUNET_TUN_DnsSoaRecord
{
/**
* The version number of the original copy of the zone. (NBO)
*/
uint32_t serial GNUNET_PACKED;
/**
* Time interval before the zone should be refreshed. (NBO)
*/
uint32_t refresh GNUNET_PACKED;
/**
* Time interval that should elapse before a failed refresh should
* be retried. (NBO)
*/
uint32_t retry GNUNET_PACKED;
/**
* Time value that specifies the upper limit on the time interval
* that can elapse before the zone is no longer authoritative. (NBO)
*/
uint32_t expire GNUNET_PACKED;
/**
* The bit minimum TTL field that should be exported with any RR
* from this zone. (NBO)
*/
uint32_t minimum GNUNET_PACKED;
};
/**
* Payload of DNS SRV record (header).
*/
struct GNUNET_TUN_DnsSrvRecord
{
/**
* Preference for this entry (lower value is higher preference). Clients
* will contact hosts from the lowest-priority group first and fall back
* to higher priorities if the low-priority entries are unavailable. (NBO
)
*/
uint16_t prio GNUNET_PACKED;
/**
* Relative weight for records with the same priority. Clients will use
* the hosts of the same (lowest) priority with a probability proportiona
l
* to the weight given. (NBO)
*/
uint16_t weight GNUNET_PACKED;
/**
* TCP or UDP port of the service. (NBO)
*/
uint16_t port GNUNET_PACKED;
/* followed by 'target' name */
};
/**
* Payload of DNS CERT record.
*/
struct GNUNET_TUN_DnsCertRecord
{
/**
* Certificate type
*/
uint16_t cert_type;
/**
* Certificate KeyTag
*/
uint16_t cert_tag;
/**
* Algorithm
*/
uint8_t algorithm;
/* Followed by the certificate */
};
/**
* Payload of DNSSEC TLSA record.
* http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/
*/
struct GNUNET_TUN_DnsTlsaRecord
{
/**
* Certificate usage
* 0: CA cert
* 1: Entity cert
* 2: Trust anchor
* 3: domain-issued cert
*/
uint8_t usage;
/**
* Selector
* What part will be matched against the cert
* presented by server
* 0: Full cert (in binary)
* 1: Full cert (in DER)
*/
uint8_t selector;
/**
* Matching type (of selected content)
* 0: exact match
* 1: SHA-256 hash
* 2: SHA-512 hash
*/
uint8_t matching_type;
/**
* followed by certificate association data
* The "certificate association data" to be matched.
* These bytes are either raw data (that is, the full certificate or
* its SubjectPublicKeyInfo, depending on the selector) for matching
* type 0, or the hash of the raw data for matching types 1 and 2.
* The data refers to the certificate in the association, not to the
* TLS ASN.1 Certificate object.
*
* The data is represented as a string of hex chars
*/
};
/**
* Payload of GNS VPN record
*/
struct GNUNET_TUN_GnsVpnRecord
{
/**
* The peer to contact
*/
struct GNUNET_PeerIdentity peer;
/**
* The protocol to use
*/
uint16_t proto;
/* followed by the servicename */
};
/**
* DNS query prefix.
*/
struct GNUNET_TUN_DnsQueryLine
{
/**
* Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
*/
uint16_t type GNUNET_PACKED;
/**
* Desired class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO)
*/
uint16_t dns_traffic_class GNUNET_PACKED;
};
/**
* General DNS record prefix.
*/
struct GNUNET_TUN_DnsRecordLine
{
/**
* Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
*/
uint16_t type GNUNET_PACKED;
/**
* Record class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO)
*/
uint16_t dns_traffic_class GNUNET_PACKED;
/**
* Expiration for the record (in seconds). (NBO)
*/
uint32_t ttl GNUNET_PACKED;
/**
* Number of bytes of data that follow. (NBO)
*/
uint16_t data_len GNUNET_PACKED;
}; };
#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0 #define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0
#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3 #define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3
#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4 #define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4
#define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5 #define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5
#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8 #define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8
#define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9 #define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9
#define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10 #define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10
#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11 #define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11
skipping to change at line 267 skipping to change at line 663
#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1 #define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1
#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2 #define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2
#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3 #define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3
#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4 #define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4
#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128 #define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128
#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129 #define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129
/** /**
* ICMP header. * ICMP header.
*/ */
struct GNUNET_TUN_IcmpHeader { struct GNUNET_TUN_IcmpHeader
{
uint8_t type; uint8_t type;
uint8_t code; uint8_t code;
uint16_t crc GNUNET_PACKED; uint16_t crc GNUNET_PACKED;
union { union
{
/** /**
* ICMP Echo (request/reply) * ICMP Echo (request/reply)
*/ */
struct { struct
{
uint16_t identifier GNUNET_PACKED; uint16_t identifier GNUNET_PACKED;
uint16_t sequence_number GNUNET_PACKED; uint16_t sequence_number GNUNET_PACKED;
} echo; } echo;
/** /**
* ICMP Destination Unreachable (RFC 1191) * ICMP Destination Unreachable (RFC 1191)
*/ */
struct ih_pmtu { struct ih_pmtu
{
uint16_t empty GNUNET_PACKED; uint16_t empty GNUNET_PACKED;
uint16_t next_hop_mtu GNUNET_PACKED; uint16_t next_hop_mtu GNUNET_PACKED;
/* followed by original IP header + first 8 bytes of original IP data gram */ /* followed by original IP header + first 8 bytes of original IP data gram */
} destination_unreachable; } destination_unreachable;
/** /**
* ICMP Redirect * ICMP Redirect
*/ */
struct in_addr redirect_gateway_address GNUNET_PACKED; struct in_addr redirect_gateway_address GNUNET_PACKED;
skipping to change at line 344 skipping to change at line 744
uint16_t payload_length, uint16_t payload_length,
const struct in6_addr *src, const struct in6_addr *src,
const struct in6_addr *dst); const struct in6_addr *dst);
/** /**
* Calculate IPv4 TCP checksum. * Calculate IPv4 TCP checksum.
* *
* @param ip ipv4 header fully initialized * @param ip ipv4 header fully initialized
* @param tcp TCP header (initialized except for CRC) * @param tcp TCP header (initialized except for CRC)
* @param payload the TCP payload * @param payload the TCP payload
* @param payload_length number of bytes of TCP payload * @param payload_length number of bytes of TCP @a payload
*/ */
void void
GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
struct GNUNET_TUN_TcpHeader *tcp, struct GNUNET_TUN_TcpHeader *tcp,
const void *payload, const void *payload,
uint16_t payload_length); uint16_t payload_length);
/** /**
* Calculate IPv6 TCP checksum. * Calculate IPv6 TCP checksum.
* *
skipping to change at line 372 skipping to change at line 772
struct GNUNET_TUN_TcpHeader *tcp, struct GNUNET_TUN_TcpHeader *tcp,
const void *payload, const void *payload,
uint16_t payload_length); uint16_t payload_length);
/** /**
* Calculate IPv4 UDP checksum. * Calculate IPv4 UDP checksum.
* *
* @param ip ipv4 header fully initialized * @param ip ipv4 header fully initialized
* @param udp UDP header (initialized except for CRC) * @param udp UDP header (initialized except for CRC)
* @param payload the UDP payload * @param payload the UDP payload
* @param payload_length number of bytes of UDP payload * @param payload_length number of bytes of UDP @a payload
*/ */
void void
GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
struct GNUNET_TUN_UdpHeader *udp, struct GNUNET_TUN_UdpHeader *udp,
const void *payload, const void *payload,
uint16_t payload_length); uint16_t payload_length);
/** /**
* Calculate IPv6 UDP checksum. * Calculate IPv6 UDP checksum.
* *
* @param ip ipv6 header fully initialized * @param ip ipv6 header fully initialized
* @param udp UDP header (initialized except for CRC) * @param udp UDP header (initialized except for CRC)
* @param payload the UDP payload * @param payload the UDP payload
* @param payload_length number of bytes of UDP payload * @param payload_length number of bytes of @a payload
*/ */
void void
GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
struct GNUNET_TUN_UdpHeader *udp, struct GNUNET_TUN_UdpHeader *udp,
const void *payload, const void *payload,
uint16_t payload_length); uint16_t payload_length);
/** /**
* Calculate ICMP checksum. * Calculate ICMP checksum.
* *
* @param icmp IMCP header (initialized except for CRC) * @param icmp IMCP header (initialized except for CRC)
* @param payload the ICMP payload * @param payload the ICMP payload
* @param payload_length number of bytes of ICMP payload * @param payload_length number of bytes of @a payload
*/ */
void void
GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp, GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp,
const void *payload, const void *payload,
uint16_t payload_length); uint16_t payload_length);
/**
* Create a regex in @a rxstr from the given @a ip and @a port.
*
* @param ip IPv4 representation.
* @param port destination port
* @param rxstr generated regex, must be at least #GNUNET_TUN_IPV4_REGEXLEN
* bytes long.
*/
void
GNUNET_TUN_ipv4toregexsearch (const struct in_addr *ip,
uint16_t port,
char *rxstr);
/**
* Create a regex in @a rxstr from the given @a ipv6 and @a port.
*
* @param ipv6 IPv6 representation.
* @param port destination port
* @param rxstr generated regex, must be at least #GNUNET_TUN_IPV6_REGEXLEN
* bytes long.
*/
void
GNUNET_TUN_ipv6toregexsearch (const struct in6_addr *ipv6,
uint16_t port,
char *rxstr);
/**
* Convert an exit policy to a regular expression. The exit policy
* specifies a set of subnets this peer is willing to serve as an
* exit for; the resulting regular expression will match the
* IPv6 address strings as returned by #GNUNET_TUN_ipv6toregexsearch.
*
* @param policy exit policy specification
* @return regular expression, NULL on error
*/
char *
GNUNET_TUN_ipv6policy2regex (const char *policy);
/**
* Convert an exit policy to a regular expression. The exit policy
* specifies a set of subnets this peer is willing to serve as an
* exit for; the resulting regular expression will match the
* IPv4 address strings as returned by #GNUNET_TUN_ipv4toregexsearch.
*
* @param policy exit policy specification
* @return regular expression, NULL on error
*/
char *
GNUNET_TUN_ipv4policy2regex (const char *policy);
/**
* Hash the service name of a hosted service to the
* hash code that is used to identify the service on
* the network.
*
* @param service_name a string
* @param hc corresponding hash
*/
void
GNUNET_TUN_service_name_to_hash (const char *service_name,
struct GNUNET_HashCode *hc);
#endif #endif
 End of changes. 20 change blocks. 
14 lines changed or deleted 478 lines changed or added


 gnunet_util_lib.h   gnunet_util_lib.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2009 Christian Grothoff (and other contributing authors) (C) 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 39 skipping to change at line 39
#define GNUNET_UTIL_LIB_H #define GNUNET_UTIL_LIB_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
} }
#endif #endif
#endif #endif
#include "gnunet_common.h" #include "gnunet_crypto_lib.h"
#include "gnunet_bandwidth_lib.h" #include "gnunet_bandwidth_lib.h"
#include "gnunet_bio_lib.h" #include "gnunet_bio_lib.h"
#include "gnunet_client_lib.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_connection_lib.h" #include "gnunet_connection_lib.h"
#include "gnunet_client_lib.h"
#include "gnunet_container_lib.h" #include "gnunet_container_lib.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_disk_lib.h"
#include "gnunet_getopt_lib.h" #include "gnunet_getopt_lib.h"
#include "gnunet_helper_lib.h" #include "gnunet_helper_lib.h"
#include "gnunet_network_lib.h" #include "gnunet_mq_lib.h"
#include "gnunet_os_lib.h" #include "gnunet_os_lib.h"
#include "gnunet_peer_lib.h" #include "gnunet_peer_lib.h"
#include "gnunet_plugin_lib.h" #include "gnunet_plugin_lib.h"
#include "gnunet_program_lib.h" #include "gnunet_program_lib.h"
#include "gnunet_protocols.h" #include "gnunet_protocols.h"
#include "gnunet_pseudonym_lib.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_server_lib.h" #include "gnunet_server_lib.h"
#include "gnunet_service_lib.h" #include "gnunet_service_lib.h"
#include "gnunet_signal_lib.h" #include "gnunet_signal_lib.h"
#include "gnunet_strings_lib.h" #include "gnunet_strings_lib.h"
#include "gnunet_time_lib.h"
#if 0 /* keep Emacsens' auto-indent happy */ #if 0 /* keep Emacsens' auto-indent happy */
{ {
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 8 change blocks. 
10 lines changed or deleted 4 lines changed or added


 gnunet_vpn_service.h   gnunet_vpn_service.h 
/* /*
This file is part of GNUnet This file is part of GNUnet
(C) 2012 Christian Grothoff (and other contributing authors) (C) 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 80 skipping to change at line 80
* begin the redirection as soon as possible and maintain it as long * begin the redirection as soon as possible and maintain it as long
* as it is actively used and keeping it is feasible. Given resource * as it is actively used and keeping it is feasible. Given resource
* limitations, the longest inactive mappings will be destroyed. * limitations, the longest inactive mappings will be destroyed.
* *
* @param vh VPN handle * @param vh VPN handle
* @param result_af desired address family for the returned allocation * @param result_af desired address family for the returned allocation
* can also be AF_UNSPEC * can also be AF_UNSPEC
* @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP
* @param peer target peer for the redirection * @param peer target peer for the redirection
* @param serv service descriptor to give to the peer * @param serv service descriptor to give to the peer
* @param nac GNUNET_YES to notify via callback only after completion of
* the MESH-level connection,
* GNUNET_NO to notify as soon as the IP has been reserved
* @param expiration_time at what time should the redirection expire? * @param expiration_time at what time should the redirection expire?
* (this should not impact connections that are active at that time) * (this should not impact connections that are active at that time)
* @param cb function to call with the IP * @param cb function to call with the IP
* @param cb_cls closure for cb * @param cb_cls closure for cb
* @return handle to cancel the request (means the callback won't be * @return handle to cancel the request (means the callback won't be
* invoked anymore; the mapping may or may not be established * invoked anymore; the mapping may or may not be established
* anyway) * anyway)
*/ */
struct GNUNET_VPN_RedirectionRequest * struct GNUNET_VPN_RedirectionRequest *
GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh, GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
int result_af, int result_af,
uint8_t protocol, uint8_t protocol,
const struct GNUNET_PeerIdentity *peer, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HashCode *serv, const struct GNUNET_HashCode *serv,
int nac,
struct GNUNET_TIME_Absolute expiration_time, struct GNUNET_TIME_Absolute expiration_time,
GNUNET_VPN_AllocationCallback cb, GNUNET_VPN_AllocationCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Tell the VPN that forwarding to the Internet via some exit node is * Tell the VPN that forwarding to the Internet via some exit node is
* requested. Note that both UDP and TCP traffic will be forwarded, * requested. Note that both UDP and TCP traffic will be forwarded,
* but possibly to different exit nodes. The VPN is to reserve a * but possibly to different exit nodes. The VPN is to reserve a
* particular IP for the redirection and return it. The VPN will * particular IP for the redirection and return it. The VPN will
* begin the redirection as soon as possible and maintain it as long * begin the redirection as soon as possible and maintain it as long
* as it is actively used and keeping it is feasible. Given resource * as it is actively used and keeping it is feasible. Given resource
* limitations, the longest inactive mappings will be destroyed. * limitations, the longest inactive mappings will be destroyed.
* *
* @param vh VPN handle * @param vh VPN handle
* @param result_af desired address family for the returned allocation, * @param result_af desired address family for the returned allocation,
* can also be AF_UNSPEC * can also be AF_UNSPEC
* @param addr_af address family for 'addr', AF_INET or AF_INET6 * @param addr_af address family for 'addr', AF_INET or AF_INET6
* @param addr destination IP address on the Internet; destination * @param addr destination IP address on the Internet; destination
* port is to be taken from the VPN packet itself * port is to be taken from the VPN packet itself
* @param nac GNUNET_YES to notify via callback only after completion of
* the MESH-level connection,
* GNUNET_NO to notify as soon as the IP has been reserved
* @param expiration_time at what time should the redirection expire? * @param expiration_time at what time should the redirection expire?
* (this should not impact connections that are active at that time) * (this should not impact connections that are active at that time)
* @param cb function to call with the IP * @param cb function to call with the IP
* @param cb_cls closure for cb * @param cb_cls closure for cb
* @return handle to cancel the request (means the callback won't be * @return handle to cancel the request (means the callback won't be
* invoked anymore; the mapping may or may not be established * invoked anymore; the mapping may or may not be established
* anyway) * anyway)
*/ */
struct GNUNET_VPN_RedirectionRequest * struct GNUNET_VPN_RedirectionRequest *
GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh, GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
int result_af, int result_af,
int addr_af, int addr_af,
const void *addr, const void *addr,
int nac,
struct GNUNET_TIME_Absolute expiration_time, struct GNUNET_TIME_Absolute expiration_time,
GNUNET_VPN_AllocationCallback cb, GNUNET_VPN_AllocationCallback cb,
void *cb_cls); void *cb_cls);
/** /**
* Connect to the VPN service * Connect to the VPN service
* *
* @param cfg configuration to use * @param cfg configuration to use
* @return VPN handle * @return VPN handle
*/ */
 End of changes. 5 change blocks. 
9 lines changed or deleted 1 lines changed or added


 platform.h   platform.h 
/* /*
This file is part of GNUnet. This file is part of GNUnet.
(C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 Christian Gro thoff (and other contributing authors) (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 Christian Gro thoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your by the Free Software Foundation; either version 3, or (at your
option) any later version. option) any later version.
GNUnet is distributed in the hope that it will be useful, but GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Free Software Foundation, Inc., 59 Temple Place - Suite 330,
skipping to change at line 51 skipping to change at line 51
#define GNUNET_SIGCHLD 17 #define GNUNET_SIGCHLD 17
#else #else
#define BREAKPOINT #define BREAKPOINT
#define GNUNET_SIGCHLD SIGCHLD #define GNUNET_SIGCHLD SIGCHLD
#endif #endif
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif #endif
/**
* These may be expensive, but good for debugging...
*/
#define ALLOW_EXTRA_CHECKS GNUNET_YES #define ALLOW_EXTRA_CHECKS GNUNET_YES
/** /**
* For strptime (glibc2 needs this). * For strptime (glibc2 needs this).
*/ */
#ifndef _XOPEN_SOURCE #ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE #define _XOPEN_SOURCE 499
#endif #endif
#ifndef _REENTRANT #ifndef _REENTRANT
#define _REENTRANT #define _REENTRANT
#endif #endif
/* configuration options */ /* configuration options */
#define VERBOSE_STATS 0 #define VERBOSE_STATS 0
skipping to change at line 89 skipping to change at line 92
#ifndef MINGW #ifndef MINGW
#include <netdb.h> #include <netdb.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#if HAVE_NETINET_IN_H #if HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#if HAVE_NETINET_IN_SYSTM_H #if HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h> #include <netinet/in_systm.h>
#endif #endif
#if HAVE_NETINET_IP_H
#include <netinet/ip.h> /* superset of previous */ #include <netinet/ip.h> /* superset of previous */
#endif
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <pwd.h> #include <pwd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <grp.h> #include <grp.h>
#else #else
#include "winproc.h" #include "winproc.h"
#endif #endif
#endif #endif
skipping to change at line 265 skipping to change at line 270
#endif #endif
#if WINDOWS #if WINDOWS
#define FDTYPE HANDLE #define FDTYPE HANDLE
#define SOCKTYPE SOCKET #define SOCKTYPE SOCKET
#else #else
#define FDTYPE int #define FDTYPE int
#define SOCKTYPE int #define SOCKTYPE int
#endif #endif
/**
* The termination signal
*/
#define GNUNET_TERM_SIG SIGTERM
#endif #endif
 End of changes. 6 change blocks. 
2 lines changed or deleted 12 lines changed or added


 plibc.h   plibc.h 
skipping to change at line 25 skipping to change at line 25
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Softwa re License along with this library; if not, write to the Free Softwa re
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1 307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1 307 USA
*/ */
/** /**
* @file include/plibc.h * @file include/plibc.h
* @brief PlibC header * @brief PlibC header
* @attention This file is usually not installed under Unix, * @attention This file is usually not installed under Unix,
* so ship it with your application * so ship it with your application
* @version $Revision: 84 $ * @version $Revision$
*/ */
#ifndef _PLIBC_H_ #ifndef _PLIBC_H_
#define _PLIBC_H_ #define _PLIBC_H_
#ifndef SIGALRM #ifndef SIGALRM
#define SIGALRM 14 #define SIGALRM 14
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
skipping to change at line 73 skipping to change at line 73
#define __BYTE_ORDER BYTE_ORDER #define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN #define __BIG_ENDIAN BIG_ENDIAN
/* Conflicts with our definitions */ /* Conflicts with our definitions */
#define __G_WIN32_H__ #define __G_WIN32_H__
/* Convert LARGE_INTEGER to double */ /* Convert LARGE_INTEGER to double */
#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \ #define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
(double)((x).LowPart)) (double)((x).LowPart))
#ifndef __MINGW64__ #ifndef HAVE_DECL__STATI64
struct stat64 struct _stati64
{ {
_dev_t st_dev; _dev_t st_dev;
_ino_t st_ino; _ino_t st_ino;
_mode_t st_mode; _mode_t st_mode;
short st_nlink; short st_nlink;
short st_uid; short st_uid;
short st_gid; short st_gid;
_dev_t st_rdev; _dev_t st_rdev;
__int64 st_size; __int64 st_size;
__time64_t st_atime; time_t st_atime;
__time64_t st_mtime; time_t st_mtime;
__time64_t st_ctime; time_t st_ctime;
}; };
#endif #endif
typedef unsigned int sa_family_t; typedef unsigned int sa_family_t;
struct sockaddr_un { struct sockaddr_un {
short sun_family; /*AF_UNIX*/ short sun_family; /*AF_UNIX*/
char sun_path[108]; /*path name */ char sun_path[108]; /*path name */
}; };
#ifndef pid_t #ifndef pid_t
skipping to change at line 118 skipping to change at line 118
#ifndef MSG_DONTWAIT #ifndef MSG_DONTWAIT
#define MSG_DONTWAIT 0 #define MSG_DONTWAIT 0
#endif #endif
enum enum
{ {
_SC_PAGESIZE = 30, _SC_PAGESIZE = 30,
_SC_PAGE_SIZE = 30 _SC_PAGE_SIZE = 30
}; };
#if !defined(EACCESS)
# define EACCESS EACCES
#endif
/* Thanks to the Cygwin project */ /* Thanks to the Cygwin project */
#define ENOCSI 43 /* No CSI structure available */ #if !defined(ENOCSI)
#define EL2HLT 44 /* Level 2 halted */ # define ENOCSI 43 /* No CSI structure available */
#ifndef EDEADLK #endif
#define EDEADLK 45 /* Deadlock condition */ #if !defined(EL2HLT)
#endif # define EL2HLT 44 /* Level 2 halted */
#ifndef ENOLCK #endif
#define ENOLCK 46 /* No record locks available */ #if !defined(EDEADLK)
#endif # define EDEADLK 45 /* Deadlock condition */
#define EBADE 50 /* Invalid exchange */ #endif
#define EBADR 51 /* Invalid request descriptor */ #if !defined(ENOLCK)
#define EXFULL 52 /* Exchange full */ # define ENOLCK 46 /* No record locks available */
#define ENOANO 53 /* No anode */ #endif
#define EBADRQC 54 /* Invalid request code */ #if !defined(EBADE)
#define EBADSLT 55 /* Invalid slot */ # define EBADE 50 /* Invalid exchange */
#ifndef EDEADLOCK #endif
#define EDEADLOCK EDEADLK /* File locking deadlock error */ #if !defined(EBADR)
#endif # define EBADR 51 /* Invalid request descriptor */
#define EBFONT 57 /* Bad font file fmt */ #endif
#define ENOSTR 60 /* Device not a stream */ #if !defined(EXFULL)
#define ENODATA 61 /* No data (for no delay io) */ # define EXFULL 52 /* Exchange full */
#define ETIME 62 /* Timer expired */ #endif
#define ENOSR 63 /* Out of streams resources */ #if !defined(ENOANO)
#define ENONET 64 /* Machine is not on the network */ # define ENOANO 53 /* No anode */
#define ENOPKG 65 /* Package not installed */ #endif
#define EREMOTE 66 /* The object is remote */ #if !defined(EBADRQC)
#define ENOLINK 67 /* The link has been severed */ # define EBADRQC 54 /* Invalid request code */
#define EADV 68 /* Advertise error */ #endif
#define ESRMNT 69 /* Srmount error */ #if !defined(EBADSLT)
#define ECOMM 70 /* Communication error on send */ # define EBADSLT 55 /* Invalid slot */
#define EPROTO 71 /* Protocol error */ #endif
#define EMULTIHOP 74 /* Multihop attempted */ #if !defined(EDEADLOCK)
#define ELBIN 75 /* Inode is remote (not really error) */ # define EDEADLOCK EDEADLK /* File locking deadlock error */
#define EDOTDOT 76 /* Cross mount point (not really error) */ #endif
#define EBADMSG 77 /* Trying to read unreadable message */ #if !defined(EBFONT)
#define ENOTUNIQ 80 /* Given log. name not unique */ # define EBFONT 57 /* Bad font file fmt */
#define EBADFD 81 /* f.d. invalid for this operation */ #endif
#define EREMCHG 82 /* Remote address changed */ #if !defined(ENOSTR)
#define ELIBACC 83 /* Can't access a needed shared lib */ # define ENOSTR 60 /* Device not a stream */
#define ELIBBAD 84 /* Accessing a corrupted shared lib */ #endif
#define ELIBSCN 85 /* .lib section in a.out corrupted */ #if !defined(ENODATA)
#define ELIBMAX 86 /* Attempting to link in too many libs */ # define ENODATA 61 /* No data (for no delay io) */
#define ELIBEXEC 87 /* Attempting to exec a shared library */ #endif
#ifndef ENOSYS #if !defined(ETIME)
#define ENOSYS 88 /* Function not implemented */ # define ETIME 62 /* Timer expired */
#endif #endif
#define ENMFILE 89 /* No more files */ #if !defined(ENOSR)
#ifndef ENOTEMPTY # define ENOSR 63 /* Out of streams resources */
#define ENOTEMPTY 90 /* Directory not empty */ #endif
#endif #if !defined(ENONET)
#ifndef ENAMETOOLONG # define ENONET 64 /* Machine is not on the network */
#define ENAMETOOLONG 91 /* File or path name too long */ #endif
#endif #if !defined(ENOPKG)
#define ELOOP 92 /* Too many symbolic links */ # define ENOPKG 65 /* Package not installed */
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #endif
#define EPFNOSUPPORT 96 /* Protocol family not supported */ #if !defined(EREMOTE)
#define ECONNRESET 104 /* Connection reset by peer */ # define EREMOTE 66 /* The object is remote */
#define ENOBUFS 105 /* No buffer space available */ #endif
#define EAFNOSUPPORT 106 /* Address family not supported by protocol family #if !defined(ENOLINK)
*/ # define ENOLINK 67 /* The link has been severed */
#define EPROTOTYPE 107 /* Protocol wrong type for socket */ #endif
#define ENOTSOCK 108 /* Socket operation on non-socket */ #if !defined(EADV)
#define ENOPROTOOPT 109 /* Protocol not available */ # define EADV 68 /* Advertise error */
#define ESHUTDOWN 110 /* Can't send after socket shutdown */ #endif
#define ECONNREFUSED 111 /* Connection refused */ #if !defined(ESRMNT)
#define EADDRINUSE 112 /* Address already in use */ # define ESRMNT 69 /* Srmount error */
#define ECONNABORTED 113 /* Connection aborted */ #endif
#define ENETUNREACH 114 /* Network is unreachable */ #if !defined(ECOMM)
#define ENETDOWN 115 /* Network interface is not configured */ # define ECOMM 70 /* Communication error on send */
#ifndef ETIMEDOUT #endif
#define ETIMEDOUT 116 /* Connection timed out */ #if !defined(EMULTIHOP)
#endif # define EMULTIHOP 74 /* Multihop attempted */
#define EHOSTDOWN 117 /* Host is down */ #endif
#define EHOSTUNREACH 118 /* Host is unreachable */ #if !defined(ELBIN)
#define EINPROGRESS 119 /* Connection already in progress */ # define ELBIN 75 /* Inode is remote (not really error) */
#define EALREADY 120 /* Socket already connected */ #endif
#define EDESTADDRREQ 121 /* Destination address required */ #if !defined(EDOTDOT)
#define EMSGSIZE 122 /* Message too long */ # define EDOTDOT 76 /* Cross mount point (not really error) */
#define EPROTONOSUPPORT 123 /* Unknown protocol */ #endif
#define ESOCKTNOSUPPORT 124 /* Socket type not supported */ #if !defined(EBADMSG)
#define EADDRNOTAVAIL 125 /* Address not available */ # define EBADMSG 77 /* Trying to read unreadable message */
#define ENETRESET 126 /* Connection aborted by network */ #endif
#define EISCONN 127 /* Socket is already connected */ #if !defined(ENOTUNIQ)
#define ENOTCONN 128 /* Socket is not connected */ # define ENOTUNIQ 80 /* Given log. name not unique */
#define ETOOMANYREFS 129 /* Too many references: cannot splice */ #endif
#define EPROCLIM 130 /* Too many processes */ #if !defined(EBADFD)
#define EUSERS 131 /* Too many users */ # define EBADFD 81 /* f.d. invalid for this operation */
#define EDQUOT 132 /* Disk quota exceeded */ #endif
#define ESTALE 133 /* Unknown error */ #if !defined(EREMCHG)
#ifndef ENOTSUP # define EREMCHG 82 /* Remote address changed */
#define ENOTSUP 134 /* Not supported */ #endif
#endif #if !defined(ELIBACC)
#define ENOMEDIUM 135 /* No medium (in tape drive) */ # define ELIBACC 83 /* Can't access a needed shared lib */
#define ENOSHARE 136 /* No such host or network path */ #endif
#define ECASECLASH 137 /* Filename exists with different case */ #if !defined(ELIBBAD)
#define EWOULDBLOCK EAGAIN /* Operation would block */ # define ELIBBAD 84 /* Accessing a corrupted shared lib */
#define EOVERFLOW 139 /* Value too large for defined data type */ #endif
#if !defined(ELIBSCN)
# define ELIBSCN 85 /* .lib section in a.out corrupted */
#endif
#if !defined(ELIBMAX)
# define ELIBMAX 86 /* Attempting to link in too many libs */
#endif
#if !defined(ELIBEXEC)
# define ELIBEXEC 87 /* Attempting to exec a shared library */
#endif
#if !defined(ENOSYS)
# define ENOSYS 88 /* Function not implemented */
#endif
#if !defined(ENMFILE)
# define ENMFILE 89 /* No more files */
#endif
#if !defined(ENOTEMPTY)
# define ENOTEMPTY 90 /* Directory not empty */
#endif
#if !defined(ENAMETOOLONG)
# define ENAMETOOLONG 91 /* File or path name too long */
#endif
#if !defined(EPFNOSUPPORT)
# define EPFNOSUPPORT 96 /* Protocol family not supported */
#endif
#if !defined(ENOSHARE)
# define ENOSHARE 97 /* No such host or network path */
#endif
#if !defined(ENOMEDIUM)
# define ENOMEDIUM 98 /* No medium (in tape drive) */
#endif
#if !defined(ESHUTDOWN)
# define ESHUTDOWN 99 /* Can't send after socket shutdown */
#endif
#if !defined(EADDRINUSE)
# define EADDRINUSE 100 /* Address already in use */
#endif
#if !defined(EADDRNOTAVAIL)
# define EADDRNOTAVAIL 101 /* Address not available */
#endif
#if !defined(EAFNOSUPPORT)
# define EAFNOSUPPORT 102 /* Address family not supported by protocol fami
ly */
#endif
#if !defined(EALREADY)
# define EALREADY 103 /* Socket already connected */
#endif
#if !defined(ECANCELED)
# define ECANCELED 105 /* Connection cancelled */
#endif
#if !defined(ECONNABORTED)
# define ECONNABORTED 106 /* Connection aborted */
#endif
#if !defined(ECONNREFUSED)
# define ECONNREFUSED 107 /* Connection refused */
#endif
#if !defined(ECONNRESET)
# define ECONNRESET 108 /* Connection reset by peer */
#endif
#if !defined(EDESTADDRREQ)
# define EDESTADDRREQ 109 /* Destination address required */
#endif
#if !defined(EHOSTUNREACH)
# define EHOSTUNREACH 110 /* Host is unreachable */
#endif
#if !defined(ECONNABORTED)
# define ECONNABORTED 111 /* Connection aborted */
#endif
#if !defined(EINPROGRESS)
# define EINPROGRESS 112 /* Connection already in progress */
#endif
#if !defined(EISCONN)
# define EISCONN 113 /* Socket is already connected */
#endif
#if !defined(ELOOP)
# define ELOOP 114 /* Too many symbolic links */
#endif
#if !defined(EMSGSIZE)
# define EMSGSIZE 115 /* Message too long */
#endif
#if !defined(ENETDOWN)
# define ENETDOWN 116 /* Network interface is not configured */
#endif
#if !defined(ENETRESET)
# define ENETRESET 117 /* Connection aborted by network */
#endif
#if !defined(ENETUNREACH)
# define ENETUNREACH 118 /* Network is unreachable */
#endif
#if !defined(ENOBUFS)
# define ENOBUFS 119 /* No buffer space available */
#endif
#if !defined(EHOSTDOWN)
# define EHOSTDOWN 120 /* Host is down */
#endif
#if !defined(EPROCLIM)
# define EPROCLIM 121 /* Too many processes */
#endif
#if !defined(EDQUOT)
# define EDQUOT 122 /* Disk quota exceeded */
#endif
#if !defined(ENOPROTOOPT)
# define ENOPROTOOPT 123 /* Protocol not available */
#endif
#if !defined(ESOCKTNOSUPPORT)
# define ESOCKTNOSUPPORT 124 /* Socket type not supported */
#endif
#if !defined(ESTALE)
# define ESTALE 125 /* Unknown error */
#endif
#if !defined(ENOTCONN)
# define ENOTCONN 126 /* Socket is not connected */
#endif
#if !defined(ETOOMANYREFS)
# define ETOOMANYREFS 127 /* Too many references: cannot splice */
#endif
#if !defined(ENOTSOCK)
# define ENOTSOCK 128 /* Socket operation on non-socket */
#endif
#if !defined(ENOTSUP)
# define ENOTSUP 129 /* Not supported */
#endif
#if !defined(EOPNOTSUPP)
# define EOPNOTSUPP 130 /* Operation not supported on transport endp
oint */
#endif
#if !defined(EUSERS)
# define EUSERS 131 /* Too many users */
#endif
#if !defined(EOVERFLOW)
# define EOVERFLOW 132 /* Value too large for defined data type */
#endif
#if !defined(EOWNERDEAD)
# define EOWNERDEAD 133 /* Unknown error */
#endif
#if !defined(EPROTO)
# define EPROTO 134 /* Protocol error */
#endif
#if !defined(EPROTONOSUPPORT)
# define EPROTONOSUPPORT 135 /* Unknown protocol */
#endif
#if !defined(EPROTOTYPE)
# define EPROTOTYPE 136 /* Protocol wrong type for socket */
#endif
#if !defined(ECASECLASH)
# define ECASECLASH 137 /* Filename exists with different case */
#endif
#if !defined(ETIMEDOUT)
/* Make sure it's the same as WSATIMEDOUT */
# define ETIMEDOUT 138 /* Connection timed out */
#endif
#if !defined(EWOULDBLOCK) || EWOULDBLOCK == 140
# undef EWOULDBLOCK /* MinGW-w64 defines it as 140, but we want it as EAGA
IN */
# define EWOULDBLOCK EAGAIN /* Operation would block */
#endif
#undef HOST_NOT_FOUND #undef HOST_NOT_FOUND
#define HOST_NOT_FOUND 1 #define HOST_NOT_FOUND 1
#undef TRY_AGAIN #undef TRY_AGAIN
#define TRY_AGAIN 2 #define TRY_AGAIN 2
#undef NO_RECOVERY #undef NO_RECOVERY
#define NO_RECOVERY 3 #define NO_RECOVERY 3
#undef NO_ADDRESS #undef NO_ADDRESS
#define NO_ADDRESS 4 #define NO_ADDRESS 4
skipping to change at line 250 skipping to change at line 407
long f_blocks; /* total data blocks in file system */ long f_blocks; /* total data blocks in file system */
long f_bfree; /* free blocks in fs */ long f_bfree; /* free blocks in fs */
long f_bavail; /* free blocks avail to non-superuser */ long f_bavail; /* free blocks avail to non-superuser */
long f_files; /* total file nodes in file system */ long f_files; /* total file nodes in file system */
long f_ffree; /* free file nodes in fs */ long f_ffree; /* free file nodes in fs */
long f_fsid; /* file system id */ long f_fsid; /* file system id */
long f_namelen; /* maximum length of filenames */ long f_namelen; /* maximum length of filenames */
long f_spare[6]; /* spare for later */ long f_spare[6]; /* spare for later */
}; };
extern const struct in6_addr in6addr_any; /* :: */
extern const struct in6_addr in6addr_loopback; /* ::1 */
/* Taken from the Wine project <http://www.winehq.org> /* Taken from the Wine project <http://www.winehq.org>
/wine/include/winternl.h */ /wine/include/winternl.h */
enum SYSTEM_INFORMATION_CLASS enum SYSTEM_INFORMATION_CLASS
{ {
SystemBasicInformation = 0, SystemBasicInformation = 0,
Unknown1, Unknown1,
SystemPerformanceInformation = 2, SystemPerformanceInformation = 2,
SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */ SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
Unknown4, Unknown4,
SystemProcessInformation = 5, SystemProcessInformation = 5,
skipping to change at line 366 skipping to change at line 520
int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows); int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows);
int plibc_conv_to_win_pathw(const wchar_t *pszUnix, wchar_t *pwszWindows); int plibc_conv_to_win_pathw(const wchar_t *pszUnix, wchar_t *pwszWindows);
int plibc_conv_to_win_pathwconv(const char *pszUnix, wchar_t *pwszWindows); int plibc_conv_to_win_pathwconv(const char *pszUnix, wchar_t *pwszWindows);
int plibc_conv_to_win_pathwconv_ex(const char *pszUnix, wchar_t *pszWindows , int derefLinks); int plibc_conv_to_win_pathwconv_ex(const char *pszUnix, wchar_t *pszWindows , int derefLinks);
unsigned plibc_get_handle_count(); unsigned plibc_get_handle_count();
typedef void (*TPanicProc) (int, char *); typedef void (*TPanicProc) (int, char *);
void plibc_set_panic_proc(TPanicProc proc); void plibc_set_panic_proc(TPanicProc proc);
void plibc_set_stat_size_size(int iLength);
void plibc_set_stat_time_size(int iLength);
int flock(int fd, int operation); int flock(int fd, int operation);
int fsync(int fildes); int fsync(int fildes);
int inet_pton(int af, const char *src, void *dst); int inet_pton(int af, const char *src, void *dst);
int inet_pton4(const char *src, u_char *dst, int pton); int inet_pton4(const char *src, u_char *dst, int pton);
#if USE_IPV6 #if USE_IPV6
int inet_pton6(const char *src, u_char *dst); int inet_pton6(const char *src, u_char *dst);
#endif #endif
int truncate(const char *fname, int distance);
int statfs(const char *path, struct statfs *buf); int statfs(const char *path, struct statfs *buf);
const char *hstrerror(int err); const char *hstrerror(int err);
int mkstemp(char *tmplate); int mkstemp(char *tmplate);
char *strptime (const char *buf, const char *format, struct tm *tm); char *strptime (const char *buf, const char *format, struct tm *tm);
const char *inet_ntop(int af, const void *src, char *dst, size_t size); const char *inet_ntop(int af, const void *src, char *dst, size_t size);
#ifndef gmtime_r
struct tm *gmtime_r(const time_t *clock, struct tm *result); struct tm *gmtime_r(const time_t *clock, struct tm *result);
#endif
int plibc_init(char *pszOrg, char *pszApp); int plibc_init(char *pszOrg, char *pszApp);
int plibc_init_utf8(char *pszOrg, char *pszApp, int utf8_mode); int plibc_init_utf8(char *pszOrg, char *pszApp, int utf8_mode);
void plibc_shutdown(); void plibc_shutdown();
int plibc_initialized(); int plibc_initialized();
void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine); void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
void SetErrnoFromWinsockError(long lWinError); void SetErrnoFromWinsockError(long lWinError);
void SetHErrnoFromWinError(long lWinError); void SetHErrnoFromWinError(long lWinError);
void SetErrnoFromHRESULT(HRESULT hRes); void SetErrnoFromHRESULT(HRESULT hRes);
skipping to change at line 408 skipping to change at line 565
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
char *_win_bindtextdomain(const char *domainname, const char *dirname); char *_win_bindtextdomain(const char *domainname, const char *dirname);
#endif #endif
int _win_chdir(const char *path); int _win_chdir(const char *path);
int _win_close(int fd); int _win_close(int fd);
int _win_creat(const char *path, mode_t mode); int _win_creat(const char *path, mode_t mode);
char *_win_ctime(const time_t *clock); char *_win_ctime(const time_t *clock);
char *_win_ctime_r(const time_t *clock, char *buf); char *_win_ctime_r(const time_t *clock, char *buf);
int _win_fstat(int handle, struct stat *buffer); int _win_fstat(int handle, struct stat *buffer);
int _win_ftruncate(int fildes, off_t length); int _win_ftruncate(int fildes, off_t length);
void _win_gettimeofday(struct timeval *tp, void *tzp); int _win_truncate(const char *fname, int distance);
int _win_kill(pid_t pid, int sig); int _win_kill(pid_t pid, int sig);
int _win_pipe(int *phandles); int _win_pipe(int *phandles);
intptr_t _win_mkfifo(const char *path, mode_t mode);
int _win_rmdir(const char *path); int _win_rmdir(const char *path);
int _win_access( const char *path, int mode ); int _win_access( const char *path, int mode );
int _win_chmod(const char *filename, int pmode); int _win_chmod(const char *filename, int pmode);
char *realpath(const char *file_name, char *resolved_name); char *realpath(const char *file_name, char *resolved_name);
long _win_random(void); long _win_random(void);
void _win_srandom(unsigned int seed); void _win_srandom(unsigned int seed);
int _win_remove(const char *path); int _win_remove(const char *path);
int _win_rename(const char *oldname, const char *newname); int _win_rename(const char *oldname, const char *newname);
int _win_stat(const char *path, struct stat *buffer); int _win_stat(const char *path, struct stat *buffer);
int _win_stat64(const char *path, struct stat64 *buffer); int _win_stati64(const char *path, struct _stati64 *buffer);
long _win_sysconf(int name); long _win_sysconf(int name);
int _win_unlink(const char *filename); int _win_unlink(const char *filename);
int _win_write(int fildes, const void *buf, size_t nbyte); int _win_write(int fildes, const void *buf, size_t nbyte);
int _win_read(int fildes, void *buf, size_t nbyte); int _win_read(int fildes, void *buf, size_t nbyte);
size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE *str eam); size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE *str eam);
size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream ); size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
int _win_symlink(const char *path1, const char *path2); int _win_symlink(const char *path1, const char *path2);
void *_win_mmap(void *start, size_t len, int access, int flags, int fd, void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
unsigned long long offset); unsigned long long offset);
int _win_msync(void *start, size_t length, int flags); int _win_msync(void *start, size_t length, int flags);
int _win_munmap(void *start, size_t length); int _win_munmap(void *start, size_t length);
int _win_lstat(const char *path, struct stat *buf); int _win_lstat(const char *path, struct stat *buf);
int _win_lstat64(const char *path, struct stat64 *buf); int _win_lstati64(const char *path, struct _stati64 *buf);
int _win_readlink(const char *path, char *buf, size_t bufsize); int _win_readlink(const char *path, char *buf, size_t bufsize);
int _win_accept(int s, struct sockaddr *addr, int *addrlen); int _win_accept(int s, struct sockaddr *addr, int *addrlen);
int _win_printf(const char *format,...);
int _win_wprintf(const wchar_t *format, ...);
int _win_fprintf(FILE *f,const char *format,...);
int _win_fwprintf(FILE *f,const wchar_t *format, ...);
int _win_vprintf(const char *format, va_list ap);
int _win_vfwprintf(FILE *stream, const wchar_t *format, va_list arg_ptr);
int _win_vfprintf(FILE *stream, const char *format, va_list arg_ptr);
int _win_vwprintf(const wchar_t *format, va_list ap);
int _win_vsprintf(char *dest,const char *format, va_list arg_ptr);
int _win_vswprintf(wchar_t *dest, const wchar_t *format, va_list arg_ptr);
int _win_vsnprintf(char* str, size_t size, const char *format, va_list arg_
ptr);
int _win_vsnwprintf(wchar_t* wstr, size_t size, const wchar_t *format, va_l
ist arg_ptr);
int _win_snprintf(char *str,size_t size,const char *format,...);
int _win_snwprintf(wchar_t *str, size_t size, const wchar_t *format, ...);
int _win_sprintf(char *dest,const char *format,...);
int _win_swprintf(wchar_t *dest, const wchar_t *format, ...);
int _win_vsscanf(const char* str, const char* format, va_list arg_ptr);
int _win_vswscanf(const wchar_t* wstr, const wchar_t* format, va_list arg_p
tr);
int _win_sscanf(const char *str, const char *format, ...);
int _win_swscanf(const wchar_t *wstr, const wchar_t *format, ...);
int _win_vfscanf(FILE *stream, const char *format, va_list arg_ptr);
int _win_vfwscanf(FILE *stream, const wchar_t *format, va_list arg_ptr);
int _win_vscanf(const char *format, va_list arg_ptr);
int _win_vwscanf(const wchar_t *format, va_list arg_ptr);
int _win_scanf(const char *format, ...);
int _win_wscanf(const wchar_t *format, ...);
int _win_fscanf(FILE *stream, const char *format, ...);
int _win_fwscanf(FILE *stream, const wchar_t *format, ...);
pid_t _win_waitpid(pid_t pid, int *stat_loc, int options); pid_t _win_waitpid(pid_t pid, int *stat_loc, int options);
int _win_bind(int s, const struct sockaddr *name, int namelen); int _win_bind(int s, const struct sockaddr *name, int namelen);
int _win_connect(int s,const struct sockaddr *name, int namelen); int _win_connect(int s,const struct sockaddr *name, int namelen);
int _win_getpeername(int s, struct sockaddr *name, int _win_getpeername(int s, struct sockaddr *name,
int *namelen); int *namelen);
int _win_getsockname(int s, struct sockaddr *name, int _win_getsockname(int s, struct sockaddr *name,
int *namelen); int *namelen);
int _win_getsockopt(int s, int level, int optname, char *optval, int _win_getsockopt(int s, int level, int optname, char *optval,
int *optlen); int *optlen);
int _win_listen(int s, int backlog); int _win_listen(int s, int backlog);
skipping to change at line 501 skipping to change at line 617
struct sockaddr *from, int *fromlen); struct sockaddr *from, int *fromlen);
int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds, int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
const struct timeval *tv); const struct timeval *tv);
int _win_send(int s, const char *buf, int len, int flags); int _win_send(int s, const char *buf, int len, int flags);
int _win_sendto(int s, const char *buf, int len, int flags, int _win_sendto(int s, const char *buf, int len, int flags,
const struct sockaddr *to, int tolen); const struct sockaddr *to, int tolen);
int _win_setsockopt(int s, int level, int optname, const void *optval, int _win_setsockopt(int s, int level, int optname, const void *optval,
int optlen); int optlen);
int _win_shutdown(int s, int how); int _win_shutdown(int s, int how);
int _win_socket(int af, int type, int protocol); int _win_socket(int af, int type, int protocol);
int _win_socketpair(int af, int type, int protocol, int socket_vector[2]);
struct hostent *_win_gethostbyaddr(const char *addr, int len, int type); struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
struct hostent *_win_gethostbyname(const char *name); struct hostent *_win_gethostbyname(const char *name);
struct hostent *gethostbyname2(const char *name, int af); struct hostent *gethostbyname2(const char *name, int af);
char *_win_strerror(int errnum); char *_win_strerror(int errnum);
int IsWinNT(); int IsWinNT();
char *index(const char *s, int c); char *index(const char *s, int c);
char *_win_strtok_r (char *ptr, const char *sep, char **end);
#if !HAVE_STRNDUP #if !HAVE_STRNDUP
char *strndup (const char *s, size_t n); char *strndup (const char *s, size_t n);
#endif #endif
#if !HAVE_STRNLEN #if !HAVE_STRNLEN && (!defined(__MINGW64_VERSION_MAJOR) || !defined(_INC_ST RING))
size_t strnlen (const char *str, size_t maxlen); size_t strnlen (const char *str, size_t maxlen);
#endif #endif
char *stpcpy(char *dest, const char *src); char *stpcpy(char *dest, const char *src);
char *strcasestr(const char *haystack_start, const char *needle_start); char *strcasestr(const char *haystack_start, const char *needle_start);
#ifndef __MINGW64__ #ifndef __MINGW64_VERSION_MAJOR
#define strcasecmp(a, b) stricmp(a, b) #define strcasecmp(a, b) stricmp(a, b)
#define wcscasecmp(a, b) wcsicmp(a, b)
#define strncasecmp(a, b, c) strnicmp(a, b, c) #define strncasecmp(a, b, c) strnicmp(a, b, c)
#endif
#ifndef wcscasecmp
#define wcscasecmp(a, b) wcsicmp(a, b)
#endif
#ifndef wcsncasecmp
#define wcsncasecmp(a, b, c) wcsnicmp(a, b, c) #define wcsncasecmp(a, b, c) wcsnicmp(a, b, c)
#endif #endif
#ifndef strtok_r /* winpthreads defines it in pthread.h */
#define strtok_r _win_strtok_r
#endif
#endif /* WINDOWS */ #endif /* WINDOWS */
#ifndef WINDOWS #ifndef WINDOWS
#define DIR_SEPARATOR '/' #define DIR_SEPARATOR '/'
#define DIR_SEPARATOR_STR "/" #define DIR_SEPARATOR_STR "/"
#define PATH_SEPARATOR ':' #define PATH_SEPARATOR ':'
#define PATH_SEPARATOR_STR ":" #define PATH_SEPARATOR_STR ":"
#define NEWLINE "\n" #define NEWLINE "\n"
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
#define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n) #define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
#endif #endif
#define CREAT(p, m) creat(p, m) #define CREAT(p, m) creat(p, m)
#define PLIBC_CTIME(c) ctime(c) #define PLIBC_CTIME(c) ctime(c)
#define CTIME_R(c, b) ctime_r(c, b) #define CTIME_R(c, b) ctime_r(c, b)
#undef FOPEN #undef FOPEN
#define FOPEN(f, m) fopen(f, m) #define FOPEN(f, m) fopen(f, m)
#define FCLOSE(f) fclose(f) #define FCLOSE(f) fclose(f)
#define FTRUNCATE(f, l) ftruncate(f, l) #define FTRUNCATE(f, l) ftruncate(f, l)
#define TRUNCATE(f, l) truncate(f, l)
#define OPENDIR(d) opendir(d) #define OPENDIR(d) opendir(d)
#define CLOSEDIR(d) closedir(d) #define CLOSEDIR(d) closedir(d)
#define READDIR(d) readdir(d) #define READDIR(d) readdir(d)
#define OPEN open #define OPEN open
#define CHDIR(d) chdir(d) #define CHDIR(d) chdir(d)
#define CLOSE(f) close(f) #define CLOSE(f) close(f)
#define LSEEK(f, o, w) lseek(f, o, w) #define LSEEK(f, o, w) lseek(f, o, w)
#define RMDIR(f) rmdir(f) #define RMDIR(f) rmdir(f)
#define ACCESS(p, m) access(p, m) #define ACCESS(p, m) access(p, m)
#define CHMOD(f, p) chmod(f, p) #define CHMOD(f, p) chmod(f, p)
skipping to change at line 605 skipping to change at line 731
#define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p) #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
#define LISTEN(s, b) listen(s, b) #define LISTEN(s, b) listen(s, b)
#define RECV(s, b, l, f) recv(s, b, l, f) #define RECV(s, b, l, f) recv(s, b, l, f)
#define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o) #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
#define SELECT(n, r, w, e, t) select(n, r, w, e, t) #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
#define SEND(s, b, l, f) send(s, b, l, f) #define SEND(s, b, l, f) send(s, b, l, f)
#define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n) #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
#define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n) #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
#define SHUTDOWN(s, h) shutdown(s, h) #define SHUTDOWN(s, h) shutdown(s, h)
#define SOCKET(a, t, p) socket(a, t, p) #define SOCKET(a, t, p) socket(a, t, p)
#define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t) #define SOCKETPAIR(a, t, p, v) socketpair(a, t, p, v)
#define GETHOSTBYADDR(a, l, t) gethostbyaddr(a, l, t)
#define GETHOSTBYNAME(n) gethostbyname(n) #define GETHOSTBYNAME(n) gethostbyname(n)
#define GETTIMEOFDAY(t, n) gettimeofday(t, n) #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
#define INSQUE(e, p) insque(e, p) #define INSQUE(e, p) insque(e, p)
#define REMQUE(e) remque(e) #define REMQUE(e) remque(e)
#define HSEARCH(i, a) hsearch(i, a) #define HSEARCH(i, a) hsearch(i, a)
#define HCREATE(n) hcreate(n) #define HCREATE(n) hcreate(n)
#define HDESTROY() hdestroy() #define HDESTROY() hdestroy()
#define HSEARCH_R(i, a, r, h) hsearch_r(i, a, r, h) #define HSEARCH_R(i, a, r, h) hsearch_r(i, a, r, h)
#define HCREATE_R(n, h) hcreate_r(n, h) #define HCREATE_R(n, h) hcreate_r(n, h)
#define HDESTROY_R(h) hdestroy_r(h) #define HDESTROY_R(h) hdestroy_r(h)
#define TSEARCH(k, r, c) tsearch(k, r, c) #define TSEARCH(k, r, c) tsearch(k, r, c)
#define TFIND(k, r, c) tfind(k, r, c) #define TFIND(k, r, c) tfind(k, r, c)
#define TDELETE(k, r, c) tdelete(k, r, c) #define TDELETE(k, r, c) tdelete(k, r, c)
#define TWALK(r, a) twalk(r, a) #define TWALK(r, a) twalk(r, a)
#define TDESTROY(r, f) tdestroy(r, f) #define TDESTROY(r, f) tdestroy(r, f)
#define LFIND(k, b, n, s, c) lfind(k, b, n, s, c) #define LFIND(k, b, n, s, c) lfind(k, b, n, s, c)
#define LSEARCH(k, b, n, s, c) lsearch(k, b, n, s, c) #define LSEARCH(k, b, n, s, c) lsearch(k, b, n, s, c)
#define STRUCT_STAT64 struct stat64
#else #else
#define DIR_SEPARATOR '\\' #define DIR_SEPARATOR '\\'
#define DIR_SEPARATOR_STR "\\" #define DIR_SEPARATOR_STR "\\"
#define PATH_SEPARATOR ';' #define PATH_SEPARATOR ';'
#define PATH_SEPARATOR_STR ";" #define PATH_SEPARATOR_STR ";"
#define NEWLINE "\r\n" #define NEWLINE "\r\n"
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
#define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n) #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
#endif #endif
#define CREAT(p, m) _win_creat(p, m) #define CREAT(p, m) _win_creat(p, m)
#define PLIBC_CTIME(c) _win_ctime(c) #define PLIBC_CTIME(c) _win_ctime(c)
#define CTIME_R(c, b) _win_ctime_r(c, b) #define CTIME_R(c, b) _win_ctime_r(c, b)
#define FOPEN(f, m) _win_fopen(f, m) #define FOPEN(f, m) _win_fopen(f, m)
#define FCLOSE(f) _win_fclose(f) #define FCLOSE(f) _win_fclose(f)
#define FTRUNCATE(f, l) _win_ftruncate(f, l) #define FTRUNCATE(f, l) _win_ftruncate(f, l)
#define TRUNCATE(f, l) _win_truncate(f, l)
#define OPENDIR(d) _win_opendir(d) #define OPENDIR(d) _win_opendir(d)
#define CLOSEDIR(d) _win_closedir(d) #define CLOSEDIR(d) _win_closedir(d)
#define READDIR(d) _win_readdir(d) #define READDIR(d) _win_readdir(d)
#define OPEN _win_open #define OPEN _win_open
#define CHDIR(d) _win_chdir(d) #define CHDIR(d) _win_chdir(d)
#define CLOSE(f) _win_close(f) #define CLOSE(f) _win_close(f)
#define PLIBC_KILL(p, s) _win_kill(p, s) #define PLIBC_KILL(p, s) _win_kill(p, s)
#define LSEEK(f, o, w) _win_lseek(f, o, w) #define LSEEK(f, o, w) lseek(f, o, w)
#define FSTAT(h, b) _win_fstat(h, b) #define FSTAT(h, b) _win_fstat(h, b)
#define RMDIR(f) _win_rmdir(f) #define RMDIR(f) _win_rmdir(f)
#define ACCESS(p, m) _win_access(p, m) #define ACCESS(p, m) _win_access(p, m)
#define CHMOD(f, p) _win_chmod(f, p) #define CHMOD(f, p) _win_chmod(f, p)
#define PIPE(h) _win_pipe(h) #define PIPE(h) _win_pipe(h)
#define RANDOM() _win_random() #define RANDOM() _win_random()
#define SRANDOM(s) _win_srandom(s) #define SRANDOM(s) _win_srandom(s)
#define REMOVE(p) _win_remove(p) #define REMOVE(p) _win_remove(p)
#define RENAME(o, n) _win_rename(o, n) #define RENAME(o, n) _win_rename(o, n)
#define STAT(p, b) _win_stat(p, b) #define STAT(p, b) _win_stat(p, b)
#define STAT64(p, b) _win_stat64(p, b) #define STAT64(p, b) _win_stati64(p, b)
#define SYSCONF(n) _win_sysconf(n) #define SYSCONF(n) _win_sysconf(n)
#define UNLINK(f) _win_unlink(f) #define UNLINK(f) _win_unlink(f)
#define WRITE(f, b, n) _win_write(f, b, n) #define WRITE(f, b, n) _win_write(f, b, n)
#define READ(f, b, n) _win_read(f, b, n) #define READ(f, b, n) _win_read(f, b, n)
#define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f) #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
#define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f) #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
#define SYMLINK(a, b) _win_symlink(a, b) #define SYMLINK(a, b) _win_symlink(a, b)
#define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o) #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
#define MKFIFO(p, m) _win_mkfifo(p, m) #define MKFIFO(p, m) _win_mkfifo(p, m)
#define MSYNC(s, l, f) _win_msync(s, l, f) #define MSYNC(s, l, f) _win_msync(s, l, f)
#define MUNMAP(s, l) _win_munmap(s, l) #define MUNMAP(s, l) _win_munmap(s, l)
#define STRERROR(i) _win_strerror(i) #define STRERROR(i) _win_strerror(i)
#define READLINK(p, b, s) _win_readlink(p, b, s) #define READLINK(p, b, s) _win_readlink(p, b, s)
#define LSTAT(p, b) _win_lstat(p, b) #define LSTAT(p, b) _win_lstat(p, b)
#define LSTAT64(p, b) _win_lstat64(p, b) #define LSTAT64(p, b) _win_lstati64(p, b)
#define PRINTF(f, ...) _win_printf(f , __VA_ARGS__) #define PRINTF printf
#define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__) #define FPRINTF fprintf
#define VPRINTF(f, a) _win_vprintf(f, a) #define VPRINTF(f, a) vprintf(f, a)
#define VFPRINTF(s, f, a) _win_vfprintf(s, f, a) #define VFPRINTF(s, f, a) vfprintf(s, f, a)
#define VSPRINTF(d, f, a) _win_vsprintf(d, f, a) #define VSPRINTF(d, f, a) vsprintf(d, f, a)
#define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a) #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
#define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt, #define _REAL_SNPRINTF snprintf
__VA_ARGS__) #define SPRINTF sprintf
#define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__) #define VSSCANF(s, f, a) vsscanf(s, f, a)
#define VSSCANF(s, f, a) _win_vsscanf(s, f, a) #define SSCANF sscanf
#define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__) #define VFSCANF(s, f, a) vfscanf(s, f, a)
#define VFSCANF(s, f, a) _win_vfscanf(s, f, a) #define VSCANF(f, a) vscanf(f, a)
#define VSCANF(f, a) _win_vscanf(f, a) #define SCANF scanf
#define SCANF(f, ...) _win_scanf(f, __VA_ARGS__) #define FSCANF fscanf
#define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__)
#define WAITPID(p, s, o) _win_waitpid(p, s, o) #define WAITPID(p, s, o) _win_waitpid(p, s, o)
#define ACCEPT(s, a, l) _win_accept(s, a, l) #define ACCEPT(s, a, l) _win_accept(s, a, l)
#define BIND(s, n, l) _win_bind(s, n, l) #define BIND(s, n, l) _win_bind(s, n, l)
#define CONNECT(s, n, l) _win_connect(s, n, l) #define CONNECT(s, n, l) _win_connect(s, n, l)
#define GETPEERNAME(s, n, l) _win_getpeername(s, n, l) #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
#define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l) #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
#define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p) #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
#define LISTEN(s, b) _win_listen(s, b) #define LISTEN(s, b) _win_listen(s, b)
#define RECV(s, b, l, f) _win_recv(s, b, l, f) #define RECV(s, b, l, f) _win_recv(s, b, l, f)
#define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o) #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
#define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t) #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
#define SEND(s, b, l, f) _win_send(s, b, l, f) #define SEND(s, b, l, f) _win_send(s, b, l, f)
#define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n) #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
#define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n) #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
#define SHUTDOWN(s, h) _win_shutdown(s, h) #define SHUTDOWN(s, h) _win_shutdown(s, h)
#define SOCKET(a, t, p) _win_socket(a, t, p) #define SOCKET(a, t, p) _win_socket(a, t, p)
#define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t) #define SOCKETPAIR(a, t, p, v) _win_socketpair(a, t, p, v)
#define GETHOSTBYADDR(a, l, t) _win_gethostbyaddr(a, l, t)
#define GETHOSTBYNAME(n) _win_gethostbyname(n) #define GETHOSTBYNAME(n) _win_gethostbyname(n)
#define GETTIMEOFDAY(t, n) _win_gettimeofday(t, n) #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
#define INSQUE(e, p) _win_insque(e, p) #define INSQUE(e, p) _win_insque(e, p)
#define REMQUE(e) _win_remque(e) #define REMQUE(e) _win_remque(e)
#define HSEARCH(i, a) _win_hsearch(i, a) #define HSEARCH(i, a) _win_hsearch(i, a)
#define HCREATE(n) _win_hcreate(n) #define HCREATE(n) _win_hcreate(n)
#define HDESTROY() _win_hdestroy() #define HDESTROY() _win_hdestroy()
#define HSEARCH_R(i, a, r, h) _win_hsearch_r(i, a, r, h) #define HSEARCH_R(i, a, r, h) _win_hsearch_r(i, a, r, h)
#define HCREATE_R(n, h) _win_hcreate_r(n, h) #define HCREATE_R(n, h) _win_hcreate_r(n, h)
#define HDESTROY_R(h) _win_hdestroy_r(h) #define HDESTROY_R(h) _win_hdestroy_r(h)
#define TSEARCH(k, r, c) _win_tsearch(k, r, c) #define TSEARCH(k, r, c) _win_tsearch(k, r, c)
#define TFIND(k, r, c) _win_tfind(k, r, c) #define TFIND(k, r, c) _win_tfind(k, r, c)
#define TDELETE(k, r, c) _win_tdelete(k, r, c) #define TDELETE(k, r, c) _win_tdelete(k, r, c)
#define TWALK(r, a) _win_twalk(r, a) #define TWALK(r, a) _win_twalk(r, a)
#define TDESTROY(r, f) _win_tdestroy(r, f) #define TDESTROY(r, f) _win_tdestroy(r, f)
#define LFIND(k, b, n, s, c) _win_lfind(k, b, n, s, c) #define LFIND(k, b, n, s, c) _win_lfind(k, b, n, s, c)
#define LSEARCH(k, b, n, s, c) _win_lsearch(k, b, n, s, c) #define LSEARCH(k, b, n, s, c) _win_lsearch(k, b, n, s, c)
#define STRUCT_STAT64 struct _stati64
#endif #endif
/* search.h */ /* search.h */
/* Prototype structure for a linked-list data structure. /* Prototype structure for a linked-list data structure.
This is the type used by the `insque' and `remque' functions. */ This is the type used by the `insque' and `remque' functions. */
struct PLIBC_SEARCH_QELEM struct PLIBC_SEARCH_QELEM
{ {
struct qelem *q_forw; struct qelem *q_forw;
 End of changes. 32 change blocks. 
178 lines changed or deleted 307 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/