GNUnet 0.21.1
Set service

Two-peer set operations. More...

Collaboration diagram for Set service:

Data Structures

struct  GNUNET_SET_Element
 Element stored in a set. More...
 
struct  GNUNET_SET_Option
 Option for set operations. More...
 
struct  GNUNET_SETI_Element
 Element stored in a set. More...
 
struct  GNUNET_SETI_Option
 Option for set operations. More...
 
struct  GNUNET_SETU_Element
 Element stored in a set. More...
 
struct  GNUNET_SETU_Option
 Option for set operations. More...
 

Macros

#define GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)
 Maximum size of a context message for set operation requests. More...
 
#define GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)
 Maximum size of a context message for set operation requests. More...
 
#define GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)
 Maximum size of a context message for set operation requests. More...
 

Typedefs

typedef void(* GNUNET_SET_Continuation) (void *cls)
 Continuation used for some of the set operations. More...
 
typedef void(* GNUNET_SET_ResultIterator) (void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
 Callback for set operation results. More...
 
typedef int(* GNUNET_SET_ElementIterator) (void *cls, const struct GNUNET_SET_Element *element)
 Iterator for set elements. More...
 
typedef void(* GNUNET_SET_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
 Called when another peer wants to do a set operation with the local peer. More...
 
typedef void(* GNUNET_SET_CopyReadyCallback) (void *cls, struct GNUNET_SET_Handle *copy)
 
typedef void(* GNUNET_SETI_ResultIterator) (void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)
 Callback for set union operation results. More...
 
typedef void(* GNUNET_SETI_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETI_Request *request)
 Called when another peer wants to do a set operation with the local peer. More...
 
typedef void(* GNUNET_SETU_ResultIterator) (void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
 Callback for set union operation results. More...
 
typedef void(* GNUNET_SETU_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
 Called when another peer wants to do a set operation with the local peer. More...
 

Enumerations

enum  GNUNET_SET_OperationType { GNUNET_SET_OPERATION_NONE , GNUNET_SET_OPERATION_INTERSECTION , GNUNET_SET_OPERATION_UNION }
 The operation that a set set supports. More...
 
enum  GNUNET_SET_Status {
  GNUNET_SET_STATUS_OK , GNUNET_SET_STATUS_ADD_LOCAL , GNUNET_SET_STATUS_ADD_REMOTE , GNUNET_SET_STATUS_FAILURE ,
  GNUNET_SET_STATUS_HALF_DONE , GNUNET_SET_STATUS_DONE
}
 Status for the result callback. More...
 
enum  GNUNET_SET_ResultMode { GNUNET_SET_RESULT_FULL , GNUNET_SET_RESULT_SYMMETRIC , GNUNET_SET_RESULT_REMOVED , GNUNET_SET_RESULT_ADDED }
 The way results are given to the client. More...
 
enum  GNUNET_SET_OptionType { GNUNET_SET_OPTION_END =0 , GNUNET_SET_OPTION_BYZANTINE =1 , GNUNET_SET_OPTION_FORCE_FULL =2 , GNUNET_SET_OPTION_FORCE_DELTA =4 }
 Possible options to pass to a set operation. More...
 
enum  GNUNET_SETI_Status { GNUNET_SETI_STATUS_ADD_LOCAL , GNUNET_SETI_STATUS_DEL_LOCAL , GNUNET_SETI_STATUS_FAILURE , GNUNET_SETI_STATUS_DONE }
 Status for the result callback. More...
 
enum  GNUNET_SETI_OptionType { GNUNET_SETI_OPTION_END = 0 , GNUNET_SETI_OPTION_RETURN_INTERSECTION = 1 }
 Possible options to pass to a set operation. More...
 
enum  GNUNET_SETU_Status { GNUNET_SETU_STATUS_ADD_LOCAL , GNUNET_SETU_STATUS_ADD_REMOTE , GNUNET_SETU_STATUS_FAILURE , GNUNET_SETU_STATUS_DONE }
 Status for the result callback. More...
 
enum  GNUNET_SETU_OptionType {
  GNUNET_SETU_OPTION_END =0 , GNUNET_SETU_OPTION_BYZANTINE =1 , GNUNET_SETU_OPTION_FORCE_FULL =2 , GNUNET_SETU_OPTION_FORCE_DELTA =4 ,
  GNUNET_SETU_OPTION_SYMMETRIC = 8 , GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND = 16 , GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF = 32 , GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR = 64 ,
  GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT = 128
}
 Possible options to pass to a set operation. More...
 

Functions

struct GNUNET_SET_HandleGNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op)
 Create an empty set, supporting the specified operation. More...
 
int GNUNET_SET_add_element (struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
 Add an element to the given set. More...
 
int GNUNET_SET_remove_element (struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
 Remove an element to the given set. More...
 
void GNUNET_SET_copy_lazy (struct GNUNET_SET_Handle *set, GNUNET_SET_CopyReadyCallback cb, void *cls)
 
void GNUNET_SET_destroy (struct GNUNET_SET_Handle *set)
 Destroy the set handle, and free all associated resources. More...
 
struct GNUNET_SET_OperationHandleGNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
 Prepare a set operation to be evaluated with another peer. More...
 
struct GNUNET_SET_ListenHandleGNUNET_SET_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op_type, const struct GNUNET_HashCode *app_id, GNUNET_SET_ListenCallback listen_cb, void *listen_cls)
 Wait for set operation requests for the given application ID. More...
 
void GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh)
 Cancel the given listen operation. More...
 
struct GNUNET_SET_OperationHandleGNUNET_SET_accept (struct GNUNET_SET_Request *request, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
 Accept a request we got via GNUNET_SET_listen(). More...
 
int GNUNET_SET_commit (struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
 Commit a set to be used with a set operation. More...
 
void GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh)
 Cancel the given set operation. More...
 
int GNUNET_SET_iterate (struct GNUNET_SET_Handle *set, GNUNET_SET_ElementIterator iter, void *iter_cls)
 Iterate over all elements in the given set. More...
 
void GNUNET_SET_iterate_cancel (struct GNUNET_SET_Handle *set)
 Stop iteration over all elements in the given set. More...
 
struct GNUNET_SET_ElementGNUNET_SET_element_dup (const struct GNUNET_SET_Element *element)
 Create a copy of an element. More...
 
void GNUNET_SET_element_hash (const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash)
 Hash a set element. More...
 
struct GNUNET_SETI_HandleGNUNET_SETI_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create an empty set, supporting the specified operation. More...
 
int GNUNET_SETI_add_element (struct GNUNET_SETI_Handle *set, const struct GNUNET_SETI_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
 Add an element to the given set. More...
 
void GNUNET_SETI_destroy (struct GNUNET_SETI_Handle *set)
 Destroy the set handle, and free all associated resources. More...
 
struct GNUNET_SETI_OperationHandleGNUNET_SETI_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
 Prepare a set operation to be evaluated with another peer. More...
 
struct GNUNET_SETI_ListenHandleGNUNET_SETI_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETI_ListenCallback listen_cb, void *listen_cls)
 Wait for set operation requests for the given application ID. More...
 
void GNUNET_SETI_listen_cancel (struct GNUNET_SETI_ListenHandle *lh)
 Cancel the given listen operation. More...
 
struct GNUNET_SETI_OperationHandleGNUNET_SETI_accept (struct GNUNET_SETI_Request *request, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
 Accept a request we got via GNUNET_SETI_listen(). More...
 
int GNUNET_SETI_commit (struct GNUNET_SETI_OperationHandle *oh, struct GNUNET_SETI_Handle *set)
 Commit a set to be used with a set operation. More...
 
void GNUNET_SETI_operation_cancel (struct GNUNET_SETI_OperationHandle *oh)
 Cancel the given set operation. More...
 
void GNUNET_SETI_element_hash (const struct GNUNET_SETI_Element *element, struct GNUNET_HashCode *ret_hash)
 Hash a set element. More...
 
struct GNUNET_SETU_HandleGNUNET_SETU_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create an empty set, supporting the specified operation. More...
 
int GNUNET_SETU_add_element (struct GNUNET_SETU_Handle *set, const struct GNUNET_SETU_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
 Add an element to the given set. More...
 
void GNUNET_SETU_destroy (struct GNUNET_SETU_Handle *set)
 Destroy the set handle, and free all associated resources. More...
 
struct GNUNET_SETU_OperationHandleGNUNET_SETU_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
 Prepare a set operation to be evaluated with another peer. More...
 
struct GNUNET_SETU_ListenHandleGNUNET_SETU_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETU_ListenCallback listen_cb, void *listen_cls)
 Wait for set operation requests for the given application ID. More...
 
void GNUNET_SETU_listen_cancel (struct GNUNET_SETU_ListenHandle *lh)
 Cancel the given listen operation. More...
 
struct GNUNET_SETU_OperationHandleGNUNET_SETU_accept (struct GNUNET_SETU_Request *request, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
 Accept a request we got via GNUNET_SETU_listen(). More...
 
int GNUNET_SETU_commit (struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set)
 Commit a set to be used with a set operation. More...
 
void GNUNET_SETU_operation_cancel (struct GNUNET_SETU_OperationHandle *oh)
 Cancel the given set operation. More...
 
void GNUNET_SETU_element_hash (const struct GNUNET_SETU_Element *element, struct GNUNET_HashCode *ret_hash)
 Hash a set element. More...
 

Detailed Description

Two-peer set operations.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE

#define GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)

Maximum size of a context message for set operation requests.

Definition at line 59 of file gnunet_set_service.h.

◆ GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE

#define GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)

Maximum size of a context message for set operation requests.

Definition at line 56 of file gnunet_seti_service.h.

◆ GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE

#define GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)

Maximum size of a context message for set operation requests.

Definition at line 56 of file gnunet_setu_service.h.

Typedef Documentation

◆ GNUNET_SET_Continuation

typedef void(* GNUNET_SET_Continuation) (void *cls)

Continuation used for some of the set operations.

Parameters
clsclosure

Definition at line 276 of file gnunet_set_service.h.

◆ GNUNET_SET_ResultIterator

typedef void(* GNUNET_SET_ResultIterator) (void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)

Callback for set operation results.

Called for each element in the result set.

Parameters
clsclosure
elementa result element, only valid if status is GNUNET_SET_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SET_Status

Definition at line 289 of file gnunet_set_service.h.

◆ GNUNET_SET_ElementIterator

typedef int(* GNUNET_SET_ElementIterator) (void *cls, const struct GNUNET_SET_Element *element)

Iterator for set elements.

Parameters
clsclosure
elementthe current element, NULL if all elements have been iterated over
Returns
GNUNET_YES to continue iterating, GNUNET_NO to stop.

Definition at line 303 of file gnunet_set_service.h.

◆ GNUNET_SET_ListenCallback

typedef void(* GNUNET_SET_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)

Called when another peer wants to do a set operation with the local peer.

If a listen error occurs, the request is NULL.

Parameters
clsclosure
other_peerthe other peer
context_msgmessage with application specific information from the other peer
requestrequest from the other peer (never NULL), use GNUNET_SET_accept() to accept it, otherwise the request will be refused Note that we can't just return value from the listen callback, as it is also necessary to specify the set we want to do the operation with, with sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 323 of file gnunet_set_service.h.

◆ GNUNET_SET_CopyReadyCallback

typedef void(* GNUNET_SET_CopyReadyCallback) (void *cls, struct GNUNET_SET_Handle *copy)

Definition at line 330 of file gnunet_set_service.h.

◆ GNUNET_SETI_ResultIterator

typedef void(* GNUNET_SETI_ResultIterator) (void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)

Callback for set union operation results.

Called for each element in the result set.

Parameters
clsclosure
elementa result element, only valid if status is #GNUNET_SETI_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SETI_Status

Definition at line 182 of file gnunet_seti_service.h.

◆ GNUNET_SETI_ListenCallback

typedef void(* GNUNET_SETI_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETI_Request *request)

Called when another peer wants to do a set operation with the local peer.

If a listen error occurs, the request is NULL.

Parameters
clsclosure
other_peerthe other peer
context_msgmessage with application specific information from the other peer
requestrequest from the other peer (never NULL), use GNUNET_SETI_accept() to accept it, otherwise the request will be refused Note that we can't just return value from the listen callback, as it is also necessary to specify the set we want to do the operation with, with sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 204 of file gnunet_seti_service.h.

◆ GNUNET_SETU_ResultIterator

typedef void(* GNUNET_SETU_ResultIterator) (void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)

Callback for set union operation results.

Called for each element in the result set.

Parameters
clsclosure
elementa result element, only valid if status is #GNUNET_SETU_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SETU_Status

Definition at line 227 of file gnunet_setu_service.h.

◆ GNUNET_SETU_ListenCallback

typedef void(* GNUNET_SETU_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)

Called when another peer wants to do a set operation with the local peer.

If a listen error occurs, the request is NULL.

Parameters
clsclosure
other_peerthe other peer
context_msgmessage with application specific information from the other peer
requestrequest from the other peer (never NULL), use GNUNET_SETU_accept() to accept it, otherwise the request will be refused Note that we can't just return value from the listen callback, as it is also necessary to specify the set we want to do the operation with, with sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 249 of file gnunet_setu_service.h.

Enumeration Type Documentation

◆ GNUNET_SET_OperationType

The operation that a set set supports.

Enumerator
GNUNET_SET_OPERATION_NONE 

A purely local set that does not support any operation.

GNUNET_SET_OPERATION_INTERSECTION 

Set intersection, only return elements that are in both sets.

GNUNET_SET_OPERATION_UNION 

Set union, return all elements that are in at least one of the sets.

Definition at line 86 of file gnunet_set_service.h.

87{
92
97
102};
@ GNUNET_SET_OPERATION_INTERSECTION
Set intersection, only return elements that are in both sets.
@ GNUNET_SET_OPERATION_UNION
Set union, return all elements that are in at least one of the sets.
@ GNUNET_SET_OPERATION_NONE
A purely local set that does not support any operation.

◆ GNUNET_SET_Status

Status for the result callback.

Enumerator
GNUNET_SET_STATUS_OK 

Everything went ok, we are transmitting an element of the result (in set, or to be removed from set, depending on the enum GNUNET_SET_ResultMode).

Only applies to GNUNET_SET_RESULT_FULL, GNUNET_SET_RESULT_ADDED, GNUNET_SET_RESULT_REMOVED,

GNUNET_SET_STATUS_ADD_LOCAL 

Element should be added to the result set of the local peer, i.e.

the local peer is missing an element.

Only applies to GNUNET_SET_RESULT_SYMMETRIC

GNUNET_SET_STATUS_ADD_REMOTE 

Element should be added to the result set of the remote peer, i.e.

the remote peer is missing an element.

Only applies to GNUNET_SET_RESULT_SYMMETRIC

GNUNET_SET_STATUS_FAILURE 

The other peer refused to to the operation with us, or something went wrong.

GNUNET_SET_STATUS_HALF_DONE 

Success, all elements have been returned (but the other peer might still be receiving some from us, so we are not done).

Only used during UNION operation.

GNUNET_SET_STATUS_DONE 

Success, all elements have been sent (and received).

Definition at line 108 of file gnunet_set_service.h.

109{
121
130
139
145
152
157};
@ GNUNET_SET_STATUS_OK
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set,...
@ GNUNET_SET_STATUS_FAILURE
The other peer refused to to the operation with us, or something went wrong.
@ GNUNET_SET_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SET_STATUS_HALF_DONE
Success, all elements have been returned (but the other peer might still be receiving some from us,...
@ GNUNET_SET_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SET_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.

◆ GNUNET_SET_ResultMode

The way results are given to the client.

Enumerator
GNUNET_SET_RESULT_FULL 

Client gets every element in the resulting set.

Only supported for set intersection.

GNUNET_SET_RESULT_SYMMETRIC 

Client gets notified of the required changes for both the local and the remote set.

Only supported for set

GNUNET_SET_RESULT_REMOVED 

Client gets only elements that have been removed from the set.

Only supported for set intersection.

GNUNET_SET_RESULT_ADDED 

Client gets only elements that have been added to the set.

Only supported for set union.

Definition at line 163 of file gnunet_set_service.h.

164{
171
179
186
193};
@ GNUNET_SET_RESULT_REMOVED
Client gets only elements that have been removed from the set.
@ GNUNET_SET_RESULT_FULL
Client gets every element in the resulting set.
@ GNUNET_SET_RESULT_SYMMETRIC
Client gets notified of the required changes for both the local and the remote set.
@ GNUNET_SET_RESULT_ADDED
Client gets only elements that have been added to the set.

◆ GNUNET_SET_OptionType

Possible options to pass to a set operation.

Used as tag for struct GNUNET_SET_Option.

Enumerator
GNUNET_SET_OPTION_END 

List terminator.

GNUNET_SET_OPTION_BYZANTINE 

Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.

For set union, 'v.num' is a lower bound on elements that the other peer must have in common with us.

GNUNET_SET_OPTION_FORCE_FULL 

Do not use the optimized set operation, but send full sets.

Might trigger Byzantine fault detection.

GNUNET_SET_OPTION_FORCE_DELTA 

Only use optimized set operations, even though for this particular set operation they might be much slower.

Might trigger Byzantine fault detection.

Definition at line 223 of file gnunet_set_service.h.

224{
248};
@ GNUNET_SET_OPTION_END
List terminator.
@ GNUNET_SET_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SET_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SET_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.

◆ GNUNET_SETI_Status

Status for the result callback.

Enumerator
GNUNET_SETI_STATUS_ADD_LOCAL 

Element should be added to the result set of the local peer, i.e.

the element is in the intersection.

GNUNET_SETI_STATUS_DEL_LOCAL 

Element should be delete from the result set of the local peer, i.e.

the local peer is having an element that is not in the intersection.

GNUNET_SETI_STATUS_FAILURE 

The other peer refused to do the operation with us, or something went wrong.

GNUNET_SETI_STATUS_DONE 

Success, all elements have been sent (and received).

Definition at line 82 of file gnunet_seti_service.h.

83{
84
90
96
102
107};
@ GNUNET_SETI_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETI_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
@ GNUNET_SETI_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETI_STATUS_DEL_LOCAL
Element should be delete from the result set of the local peer, i.e.

◆ GNUNET_SETI_OptionType

Possible options to pass to a set operation.

Used as tag for struct GNUNET_SETI_Option.

Enumerator
GNUNET_SETI_OPTION_END 

List terminator.

GNUNET_SETI_OPTION_RETURN_INTERSECTION 

Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL).

If not given, the default is to return a list of the elements to be removed (GNUNET_SETI_STATUS_DEL_LOCAL).

Definition at line 137 of file gnunet_seti_service.h.

138{
143
150};
@ GNUNET_SETI_OPTION_RETURN_INTERSECTION
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL).
@ GNUNET_SETI_OPTION_END
List terminator.

◆ GNUNET_SETU_Status

Status for the result callback.

Enumerator
GNUNET_SETU_STATUS_ADD_LOCAL 

Element should be added to the result set of the local peer, i.e.

the local peer is missing an element.

GNUNET_SETU_STATUS_ADD_REMOTE 

Element should be added to the result set of the remote peer, i.e.

the remote peer is missing an element. Only used if GNUNET_SETU_OPTION_SYMMETRIC is set.

GNUNET_SETU_STATUS_FAILURE 

The other peer refused to do the operation with us, or something went wrong.

GNUNET_SETU_STATUS_DONE 

Success, all elements have been sent (and received).

Definition at line 82 of file gnunet_setu_service.h.

83{
84
90
97
103
108};
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.

◆ GNUNET_SETU_OptionType

Possible options to pass to a set operation.

Used as tag for struct GNUNET_SETU_Option.

Enumerator
GNUNET_SETU_OPTION_END 

List terminator.

GNUNET_SETU_OPTION_BYZANTINE 

Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.

For set union, 'v.num' is a lower bound on elements that the other peer must have in common with us.

GNUNET_SETU_OPTION_FORCE_FULL 

Do not use the optimized set operation, but send full sets.

Might trigger Byzantine fault detection.

GNUNET_SETU_OPTION_FORCE_DELTA 

Only use optimized set operations, even though for this particular set operation they might be much slower.

Might trigger Byzantine fault detection.

GNUNET_SETU_OPTION_SYMMETRIC 

Notify client also if we are sending a value to the other peer.

GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND 

Byzantine upper bound.

Is the maximal plausible number of elements a peer can have default max uint64

GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF 

Bandwidth latency tradeoff determines how much bytes a single RTT is worth, which is a performance setting.

GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR 

The factor determines the number of buckets an IBF has which is multiplied by the estimated setsize default: 2.

GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT 

This setting determines to how many IBF buckets an single elements is mapped to.

Definition at line 138 of file gnunet_setu_service.h.

139{
144
153
159
166
171
177
183
189
195};
@ GNUNET_SETU_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT
This setting determines to how many IBF buckets an single elements is mapped to.
@ GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF
Bandwidth latency tradeoff determines how much bytes a single RTT is worth, which is a performance se...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR
The factor determines the number of buckets an IBF has which is multiplied by the estimated setsize d...
@ GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND
Byzantine upper bound.
@ GNUNET_SETU_OPTION_SYMMETRIC
Notify client also if we are sending a value to the other peer.
@ GNUNET_SETU_OPTION_END
List terminator.
@ GNUNET_SETU_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SETU_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.

Function Documentation

◆ GNUNET_SET_create()

struct GNUNET_SET_Handle * GNUNET_SET_create ( const struct GNUNET_CONFIGURATION_Handle cfg,
enum GNUNET_SET_OperationType  op 
)

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
opoperation supported by the set Note that the operation has to be specified beforehand, as certain set operations need to maintain data structures specific to the operation
Returns
a handle to the set

Definition at line 656 of file set_api.c.

658{
659 struct GNUNET_SET_Handle *set;
660
661 set = create_internal (cfg,
662 op,
663 NULL);
665 "Creating set %p for operation %d\n",
666 set,
667 op);
668 return set;
669}
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
@ GNUNET_ERROR_TYPE_DEBUG
static struct GNUNET_SET_Handle * create_internal(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op, const uint32_t *cookie)
FIXME.
Definition: set_api.c:582
#define LOG(kind,...)
Definition: set_api.c:33
Opaque handle to a set.
Definition: set_api.c:50

References cfg, create_internal(), GNUNET_ERROR_TYPE_DEBUG, LOG, and op.

Referenced by commit_set(), and handle_client_join().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_add_element()

int GNUNET_SET_add_element ( struct GNUNET_SET_Handle set,
const struct GNUNET_SET_Element element,
GNUNET_SET_Continuation  cont,
void *  cont_cls 
)

Add an element to the given set.

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Calls to GNUNET_SET_add_element can be queued

Parameters
setset to add element to
elementelement to add to the set
contcontinuation called after the element has been added
cont_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 673 of file set_api.c.

677{
678 struct GNUNET_MQ_Envelope *mqm;
680
682 "adding element of type %u to set %p\n",
683 (unsigned int) element->element_type,
684 set);
685 GNUNET_assert (NULL != set);
686 if (GNUNET_YES == set->invalid)
687 {
688 if (NULL != cont)
689 cont (cont_cls);
690 return GNUNET_SYSERR;
691 }
693 element->size,
695 msg->element_type = htons (element->element_type);
696 GNUNET_memcpy (&msg[1],
697 element->data,
698 element->size);
700 cont, cont_cls);
701 GNUNET_MQ_send (set->mq, mqm);
702 return GNUNET_OK;
703}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition: mq.c:638
#define GNUNET_MESSAGE_TYPE_SET_ADD
Add element to set.
Message sent by client to the service to add or remove an element to/from the set.
Definition: set.h:281
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
int invalid
Has the set become invalid (e.g.
Definition: set_api.c:87
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_ADD, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, LOG, GNUNET_SET_Handle::mq, msg, and GNUNET_SET_Element::size.

Referenced by commit_set(), handle_client_insert(), set_result_cb(), task_start_apply_round(), and task_start_eval_echo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_remove_element()

int GNUNET_SET_remove_element ( struct GNUNET_SET_Handle set,
const struct GNUNET_SET_Element element,
GNUNET_SET_Continuation  cont,
void *  cont_cls 
)

Remove an element to the given set.

After the element has been removed (in the sense of the request being transmitted to the set service), cont will be called.
Multiple calls to GNUNET_SET_remove_element() can be queued

Parameters
setset to remove element from
elementelement to remove from the set
contcontinuation called after the element has been removed
cont_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 707 of file set_api.c.

711{
712 struct GNUNET_MQ_Envelope *mqm;
714
716 "Removing element from set %p\n",
717 set);
718 if (GNUNET_YES == set->invalid)
719 {
720 if (NULL != cont)
721 cont (cont_cls);
722 return GNUNET_SYSERR;
723 }
725 element->size,
727 msg->element_type = htons (element->element_type);
728 GNUNET_memcpy (&msg[1],
729 element->data,
730 element->size);
732 cont, cont_cls);
733 GNUNET_MQ_send (set->mq, mqm);
734 return GNUNET_OK;
735}
#define GNUNET_MESSAGE_TYPE_SET_REMOVE
Remove element from set.

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_REMOVE, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, LOG, GNUNET_SET_Handle::mq, msg, and GNUNET_SET_Element::size.

Referenced by set_result_cb(), task_start_apply_round(), and task_start_eval_echo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_copy_lazy()

void GNUNET_SET_copy_lazy ( struct GNUNET_SET_Handle set,
GNUNET_SET_CopyReadyCallback  cb,
void *  cls 
)

Definition at line 1139 of file set_api.c.

1142{
1143 struct GNUNET_MQ_Envelope *ev;
1144 struct SetCopyRequest *req;
1145
1147 "Creating lazy copy of set\n");
1149 GNUNET_MQ_send (set->mq, ev);
1150
1151 req = GNUNET_new (struct SetCopyRequest);
1152 req->cb = cb;
1153 req->cls = cls;
1155 set->copy_req_tail,
1156 req);
1157}
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
Definition: gnunet_mq_lib.h:87
#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE
Ask the set service to prepare a copy of a set.
struct SetCopyRequest * copy_req_head
Doubly linked list of copy requests.
Definition: set_api.c:103
struct SetCopyRequest * copy_req_tail
Doubly linked list of copy requests.
Definition: set_api.c:108
void * cls
Definition: set_api.c:41
GNUNET_SET_CopyReadyCallback cb
Definition: set_api.c:43

References SetCopyRequest::cb, SetCopyRequest::cls, GNUNET_SET_Handle::copy_req_head, GNUNET_SET_Handle::copy_req_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE, GNUNET_MQ_msg_header, GNUNET_MQ_send(), GNUNET_new, LOG, and GNUNET_SET_Handle::mq.

Referenced by create_set_copy_for_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_destroy()

void GNUNET_SET_destroy ( struct GNUNET_SET_Handle set)

Destroy the set handle, and free all associated resources.

Iterations must have completed (or be explicitly canceled) before destroying the corresponding set. Operations may still be pending when a set is destroyed.

Parameters
setset to destroy

Destroy the set handle, and free all associated resources.

Parameters
setset handle to destroy

Definition at line 745 of file set_api.c.

746{
747 /* destroying set while iterator is active is currently
748 not supported; we should expand the API to allow
749 clients to explicitly cancel the iteration! */
750 GNUNET_assert (NULL != set);
751 if ((NULL != set->ops_head) ||
752 (NULL != set->iterator) ||
754 {
756 "Set operations are pending, delaying set destruction\n");
758 return;
759 }
761 "Really destroying set\n");
762 if (NULL != set->mq)
763 {
764 GNUNET_MQ_destroy (set->mq);
765 set->mq = NULL;
766 }
767 GNUNET_free (set);
768}
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
struct GNUNET_SET_OperationHandle * ops_head
Linked list of operations on the set.
Definition: set_api.c:59
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SET_destroy() must ...
Definition: set_api.c:82
GNUNET_SET_ElementIterator iterator
Callback for the current iteration over the set, NULL if no iterator is active.
Definition: set_api.c:70

References GNUNET_SET_Handle::destroy_requested, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::iterator, LOG, GNUNET_SET_Handle::mq, and GNUNET_SET_Handle::ops_head.

Referenced by client_disconnect_cb(), commit_set(), GNUNET_SET_operation_cancel(), handle_iter_done(), and handle_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_prepare()

struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare ( const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_HashCode app_id,
const struct GNUNET_MessageHeader context_msg,
enum GNUNET_SET_ResultMode  result_mode,
struct GNUNET_SET_Option  options[],
GNUNET_SET_ResultIterator  result_cb,
void *  result_cls 
)

Prepare a set operation to be evaluated with another peer.

The evaluation will not start until the client provides a local set with GNUNET_SET_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
result_modespecified how results will be returned, see enum GNUNET_SET_ResultMode.
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 772 of file set_api.c.

779{
780 struct GNUNET_MQ_Envelope *mqm;
783 struct GNUNET_SET_Option *opt;
784
786 "Client prepares set operation (%d)\n",
787 result_mode);
789 oh->result_cb = result_cb;
790 oh->result_cls = result_cls;
793 context_msg);
794 msg->app_id = *app_id;
795 msg->result_mode = htonl (result_mode);
796 msg->target_peer = *other_peer;
797 for (opt = options; opt->type != 0; opt++)
798 {
799 switch (opt->type)
800 {
802 msg->byzantine = GNUNET_YES;
803 msg->byzantine_lower_bound = opt->v.num;
804 break;
805
807 msg->force_full = GNUNET_YES;
808 break;
809
811 msg->force_delta = GNUNET_YES;
812 break;
813
814 default:
816 "Option with type %d not recognized\n", (int) opt->type);
817 }
818 }
819 oh->conclude_mqm = mqm;
820 oh->request_id_addr = &msg->request_id;
821
822 return oh;
823}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
#define GNUNET_MESSAGE_TYPE_SET_EVALUATE
Evaluate a set operation.
Message sent by client to service to initiate a set operation as a client (not as listener).
Definition: set.h:181
Handle to an operation.
Definition: set_api.c:136
GNUNET_SET_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: set_api.c:141
uint32_t * request_id_addr
Address of the request if in the conclude message, used to patch the request id into the message when...
Definition: set_api.c:164
void * result_cls
Closure for result_cb.
Definition: set_api.c:146
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called.
Definition: set_api.c:158
Option for set operations.
union GNUNET_SET_Option::@30 v
Value for the option, only used with some options.
enum GNUNET_SET_OptionType type
Type of the option.

References GNUNET_SET_OperationHandle::conclude_mqm, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SET_EVALUATE, GNUNET_MQ_msg_nested_mh, GNUNET_new, GNUNET_SET_OPTION_BYZANTINE, GNUNET_SET_OPTION_FORCE_DELTA, GNUNET_SET_OPTION_FORCE_FULL, GNUNET_YES, LOG, msg, GNUNET_SET_Option::num, options, GNUNET_SET_OperationHandle::request_id_addr, GNUNET_SET_OperationHandle::result_cb, GNUNET_SET_OperationHandle::result_cls, GNUNET_SET_Option::type, and GNUNET_SET_Option::v.

Referenced by task_start_reconcile().

Here is the caller graph for this function:

◆ GNUNET_SET_listen()

struct GNUNET_SET_ListenHandle * GNUNET_SET_listen ( const struct GNUNET_CONFIGURATION_Handle cfg,
enum GNUNET_SET_OperationType  operation,
const struct GNUNET_HashCode app_id,
GNUNET_SET_ListenCallback  listen_cb,
void *  listen_cls 
)

Wait for set operation requests for the given application ID.

If the connection to the set service is lost, the listener is re-created transparently with exponential backoff.

Parameters
cfgconfiguration to use for connecting to the set service
operationoperation we want to listen for
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Wait for set operation requests for the given application ID.

Parameters
cfgconfiguration to use for connecting to the set service, needs to be valid for the lifetime of the listen handle
operationoperation we want to listen for
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Definition at line 976 of file set_api.c.

981{
982 struct GNUNET_SET_ListenHandle *lh;
983
985 "Starting listener for app %s\n",
988 lh->listen_cb = listen_cb;
990 lh->cfg = cfg;
991 lh->operation = operation;
992 lh->app_id = *app_id;
994 listen_connect (lh);
995 if (NULL == lh->mq)
996 {
997 GNUNET_free (lh);
998 return NULL;
999 }
1000 return lh;
1001}
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: set_api.c:933
Opaque handle to a listen operation.
Definition: set_api.c:187
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: set_api.c:219
void * listen_cls
Closure for listen_cb.
Definition: set_api.c:209
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: set_api.c:214
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Definition: set_api.c:198
enum GNUNET_SET_OperationType operation
Operation we listen for.
Definition: set_api.c:229
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: set_api.c:191
GNUNET_SET_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: set_api.c:204

References GNUNET_SET_ListenHandle::app_id, cfg, GNUNET_SET_ListenHandle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_new, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_SET_ListenHandle::listen_cb, listen_cb(), GNUNET_SET_ListenHandle::listen_cls, listen_connect(), LOG, GNUNET_SET_ListenHandle::mq, GNUNET_SET_ListenHandle::operation, and GNUNET_SET_ListenHandle::reconnect_backoff.

Referenced by handle_client_join().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_listen_cancel()

void GNUNET_SET_listen_cancel ( struct GNUNET_SET_ListenHandle lh)

Cancel the given listen operation.

After calling cancel, the listen callback for this listen handle will not be called again. Note that cancelling a listen operation will automatically reject all operations that have not yet been accepted.

Parameters
lhhandle for the listen operation
lhhandle for the listen operation

Definition at line 1010 of file set_api.c.

1011{
1013 "Canceling listener %s\n",
1014 GNUNET_h2s (&lh->app_id));
1015 if (NULL != lh->mq)
1016 {
1017 GNUNET_MQ_destroy (lh->mq);
1018 lh->mq = NULL;
1019 }
1020 if (NULL != lh->reconnect_task)
1021 {
1023 lh->reconnect_task = NULL;
1024 }
1025 GNUNET_free (lh);
1026}
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: set_api.c:224

References GNUNET_SET_ListenHandle::app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_SET_ListenHandle::mq, and GNUNET_SET_ListenHandle::reconnect_task.

Referenced by client_disconnect_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_accept()

struct GNUNET_SET_OperationHandle * GNUNET_SET_accept ( struct GNUNET_SET_Request request,
enum GNUNET_SET_ResultMode  result_mode,
struct GNUNET_SET_Option  options[],
GNUNET_SET_ResultIterator  result_cb,
void *  result_cls 
)

Accept a request we got via GNUNET_SET_listen().

Must be called during GNUNET_SET_listen(), as the struct GNUNET_SET_Request becomes invalid afterwards. Call GNUNET_SET_commit() to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
result_modespecified how results will be returned, see enum GNUNET_SET_ResultMode.
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 1030 of file set_api.c.

1035{
1036 struct GNUNET_MQ_Envelope *mqm;
1037 struct GNUNET_SET_OperationHandle *oh;
1039
1040 GNUNET_assert (GNUNET_NO == request->accepted);
1042 "Client accepts set operation (%d) with id %u\n",
1044 request->accept_id);
1045 request->accepted = GNUNET_YES;
1046 mqm = GNUNET_MQ_msg (msg,
1048 msg->accept_reject_id = htonl (request->accept_id);
1049 msg->result_mode = htonl (result_mode);
1051 oh->result_cb = result_cb;
1052 oh->result_cls = result_cls;
1053 oh->conclude_mqm = mqm;
1054 oh->request_id_addr = &msg->request_id;
1055 return oh;
1056}
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
@ GNUNET_NO
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_SET_ACCEPT
Accept a set request.
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: set.h:83
uint32_t result_mode
How should results be sent to us? See enum GNUNET_SET_ResultMode.
Definition: set.h:103

References GNUNET_SET_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_ACCEPT, GNUNET_MQ_msg, GNUNET_new, GNUNET_NO, GNUNET_YES, LOG, msg, request, GNUNET_SET_OperationHandle::request_id_addr, GNUNET_SET_OperationHandle::result_cb, GNUNET_SET_OperationHandle::result_cls, and GNUNET_SET_AcceptMessage::result_mode.

Referenced by set_listen_cb().

Here is the caller graph for this function:

◆ GNUNET_SET_commit()

int GNUNET_SET_commit ( struct GNUNET_SET_OperationHandle oh,
struct GNUNET_SET_Handle set 
)

Commit a set to be used with a set operation.

This function is called once we have fully constructed the set that we want to use for the operation. At this time, the P2P protocol can then begin to exchange the set information and call the result callback with the result information.

Parameters
ohhandle to the set operation
setthe set to use for the operation
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 1073 of file set_api.c.

1075{
1076 if (NULL != oh->set)
1077 {
1078 /* Some other set was already committed for this
1079 * operation, there is a logic bug in the client of this API */
1080 GNUNET_break (0);
1081 return GNUNET_OK;
1082 }
1083 GNUNET_assert (NULL != set);
1084 if (GNUNET_YES == set->invalid)
1085 return GNUNET_SYSERR;
1087 "Client commits to SET\n");
1088 GNUNET_assert (NULL != oh->conclude_mqm);
1089 oh->set = set;
1091 set->ops_tail,
1092 oh);
1093 oh->request_id = GNUNET_MQ_assoc_add (set->mq,
1094 oh);
1095 *oh->request_id_addr = htonl (oh->request_id);
1096 GNUNET_MQ_send (set->mq,
1097 oh->conclude_mqm);
1098 oh->conclude_mqm = NULL;
1099 oh->request_id_addr = NULL;
1100 return GNUNET_OK;
1101}
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
uint32_t GNUNET_MQ_assoc_add(struct GNUNET_MQ_Handle *mq, void *assoc_data)
Associate the assoc_data in mq with a unique request id.
Definition: mq.c:575
struct GNUNET_SET_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: set_api.c:64
struct GNUNET_SET_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
Definition: set_api.c:152
uint32_t request_id
Request ID to identify the operation within the set.
Definition: set_api.c:179

References GNUNET_SET_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_assoc_add(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, LOG, GNUNET_SET_Handle::mq, GNUNET_SET_Handle::ops_head, GNUNET_SET_Handle::ops_tail, GNUNET_SET_OperationHandle::request_id, GNUNET_SET_OperationHandle::request_id_addr, and GNUNET_SET_OperationHandle::set.

Referenced by commit_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_operation_cancel()

void GNUNET_SET_operation_cancel ( struct GNUNET_SET_OperationHandle oh)

Cancel the given set operation.

May not be called after the operation's GNUNET_SET_ResultIterator has been called with a status that indicates error, timeout or done.

Parameters
ohset operation to cancel

We need to send an explicit cancel message, as all operations one one set communicate using one handle.

Parameters
ohset operation to cancel

Definition at line 516 of file set_api.c.

517{
518 struct GNUNET_SET_Handle *set = oh->set;
520 struct GNUNET_MQ_Envelope *mqm;
521
523 "Cancelling SET operation\n");
524 if (NULL != set)
525 {
527 m->request_id = htonl (oh->request_id);
528 GNUNET_MQ_send (set->mq, mqm);
529 }
531 if ((NULL != set) &&
532 (GNUNET_YES == set->destroy_requested) &&
533 (NULL == set->ops_head))
534 {
536 "Destroying set after operation cancel\n");
537 GNUNET_SET_destroy (set);
538 }
539}
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
#define GNUNET_MESSAGE_TYPE_SET_CANCEL
Cancel a set operation.
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
Definition: set_api.c:745
static void set_operation_destroy(struct GNUNET_SET_OperationHandle *oh)
Destroy the given set operation.
Definition: set_api.c:486
Sent to the service by the client in order to cancel a set operation.
Definition: set.h:307

References GNUNET_SET_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SET_destroy(), GNUNET_YES, LOG, m, GNUNET_SET_Handle::mq, GNUNET_SET_Handle::ops_head, GNUNET_SET_OperationHandle::request_id, GNUNET_SET_OperationHandle::set, and set_operation_destroy().

Referenced by commit_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_iterate()

int GNUNET_SET_iterate ( struct GNUNET_SET_Handle set,
GNUNET_SET_ElementIterator  iter,
void *  iter_cls 
)

Iterate over all elements in the given set.

Note that this operation involves transferring every element of the set from the service to the client, and is thus costly. Only one iteration per set may be active at the same time.

Parameters
setthe set to iterate over
iterthe iterator to call for each element
iter_clsclosure for iter
Returns
GNUNET_YES if the iteration started successfully, GNUNET_NO if another iteration was still active, GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected)

Note that this operation involves transferring every element of the set from the service to the client, and is thus costly.

Parameters
setthe set to iterate over
iterthe iterator to call for each element
iter_clsclosure for iter
Returns
GNUNET_YES if the iteration started successfully, GNUNET_NO if another iteration is active GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected)

Definition at line 1117 of file set_api.c.

1120{
1121 struct GNUNET_MQ_Envelope *ev;
1122
1123 GNUNET_assert (NULL != iter);
1124 if (GNUNET_YES == set->invalid)
1125 return GNUNET_SYSERR;
1126 if (NULL != set->iterator)
1127 return GNUNET_NO;
1129 "Iterating over set\n");
1130 set->iterator = iter;
1131 set->iterator_cls = iter_cls;
1133 GNUNET_MQ_send (set->mq, ev);
1134 return GNUNET_YES;
1135}
#define GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST
Start iteration over set elements.
void * iterator_cls
Closure for iterator.
Definition: set_api.c:75

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST, GNUNET_MQ_msg_header, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, GNUNET_SET_Handle::iterator, GNUNET_SET_Handle::iterator_cls, LOG, and GNUNET_SET_Handle::mq.

Referenced by task_start_finish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_iterate_cancel()

void GNUNET_SET_iterate_cancel ( struct GNUNET_SET_Handle set)

Stop iteration over all elements in the given set.

Can only be called before the iteration has "naturally" completed its turn.

Parameters
setthe set to stop iterating over

◆ GNUNET_SET_element_dup()

struct GNUNET_SET_Element * GNUNET_SET_element_dup ( const struct GNUNET_SET_Element element)

Create a copy of an element.

The copy must be GNUNET_free-d by the caller.

Parameters
elementthe element to copy
Returns
the copied element

Definition at line 1168 of file set_api.c.

1169{
1170 struct GNUNET_SET_Element *copy;
1171
1172 copy = GNUNET_malloc (element->size + sizeof(struct GNUNET_SET_Element));
1173 copy->size = element->size;
1174 copy->element_type = element->element_type;
1175 copy->data = &copy[1];
1176 GNUNET_memcpy (&copy[1],
1177 element->data,
1178 copy->size);
1179 return copy;
1180}
#define GNUNET_malloc(size)
Wrapper around malloc.
Element stored in a set.

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_malloc, GNUNET_memcpy, and GNUNET_SET_Element::size.

Referenced by diff_insert(), and rfn_vote().

Here is the caller graph for this function:

◆ GNUNET_SET_element_hash()

void GNUNET_SET_element_hash ( const struct GNUNET_SET_Element element,
struct GNUNET_HashCode ret_hash 
)

Hash a set element.

Parameters
elementthe element that should be hashed
[out]ret_hasha pointer to where the hash of element should be stored

Definition at line 1184 of file set_api.c.

1186{
1188
1189 /* It's not guaranteed that the element data is always after the element header,
1190 so we need to hash the chunks separately. */
1191 GNUNET_CRYPTO_hash_context_read (ctx, &element->size, sizeof(uint16_t));
1193 sizeof(uint16_t));
1194 GNUNET_CRYPTO_hash_context_read (ctx, element->data, element->size);
1196}
static struct GNUNET_FS_Handle * ctx
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
Definition: crypto_hash.c:366
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:390
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:350

References ctx, GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), and GNUNET_SET_Element::size.

Referenced by diff_insert(), execute_add(), execute_remove(), handle_union_p2p_elements(), handle_union_p2p_full_element(), and rfn_vote().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_create()

struct GNUNET_SETI_Handle * GNUNET_SETI_create ( const struct GNUNET_CONFIGURATION_Handle cfg)

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
Returns
a handle to the set

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
Returns
a handle to the set

Definition at line 399 of file seti_api.c.

400{
401 struct GNUNET_SETI_Handle *set = GNUNET_new (struct GNUNET_SETI_Handle);
402 struct GNUNET_MQ_MessageHandler mq_handlers[] = {
406 set),
408 };
409 struct GNUNET_MQ_Envelope *mqm;
410 struct GNUNET_SETI_CreateMessage *create_msg;
411
412 set->cfg = cfg;
414 "seti",
415 mq_handlers,
417 set);
418 if (NULL == set->mq)
419 {
420 GNUNET_free (set);
421 return NULL;
422 }
424 "Creating new intersection set\n");
425 mqm = GNUNET_MQ_msg (create_msg,
427 GNUNET_MQ_send (set->mq,
428 mqm);
429 return set;
430}
static int result
Global testing status.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_SETI_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETI_CREATE
Create a new local set.
static void handle_client_set_error(void *cls, enum GNUNET_MQ_Error error)
We encountered an error communicating with the set service while performing a set operation.
Definition: seti_api.c:369
#define LOG(kind,...)
Definition: seti_api.c:33
Message handler for a specific message type.
Message sent by the client to the service to ask starting a new set to perform operations with.
Definition: seti.h:40
Opaque handle to a set.
Definition: seti_api.c:40
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: seti_api.c:44
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration, needed when creating (lazy) copies.
Definition: seti_api.c:59
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
Definition: seti.h:192

References cfg, GNUNET_SETI_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MESSAGE_TYPE_SETI_CREATE, GNUNET_MESSAGE_TYPE_SETI_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, handle_client_set_error(), LOG, GNUNET_SETI_Handle::mq, and result.

Referenced by handle_alice_client_message(), and handle_bob_client_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_add_element()

int GNUNET_SETI_add_element ( struct GNUNET_SETI_Handle set,
const struct GNUNET_SETI_Element element,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cb_cls 
)

Add an element to the given set.

Parameters
setset to add element to
elementelement to add to the set
cbfunction to call when finished, can be NULL
cb_clsclosure for cb
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Multiple calls to GNUNET_SETI_add_element() can be queued.

Parameters
setset to add element to
elementelement to add to the set
cbcontinuation called after the element has been added
cb_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 447 of file seti_api.c.

451{
452 struct GNUNET_MQ_Envelope *mqm;
454
456 "adding element of type %u to set %p\n",
457 (unsigned int) element->element_type,
458 set);
459 if (GNUNET_YES == set->invalid)
460 {
461 if (NULL != cb)
462 cb (cb_cls);
463 return GNUNET_SYSERR;
464 }
466 element->size,
468 msg->element_type = htons (element->element_type);
469 GNUNET_memcpy (&msg[1],
470 element->data,
471 element->size);
473 cb,
474 cb_cls);
475 GNUNET_MQ_send (set->mq,
476 mqm);
477 return GNUNET_OK;
478}
#define GNUNET_MESSAGE_TYPE_SETI_ADD
Add element to set.
Message sent by client to the service to add an element to the set.
Definition: seti.h:227
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
int invalid
Has the set become invalid (e.g.
Definition: seti_api.c:71

References GNUNET_SETI_Element::data, GNUNET_SETI_Element::element_type, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SETI_ADD, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETI_Handle::invalid, LOG, GNUNET_SETI_Handle::mq, msg, and GNUNET_SETI_Element::size.

Referenced by handle_alice_client_message(), handle_alice_client_message_multipart(), handle_bob_client_message(), and handle_bob_client_message_multipart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_destroy()

void GNUNET_SETI_destroy ( struct GNUNET_SETI_Handle set)

Destroy the set handle, and free all associated resources.

Operations may still be pending when a set is destroyed (and will be allowed to complete).

Parameters
setset to destroy

Destroy the set handle, and free all associated resources.

Parameters
setset handle to destroy

Definition at line 488 of file seti_api.c.

489{
490 /* destroying set while iterator is active is currently
491 not supported; we should expand the API to allow
492 clients to explicitly cancel the iteration! */
493 if ((NULL != set->ops_head) ||
495 {
497 "Set operations are pending, delaying set destruction\n");
499 return;
500 }
502 "Really destroying set\n");
503 if (NULL != set->mq)
504 {
505 GNUNET_MQ_destroy (set->mq);
506 set->mq = NULL;
507 }
508 GNUNET_free (set);
509}
struct GNUNET_SETI_OperationHandle * ops_head
Linked list of operations on the set.
Definition: seti_api.c:49
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETI_destroy() must...
Definition: seti_api.c:66

References GNUNET_SETI_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, LOG, GNUNET_SETI_Handle::mq, and GNUNET_SETI_Handle::ops_head.

Referenced by cb_intersection_element_removed(), destroy_service_session(), GNUNET_SETI_operation_cancel(), and handle_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_prepare()

struct GNUNET_SETI_OperationHandle * GNUNET_SETI_prepare ( const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_HashCode app_id,
const struct GNUNET_MessageHeader context_msg,
const struct GNUNET_SETI_Option  options[],
GNUNET_SETI_ResultIterator  result_cb,
void *  result_cls 
)

Prepare a set operation to be evaluated with another peer.

The evaluation will not start until the client provides a local set with GNUNET_SETI_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
optionsoptions to use when processing the request
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 513 of file seti_api.c.

519{
520 struct GNUNET_MQ_Envelope *mqm;
523
525 oh->result_cb = result_cb;
526 oh->result_cls = result_cls;
529 context_msg);
530 msg->app_id = *app_id;
531 msg->target_peer = *other_peer;
532 for (const struct GNUNET_SETI_Option *opt = options;
533 GNUNET_SETI_OPTION_END != opt->type;
534 opt++)
535 {
536 switch (opt->type)
537 {
539 msg->return_intersection = htonl (GNUNET_YES);
540 break;
541 default:
543 "Option with type %d not recognized\n",
544 (int) opt->type);
545 }
546 }
547 oh->conclude_mqm = mqm;
548 oh->request_id_addr = &msg->request_id;
549 return oh;
550}
#define GNUNET_MESSAGE_TYPE_SETI_EVALUATE
Evaluate a set operation.
Message sent by client to service to initiate a set operation as a client (not as listener).
Definition: seti.h:152
struct GNUNET_HashCode app_id
Application id.
Definition: seti.h:172
Handle to an operation.
Definition: seti_api.c:106
void * result_cls
Closure for result_cb.
Definition: seti_api.c:116
GNUNET_SETI_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: seti_api.c:111
uint32_t * request_id_addr
Address of the request if in the conclude message, used to patch the request id into the message when...
Definition: seti_api.c:134
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called.
Definition: seti_api.c:128
Option for set operations.

References GNUNET_SETI_EvaluateMessage::app_id, GNUNET_SETI_OperationHandle::conclude_mqm, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETI_EVALUATE, GNUNET_MQ_msg_nested_mh, GNUNET_new, GNUNET_SETI_OPTION_END, GNUNET_SETI_OPTION_RETURN_INTERSECTION, GNUNET_YES, LOG, msg, options, GNUNET_SETI_OperationHandle::request_id_addr, GNUNET_SETI_OperationHandle::result_cb, and GNUNET_SETI_OperationHandle::result_cls.

Referenced by start_intersection().

Here is the caller graph for this function:

◆ GNUNET_SETI_listen()

struct GNUNET_SETI_ListenHandle * GNUNET_SETI_listen ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_HashCode app_id,
GNUNET_SETI_ListenCallback  listen_cb,
void *  listen_cls 
)

Wait for set operation requests for the given application ID.

If the connection to the set service is lost, the listener is re-created transparently with exponential backoff.

Parameters
cfgconfiguration to use for connecting to the set service
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Wait for set operation requests for the given application ID.

Parameters
cfgconfiguration to use for connecting to the set service, needs to be valid for the lifetime of the listen handle
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Definition at line 702 of file seti_api.c.

706{
707 struct GNUNET_SETI_ListenHandle *lh;
708
710 "Starting listener for app %s\n",
713 lh->listen_cb = listen_cb;
715 lh->cfg = cfg;
716 lh->app_id = *app_id;
718 listen_connect (lh);
719 if (NULL == lh->mq)
720 {
721 GNUNET_free (lh);
722 return NULL;
723 }
724 return lh;
725}
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: seti_api.c:661
Opaque handle to a listen operation.
Definition: seti_api.c:163
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: seti_api.c:195
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: seti_api.c:200
GNUNET_SETI_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: seti_api.c:180
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: seti_api.c:167
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Definition: seti_api.c:174
void * listen_cls
Closure for listen_cb.
Definition: seti_api.c:185

References GNUNET_SETI_ListenHandle::app_id, cfg, GNUNET_SETI_ListenHandle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_new, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_SETI_ListenHandle::listen_cb, listen_cb(), GNUNET_SETI_ListenHandle::listen_cls, listen_connect(), LOG, GNUNET_SETI_ListenHandle::mq, and GNUNET_SETI_ListenHandle::reconnect_backoff.

Referenced by client_request_complete_alice().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_listen_cancel()

void GNUNET_SETI_listen_cancel ( struct GNUNET_SETI_ListenHandle lh)

Cancel the given listen operation.

After calling cancel, the listen callback for this listen handle will not be called again. Note that cancelling a listen operation will automatically reject all operations that have not yet been accepted.

Parameters
lhhandle for the listen operation
lhhandle for the listen operation

Definition at line 734 of file seti_api.c.

735{
737 "Canceling listener %s\n",
738 GNUNET_h2s (&lh->app_id));
739 if (NULL != lh->mq)
740 {
741 GNUNET_MQ_destroy (lh->mq);
742 lh->mq = NULL;
743 }
744 if (NULL != lh->reconnect_task)
745 {
747 lh->reconnect_task = NULL;
748 }
749 GNUNET_free (lh);
750}
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: seti_api.c:190

References GNUNET_SETI_ListenHandle::app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_SETI_ListenHandle::mq, and GNUNET_SETI_ListenHandle::reconnect_task.

Referenced by cb_intersection_element_removed(), and destroy_service_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_accept()

struct GNUNET_SETI_OperationHandle * GNUNET_SETI_accept ( struct GNUNET_SETI_Request request,
const struct GNUNET_SETI_Option  options[],
GNUNET_SETI_ResultIterator  result_cb,
void *  result_cls 
)

Accept a request we got via GNUNET_SETI_listen().

Must be called during GNUNET_SETI_listen(), as the struct GNUNET_SETI_Request becomes invalid afterwards. Call GNUNET_SETI_commit() to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
optionsoptions to use when processing the request
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 754 of file seti_api.c.

758{
759 struct GNUNET_MQ_Envelope *mqm;
762
763 GNUNET_assert (GNUNET_NO == request->accepted);
765 "Client accepts set intersection operation with id %u\n",
766 request->accept_id);
767 request->accepted = GNUNET_YES;
768 mqm = GNUNET_MQ_msg (msg,
770 msg->accept_reject_id = htonl (request->accept_id);
772 oh->result_cb = result_cb;
773 oh->result_cls = result_cls;
774 oh->conclude_mqm = mqm;
775 oh->request_id_addr = &msg->request_id;
776 for (const struct GNUNET_SETI_Option *opt = options;
777 GNUNET_SETI_OPTION_END != opt->type;
778 opt++)
779 {
780 switch (opt->type)
781 {
784 msg->return_intersection = htonl (GNUNET_YES);
785 break;
786 default:
788 "Option with type %d not recognized\n",
789 (int) opt->type);
790 }
791 }
792 return oh;
793}
#define GNUNET_MESSAGE_TYPE_SETI_ACCEPT
Accept an incoming set request.
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: seti.h:77
int return_intersection
Should we return the resulting intersection (ADD) or the elements to remove (DEL)?
Definition: seti_api.c:155

References GNUNET_SETI_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETI_ACCEPT, GNUNET_MQ_msg, GNUNET_new, GNUNET_NO, GNUNET_SETI_OPTION_END, GNUNET_SETI_OPTION_RETURN_INTERSECTION, GNUNET_YES, LOG, msg, options, request, GNUNET_SETI_OperationHandle::request_id_addr, GNUNET_SETI_OperationHandle::result_cb, GNUNET_SETI_OperationHandle::result_cls, and GNUNET_SETI_OperationHandle::return_intersection.

Referenced by cb_intersection_request_alice().

Here is the caller graph for this function:

◆ GNUNET_SETI_commit()

int GNUNET_SETI_commit ( struct GNUNET_SETI_OperationHandle oh,
struct GNUNET_SETI_Handle set 
)

Commit a set to be used with a set operation.

This function is called once we have fully constructed the set that we want to use for the operation. At this time, the P2P protocol can then begin to exchange the set information and call the result callback with the result information.

Parameters
ohhandle to the set operation
setthe set to use for the operation
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 810 of file seti_api.c.

812{
813 if (NULL != oh->set)
814 {
815 /* Some other set was already committed for this
816 * operation, there is a logic bug in the client of this API */
817 GNUNET_break (0);
818 return GNUNET_OK;
819 }
820 GNUNET_assert (NULL != set);
821 if (GNUNET_YES == set->invalid)
822 return GNUNET_SYSERR;
824 "Client commits to SET\n");
825 GNUNET_assert (NULL != oh->conclude_mqm);
826 oh->set = set;
828 set->ops_tail,
829 oh);
831 oh);
832 *oh->request_id_addr = htonl (oh->request_id);
833 GNUNET_MQ_send (set->mq,
834 oh->conclude_mqm);
835 oh->conclude_mqm = NULL;
836 oh->request_id_addr = NULL;
837 return GNUNET_OK;
838}
struct GNUNET_SETI_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: seti_api.c:54
uint32_t request_id
Request ID to identify the operation within the set.
Definition: seti_api.c:149
struct GNUNET_SETI_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
Definition: seti_api.c:122

References GNUNET_SETI_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_assoc_add(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETI_Handle::invalid, LOG, GNUNET_SETI_Handle::mq, GNUNET_SETI_Handle::ops_head, GNUNET_SETI_Handle::ops_tail, GNUNET_SETI_OperationHandle::request_id, GNUNET_SETI_OperationHandle::request_id_addr, and GNUNET_SETI_OperationHandle::set.

Referenced by cb_intersection_request_alice().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_operation_cancel()

void GNUNET_SETI_operation_cancel ( struct GNUNET_SETI_OperationHandle oh)

Cancel the given set operation.

May not be called after the operation's GNUNET_SETI_ResultIterator has been called with a status of GNUNET_SETI_STATUS_FAILURE or GNUNET_SETI_STATUS_DONE.

Parameters
ohset operation to cancel

We need to send an explicit cancel message, as all operations one one set communicate using one handle.

Parameters
ohset operation to cancel

Definition at line 335 of file seti_api.c.

336{
337 struct GNUNET_SETI_Handle *set = oh->set;
339 struct GNUNET_MQ_Envelope *mqm;
340
342 "Cancelling SET operation\n");
343 if (NULL != set)
344 {
346 m->request_id = htonl (oh->request_id);
347 GNUNET_MQ_send (set->mq, mqm);
348 }
350 if ((NULL != set) &&
351 (GNUNET_YES == set->destroy_requested) &&
352 (NULL == set->ops_head))
353 {
355 "Destroying set after operation cancel\n");
357 }
358}
#define GNUNET_MESSAGE_TYPE_SETI_CANCEL
Cancel a set operation.
void GNUNET_SETI_destroy(struct GNUNET_SETI_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
Definition: seti_api.c:488
static void set_operation_destroy(struct GNUNET_SETI_OperationHandle *oh)
Destroy the given set operation.
Definition: seti_api.c:305
Sent to the service by the client in order to cancel a set operation.
Definition: seti.h:252

References GNUNET_SETI_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETI_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SETI_destroy(), GNUNET_YES, LOG, m, GNUNET_SETI_Handle::mq, GNUNET_SETI_Handle::ops_head, GNUNET_SETI_OperationHandle::request_id, GNUNET_SETI_OperationHandle::set, and set_operation_destroy().

Referenced by destroy_service_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_element_hash()

void GNUNET_SETI_element_hash ( const struct GNUNET_SETI_Element element,
struct GNUNET_HashCode ret_hash 
)

Hash a set element.

Parameters
elementthe element that should be hashed
[out]ret_hasha pointer to where the hash of element should be stored

Definition at line 849 of file seti_api.c.

851{
853
854 /* It's not guaranteed that the element data is always after the element header,
855 so we need to hash the chunks separately. */
857 &element->size,
858 sizeof(uint16_t));
860 &element->element_type,
861 sizeof(uint16_t));
863 element->data,
864 element->size);
866 ret_hash);
867}

References ctx, GNUNET_SETI_Element::data, GNUNET_SETI_Element::element_type, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), and GNUNET_SETI_Element::size.

Referenced by handle_client_set_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_create()

struct GNUNET_SETU_Handle * GNUNET_SETU_create ( const struct GNUNET_CONFIGURATION_Handle cfg)

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
Returns
a handle to the set

Definition at line 384 of file setu_api.c.

385{
386 struct GNUNET_SETU_Handle *set = GNUNET_new (struct GNUNET_SETU_Handle);
387 struct GNUNET_MQ_MessageHandler mq_handlers[] = {
391 set),
393 };
394 struct GNUNET_MQ_Envelope *mqm;
395 struct GNUNET_SETU_CreateMessage *create_msg;
396
398 "setu",
399 mq_handlers,
401 set);
402 if (NULL == set->mq)
403 {
404 GNUNET_free (set);
405 return NULL;
406 }
407 mqm = GNUNET_MQ_msg (create_msg,
409 GNUNET_MQ_send (set->mq,
410 mqm);
411 return set;
412}
#define GNUNET_MESSAGE_TYPE_SETU_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETU_CREATE
Create a new local set.
static void handle_client_set_error(void *cls, enum GNUNET_MQ_Error error)
We encountered an error communicating with the set service while performing a set operation.
Definition: setu_api.c:354
Message sent by the client to the service to ask starting a new set to perform operations with.
Definition: setu.h:41
Opaque handle to a set.
Definition: setu_api.c:40
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: setu_api.c:44
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
Definition: setu.h:290

References cfg, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_MESSAGE_TYPE_SETU_CREATE, GNUNET_MESSAGE_TYPE_SETU_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, handle_client_set_error(), GNUNET_SETU_Handle::mq, and result.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_add_element()

int GNUNET_SETU_add_element ( struct GNUNET_SETU_Handle set,
const struct GNUNET_SETU_Element element,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cb_cls 
)

Add an element to the given set.

Parameters
setset to add element to
elementelement to add to the set
cbfunction to call when finished, can be NULL
cb_clsclosure for cb
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Multiple calls to GNUNET_SETU_add_element() can be queued.

Parameters
setset to add element to
elementelement to add to the set
cbcontinuation called after the element has been added
cb_clsclosure for cb
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 429 of file setu_api.c.

433{
434 struct GNUNET_MQ_Envelope *mqm;
436
438 "adding element of type %u to set %p\n",
439 (unsigned int) element->element_type,
440 set);
441 GNUNET_assert (NULL != set);
442 if (GNUNET_YES == set->invalid)
443 {
444 if (NULL != cb)
445 cb (cb_cls);
446 return GNUNET_SYSERR;
447 }
449 element->size,
451 msg->element_type = htons (element->element_type);
452 GNUNET_memcpy (&msg[1],
453 element->data,
454 element->size);
456 cb,
457 cb_cls);
458 GNUNET_MQ_send (set->mq,
459 mqm);
460 return GNUNET_OK;
461}
#define GNUNET_MESSAGE_TYPE_SETU_ADD
Add element to set.
#define LOG(kind,...)
Definition: setu_api.c:34
Message sent by client to the service to add an element to the set.
Definition: setu.h:326
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
int invalid
Has the set become invalid (e.g.
Definition: setu_api.c:66

References GNUNET_SETU_Element::data, GNUNET_SETU_Element::element_type, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SETU_ADD, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETU_Handle::invalid, LOG, GNUNET_SETU_Handle::mq, msg, and GNUNET_SETU_Element::size.

Referenced by publicize_rm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_destroy()

void GNUNET_SETU_destroy ( struct GNUNET_SETU_Handle set)

Destroy the set handle, and free all associated resources.

Operations may still be pending when a set is destroyed (and will be allowed to complete).

Parameters
setset to destroy

Destroy the set handle, and free all associated resources.

Parameters
setset handle to destroy

Definition at line 471 of file setu_api.c.

472{
473 /* destroying set while iterator is active is currently
474 not supported; we should expand the API to allow
475 clients to explicitly cancel the iteration! */
476 GNUNET_assert (NULL != set);
477 if ((NULL != set->ops_head) ||
479 {
481 "Set operations are pending, delaying set destruction\n");
483 return;
484 }
486 "Really destroying set\n");
487 if (NULL != set->mq)
488 {
489 GNUNET_MQ_destroy (set->mq);
490 set->mq = NULL;
491 }
492 GNUNET_free (set);
493}
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETU_destroy() must...
Definition: setu_api.c:61
struct GNUNET_SETU_OperationHandle * ops_head
Linked list of operations on the set.
Definition: setu_api.c:49

References GNUNET_SETU_Handle::destroy_requested, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, LOG, GNUNET_SETU_Handle::mq, and GNUNET_SETU_Handle::ops_head.

Referenced by GNUNET_SETU_operation_cancel(), handle_result(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_prepare()

struct GNUNET_SETU_OperationHandle * GNUNET_SETU_prepare ( const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_HashCode app_id,
const struct GNUNET_MessageHeader context_msg,
const struct GNUNET_SETU_Option  options[],
GNUNET_SETU_ResultIterator  result_cb,
void *  result_cls 
)

Prepare a set operation to be evaluated with another peer.

The evaluation will not start until the client provides a local set with GNUNET_SETU_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
optionsoptions to use when processing the request
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 497 of file setu_api.c.

503{
504 struct GNUNET_MQ_Envelope *mqm;
507
509 "Client prepares set union operation\n");
511 oh->result_cb = result_cb;
512 oh->result_cls = result_cls;
515 context_msg);
516 msg->app_id = *app_id;
517 msg->target_peer = *other_peer;
518
519 /* Set default values */
520 msg->byzantine_upper_bond = UINT64_MAX;
521 msg->bandwidth_latency_tradeoff = 0;
522 msg->ibf_bucket_number_factor = 2;
523 msg->ibf_number_of_buckets_per_element = 3;
524
525
526 for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
527 {
528 switch (opt->type)
529 {
531 msg->byzantine = GNUNET_YES;
532 msg->byzantine_lower_bound = htonl (opt->v.num);
533 break;
535 msg->byzantine_upper_bond = htonl (opt->v.num);
536 break;
538 msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
539 break;
541 msg->ibf_bucket_number_factor = htonl (opt->v.num);
542 break;
544 msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
545 break;
547 msg->force_full = GNUNET_YES;
548 break;
550 msg->force_delta = GNUNET_YES;
551 break;
553 msg->symmetric = GNUNET_YES;
554 break;
555 default:
557 "Option with type %d not recognized\n",
558 (int) opt->type);
559 }
560 }
561 oh->conclude_mqm = mqm;
562 oh->request_id_addr = &msg->request_id;
563 return oh;
564}
#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE
Evaluate a set operation.
Message sent by client to service to initiate a set operation as a client (not as listener).
Definition: setu.h:203
struct GNUNET_HashCode app_id
Application id.
Definition: setu.h:223
Handle to an operation.
Definition: setu_api.c:95
void * result_cls
Closure for result_cb.
Definition: setu_api.c:105
GNUNET_SETU_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: setu_api.c:100
uint32_t * request_id_addr
Address of the request if in the conclude message, used to patch the request id into the message when...
Definition: setu_api.c:123
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called.
Definition: setu_api.c:117
Option for set operations.

References GNUNET_SETU_EvaluateMessage::app_id, GNUNET_SETU_OperationHandle::conclude_mqm, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETU_EVALUATE, GNUNET_MQ_msg_nested_mh, GNUNET_new, GNUNET_SETU_OPTION_BYZANTINE, GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF, GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT, GNUNET_SETU_OPTION_FORCE_DELTA, GNUNET_SETU_OPTION_FORCE_FULL, GNUNET_SETU_OPTION_SYMMETRIC, GNUNET_YES, LOG, msg, options, GNUNET_SETU_OperationHandle::request_id_addr, GNUNET_SETU_OperationHandle::result_cb, and GNUNET_SETU_OperationHandle::result_cls.

Referenced by transmit_task_cb().

Here is the caller graph for this function:

◆ GNUNET_SETU_listen()

struct GNUNET_SETU_ListenHandle * GNUNET_SETU_listen ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_HashCode app_id,
GNUNET_SETU_ListenCallback  listen_cb,
void *  listen_cls 
)

Wait for set operation requests for the given application ID.

If the connection to the set service is lost, the listener is re-created transparently with exponential backoff.

Parameters
cfgconfiguration to use for connecting to the set service
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Wait for set operation requests for the given application ID.

Parameters
cfgconfiguration to use for connecting to the set service, needs to be valid for the lifetime of the listen handle
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Definition at line 717 of file setu_api.c.

721{
722 struct GNUNET_SETU_ListenHandle *lh;
723
725 "Starting listener for app %s\n",
728 lh->listen_cb = listen_cb;
730 lh->cfg = cfg;
731 lh->app_id = *app_id;
733 listen_connect (lh);
734 if (NULL == lh->mq)
735 {
736 GNUNET_free (lh);
737 return NULL;
738 }
739 return lh;
740}
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: setu_api.c:675
Opaque handle to a listen operation.
Definition: setu_api.c:146
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: setu_api.c:173
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: setu_api.c:150
GNUNET_SETU_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: setu_api.c:163
void * listen_cls
Closure for listen_cb.
Definition: setu_api.c:168
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: setu_api.c:178
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Definition: setu_api.c:157

References GNUNET_SETU_ListenHandle::app_id, cfg, GNUNET_SETU_ListenHandle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_new, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_SETU_ListenHandle::listen_cb, listen_cb(), GNUNET_SETU_ListenHandle::listen_cls, listen_connect(), LOG, GNUNET_SETU_ListenHandle::mq, and GNUNET_SETU_ListenHandle::reconnect_backoff.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_listen_cancel()

void GNUNET_SETU_listen_cancel ( struct GNUNET_SETU_ListenHandle lh)

Cancel the given listen operation.

After calling cancel, the listen callback for this listen handle will not be called again. Note that cancelling a listen operation will automatically reject all operations that have not yet been accepted.

Parameters
lhhandle for the listen operation
lhhandle for the listen operation

Definition at line 749 of file setu_api.c.

750{
752 "Canceling listener %s\n",
753 GNUNET_h2s (&lh->app_id));
754 if (NULL != lh->mq)
755 {
756 GNUNET_MQ_destroy (lh->mq);
757 lh->mq = NULL;
758 }
759 if (NULL != lh->reconnect_task)
760 {
762 lh->reconnect_task = NULL;
763 }
764 GNUNET_free (lh);
765}
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: setu_api.c:183

References GNUNET_SETU_ListenHandle::app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_SETU_ListenHandle::mq, and GNUNET_SETU_ListenHandle::reconnect_task.

Referenced by shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_accept()

struct GNUNET_SETU_OperationHandle * GNUNET_SETU_accept ( struct GNUNET_SETU_Request request,
const struct GNUNET_SETU_Option  options[],
GNUNET_SETU_ResultIterator  result_cb,
void *  result_cls 
)

Accept a request we got via GNUNET_SETU_listen().

Must be called during GNUNET_SETU_listen(), as the struct GNUNET_SETU_Request becomes invalid afterwards. Call GNUNET_SETU_commit() to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
optionsoptions to use when processing the request
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 769 of file setu_api.c.

773{
774 struct GNUNET_MQ_Envelope *mqm;
777
778 GNUNET_assert (GNUNET_NO == request->accepted);
780 "Client accepts set union operation with id %u\n",
781 request->accept_id);
782 request->accepted = GNUNET_YES;
783 mqm = GNUNET_MQ_msg (msg,
785 msg->accept_reject_id = htonl (request->accept_id);
786
787 /* Set default values */
788 msg->byzantine_upper_bond = UINT64_MAX;
789 msg->bandwidth_latency_tradeoff = 0;
790 msg->ibf_bucket_number_factor = 2;
791 msg->ibf_number_of_buckets_per_element = 3;
792
793 for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
794 {
795 switch (opt->type)
796 {
798 msg->byzantine = GNUNET_YES;
799 msg->byzantine_lower_bound = htonl (opt->v.num);
800 break;
802 msg->byzantine_upper_bond = htonl (opt->v.num);
803 break;
805 msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
806 break;
808 msg->ibf_bucket_number_factor = htonl (opt->v.num);
809 break;
811 msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
812 break;
814 msg->force_full = GNUNET_YES;
815 break;
817 msg->force_delta = GNUNET_YES;
818 break;
820 msg->symmetric = GNUNET_YES;
821 break;
822 default:
824 "Option with type %d not recognized\n",
825 (int) opt->type);
826 }
827 }
829 oh->result_cb = result_cb;
830 oh->result_cls = result_cls;
831 oh->conclude_mqm = mqm;
832 oh->request_id_addr = &msg->request_id;
833 return oh;
834}
#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT
Accept an incoming set request.
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: setu.h:79

References GNUNET_SETU_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETU_ACCEPT, GNUNET_MQ_msg, GNUNET_new, GNUNET_NO, GNUNET_SETU_OPTION_BYZANTINE, GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF, GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT, GNUNET_SETU_OPTION_FORCE_DELTA, GNUNET_SETU_OPTION_FORCE_FULL, GNUNET_SETU_OPTION_SYMMETRIC, GNUNET_YES, LOG, msg, options, request, GNUNET_SETU_OperationHandle::request_id_addr, GNUNET_SETU_OperationHandle::result_cb, and GNUNET_SETU_OperationHandle::result_cls.

Referenced by handle_revocation_union_request().

Here is the caller graph for this function:

◆ GNUNET_SETU_commit()

int GNUNET_SETU_commit ( struct GNUNET_SETU_OperationHandle oh,
struct GNUNET_SETU_Handle set 
)

Commit a set to be used with a set operation.

This function is called once we have fully constructed the set that we want to use for the operation. At this time, the P2P protocol can then begin to exchange the set information and call the result callback with the result information.

Parameters
ohhandle to the set operation
setthe set to use for the operation
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 851 of file setu_api.c.

853{
854 if (NULL != oh->set)
855 {
856 /* Some other set was already committed for this
857 * operation, there is a logic bug in the client of this API */
858 GNUNET_break (0);
859 return GNUNET_OK;
860 }
861 GNUNET_assert (NULL != set);
862 if (GNUNET_YES == set->invalid)
863 return GNUNET_SYSERR;
865 "Client commits to SET\n");
866 GNUNET_assert (NULL != oh->conclude_mqm);
867 oh->set = set;
869 set->ops_tail,
870 oh);
872 oh);
873 *oh->request_id_addr = htonl (oh->request_id);
874 GNUNET_MQ_send (set->mq,
875 oh->conclude_mqm);
876 oh->conclude_mqm = NULL;
877 oh->request_id_addr = NULL;
878 return GNUNET_OK;
879}
struct GNUNET_SETU_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: setu_api.c:54
struct GNUNET_SETU_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
Definition: setu_api.c:111
uint32_t request_id
Request ID to identify the operation within the set.
Definition: setu_api.c:138

References GNUNET_SETU_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_assoc_add(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETU_Handle::invalid, LOG, GNUNET_SETU_Handle::mq, GNUNET_SETU_Handle::ops_head, GNUNET_SETU_Handle::ops_tail, GNUNET_SETU_OperationHandle::request_id, GNUNET_SETU_OperationHandle::request_id_addr, and GNUNET_SETU_OperationHandle::set.

Referenced by handle_revocation_union_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_operation_cancel()

void GNUNET_SETU_operation_cancel ( struct GNUNET_SETU_OperationHandle oh)

Cancel the given set operation.

May not be called after the operation's GNUNET_SETU_ResultIterator has been called with a status of GNUNET_SETU_STATUS_FAILURE or GNUNET_SETU_STATUS_DONE.

Parameters
ohset operation to cancel

We need to send an explicit cancel message, as all operations one one set communicate using one handle.

Parameters
ohset operation to cancel

Definition at line 320 of file setu_api.c.

321{
322 struct GNUNET_SETU_Handle *set = oh->set;
324 struct GNUNET_MQ_Envelope *mqm;
325
327 "Cancelling SET operation\n");
328 if (NULL != set)
329 {
331 m->request_id = htonl (oh->request_id);
332 GNUNET_MQ_send (set->mq, mqm);
333 }
335 if ((NULL != set) &&
336 (GNUNET_YES == set->destroy_requested) &&
337 (NULL == set->ops_head))
338 {
340 "Destroying set after operation cancel\n");
342 }
343}
#define GNUNET_MESSAGE_TYPE_SETU_CANCEL
Cancel a set operation.
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
Definition: setu_api.c:471
static void set_operation_destroy(struct GNUNET_SETU_OperationHandle *oh)
Destroy the given set operation.
Definition: setu_api.c:290
Sent to the service by the client in order to cancel a set operation.
Definition: setu.h:350

References GNUNET_SETU_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETU_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SETU_destroy(), GNUNET_YES, LOG, m, GNUNET_SETU_Handle::mq, GNUNET_SETU_Handle::ops_head, GNUNET_SETU_OperationHandle::request_id, GNUNET_SETU_OperationHandle::set, and set_operation_destroy().

Referenced by handle_core_disconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_element_hash()

void GNUNET_SETU_element_hash ( const struct GNUNET_SETU_Element element,
struct GNUNET_HashCode ret_hash 
)

Hash a set element.

Parameters
elementthe element that should be hashed
[out]ret_hasha pointer to where the hash of element should be stored

Definition at line 890 of file setu_api.c.

892{
894
895 /* It's not guaranteed that the element data is always after the element header,
896 so we need to hash the chunks separately. */
898 &element->size,
899 sizeof(uint16_t));
901 &element->element_type,
902 sizeof(uint16_t));
904 element->data,
905 element->size);
907 ret_hash);
908}

References ctx, GNUNET_SETU_Element::data, GNUNET_SETU_Element::element_type, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), and GNUNET_SETU_Element::size.

Referenced by handle_client_set_add(), handle_union_p2p_elements(), and handle_union_p2p_full_element().

Here is the call graph for this function:
Here is the caller graph for this function: