GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
Set service

Two-peer set operations. More...

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
}
 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 55 of file gnunet_set_service.h.

Referenced by check_incoming_msg().

◆ 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 52 of file gnunet_seti_service.h.

Referenced by check_incoming_msg().

◆ 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 52 of file gnunet_setu_service.h.

Referenced by check_incoming_msg().

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 273 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 286 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 300 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, whith sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 320 of file gnunet_set_service.h.

◆ GNUNET_SET_CopyReadyCallback

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

Definition at line 327 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 179 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, whith sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 201 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 200 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, whith sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 222 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 82 of file gnunet_set_service.h.

83 {
88 
93 
98 };
A purely local set that does not support any operation.
Set intersection, only return elements that are in both sets.
Set union, return all elements that are in at least one of the sets.

◆ 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 104 of file gnunet_set_service.h.

105 {
117 
126 
135 
141 
148 
153 };
Element should be added to the result set of the remote peer, i.e.
Element should be added to the result set of the local peer, i.e.
Success, all elements have been sent (and received).
The other peer refused to to the operation with us, or something went wrong.
Success, all elements have been returned (but the other peer might still be receiving some from us...
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set...

◆ 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 159 of file gnunet_set_service.h.

160 {
167 
175 
182 
189 };
Client gets only elements that have been added to the set.
Client gets every element in the resulting set.
Client gets notified of the required changes for both the local and the remote set.
Client gets only elements that have been removed from 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 219 of file gnunet_set_service.h.

220 {
244 };
Do not use the optimized set operation, but send full sets.
Only use optimized set operations, even though for this particular set operation they might be much s...
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...

◆ 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 78 of file gnunet_seti_service.h.

79 {
80 
86 
92 
98 
103 };
Success, all elements have been sent (and received).
The other peer refused to do the operation with us, or something went wrong.
Element should be added to the result set of the local peer, i.e.
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 133 of file gnunet_seti_service.h.

134 {
139 
146 };
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL). ...

◆ 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 78 of file gnunet_setu_service.h.

79 {
80 
86 
93 
99 
104 };
The other peer refused to do the operation with us, or something went wrong.
Success, all elements have been sent (and received).
Element should be added to the result set of the local peer, i.e.
Element should be added to the result set of the remote 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.

Definition at line 134 of file gnunet_setu_service.h.

135 {
140 
149 
155 
162 
167 };
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...
Notify client also if we are sending a value to the other peer.
Do not use the optimized set operation, but send full sets.
Only use optimized set operations, even though for this particular set operation they might be much s...

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 spefific to the operation
Returns
a handle to the set

Definition at line 657 of file set_api.c.

References create_internal(), GNUNET_ERROR_TYPE_DEBUG, and LOG.

Referenced by commit_set(), handle_client_join(), and run().

659 {
660  struct GNUNET_SET_Handle *set;
661 
662  set = create_internal (cfg,
663  op,
664  NULL);
666  "Creating set %p for operation %d\n",
667  set,
668  op);
669  return set;
670 }
#define LOG(kind,...)
Definition: set_api.c:33
Opaque handle to a set.
Definition: set_api.c:49
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
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
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)

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Multiple 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 687 of file set_api.c.

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_SET_ElementMessage::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, LOG, msg, and GNUNET_SET_Element::size.

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

691 {
692  struct GNUNET_MQ_Envelope *mqm;
694 
696  "adding element of type %u to set %p\n",
697  (unsigned int) element->element_type,
698  set);
699  GNUNET_assert (NULL != set);
700  if (GNUNET_YES == set->invalid)
701  {
702  if (NULL != cont)
703  cont (cont_cls);
704  return GNUNET_SYSERR;
705  }
706  mqm = GNUNET_MQ_msg_extra (msg,
707  element->size,
709  msg->element_type = htons (element->element_type);
710  GNUNET_memcpy (&msg[1],
711  element->data,
712  element->size);
714  cont, cont_cls);
715  GNUNET_MQ_send (set->mq, mqm);
716  return GNUNET_OK;
717 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_MESSAGE_TYPE_SET_ADD
Add element to set.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t element_type
Type of the element to add or remove.
Definition: set.h:291
const void * data
Actual data of the element.
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54
#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:52
int invalid
Has the set become invalid (e.g.
Definition: set_api.c:87
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:787
uint16_t size
Number of bytes in the buffer pointed to by data.
Message sent by client to the service to add or remove an element to/from the set.
Definition: set.h:280
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:355
uint16_t element_type
Application-specific element type.
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. Calls to 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)

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 734 of file set_api.c.

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_SET_ElementMessage::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, LOG, msg, and GNUNET_SET_Element::size.

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

738 {
739  struct GNUNET_MQ_Envelope *mqm;
741 
743  "Removing element from set %p\n",
744  set);
745  if (GNUNET_YES == set->invalid)
746  {
747  if (NULL != cont)
748  cont (cont_cls);
749  return GNUNET_SYSERR;
750  }
751  mqm = GNUNET_MQ_msg_extra (msg,
752  element->size,
754  msg->element_type = htons (element->element_type);
755  GNUNET_memcpy (&msg[1],
756  element->data,
757  element->size);
759  cont, cont_cls);
760  GNUNET_MQ_send (set->mq, mqm);
761  return GNUNET_OK;
762 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t element_type
Type of the element to add or remove.
Definition: set.h:291
const void * data
Actual data of the element.
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54
#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:52
int invalid
Has the set become invalid (e.g.
Definition: set_api.c:87
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:787
#define GNUNET_MESSAGE_TYPE_SET_REMOVE
Remove element from set.
uint16_t size
Number of bytes in the buffer pointed to by data.
Message sent by client to the service to add or remove an element to/from the set.
Definition: set.h:280
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:355
uint16_t element_type
Application-specific element type.
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 1194 of file set_api.c.

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

Referenced by create_set_copy_for_task().

1197 {
1198  struct GNUNET_MQ_Envelope *ev;
1199  struct SetCopyRequest *req;
1200 
1202  "Creating lazy copy of set\n");
1204  GNUNET_MQ_send (set->mq, ev);
1205 
1206  req = GNUNET_new (struct SetCopyRequest);
1207  req->cb = cb;
1208  req->cls = cls;
1210  set->copy_req_tail,
1211  req);
1212 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#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
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * cls
Definition: set_api.c:41
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54
GNUNET_SET_CopyReadyCallback cb
Definition: set_api.c:43
struct SetCopyRequest * copy_req_tail
Doubly linked list of copy requests.
Definition: set_api.c:108
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
Definition: gnunet_mq_lib.h:76
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:355
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 772 of file set_api.c.

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, and LOG.

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

