* down. Unloads our datastore plugin.
*
* @param api api to unload
+ * @param cfg configuration to use
*/
static void
unload_plugin (struct GNUNET_DATASTORE_PluginFunctions * api,
/**
* Create a temporary file on disk to store the current
* state of "fi" in.
+ *
+ * @param fi file information to sync with disk
*/
void
GNUNET_FS_file_information_sync (struct GNUNET_FS_FileInformation * fi)
* are free in the transmission buffer. May call the notify
* method immediately if enough space is available.
*
- * @param client connection to the service
+ * @param sock connection to the service
* @param size number of bytes to send
* @param timeout after how long should we give up (and call
* notify with buf NULL and size 0)?
/**
* Setup logging.
*
- * @param component default component to use
+ * @param comp default component to use
* @param loglevel what types of messages should be logged
* @param logfile change logging to logfile (use NULL to keep stderr)
* @return GNUNET_OK on success, GNUNET_SYSERR if logfile could not be opened
*/
int
-GNUNET_log_setup (const char *component,
+GNUNET_log_setup (const char *comp,
const char *loglevel, const char *logfile);
/**
/**
* Duplicate an existing configuration object.
*
- * @param c configuration to duplicate
+ * @param cfg configuration to duplicate
* @return duplicate configuration
*/
struct GNUNET_CONFIGURATION_Handle *
-GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *c);
+GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg);
/**
/**
* Duplicate a MetaData token.
*
- * @param meta what to duplicate
+ * @param md what to duplicate
* @return duplicate meta-data container
*/
struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const
struct
GNUNET_CONTAINER_MetaData
- *meta);
+ *md);
/**
* Free meta data.
/**
* Remove an item.
*
+ * @param md metadata to manipulate
* @param type type of the item to remove
* @param data specific value to remove, NULL to remove all
* entries of the given type
*
* @param md metadata to serialize
* @param target where to write the serialized metadata
- * @param size maximum number of bytes available
+ * @param max maximum number of bytes available
* @param opt is it ok to just write SOME of the
* meta-data to match the size constraint,
* possibly discarding some data?
ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct
GNUNET_CONTAINER_MetaData *md,
char *target,
- size_t size,
+ size_t max,
enum
GNUNET_CONTAINER_MetaDataSerializationOptions
opt);
* Check if a list contains a certain element
* @param l list
* @param buf payload buffer to find
- * @param lenght of the payload
+ * @param len length of the payload (number of bytes in buf)
*/
int GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l, const void *buf, size_t len);
/**
- * Random on unsigned 64-bit values. We break them down into signed
- * 32-bit values and reassemble the 64-bit random value bit-wise.
+ * Random on unsigned 64-bit values.
*
* @param mode desired quality of the random number
* @param max value returned will be in range [0,max) (exclusive)
* @param sessionkey the key used to encrypt
* @param iv the initialization vector to use, use INITVALUE
* for streams.
- * @returns the size of the encrypted block, -1 for errors
+ * @return the size of the encrypted block, -1 for errors
*/
ssize_t GNUNET_CRYPTO_aes_encrypt (const void *block,
size_t len,
/**
- * Convert GNUNET_CRYPTO_hash to ASCII encoding.
- * @param block the GNUNET_CRYPTO_hash code
+ * Convert hash to ASCII encoding.
+ * @param block the hash code
* @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be
- * safely cast to char*, a '\0' termination is set).
+ * safely cast to char*, a '\\0' termination is set).
*/
void GNUNET_CRYPTO_hash_to_enc (const GNUNET_HashCode * block,
struct GNUNET_CRYPTO_HashAsciiEncoded
* Deterministically (!) create a private key using only the
* given HashCode as input to the PRNG.
*
- * @param input "random" input to PRNG
+ * @param hc "random" input to PRNG
* @return some private key purely dependent on input
*/
struct GNUNET_CRYPTO_RsaPrivateKey
- *GNUNET_CRYPTO_rsa_key_create_from_hash (const GNUNET_HashCode * input);
+ *GNUNET_CRYPTO_rsa_key_create_from_hash (const GNUNET_HashCode * hc);
/**
* @param size the size of block
* @param publicKey the encoded public key used to encrypt
* @param target where to store the encrypted block
- * @returns GNUNET_SYSERR on error, GNUNET_OK if ok
+ * @return GNUNET_SYSERR on error, GNUNET_OK if ok
*/
int GNUNET_CRYPTO_rsa_encrypt (const void *block,
size_t size,
* @param key the key to use
* @param block the data to decrypt, encoded as returned by encrypt, not consumed
* @param result pointer to a location where the result can be stored
- * @param size how many bytes of a result are expected? Must be exact.
- * @returns the size of the decrypted block (that is, size) or -1 on error
+ * @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
*block,
void *result,
- size_t size);
+ size_t max);
/**
*
* @param key private key to use for the signing
* @param purpose what to sign (size, purpose)
- * @param result where to write the signature
+ * @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
*purpose,
- struct GNUNET_CRYPTO_RsaSignature *result);
+ struct GNUNET_CRYPTO_RsaSignature *sig);
/**
* @param validate block to validate (size, purpose, data)
* @param sig signature that is being validated
* @param publicKey public key of the signer
- * @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
+ * @return GNUNET_OK if ok, GNUNET_SYSERR if invalid
*/
int GNUNET_CRYPTO_rsa_verify (uint32_t purpose,
const struct GNUNET_CRYPTO_RsaSignaturePurpose
/**
* Perform an asynchronous GET operation on the DHT identified.
*
+ * @param h handle to the DHT service
* @param type expected type of the response object
* @param key the key to look up
* @param iter function to call on each result
/**
* Construct a location URI (this peer will be used for the location).
*
- * @param baseURI content offered by the sender
+ * @param baseUri content offered by the sender
* @param cfg configuration information (used to find our hostkey)
* @param expiration_time how long will the content be offered?
* @return the location URI, NULL on error
* file information data should already call "sync" internally,
* so this function is likely not useful for clients.
*
- * @param s the struct to sync
+ * @param fi the struct to sync
*/
void
-GNUNET_FS_file_information_sync (struct GNUNET_FS_FileInformation *s);
+GNUNET_FS_file_information_sync (struct GNUNET_FS_FileInformation *f);
/**
* "GNUNET_FS_publish_start" already.
*
* @param dir the directory
- * @param end 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
* must not include "dir" in its structure
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
- struct GNUNET_FS_FileInformation *end);
+ struct GNUNET_FS_FileInformation *ent);
/**
* Publish a KBlock on GNUnet.
*
* @param h handle to the file sharing subsystem
- * @param keywords keywords to use
+ * @param ksk_uri keywords to use
* @param meta metadata to use
* @param uri URI to refer to in the KBlock
* @param expirationTime when the KBlock expires
*/
void
GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
- struct GNUNET_FS_Uri *keywords,
+ struct GNUNET_FS_Uri *ksk_uri,
struct GNUNET_CONTAINER_MetaData *meta,
struct GNUNET_FS_Uri *uri,
struct GNUNET_TIME_Absolute expirationTime,
/**
* Stop a download (aborts if download is incomplete).
*
- * @param rm handle for the download
+ * @param dc handle for the download
* @param do_delete delete files of incomplete downloads
*/
void
-GNUNET_FS_file_download_stop (struct GNUNET_FS_DownloadContext *rm,
+GNUNET_FS_file_download_stop (struct GNUNET_FS_DownloadContext *dc,
int do_delete);
* in-memory.
*
* @param bld directory to finish
- * @param size set to the number of bytes needed
- * @param data set to the encoded directory
+ * @param rsize set to the number of bytes needed
+ * @param rdata set to the encoded directory
* @return GNUNET_OK on success
*/
int
GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
- size_t *size,
- void **data);
+ size_t *rsize,
+ void **rdata);
#if 0 /* keep Emacsens' auto-indent happy */
/**
* Parse the command line.
*
- * @param binaryName name of the binary / application with options
+ * @param binaryOptions Name of application with option summary
* @param allOptions defined options and handlers
* @param argc number of arguments
* @param argv actual arguments
* @return index into argv with first non-option
* argument, or GNUNET_SYSERR on error
*/
-int GNUNET_GETOPT_run (const char *binaryName,
+int GNUNET_GETOPT_run (const char *binaryOptions,
const struct GNUNET_GETOPT_CommandLineOption
*allOptions, unsigned int argc, char *const *argv);
*
* @param desc socket to connect
* @param address peer address
- * @param length of address
+ * @param address_len of address
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise
*/
int GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
- const struct sockaddr *address, socklen_t address_len);
+ const struct sockaddr *address,
+ socklen_t address_len);
/**
* Copy a native fd set
* @param to destination
* @param from native source set
- * @param the biggest socket number in from + 1
+ * @param nfds the biggest socket number in from + 1
*/
void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to,
const fd_set *from,
/**
* Change the ranking of a pseudonym.
*
- * @param pseudonym id of the pseudonym
+ * @param cfg overall configuration
+ * @param nsid id of the pseudonym
* @param delta by how much should the rating be changed?
* @return new rating of the namespace
*/
int GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const GNUNET_HashCode * pseudonym, int delta);
+ const GNUNET_HashCode *nsid, int delta);
/**
* Add a pseudonym to the set of known pseudonyms.
+ * For all pseudonym advertisements that we discover
+ * FS should automatically call this function.
*
- * @param pseudonym the pseudonym's identifier
+ * @param cfg overall configuration
+ * @param id the pseudonym identifier
+ * @param meta metadata for the pseudonym
*/
void GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const GNUNET_HashCode * pseudo,
+ const GNUNET_HashCode *id,
const struct GNUNET_CONTAINER_MetaData *meta);
* are satisfied). Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
* on completion of other tasks.
* @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
- * @param nfds highest-numbered file descriptor in any of the two sets plus one
* @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 main main function of the task
GNUNET_SCHEDULER_TaskIdentifier
prerequisite_task,
struct GNUNET_TIME_Relative delay,
- const struct GNUNET_NETWORK_FDSet * rs, const struct GNUNET_NETWORK_FDSet * ws,
+ const struct GNUNET_NETWORK_FDSet * rs,
+ const struct GNUNET_NETWORK_FDSet * ws,
GNUNET_SCHEDULER_Task main, void *cls);
#if 0 /* keep Emacsens' auto-indent happy */
* @param server the server to use
* @param chandle opaque handle for the connection
* @param creceive receive function for the connection
- * @param creceive_cancel cancel receive function for the connection
+ * @param ccancel cancel receive function for the connection
* @param cnotify transmit notification function for the connection
* @param cnotify_cancel transmit notification cancellation function for the connection
* @param ccheck function to test if the connection is still up
/**
* Stop a service that was started with "GNUNET_SERVICE_start".
*
- * @param ctx the service context returned from the start function
+ * @param sctx the service context returned from the start function
*/
-void GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *ctx);
+void GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx);
#if 0 /* keep Emacsens' auto-indent happy */
* @param cls closure for the callbacks
* @param rec receive function to call
* @param nc function to call on connect events
- * @param dc function to call on disconnect events
+ * @param nd function to call on disconnect events
*/
struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (struct
GNUNET_SCHEDULER_Handle
* Address iterator that causes expired entries to be discarded.
*
* @param cls pointer to the current time
+ * @param tname name of the transport
+ * @param expiration expiration time for the address
+ * @param addr the address
+ * @param addrlen length of addr in bytes
* @return GNUNET_NO if expiration smaller than the current time
*/
static int
* Add a host to the list.
*
* @param identity the identity of the host
- * @param protocol the protocol for the host
*/
static void
add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
* argument or for all known hosts and change their trust values by
* the given delta.
*
- * @param only NULL to hit all hosts
+ * @param only NULL to hit all hosts, otherwise specifies a particular target
+ * @param trust_change how much should the trust be changed
+ * @param client who is making the request (and will thus receive our confirmation)
*/
static void
send_to_each_host (const struct GNUNET_PeerIdentity *only,
* @param sched scheduler to use
* @param peer identity of the peer
* @param hello the verified (!) HELLO message
- * @param expiration when the HELLO will expire
*/
void
GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg,
static int
printer (void *cls,
const char *subsystem,
- const char *sname, unsigned long long value, int is_persistent)
+ const char *name, unsigned long long value, int is_persistent)
{
FPRINTF (stdout,
"%s%-20s %-40s: %16llu\n",
- is_persistent ? "!" : " ", subsystem, _(sname), value);
+ is_persistent ? "!" : " ", subsystem, _(name), value);
return GNUNET_OK;
}
/**
* Get handle for the statistics service.
*
+ * @param sched scheduler to use
* @param subsystem name of subsystem using the service
* @param cfg services configuration in use
* @return handle to use
/**
* Try to connect to the specified peer.
*
- * @param pos NULL if not in friend list yet
+ * @param peer who we should try to connect to
+ * @param pos entry in our friend list; NULL if not in friend list yet
*/
static void
attempt_connect (const struct GNUNET_PeerIdentity *peer,
/**
* Iterator called on each address.
*
- * @param cls flag that we will set if we see any addresses.
+ * @param cls flag that we will set if we see any addresses
+ * @param tname name of the transport
+ * @param expiration when will the given address expire
+ * @param addr the address of the peer
+ * @param addrlen number of bytes in addr
+ * @return GNUNET_SYSERR always, to terminate iteration
*/
static int
address_iterator (void *cls,
* received.
*
* @param cls closure
- * @param peer the other peer involved (sender or receiver, NULL
+ * @param other the other peer involved (sender or receiver, NULL
* for loopback messages where we are both sender and receiver)
* @param message the actual HELLO message
* @return GNUNET_OK to keep the connection open,
/**
* Peerinfo calls this function to let us know about a
* possible peer that we might want to connect to.
+ *
+ * @param cls unused
+ * @param peer NULL for the end of the list, otherwise a peer identity
+ * @param hello a HELLO for a peer, or NULL
+ * @param trust how much do we trust the given peer?
*/
static void
gather_hello_callback (void *cls,
/**
* Function to fill send buffer with HELLO.
*
+ * @param cls unused
* @param receiver the receiver of the message
* @param position is the reference to the
* first unused position in the buffer where GNUnet is building
* reducing the rate at which they read from the socket
* and generally forward to our receive callback.
*
+ * @param cls the "struct TransportPlugin *" we gave to the plugin
* @param plugin_context value to pass to this plugin
* to respond to the given peer (use is optional,
* but may speed up processing)
*
* @param hello the hello-Message for the target node
* @param tsessionPtr the session handle that is set
+ * @param may_reuse are we allowed to re-use an existing connection?
* @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
*/
static int
* @param tsession the GNUNET_MessageHello identifying the remote node
* @param msg the message
* @param size the size of the message
+ * @param important is this message so important that usual restrictions do not apply?
* @return GNUNET_SYSERR on error, GNUNET_OK on success, GNUNET_NO if queue is full
*/
static int
* Send a message to the specified remote node.
*
* @param tsession the GNUNET_MessageHello identifying the remote node
- * @param message what to send
+ * @param msg what to send
* @param size the size of the message
+ * @param important is this message important enough to override typical limits?
* @return GNUNET_SYSERR on error, GNUNET_OK on success
*/
static int
/**
* Establish a connection to a remote node.
- * @param helo the hello-Message for the target node
+ * @param hello the hello-Message for the target node
* @param tsessionPtr the session handle that is to be set
+ * @param may_reuse can we re-use an existing connection?
* @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
*/
static int
* @param target who should receive this message
* @param priority how important is the message
* @param msg the message to transmit
+ * @param timeout when should we time out (give up) if we can not transmit?
* @param cont continuation to call once the message has
* been transmitted (or if the transport is ready
* for the next transmission call; or if the
* peer disconnected...)
* @param cont_cls closure for cont
* @return plugin_context that should be used next time for
- * sending messages to the specified peer
+ * sending messages to the specified peer
*/
static void *
tcp_plugin_send (void *cls,
* format.
*
* @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
* the specific address format depends on the transport
* @param addrlen length of the address
* calls to stay below the quota (in terms of incoming data).
*
* @param cls closure
- * @param peer the peer for whom the quota is given
+ * @param target the peer for whom the quota is given
* @param quota_in quota for receiving/sending data in bytes per ms
*/
static void
/**
* Handle PONG-message.
*
- * @param plugin handle for this plugin
- * @param sender claimed sender of the PONG
+ * @param cls handle for this plugin
+ * @param client from where did we receive the PONG
* @param message the actual message
*/
static void
* @param target who should receive this message
* @param priority how important is the message
* @param msg the message to transmit
+ * @param timeout when should we time out
* @param cont continuation to call once the message has
* been transmitted (or if the transport is ready
* for the next transmission call; or if the
* format.
*
* @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
* the specific address format depends on the transport
* @param addrlen length of the address
* calls to stay below the quota (in terms of incoming data).
*
* @param cls closure
- * @param peer the peer for whom the quota is given
+ * @param target the peer for whom the quota is given
* @param quota_in quota for receiving/sending data in bytes per ms
*/
static void
*
* @param hello the hello-Message for the target node
* @param tsessionPtr the session handle that is to be set
+ * @param may_reuse are we allowed to re-use an existing connection (ignored for UDP)
* @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
*/
static int
* @param tsession the GNUNET_MessageHello identifying the remote node
* @param message what to send
* @param size the size of the message
+ * @param important is this message "important" to override typical transmit limits?
* @return GNUNET_SYSERR on error, GNUNET_OK on success
*/
static int
* Queue control request for transmission to the transport
* service.
*
+ * @param h handle to the transport service
* @param size number of bytes to be transmitted
* @param at_head request must be added to the head of the queue
* (otherwise request will be appended)
* @param cls closure for the callbacks
* @param rec receive function to call
* @param nc function to call on connect events
- * @param dc function to call on disconnect events
+ * @param nd function to call on disconnect events
*/
struct GNUNET_TRANSPORT_Handle *
GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched,
* this gaim client. Essentially, this function takes care of the port
* forwarding so things like file transfers can work behind NAT firewalls
*
+ * @param cfg configuration to use
+ * @param do_add TRUE/GNUNET_YES to add, FALSE/GNUNET_NO to remove
* @param portmap The port to map to this client
* @param protocol The protocol to map, either "TCP" or "UDP"
- * @param do_add TRUE/GNUNET_YES to add, FALSE/GNUNET_NO to remove
- * @param cb an optional callback function to be notified when the mapping
- * addition is complete
- * @param cb_data Extra data to be passed to the callback
*/
int gaim_upnp_change_port_mapping (struct GNUNET_CONFIGURATION_Handle *cfg,
int do_add,
* This is one of the very few calls in the entire API that is
* NOT reentrant!
*
- * @param pid the peer identity
+ * @param hc the hash code
* @return string form; will be overwritten by next call to GNUNET_h2s.
*/
const char *
-GNUNET_h2s (const GNUNET_HashCode *pid)
+GNUNET_h2s (const GNUNET_HashCode *hc)
{
static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
- GNUNET_CRYPTO_hash_to_enc (pid, &ret);
+ GNUNET_CRYPTO_hash_to_enc (hc, &ret);
ret.encoding[8] = '\0';
return (const char *) ret.encoding;
}
*
* @param bf the filter
* @param iterator an iterator over all elements stored in the BF
- * @param iterator_arg argument to the iterator function
+ * @param iterator_cls argument to the iterator function
* @param size the new size for the filter
* @param k the new number of GNUNET_CRYPTO_hash-function to apply per element
*/
void
GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
GNUNET_HashCodeIterator iterator,
- void *iterator_arg,
+ void *iterator_cls,
size_t size,
unsigned int k)
{
memset (bf->bitArray, 0, bf->bitArraySize);
if (bf->filename != NULL)
makeEmptyFile (bf->fh, bf->bitArraySize * 4);
- while (GNUNET_YES == iterator (iterator_arg, &hc))
+ while (GNUNET_YES == iterator (iterator_cls, &hc))
GNUNET_CONTAINER_bloomfilter_add (bf, &hc);
}
/**
* Remove an item.
+ *
+ * @param md metadata to manipulate
+ * @param type type of the item to remove
+ * @param data specific value to remove, NULL to remove all
+ * entries of the given type
* @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md
*/
int
/**
* Iterate over MD entries, excluding thumbnails.
*
+ * @param md metadata to inspect
+ * @param iter function to call on each entry
+ * @param iter_cls closure for iterator
* @return number of entries
*/
int
GNUNET_CONTAINER_meta_data_get_contents (const struct
GNUNET_CONTAINER_MetaData *md,
GNUNET_CONTAINER_MetaDataProcessor
- iterator, void *closure)
+ iter, void *iter_cls)
{
uint32_t i;
uint32_t sub;
if (!EXTRACTOR_isBinaryType (md->items[i].type))
{
if ((iterator != NULL) &&
- (GNUNET_OK != iterator (closure,
- md->items[i].type,
- md->items[i].data)))
+ (GNUNET_OK != iter (iter_cls,
+ md->items[i].type,
+ md->items[i].data)))
return GNUNET_SYSERR;
}
else
/**
* Duplicate struct GNUNET_CONTAINER_MetaData.
+ *
+ * @param md what to duplicate
+ * @return duplicate meta-data container
*/
struct GNUNET_CONTAINER_MetaData *
GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData
* @param md metadata to serialize
* @param target where to write the serialized metadata
* @param max maximum number of bytes available in target
- * @param part 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,
* possibly discarding some data?
* @return number of bytes written on success,
*md, char *target, size_t max,
enum
GNUNET_CONTAINER_MetaDataSerializationOptions
- part)
+ opt)
{
struct MetaDataHeader *hdr;
size_t size;
}
hdr->size = htonl (size);
- if ((part & GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS) == 0)
+ if ((opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS) == 0)
{
pos = tryCompression ((char *) &hdr[1],
size - sizeof (struct MetaDataHeader));
GNUNET_free (hdr);
hdr = NULL;
- if ((part & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART) == 0)
+ if ((opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART) == 0)
{
return GNUNET_SYSERR; /* does not fit! */
}
* small number of characters. The GNUnet encoding uses 102
* characters plus a null terminator.
*
- * @param block the GNUNET_CRYPTO_hash code
+ * @param block the hash code
* @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be
* safely cast to char*, a '\\0' termination is set).
*/
#include <gcrypt.h>
/**
+ * Produce a random value.
+ *
+ * @param mode desired quality of the random number
+ * @param i the upper limit (exclusive) for the random number
* @return a random value in the interval [0,i[.
*/
uint32_t
/**
* Random on unsigned 64-bit values.
+ *
+ *
+ * @param mode desired quality of the random number
+ * @param max value returned will be in range [0,max) (exclusive)
+ * @return random 64-bit number
*/
uint64_t
GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode,
- uint64_t u)
+ uint64_t max)
{
uint64_t ret;
- GNUNET_assert (u > 0);
+ GNUNET_assert (max > 0);
if (mode == GNUNET_CRYPTO_QUALITY_STRONG)
{
gcry_randomize ((unsigned char *) &ret,
sizeof (uint64_t),
GCRY_STRONG_RANDOM);
- return ret % u;
+ return ret % max;
}
else
{
- ret = u * ((double) RANDOM () / RAND_MAX);
- if (ret >= u)
- ret = u - 1;
+ ret = max * ((double) RANDOM () / RAND_MAX);
+ if (ret >= max)
+ ret = max - 1;
return ret;
}
}
/**
* Extract the public key of the host.
- * @param hostkey the hostkey to extract into the result.
- * @param result where to write the result.
+ * @param priv the private key
+ * @param pub where to write the public key
*/
void
GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey
- *hostkey,
+ *priv,
struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
- *result)
+ *pub)
{
gcry_mpi_t skey[2];
size_t size;
/**
* Decrypt a given block with the hostkey.
*
- * @param hostkey the hostkey with which to decrypt this block
+ * @param key the key with which to decrypt this block
* @param block the data to decrypt, encoded as returned by encrypt
* @param result pointer to a location where the result can be stored
* @param max the maximum number of bits to store for the result, if
* the decrypted block is bigger, an error is returned
- * @returns the size of the decrypted block, -1 on error
+ * @return the size of the decrypted block, -1 on error
*/
ssize_t
-GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey,
+GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
const struct GNUNET_CRYPTO_RsaEncryptedData *block,
void *result,
size_t max)
unsigned char *tmp;
#if EXTRA_CHECKS
- GNUNET_assert (0 == gcry_pk_testkey (hostkey->sexp));
+ GNUNET_assert (0 == gcry_pk_testkey (key->sexp));
#endif
size = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData);
GNUNET_assert (0 == gcry_mpi_scan (&val,
gcry_sexp_build (&data, &erroff,
"(enc-val(flags)(rsa(a %m)))", val));
gcry_mpi_release (val);
- GNUNET_assert (0 == gcry_pk_decrypt (&resultsexp, data, hostkey->sexp));
+ GNUNET_assert (0 == gcry_pk_decrypt (&resultsexp, data, key->sexp));
gcry_sexp_release (data);
/* resultsexp has format "(value %m)" */
GNUNET_assert (NULL !=
/**
* Sign a given block.
*
- * @param hostkey private key to use for the signing
+ * @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 *hostkey,
+GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
const struct GNUNET_CRYPTO_RsaSignaturePurpose
*purpose, struct GNUNET_CRYPTO_RsaSignature *sig)
{
- 1], &hc, sizeof (GNUNET_HashCode));
GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0));
GNUNET_free (buff);
- GNUNET_assert (0 == gcry_pk_sign (&result, data, hostkey->sexp));
+ GNUNET_assert (0 == gcry_pk_sign (&result, data, key->sexp));
gcry_sexp_release (data);
GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s"));
gcry_sexp_release (result);
/**
* Parse the command line.
*
- * @param binaryOptions name of this binary / application
+ * @param binaryOptions Name of application with option summary
* @param allOptions defined options and handlers
* @param argc number of arguments
* @param argv actual arguments
*/
/**
- * @file resolver/gnunet-service-resolver.c
+ * @file util/gnunet-service-resolver.c
* @brief code to do DNS resolution
* @author Christian Grothoff
*/
#include "gnunet_time_lib.h"
#include "resolver.h"
-
+/**
+ * A cached DNS lookup result.
+ */
struct IPCache
{
+ /**
+ * This is a linked list.
+ */
struct IPCache *next;
+
+ /**
+ * Hostname in human-readable form.
+ */
char *addr;
+
+ /**
+ * Hostname in binary format.
+ */
struct sockaddr *sa;
+
+ /**
+ * Last time this entry was updated.
+ */
struct GNUNET_TIME_Absolute last_refresh;
+
+ /**
+ * Last time this entry was requested.
+ */
struct GNUNET_TIME_Absolute last_request;
- unsigned int salen;
+
+ /**
+ * Number of bytes in sa.
+ */
+ socklen_t salen;
};
+/**
+ * Start of the linked list of cached DNS lookup results.
+ */
static struct IPCache *head;
-
-
#if HAVE_GETNAMEINFO
+/**
+ * Resolve the given request using getnameinfo
+ *
+ * @param cache the request to resolve (and where to store the result)
+ */
static void
getnameinfo_resolve (struct IPCache *cache)
{
#if HAVE_GETHOSTBYADDR
+/**
+ * Resolve the given request using gethostbyaddr
+ *
+ * @param cache the request to resolve (and where to store the result)
+ */
static void
gethostbyaddr_resolve (struct IPCache *cache)
{
}
#endif
-
+/**
+ * Resolve the given request using the available methods.
+ *
+ * @param cache the request to resolve (and where to store the result)
+ */
static void
cache_resolve (struct IPCache *cache)
{
* may not immediately result in the FQN (but instead in a
* human-readable IP address).
*
+ * @param client handle to the client making the request (for sending the reply)
* @param sa should be of type "struct sockaddr*"
+ * @param salen number of bytes in sa
*/
static void
get_ip_as_string (struct GNUNET_SERVER_Client *client,
- const struct sockaddr *sav, socklen_t salen)
+ const struct sockaddr *sa, socklen_t salen)
{
struct IPCache *cache;
struct IPCache *prev;
cache = head;
prev = NULL;
while ((cache != NULL) &&
- ((cache->salen != salen) || (0 != memcmp (cache->sa, sav, salen))))
+ ((cache->salen != salen) || (0 != memcmp (cache->sa, sa, salen))))
{
if (GNUNET_TIME_absolute_get_duration (cache->last_request).value <
60 * 60 * 1000)
cache->next = head;
cache->salen = salen;
cache->sa = GNUNET_malloc (salen);
- memcpy (cache->sa, sav, salen);
+ memcpy (cache->sa, sa, salen);
cache->last_request = GNUNET_TIME_absolute_get ();
cache->last_refresh = GNUNET_TIME_absolute_get ();
cache->addr = NULL;
* @brief Enumerate all network interfaces
*
* @param proc the callback function
- * @param cls closure for proc
+ * @param proc_cls closure for proc
*/
void
GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc,
- void *cls)
+ void *proc_cls)
{
#ifdef MINGW
PMIB_IFTABLE pTable;
free (pszIfName);
if (GNUNET_OK !=
- proc (cls,
+ proc (proc_cls,
szEntry,
pAddrTable->table[dwIfIdx].dwIndex == dwExternalNIC,
NULL /* FIXME: pass actual IP address! */ ,
alen = sizeof (struct sockaddr_in);
else
alen = sizeof (struct sockaddr_in6);
- if (GNUNET_OK != proc (cls,
+ if (GNUNET_OK != proc (proc_cls,
ifa_ptr->ifa_name,
0 == strcmp (ifa_ptr->ifa_name,
GNUNET_DEFAULT_INTERFACE),
a4.sin_family = AF_INET;
a4.sin_addr = v4;
if (GNUNET_OK !=
- proc (cls,
+ proc (proc_cls,
ifc,
0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE),
(const struct sockaddr *) &a4, sizeof (a4)))
a6.sin6_addr = v6;
fprintf (stderr, "procing %s\n", addrstr);
if (GNUNET_OK !=
- proc (cls,
+ proc (proc_cls,
ifc,
0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE),
(const struct sockaddr *) &a6, sizeof (a6)))
#include "gnunet_os_lib.h"
/**
- * Set our process priority
+ * Set process priority
+ *
+ * @param proc id of the process
+ * @param prio priority value
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
GNUNET_OS_set_process_priority (pid_t proc,
- enum GNUNET_SCHEDULER_Priority eprio)
+ enum GNUNET_SCHEDULER_Priority prio)
{
int prio = 0;
- GNUNET_assert (eprio < GNUNET_SCHEDULER_PRIORITY_COUNT);
- if (eprio == GNUNET_SCHEDULER_PRIORITY_KEEP)
+ GNUNET_assert (prio < GNUNET_SCHEDULER_PRIORITY_COUNT);
+ if (prio == GNUNET_SCHEDULER_PRIORITY_KEEP)
return GNUNET_OK;
/* convert to MINGW/Unix values */
- switch (eprio)
+ switch (prio)
{
case GNUNET_SCHEDULER_PRIORITY_DEFAULT:
#ifdef MINGW
/**
* Add a pseudonym to the set of known pseudonyms.
* For all pseudonym advertisements that we discover
- * FSUI should automatically call this function.
+ * FS should automatically call this function.
*
* @param cfg overall configuration
* @param id the pseudonym identifier
/**
* @author Christian Grothoff
- * @file resolver/resolver.h
+ * @file util/resolver.h
*/
#ifndef RESOLVER_H
#define RESOLVER_H
*/
/**
- * @file resolver/resolver_api.c
+ * @file util/resolver_api.c
* @brief resolver for writing a tool
* @author Christian Grothoff
*/
/**
* Give relative time in human-readable fancy format.
*
- * @param del time in milli seconds
+ * @param delta time in milli seconds
* @return time as human-readable string
*/
char *
-GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative del)
+GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta)
{
const char *unit = _( /* time unit */ "ms");
char *ret;
- uint64_t delta = del.value;
+ uint64_t dval = delta.value;
- if (delta > 5 * 1000)
+ if (dval > 5 * 1000)
{
- delta = delta / 1000;
+ dval = dval / 1000;
unit = _( /* time unit */ "s");
- if (delta > 5 * 60)
+ if (dval > 5 * 60)
{
- delta = delta / 60;
+ dval = dval / 60;
unit = _( /* time unit */ "m");
- if (delta > 5 * 60)
+ if (dval > 5 * 60)
{
- delta = delta / 60;
+ dval = dval / 60;
unit = _( /* time unit */ "h");
- if (delta > 5 * 24)
+ if (dval > 5 * 24)
{
- delta = delta / 24;
+ dval = dval / 24;
unit = _( /* time unit */ " days");
}
}
}
}
- GNUNET_asprintf (&ret, "%llu%s", delta, unit);
+ GNUNET_asprintf (&ret, "%llu%s", dval, unit);
return ret;
}