773 {
774  /* destroying set while iterator is active is currently
775  not supported; we should expand the API to allow
776  clients to explicitly cancel the iteration! */
777  GNUNET_assert (NULL != set);
778  if ((NULL != set->ops_head) ||
779  (NULL != set->iterator) ||
781  {
783  "Set operations are pending, delaying set destruction\n");
784  set->destroy_requested = GNUNET_YES;
785  return;
786  }
788  "Really destroying set\n");
789  if (NULL != set->mq)
790  {
791  GNUNET_MQ_destroy (set->mq);
792  set->mq = NULL;
793  }
794  GNUNET_free (set);
795 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54
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
struct GNUNET_SET_OperationHandle * ops_head
Linked list of operations on the set.
Definition: set_api.c:59
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
#define GNUNET_free(ptr)
Wrapper around free.
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

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 813 of file set_api.c.

References app_id, GNUNET_SET_EvaluateMessage::app_id, GNUNET_SET_EvaluateMessage::byzantine, GNUNET_SET_EvaluateMessage::byzantine_lower_bound, SetCopyRequest::cls, GNUNET_SET_OperationHandle::conclude_mqm, GNUNET_SET_EvaluateMessage::force_delta, GNUNET_SET_EvaluateMessage::force_full, 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, listen_connect(), LOG, msg, GNUNET_SET_Option::num, oh, GNUNET_SET_EvaluateMessage::request_id, GNUNET_SET_OperationHandle::request_id_addr, GNUNET_SET_OperationHandle::result_cb, GNUNET_SET_OperationHandle::result_cls, GNUNET_SET_EvaluateMessage::result_mode, GNUNET_SET_EvaluateMessage::target_peer, GNUNET_SET_Option::type, and GNUNET_SET_Option::v.

Referenced by run(), and task_start_reconcile().

820 {
821  struct GNUNET_MQ_Envelope *mqm;
824  struct GNUNET_SET_Option *opt;
825 
827  "Client prepares set operation (%d)\n",
828  result_mode);
830  oh->result_cb = result_cb;
831  oh->result_cls = result_cls;
832  mqm = GNUNET_MQ_msg_nested_mh (msg,
834  context_msg);
835  msg->app_id = *app_id;
836  msg->result_mode = htonl (result_mode);
837  msg->target_peer = *other_peer;
838  for (opt = options; opt->type != 0; opt++)
839  {
840  switch (opt->type)
841  {
843  msg->byzantine = GNUNET_YES;
844  msg->byzantine_lower_bound = opt->v.num;
845  break;
846 
848  msg->force_full = GNUNET_YES;
849  break;
850 
852  msg->force_delta = GNUNET_YES;
853  break;
854 
855  default:
857  "Option with type %d not recognized\n", (int) opt->type);
858  }
859  }
860  oh->conclude_mqm = mqm;
861  oh->request_id_addr = &msg->request_id;
862 
863  return oh;
864 }
struct GNUNET_PeerIdentity target_peer
Peer to evaluate the operation with.
Definition: set.h:196
void * result_cls
Closure for result_cb.
Definition: set_api.c:146
union GNUNET_SET_Option::@54 v
Value for the option, only used with some options.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct...
Do not use the optimized set operation, but send full sets.
#define GNUNET_MESSAGE_TYPE_SET_EVALUATE
Evaluate a set operation.
static struct GNUNET_HashCode app_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t result_mode
How should results be sent to us? See enum GNUNET_SET_ResultMode.
Definition: set.h:191
uint8_t force_full
Always send full sets, even if delta operations would be more efficient.
Definition: set.h:219
enum GNUNET_SET_OptionType type
Type of the option.
#define LOG(kind,...)
Definition: set_api.c:33
GNUNET_SET_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: set_api.c:141
Only use optimized set operations, even though for this particular set operation they might be much s...
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
uint8_t force_delta
Always use delta operation instead of sending full sets, even it it&#39;s less efficient.
Definition: set.h:213
uint32_t request_id
Id of our set to evaluate, chosen implicitly by the client when it calls GNUNET_SET_commit().
Definition: set.h:207
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
uint8_t byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
Definition: set.h:225
uint8_t byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
Definition: set.h:231
Message sent by client to service to initiate a set operation as a client (not as listener)...
Definition: set.h:180
Option for set operations.
Handle to an operation.
Definition: set_api.c:135
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
struct GNUNET_HashCode app_id
Application id.
Definition: set.h:201
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...
Here is the call graph for this function:
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 1017 of file set_api.c.

References app_id, 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(), and run().

1022 {
1023  struct GNUNET_SET_ListenHandle *lh;
1024 
1026  "Starting listener for app %s\n",
1027  GNUNET_h2s (app_id));
1028  lh = GNUNET_new (struct GNUNET_SET_ListenHandle);
1029  lh->listen_cb = listen_cb;
1030  lh->listen_cls = listen_cls;
1031  lh->cfg = cfg;
1032  lh->operation = operation;
1033  lh->app_id = *app_id;
1035  listen_connect (lh);
1036  if (NULL == lh->mq)
1037  {
1038  GNUNET_free (lh);
1039  return NULL;
1040  }
1041  return lh;
1042 }
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: set_api.c:191
void * listen_cls
Closure for listen_cb.
Definition: set_api.c:209
GNUNET_SET_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: set_api.c:204
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_HashCode app_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: set_api.c:219
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: set_api.c:974
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: set_api.c:214
enum GNUNET_SET_OperationType operation
Operation we listen for.
Definition: set_api.c:229
Opaque handle to a listen operation.
Definition: set_api.c:186
#define GNUNET_free(ptr)
Wrapper around free.
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
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 1051 of file set_api.c.

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(), and handle_shutdown().

1052 {
1054  "Canceling listener %s\n",
1055  GNUNET_h2s (&lh->app_id));
1056  if (NULL != lh->mq)
1057  {
1058  GNUNET_MQ_destroy (lh->mq);
1059  lh->mq = NULL;
1060  }
1061  if (NULL != lh->reconnect_task)
1062  {
1064  lh->reconnect_task = NULL;
1065  }
1066  GNUNET_free (lh);
1067 }
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: set_api.c:191
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: set_api.c:214
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: set_api.c:224
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
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

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 1085 of file set_api.c.

References GNUNET_SET_Request::accept_id, GNUNET_SET_AcceptMessage::accept_reject_id, GNUNET_SET_Request::accepted, 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, oh, GNUNET_SET_AcceptMessage::request_id, 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().

1090 {
1091  struct GNUNET_MQ_Envelope *mqm;
1093  struct GNUNET_SET_AcceptMessage *msg;
1094 
1095  GNUNET_assert (GNUNET_NO == request->accepted);
1097  "Client accepts set operation (%d) with id %u\n",
1098  result_mode,
1099  request->accept_id);
1100  request->accepted = GNUNET_YES;
1101  mqm = GNUNET_MQ_msg (msg,
1103  msg->accept_reject_id = htonl (request->accept_id);
1104  msg->result_mode = htonl (result_mode);
1105  oh = GNUNET_new (struct GNUNET_SET_OperationHandle);
1106  oh->result_cb = result_cb;
1107  oh->result_cls = result_cls;
1108  oh->conclude_mqm = mqm;
1109  oh->request_id_addr = &msg->request_id;
1110  return oh;
1111 }
void * result_cls
Closure for result_cb.
Definition: set_api.c:146
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint32_t request_id
Request ID to identify responses.
Definition: set.h:97
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_SET_ACCEPT
Accept a set request.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define LOG(kind,...)
Definition: set_api.c:33
int accepted
Has the request been accepted already? GNUNET_YES/GNUNET_NO.
Definition: set_api.c:127
GNUNET_SET_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: set_api.c:141
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
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
uint32_t accept_id
Id of the request, used to identify the request when accepting/rejecting it.
Definition: set_api.c:121
uint32_t result_mode
How should results be sent to us? See enum GNUNET_SET_ResultMode.
Definition: set.h:103
uint32_t accept_reject_id
ID of the incoming request we want to accept.
Definition: set.h:92
Handle to an operation.
Definition: set_api.c:135
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
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: set.h:82
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 1128 of file set_api.c.

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, LOG, GNUNET_SET_OperationHandle::request_id, GNUNET_SET_OperationHandle::request_id_addr, and GNUNET_SET_OperationHandle::set.

Referenced by commit_set(), run(), and set_listen_cb().

1130 {
1131  if (NULL != oh->set)
1132  {
1133  /* Some other set was already committed for this
1134  * operation, there is a logic bug in the client of this API */
1135  GNUNET_break (0);
1136  return GNUNET_OK;
1137  }
1138  GNUNET_assert (NULL != set);
1139  if (GNUNET_YES == set->invalid)
1140  return GNUNET_SYSERR;
1142  "Client commits to SET\n");
1143  GNUNET_assert (NULL != oh->conclude_mqm);
1144  oh->set = set;
1146  set->ops_tail,
1147  oh);
1148  oh->request_id = GNUNET_MQ_assoc_add (set->mq,
1149  oh);
1150  *oh->request_id_addr = htonl (oh->request_id);
1151  GNUNET_MQ_send (set->mq,
1152  oh->conclude_mqm);
1153  oh->conclude_mqm = NULL;
1154  oh->request_id_addr = NULL;
1155  return GNUNET_OK;
1156 }
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
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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:721
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SET_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: set_api.c:64
uint32_t request_id
Request ID to identify the operation within the set.
Definition: set_api.c:179
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54
int invalid
Has the set become invalid (e.g.
Definition: set_api.c:87
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
struct GNUNET_SET_OperationHandle * ops_head
Linked list of operations on the set.
Definition: set_api.c:59
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
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:355
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.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SET_destroy(), GNUNET_YES, LOG, m, GNUNET_SET_OperationHandle::request_id, GNUNET_SET_CancelMessage::request_id, GNUNET_SET_OperationHandle::set, and set_operation_destroy().

Referenced by commit_set(), and handle_shutdown().

517 {
518  struct GNUNET_SET_Handle *set = oh->set;
519  struct GNUNET_SET_CancelMessage *m;
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 }
#define GNUNET_MESSAGE_TYPE_SET_CANCEL
Cancel a set operation.
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
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint32_t request_id
Request ID to identify the operation within the set.
Definition: set_api.c:179
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:772
#define LOG(kind,...)
Definition: set_api.c:33
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
Opaque handle to a set.
Definition: set_api.c:49
Sent to the service by the client in order to cancel a set operation.
Definition: set.h:306
static void set_operation_destroy(struct GNUNET_SET_OperationHandle *oh)
Destroy the given set operation.
Definition: set_api.c:486
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:355
uint32_t request_id
ID of the request we want to cancel.
Definition: set.h:316
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 successfuly, 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 successfuly, GNUNET_NO if another iteration is active GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected)

Definition at line 1172 of file set_api.c.

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, and LOG.

Referenced by task_start_finish().

1175 {
1176  struct GNUNET_MQ_Envelope *ev;
1177 
1178  GNUNET_assert (NULL != iter);
1179  if (GNUNET_YES == set->invalid)
1180  return GNUNET_SYSERR;
1181  if (NULL != set->iterator)
1182  return GNUNET_NO;
1184  "Iterating over set\n");
1185  set->iterator = iter;
1186  set->iterator_cls = iter_cls;
1188  GNUNET_MQ_send (set->mq, ev);
1189  return GNUNET_YES;
1190 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define LOG(kind,...)
Definition: set_api.c:33
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54
int invalid
Has the set become invalid (e.g.
Definition: set_api.c:87
#define GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST
Start iteration over set elements.
GNUNET_SET_ElementIterator iterator
Callback for the current iteration over the set, NULL if no iterator is active.
Definition: set_api.c:70
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
Definition: gnunet_mq_lib.h:76
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:355
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 1223 of file set_api.c.

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().

1224 {
1225  struct GNUNET_SET_Element *copy;
1226 
1227  copy = GNUNET_malloc (element->size + sizeof(struct GNUNET_SET_Element));
1228  copy->size = element->size;
1229  copy->element_type = element->element_type;
1230  copy->data = &copy[1];
1231  GNUNET_memcpy (&copy[1],
1232  element->data,
1233  copy->size);
1234  return copy;
1235 }
Element stored in a set.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const void * data
Actual data of the element.
uint16_t size
Number of bytes in the buffer pointed to by data.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint16_t element_type
Application-specific element type.
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
ret_hasha pointer to where the hash of element should be stored
elementthe element that should be hashed
[out]ret_hasha pointer to where the hash of element should be stored

Definition at line 1246 of file set_api.c.

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(), diffname(), execute_add(), execute_remove(), handle_union_p2p_elements(), handle_union_p2p_full_element(), and rfn_vote().

1248 {
1250 
1251  /* It's not guaranteed that the element data is always after the element header,
1252  so we need to hash the chunks separately. */
1253  GNUNET_CRYPTO_hash_context_read (ctx, &element->size, sizeof(uint16_t));
1255  sizeof(uint16_t));
1256  GNUNET_CRYPTO_hash_context_read (ctx, element->data, element->size);
1257  GNUNET_CRYPTO_hash_context_finish (ctx, ret_hash);
1258 }
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:483
Context for cummulative hashing.
Definition: crypto_hash.c:468
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
const void * data
Actual data of the element.
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:509
uint16_t size
Number of bytes in the buffer pointed to by data.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:526
uint16_t element_type
Application-specific element type.
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.

References 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, and result.

Referenced by handle_alice_client_message(), handle_bob_client_message(), and run().

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;
413  set->mq = GNUNET_CLIENT_connect (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 }
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
Definition: seti.h:191
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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:1063
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Opaque handle to a set.
Definition: seti_api.c:39
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define LOG(kind,...)
Definition: seti_api.c:33
static int result
Global testing status.
#define GNUNET_MESSAGE_TYPE_SETI_RESULT
Handle result message from operation.
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:39
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:355
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 GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSAGE_TYPE_SETI_CREATE
Create a new local set.
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.

References GNUNET_SETI_Element::data, GNUNET_SETI_Element::element_type, GNUNET_SETI_ElementMessage::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, LOG, msg, and GNUNET_SETI_Element::size.

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

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  }
465  mqm = GNUNET_MQ_msg_extra (msg,
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 }
int invalid
Has the set become invalid (e.g.
Definition: seti_api.c:71
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint16_t size
Number of bytes in the buffer pointed to by data.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t element_type
Type of the element to add or remove.
Definition: seti.h:236
#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:52
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:787
#define LOG(kind,...)
Definition: seti_api.c:33
const void * data
Actual data of the element.
#define GNUNET_MESSAGE_TYPE_SETI_ADD
Add element to set.
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: seti_api.c:44
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:355
Message sent by client to the service to add an element to the set.
Definition: seti.h:226
uint16_t element_type
Application-specific element type.
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.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, and LOG.

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

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");
498  set->destroy_requested = GNUNET_YES;
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 }
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
#define LOG(kind,...)
Definition: seti_api.c:33
struct GNUNET_SETI_OperationHandle * ops_head
Linked list of operations on the set.
Definition: seti_api.c:49
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: seti_api.c:44
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
#define GNUNET_free(ptr)
Wrapper around free.
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

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 526 of file seti_api.c.

References app_id, 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, listen_connect(), LOG, msg, oh, GNUNET_SETI_EvaluateMessage::request_id, GNUNET_SETI_OperationHandle::request_id_addr, GNUNET_SETI_OperationHandle::result_cb, GNUNET_SETI_OperationHandle::result_cls, GNUNET_SETI_EvaluateMessage::return_intersection, and GNUNET_SETI_EvaluateMessage::target_peer.

Referenced by run(), and start_intersection().

532 {
533  struct GNUNET_MQ_Envelope *mqm;
536 
538  oh->result_cb = result_cb;
539  oh->result_cls = result_cls;
540  mqm = GNUNET_MQ_msg_nested_mh (msg,
542  context_msg);
543  msg->app_id = *app_id;
544  msg->target_peer = *other_peer;
545  for (const struct GNUNET_SETI_Option *opt = options;
546  GNUNET_SETI_OPTION_END != opt->type;
547  opt++)
548  {
549  switch (opt->type)
550  {
552  msg->return_intersection = htonl (GNUNET_YES);
553  break;
554  default:
556  "Option with type %d not recognized\n",
557  (int) opt->type);
558  }
559  }
560  oh->conclude_mqm = mqm;
561  oh->request_id_addr = &msg->request_id;
562  return oh;
563 }
uint32_t request_id
Id of our set to evaluate, chosen implicitly by the client when it calls GNUNET_SETI_commit().
Definition: seti.h:162
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#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_SETI_EVALUATE
Evaluate a set operation.
Option for set operations.
static struct GNUNET_HashCode app_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * result_cls
Closure for result_cb.
Definition: seti_api.c:116
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
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
struct GNUNET_HashCode app_id
Application id.
Definition: seti.h:172
#define LOG(kind,...)
Definition: seti_api.c:33
Handle to an operation.
Definition: seti_api.c:105
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_PeerIdentity target_peer
Peer to evaluate the operation with.
Definition: seti.h:167
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL). ...
GNUNET_SETI_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: seti_api.c:111
uint32_t return_intersection
Return the intersection (1), instead of the elements to remove / the delta (0), in NBO...
Definition: seti.h:178
Message sent by client to service to initiate a set operation as a client (not as listener)...
Definition: seti.h:151
Here is the call graph for this function:
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 715 of file seti_api.c.

References app_id, GNUNET_SETI_ListenHandle::app_id, GNUNET_SETI_Handle::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(), and run().

719 {
720  struct GNUNET_SETI_ListenHandle *lh;
721 
723  "Starting listener for app %s\n",
724  GNUNET_h2s (app_id));
725  lh = GNUNET_new (struct GNUNET_SETI_ListenHandle);
726  lh->listen_cb = listen_cb;
727  lh->listen_cls = listen_cls;
728  lh->cfg = cfg;
729  lh->app_id = *app_id;
731  listen_connect (lh);
732  if (NULL == lh->mq)
733  {
734  GNUNET_free (lh);
735  return NULL;
736  }
737  return lh;
738 }
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_HashCode app_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * listen_cls
Closure for listen_cb.
Definition: seti_api.c:185
Opaque handle to a listen operation.
Definition: seti_api.c:162
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
#define LOG(kind,...)
Definition: seti_api.c:33
#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: seti_api.c:674
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
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: seti_api.c:195
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 747 of file seti_api.c.

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(), destroy_service_session(), and handle_shutdown().

748 {
750  "Canceling listener %s\n",
751  GNUNET_h2s (&lh->app_id));
752  if (NULL != lh->mq)
753  {
754  GNUNET_MQ_destroy (lh->mq);
755  lh->mq = NULL;
756  }
757  if (NULL != lh->reconnect_task)
758  {
760  lh->reconnect_task = NULL;
761  }
762  GNUNET_free (lh);
763 }
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define LOG(kind,...)
Definition: seti_api.c:33
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: seti_api.c:190
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: seti_api.c:167
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: seti_api.c:195
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
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

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 780 of file seti_api.c.

References GNUNET_SETI_Request::accept_id, GNUNET_SETI_AcceptMessage::accept_reject_id, GNUNET_SETI_Request::accepted, 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, oh, GNUNET_SETI_AcceptMessage::request_id, GNUNET_SETI_OperationHandle::request_id_addr, GNUNET_SETI_OperationHandle::result_cb, GNUNET_SETI_OperationHandle::result_cls, GNUNET_SETI_AcceptMessage::return_intersection, and GNUNET_SETI_OperationHandle::return_intersection.

Referenced by cb_intersection_request_alice(), and set_listen_cb().

784 {
785  struct GNUNET_MQ_Envelope *mqm;
788 
789  GNUNET_assert (GNUNET_NO == request->accepted);
791  "Client accepts set intersection operation with id %u\n",
792  request->accept_id);
793  request->accepted = GNUNET_YES;
794  mqm = GNUNET_MQ_msg (msg,
796  msg->accept_reject_id = htonl (request->accept_id);
798  oh->result_cb = result_cb;
799  oh->result_cls = result_cls;
800  oh->conclude_mqm = mqm;
801  oh->request_id_addr = &msg->request_id;
802  for (const struct GNUNET_SETI_Option *opt = options;
803  GNUNET_SETI_OPTION_END != opt->type;
804  opt++)
805  {
806  switch (opt->type)
807  {
810  msg->return_intersection = htonl (GNUNET_YES);
811  break;
812  default:
814  "Option with type %d not recognized\n",
815  (int) opt->type);
816  }
817  }
818  return oh;
819 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint32_t accept_id
Id of the request, used to identify the request when accepting/rejecting it.
Definition: seti_api.c:91
#define GNUNET_MESSAGE_TYPE_SETI_ACCEPT
Accept an incoming set request.
Option for set operations.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: seti.h:76
uint32_t accept_reject_id
ID of the incoming request we want to accept.
Definition: seti.h:86
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t return_intersection
Return the intersection (1), instead of the elements to remove / the delta (0), in NBO...
Definition: seti.h:97
void * result_cls
Closure for result_cb.
Definition: seti_api.c:116
int accepted
Has the request been accepted already? GNUNET_YES/GNUNET_NO.
Definition: seti_api.c:97
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
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
#define LOG(kind,...)
Definition: seti_api.c:33
Handle to an operation.
Definition: seti_api.c:105
uint32_t request_id
Request ID to identify responses.
Definition: seti.h:91
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
int return_intersection
Should we return the resulting intersection (ADD) or the elements to remove (DEL)?
Definition: seti_api.c:155
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL). ...
GNUNET_SETI_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: seti_api.c:111
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 836 of file seti_api.c.

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, LOG, GNUNET_SETI_OperationHandle::request_id, GNUNET_SETI_OperationHandle::request_id_addr, and GNUNET_SETI_OperationHandle::set.

Referenced by cb_intersection_request_alice(), run(), and set_listen_cb().

838 {
839  if (NULL != oh->set)
840  {
841  /* Some other set was already committed for this
842  * operation, there is a logic bug in the client of this API */
843  GNUNET_break (0);
844  return GNUNET_OK;
845  }
846  GNUNET_assert (NULL != set);
847  if (GNUNET_YES == set->invalid)
848  return GNUNET_SYSERR;
850  "Client commits to SET\n");
851  GNUNET_assert (NULL != oh->conclude_mqm);
852  oh->set = set;
854  set->ops_tail,
855  oh);
856  oh->request_id = GNUNET_MQ_assoc_add (set->mq,
857  oh);
858  *oh->request_id_addr = htonl (oh->request_id);
859  GNUNET_MQ_send (set->mq,
860  oh->conclude_mqm);
861  oh->conclude_mqm = NULL;
862  oh->request_id_addr = NULL;
863  return GNUNET_OK;
864 }
int invalid
Has the set become invalid (e.g.
Definition: seti_api.c:71
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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:721
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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
#define LOG(kind,...)
Definition: seti_api.c:33
struct GNUNET_SETI_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: seti_api.c:54
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
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
struct GNUNET_SETI_OperationHandle * ops_head
Linked list of operations on the set.
Definition: seti_api.c:49
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: seti_api.c:44
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:355
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.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETI_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SETI_destroy(), GNUNET_YES, LOG, m, GNUNET_SETI_OperationHandle::request_id, GNUNET_SETI_CancelMessage::request_id, GNUNET_SETI_OperationHandle::set, and set_operation_destroy().

Referenced by destroy_service_session(), and handle_shutdown().

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");
356  GNUNET_SETI_destroy (set);
357  }
358 }
Sent to the service by the client in order to cancel a set operation.
Definition: seti.h:251
#define GNUNET_MESSAGE_TYPE_SETI_CANCEL
Cancel a set operation.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
Opaque handle to a set.
Definition: seti_api.c:39
uint32_t request_id
ID of the request we want to cancel.
Definition: seti.h:261
#define LOG(kind,...)
Definition: seti_api.c:33
static void set_operation_destroy(struct GNUNET_SETI_OperationHandle *oh)
Destroy the given set operation.
Definition: seti_api.c:305
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
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:355
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
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 875 of file seti_api.c.

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().

877 {
879 
880  /* It's not guaranteed that the element data is always after the element header,
881  so we need to hash the chunks separately. */
883  &element->size,
884  sizeof(uint16_t));
886  &element->element_type,
887  sizeof(uint16_t));
889  element->data,
890  element->size);
892  ret_hash);
893 }
uint16_t size
Number of bytes in the buffer pointed to by data.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:483
Context for cummulative hashing.
Definition: crypto_hash.c:468
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
const void * data
Actual data of the element.
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:509
uint16_t element_type
Application-specific element type.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:526
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 383 of file setu_api.c.

References 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(), and result.

Referenced by run().

384 {
385  struct GNUNET_SETU_Handle *set = GNUNET_new (struct GNUNET_SETU_Handle);
386  struct GNUNET_MQ_MessageHandler mq_handlers[] = {
390  set),
392  };
393  struct GNUNET_MQ_Envelope *mqm;
394  struct GNUNET_SETU_CreateMessage *create_msg;
395 
396  set->mq = GNUNET_CLIENT_connect (cfg,
397  "setu",
398  mq_handlers,
400  set);
401  if (NULL == set->mq)
402  {
403  GNUNET_free (set);
404  return NULL;
405  }
406  mqm = GNUNET_MQ_msg (create_msg,
408  GNUNET_MQ_send (set->mq,
409  mqm);
410  return set;
411 }
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:1063
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:353
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Message sent by the client to the service to ask starting a new set to perform operations with...
Definition: setu.h:40
#define GNUNET_MESSAGE_TYPE_SETU_RESULT
Handle result message from operation.
Opaque handle to a set.
Definition: setu_api.c:38
#define GNUNET_MESSAGE_TYPE_SETU_CREATE
Create a new local set.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static int result
Global testing status.
Message handler for a specific message type.
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
Definition: setu.h:239
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:355
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
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 428 of file setu_api.c.

References GNUNET_SETU_Element::data, GNUNET_SETU_Element::element_type, GNUNET_SETU_ElementMessage::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, LOG, msg, and GNUNET_SETU_Element::size.

Referenced by publicize_rm(), and set_insert_iterator().

432 {
433  struct GNUNET_MQ_Envelope *mqm;
435 
437  "adding element of type %u to set %p\n",
438  (unsigned int) element->element_type,
439  set);
440  GNUNET_assert (NULL != set);
441  if (GNUNET_YES == set->invalid)
442  {
443  if (NULL != cb)
444  cb (cb_cls);
445  return GNUNET_SYSERR;
446  }
447  mqm = GNUNET_MQ_msg_extra (msg,
448  element->size,
450  msg->element_type = htons (element->element_type);
451  GNUNET_memcpy (&msg[1],
452  element->data,
453  element->size);
455  cb,
456  cb_cls);
457  GNUNET_MQ_send (set->mq,
458  mqm);
459  return GNUNET_OK;
460 }
int invalid
Has the set become invalid (e.g.
Definition: setu_api.c:65
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
const void * data
Actual data of the element.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: setu_api.c:43
#define LOG(kind,...)
Definition: setu_api.c:33
uint16_t element_type
Type of the element to add or remove.
Definition: setu.h:285
#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:52
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:787
uint16_t element_type
Application-specific element type.
#define GNUNET_MESSAGE_TYPE_SETU_ADD
Add element to set.
Message sent by client to the service to add an element to the set.
Definition: setu.h:275
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:355
uint16_t size
Number of bytes in the buffer pointed to by data.
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 470 of file setu_api.c.

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, and LOG.

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

471 {
472  /* destroying set while iterator is active is currently
473  not supported; we should expand the API to allow
474  clients to explicitly cancel the iteration! */
475  GNUNET_assert (NULL != set);
476  if ((NULL != set->ops_head) ||
478  {
480  "Set operations are pending, delaying set destruction\n");
481  set->destroy_requested = GNUNET_YES;
482  return;
483  }
485  "Really destroying set\n");
486  if (NULL != set->mq)
487  {
488  GNUNET_MQ_destroy (set->mq);
489  set->mq = NULL;
490  }
491  GNUNET_free (set);
492 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: setu_api.c:43
#define LOG(kind,...)
Definition: setu_api.c:33
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETU_destroy() must...
Definition: setu_api.c:60
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SETU_OperationHandle * ops_head
Linked list of operations on the set.
Definition: setu_api.c:48
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

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
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 508 of file setu_api.c.

References app_id, GNUNET_SETU_EvaluateMessage::app_id, GNUNET_SETU_EvaluateMessage::byzantine, GNUNET_SETU_EvaluateMessage::byzantine_lower_bound, GNUNET_SETU_OperationHandle::conclude_mqm, GNUNET_SETU_EvaluateMessage::force_delta, GNUNET_SETU_EvaluateMessage::force_full, 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_FORCE_DELTA, GNUNET_SETU_OPTION_FORCE_FULL, GNUNET_SETU_OPTION_SYMMETRIC, GNUNET_YES, listen_connect(), LOG, msg, oh, GNUNET_SETU_EvaluateMessage::request_id, GNUNET_SETU_OperationHandle::request_id_addr, GNUNET_SETU_OperationHandle::result_cb, GNUNET_SETU_OperationHandle::result_cls, GNUNET_SETU_EvaluateMessage::symmetric, GNUNET_SETU_EvaluateMessage::target_peer, and GNUNET_SETU_Option::type.

Referenced by run(), and transmit_task_cb().

514 {
515  struct GNUNET_MQ_Envelope *mqm;
518 
520  "Client prepares set union operation\n");
522  oh->result_cb = result_cb;
523  oh->result_cls = result_cls;
524  mqm = GNUNET_MQ_msg_nested_mh (msg,
526  context_msg);
527  msg->app_id = *app_id;
528  msg->target_peer = *other_peer;
529  for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
530  {
531  switch (opt->type)
532  {
534  msg->byzantine = GNUNET_YES;
535  msg->byzantine_lower_bound = htonl (opt->v.num);
536  break;
538  msg->force_full = GNUNET_YES;
539  break;
541  msg->force_delta = GNUNET_YES;
542  break;
544  msg->symmetric = GNUNET_YES;
545  break;
546  default:
548  "Option with type %d not recognized\n",
549  (int) opt->type);
550  }
551  }
552  oh->conclude_mqm = mqm;
553  oh->request_id_addr = &msg->request_id;
554  return oh;
555 }
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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:122
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct...
struct GNUNET_HashCode app_id
Application id.
Definition: setu.h:197
uint8_t symmetric
Also return set elements we are sending to the remote peer.
Definition: setu.h:220
Option for set operations.
void * result_cls
Closure for result_cb.
Definition: setu_api.c:104
static struct GNUNET_HashCode app_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint8_t force_full
Always send full sets, even if delta operations would be more efficient.
Definition: setu.h:209
#define LOG(kind,...)
Definition: setu_api.c:33
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called. ...
Definition: setu_api.c:116
Message sent by client to service to initiate a set operation as a client (not as listener)...
Definition: setu.h:176
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
uint32_t byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
Definition: setu.h:226
uint8_t force_delta
Always use delta operation instead of sending full sets, even it it&#39;s less efficient.
Definition: setu.h:203
Handle to an operation.
Definition: setu_api.c:93
GNUNET_SETU_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: setu_api.c:99
uint8_t byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
Definition: setu.h:215
enum GNUNET_SETU_OptionType type
Type of the option.
struct GNUNET_PeerIdentity target_peer
Peer to evaluate the operation with.
Definition: setu.h:192
Notify client also if we are sending a value to the other peer.
uint32_t request_id
Id of our set to evaluate, chosen implicitly by the client when it calls GNUNET_SETU_commit().
Definition: setu.h:187
Do not use the optimized set operation, but send full sets.
Only use optimized set operations, even though for this particular set operation they might be much s...
#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE
Evaluate a set operation.
Here is the call graph for this function:
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 708 of file setu_api.c.

References app_id, 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().

712 {
713  struct GNUNET_SETU_ListenHandle *lh;
714 
716  "Starting listener for app %s\n",
717  GNUNET_h2s (app_id));
718  lh = GNUNET_new (struct GNUNET_SETU_ListenHandle);
719  lh->listen_cb = listen_cb;
720  lh->listen_cls = listen_cls;
721  lh->cfg = cfg;
722  lh->app_id = *app_id;
724  listen_connect (lh);
725  if (NULL == lh->mq)
726  {
727  GNUNET_free (lh);
728  return NULL;
729  }
730  return lh;
731 }
void * listen_cls
Closure for listen_cb.
Definition: setu_api.c:167
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: setu_api.c:149
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: setu_api.c:172
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: setu_api.c:177
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_HashCode app_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Opaque handle to a listen operation.
Definition: setu_api.c:144
#define LOG(kind,...)
Definition: setu_api.c:33
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: setu_api.c:666
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
GNUNET_SETU_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: setu_api.c:162
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:156
#define GNUNET_free(ptr)
Wrapper around free.
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 740 of file setu_api.c.

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 handle_shutdown(), and shutdown_task().

741 {
743  "Canceling listener %s\n",
744  GNUNET_h2s (&lh->app_id));
745  if (NULL != lh->mq)
746  {
747  GNUNET_MQ_destroy (lh->mq);
748  lh->mq = NULL;
749  }
750  if (NULL != lh->reconnect_task)
751  {
753  lh->reconnect_task = NULL;
754  }
755  GNUNET_free (lh);
756 }
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: setu_api.c:149
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: setu_api.c:182
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: setu_api.c:172
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define LOG(kind,...)
Definition: setu_api.c:33
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
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

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
result_modespecified how results will be returned, see enum GNUNET_SETU_ResultMode.
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 774 of file setu_api.c.

References GNUNET_SETU_Request::accept_id, GNUNET_SETU_AcceptMessage::accept_reject_id, GNUNET_SETU_Request::accepted, GNUNET_SETU_AcceptMessage::byzantine, GNUNET_SETU_AcceptMessage::byzantine_lower_bound, GNUNET_SETU_OperationHandle::conclude_mqm, GNUNET_SETU_AcceptMessage::force_delta, GNUNET_SETU_AcceptMessage::force_full, 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_FORCE_DELTA, GNUNET_SETU_OPTION_FORCE_FULL, GNUNET_SETU_OPTION_SYMMETRIC, GNUNET_YES, LOG, msg, oh, GNUNET_SETU_AcceptMessage::request_id, GNUNET_SETU_OperationHandle::request_id_addr, GNUNET_SETU_OperationHandle::result_cb, GNUNET_SETU_OperationHandle::result_cls, GNUNET_SETU_AcceptMessage::symmetric, and GNUNET_SETU_Option::type.

Referenced by handle_revocation_union_request(), and set_listen_cb().

778 {
779  struct GNUNET_MQ_Envelope *mqm;
782 
783  GNUNET_assert (GNUNET_NO == request->accepted);
785  "Client accepts set union operation with id %u\n",
786  request->accept_id);
787  request->accepted = GNUNET_YES;
788  mqm = GNUNET_MQ_msg (msg,
790  msg->accept_reject_id = htonl (request->accept_id);
791  for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
792  {
793  switch (opt->type)
794  {
796  msg->byzantine = GNUNET_YES;
797  msg->byzantine_lower_bound = htonl (opt->v.num);
798  break;
800  msg->force_full = GNUNET_YES;
801  break;
803  msg->force_delta = GNUNET_YES;
804  break;
806  msg->symmetric = GNUNET_YES;
807  break;
808  default:
810  "Option with type %d not recognized\n",
811  (int) opt->type);
812  }
813  }
815  oh->result_cb = result_cb;
816  oh->result_cls = result_cls;
817  oh->conclude_mqm = mqm;
818  oh->request_id_addr = &msg->request_id;
819  return oh;
820 }
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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:122
int accepted
Has the request been accepted already? GNUNET_YES/GNUNET_NO.
Definition: setu_api.c:85
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Option for set operations.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint32_t accept_reject_id
ID of the incoming request we want to accept.
Definition: setu.h:88
void * result_cls
Closure for result_cb.
Definition: setu_api.c:104
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t request_id
Request ID to identify responses.
Definition: setu.h:93
uint8_t byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
Definition: setu.h:111
#define LOG(kind,...)
Definition: setu_api.c:33
uint8_t symmetric
GNUNET_YES to also send back set elements we are sending to the remote peer.
Definition: setu.h:117
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called. ...
Definition: setu_api.c:116
#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT
Accept an incoming set request.
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: setu.h:78
Handle to an operation.
Definition: setu_api.c:93
GNUNET_SETU_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: setu_api.c:99
enum GNUNET_SETU_OptionType type
Type of the option.
Notify client also if we are sending a value to the other peer.
Do not use the optimized set operation, but send full sets.
uint8_t force_full
Always send full sets, even if delta operations would be more efficient.
Definition: setu.h:105
Only use optimized set operations, even though for this particular set operation they might be much s...
uint8_t force_delta
Always use delta operation instead of sending full sets, even it it&#39;s less efficient.
Definition: setu.h:99
uint32_t accept_id
Id of the request, used to identify the request when accepting/rejecting it.
Definition: setu_api.c:79
uint32_t byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
Definition: setu.h:123
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 837 of file setu_api.c.

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, LOG, GNUNET_SETU_OperationHandle::request_id, GNUNET_SETU_OperationHandle::request_id_addr, and GNUNET_SETU_OperationHandle::set.

Referenced by handle_revocation_union_request(), run(), and set_listen_cb().

839 {
840  if (NULL != oh->set)
841  {
842  /* Some other set was already committed for this
843  * operation, there is a logic bug in the client of this API */
844  GNUNET_break (0);
845  return GNUNET_OK;
846  }
847  GNUNET_assert (NULL != set);
848  if (GNUNET_YES == set->invalid)
849  return GNUNET_SYSERR;
851  "Client commits to SET\n");
852  GNUNET_assert (NULL != oh->conclude_mqm);
853  oh->set = set;
855  set->ops_tail,
856  oh);
857  oh->request_id = GNUNET_MQ_assoc_add (set->mq,
858  oh);
859  *oh->request_id_addr = htonl (oh->request_id);
860  GNUNET_MQ_send (set->mq,
861  oh->conclude_mqm);
862  oh->conclude_mqm = NULL;
863  oh->request_id_addr = NULL;
864  return GNUNET_OK;
865 }
int invalid
Has the set become invalid (e.g.
Definition: setu_api.c:65
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:122
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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:110
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:721
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: setu_api.c:43
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define LOG(kind,...)
Definition: setu_api.c:33
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called. ...
Definition: setu_api.c:116
struct GNUNET_SETU_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: setu_api.c:53
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:355
uint32_t request_id
Request ID to identify the operation within the set.
Definition: setu_api.c:137
struct GNUNET_SETU_OperationHandle * ops_head
Linked list of operations on the set.
Definition: setu_api.c:48
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 319 of file setu_api.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETU_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SETU_destroy(), GNUNET_YES, LOG, m, GNUNET_SETU_OperationHandle::request_id, GNUNET_SETU_CancelMessage::request_id, GNUNET_SETU_OperationHandle::set, and set_operation_destroy().

Referenced by handle_core_disconnect(), and handle_shutdown().

320 {
321  struct GNUNET_SETU_Handle *set = oh->set;
323  struct GNUNET_MQ_Envelope *mqm;
324 
326  "Cancelling SET operation\n");
327  if (NULL != set)
328  {
330  m->request_id = htonl (oh->request_id);
331  GNUNET_MQ_send (set->mq, mqm);
332  }
334  if ((NULL != set) &&
335  (GNUNET_YES == set->destroy_requested) &&
336  (NULL == set->ops_head))
337  {
339  "Destroying set after operation cancel\n");
340  GNUNET_SETU_destroy (set);
341  }
342 }
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:110
uint32_t request_id
ID of the request we want to cancel.
Definition: setu.h:309
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define LOG(kind,...)
Definition: setu_api.c:33
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
Opaque handle to a set.
Definition: setu_api.c:38
#define GNUNET_MESSAGE_TYPE_SETU_CANCEL
Cancel a set operation.
static void set_operation_destroy(struct GNUNET_SETU_OperationHandle *oh)
Destroy the given set operation.
Definition: setu_api.c:289
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:470
Sent to the service by the client in order to cancel a set operation.
Definition: setu.h:299
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:355
uint32_t request_id
Request ID to identify the operation within the set.
Definition: setu_api.c:137
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 876 of file setu_api.c.

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().

878 {
880 
881  /* It's not guaranteed that the element data is always after the element header,
882  so we need to hash the chunks separately. */
884  &element->size,
885  sizeof(uint16_t));
887  &element->element_type,
888  sizeof(uint16_t));
890  element->data,
891  element->size);
893  ret_hash);
894 }
const void * data
Actual data of the element.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:483
Context for cummulative hashing.
Definition: crypto_hash.c:468
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
uint16_t element_type
Application-specific element type.
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:509
uint16_t size
Number of bytes in the buffer pointed to by data.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:526
Here is the call graph for this function:
Here is the caller graph for this function: