GNUnet  0.10.x
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Macros | Typedefs | Enumerations | Functions
Social service

Social interactions through the PSYC service. More...

Macros

#define GNUNET_SOCIAL_VERSION   0x00000000
 Version number of GNUnet Social API. More...
 
#define GNUNET_SOCIAL_APP_MAX_ID_SIZE   256
 Maximum size of client ID including '\0' terminator. More...
 

Typedefs

typedef void(* GNUNET_SOCIAL_AppEgoCallback )(void *cls, struct GNUNET_SOCIAL_Ego *ego, const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key, const char *name)
 Notification about an available identity. More...
 
typedef void(* GNUNET_SOCIAL_AppConnectedCallback )(void *cls)
 Called after receiving initial list of egos and places. More...
 
typedef void(* GNUNET_SOCIAL_AppHostPlaceCallback )(void *cls, struct GNUNET_SOCIAL_HostConnection *hconn, struct GNUNET_SOCIAL_Ego *ego, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, enum GNUNET_SOCIAL_AppPlaceState place_state)
 Notification about a home. More...
 
typedef void(* GNUNET_SOCIAL_AppGuestPlaceCallback )(void *cls, struct GNUNET_SOCIAL_GuestConnection *gconn, struct GNUNET_SOCIAL_Ego *ego, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, enum GNUNET_SOCIAL_AppPlaceState place_state)
 Notification about a place. More...
 
typedef void(* GNUNET_SOCIAL_AnswerDoorCallback )(void *cls, struct GNUNET_SOCIAL_Nym *nym, const char *method_name, struct GNUNET_PSYC_Environment *env, const void *data, size_t data_size)
 Function called asking for nym to be admitted to the place. More...
 
typedef void(* GNUNET_SOCIAL_FarewellCallback )(void *cls, const struct GNUNET_SOCIAL_Nym *nym, struct GNUNET_PSYC_Environment *env)
 Function called when a nym leaves the place. More...
 
typedef void(* GNUNET_SOCIAL_HostEnterCallback )(void *cls, int result, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, uint64_t max_message_id)
 Function called after the host entered a home. More...
 
typedef void(* GNUNET_SOCIAL_GuestEnterCallback )(void *cls, int result, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, uint64_t max_message_id)
 Function called after the guest entered the local copy of the place. More...
 
typedef void(* GNUNET_SOCIAL_EntryDecisionCallback )(void *cls, int is_admitted, const struct GNUNET_PSYC_Message *entry_resp)
 Function called upon a guest receives a decision about entry to the place. More...
 

Enumerations

enum  GNUNET_SOCIAL_MsgProcFlags { GNUNET_SOCIAL_MSG_PROC_NONE = 0, GNUNET_SOCIAL_MSG_PROC_RELAY = 1, GNUNET_SOCIAL_MSG_PROC_SAVE = 2 }
 
enum  GNUNET_SOCIAL_AppPlaceState { GNUNET_SOCIAL_PLACE_STATE_ARCHIVED = 0, GNUNET_SOCIAL_PLACE_STATE_ENTERED = 1, GNUNET_SOCIAL_PLACE_STATE_SUBSCRIBED = 2 }
 Entry status of a place per application. More...
 
enum  GNUNET_SOCIAL_AnnounceFlags { GNUNET_SOCIAL_ANNOUNCE_NONE = 0, GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0 }
 Flags for announcements by a host. More...
 
enum  GNUNET_SOCIAL_TalkFlags { GNUNET_SOCIAL_TALK_NONE = 0 }
 Flags for talking to the host of a place. More...
 

Functions

struct GNUNET_SOCIAL_AppGNUNET_SOCIAL_app_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *id, GNUNET_SOCIAL_AppEgoCallback ego_cb, GNUNET_SOCIAL_AppHostPlaceCallback host_cb, GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb, GNUNET_SOCIAL_AppConnectedCallback connected_cb, void *cls)
 Establish application connection to the social service. More...
 
void GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app, GNUNET_ContinuationCallback disconnect_cb, void *disconnect_cls)
 Disconnect app. More...
 
const struct
GNUNET_CRYPTO_EcdsaPublicKey
GNUNET_SOCIAL_ego_get_pub_key (const struct GNUNET_SOCIAL_Ego *ego)
 Get the public key of ego. More...
 
const char * GNUNET_SOCIAL_ego_get_name (const struct GNUNET_SOCIAL_Ego *ego)
 Get the name of ego. More...
 
const struct
GNUNET_CRYPTO_EcdsaPublicKey
GNUNET_SOCIAL_nym_get_pub_key (const struct GNUNET_SOCIAL_Nym *nym)
 Get the public key of a nym. More...
 
const struct GNUNET_HashCodeGNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym)
 Get the hash of the public key of a nym. More...
 
struct GNUNET_SOCIAL_HostGNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, const struct GNUNET_SOCIAL_Ego *ego, enum GNUNET_PSYC_Policy policy, struct GNUNET_PSYC_Slicer *slicer, GNUNET_SOCIAL_HostEnterCallback enter_cb, GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, GNUNET_SOCIAL_FarewellCallback farewell_cb, void *cls)
 Enter a place as host. More...
 
struct GNUNET_SOCIAL_HostGNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, struct GNUNET_PSYC_Slicer *slicer, GNUNET_SOCIAL_HostEnterCallback enter_cb, GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, GNUNET_SOCIAL_FarewellCallback farewell_cb, void *cls)
 Reconnect to an already entered place as host. More...
 
int GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst, struct GNUNET_SOCIAL_Nym *nym, int is_admitted, const struct GNUNET_PSYC_Message *entry_resp)
 Decision whether to admit nym into the place or refuse entry. More...
 
void GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host, const struct GNUNET_SOCIAL_Nym *nym, struct GNUNET_PSYC_Environment *env)
 Throw nym out of the place. More...
 
struct GNUNET_SOCIAL_AnnouncementGNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, const char *method_name, const struct GNUNET_PSYC_Environment *env, GNUNET_PSYC_TransmitNotifyData notify_data, void *notify_data_cls, enum GNUNET_SOCIAL_AnnounceFlags flags)
 Send a message to all nyms that are present in the place. More...
 
void GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a)
 Resume transmitting announcement. More...
 
void GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a)
 Cancel announcement. More...
 
void GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host, const char *method_prefix)
 Allow relaying messages from guests matching a given method_prefix. More...
 
void GNUNET_SOCIAL_host_relay_stop (struct GNUNET_SOCIAL_Host *host)
 Stop relaying messages from guests. More...
 
struct GNUNET_SOCIAL_PlaceGNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host)
 Obtain handle for a hosted place. More...
 
void GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst, GNUNET_ContinuationCallback disconnect_cb, void *cls)
 Disconnect from a home. More...
 
void GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, const struct GNUNET_PSYC_Environment *env, GNUNET_ContinuationCallback disconnect_cb, void *cls)
 Stop hosting a home. More...
 
struct GNUNET_SOCIAL_GuestGNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app, const struct GNUNET_SOCIAL_Ego *ego, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, enum GNUNET_PSYC_SlaveJoinFlags flags, const struct GNUNET_PeerIdentity *origin, uint32_t relay_count, const struct GNUNET_PeerIdentity *relays, const struct GNUNET_PSYC_Message *entry_msg, struct GNUNET_PSYC_Slicer *slicer, GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb, void *cls)
 Request entry to a place as a guest. More...
 
struct GNUNET_SOCIAL_GuestGNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, const struct GNUNET_SOCIAL_Ego *ego, const char *gns_name, const char *password, const struct GNUNET_PSYC_Message *join_msg, struct GNUNET_PSYC_Slicer *slicer, GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, void *cls)
 Request entry to a place by name as a guest. More...
 
struct GNUNET_SOCIAL_GuestGNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, enum GNUNET_PSYC_SlaveJoinFlags flags, struct GNUNET_PSYC_Slicer *slicer, GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, void *cls)
 Reconnect to an already entered place as guest. More...
 
struct GNUNET_SOCIAL_TalkRequestGNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, const char *method_name, const struct GNUNET_PSYC_Environment *env, GNUNET_PSYC_TransmitNotifyData notify_data, void *notify_data_cls, enum GNUNET_SOCIAL_TalkFlags flags)
 Talk to the host of the place. More...
 
void GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr)
 Resume talking to the host of the place. More...
 
void GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr)
 Cancel talking to the host of the place. More...
 
void GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst, GNUNET_ContinuationCallback disconnect_cb, void *cls)
 Disconnect from a place. More...
 
void GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, struct GNUNET_PSYC_Environment *env, GNUNET_ContinuationCallback disconnect_cb, void *leave_cls)
 Leave a place temporarily or permanently. More...
 
struct GNUNET_SOCIAL_PlaceGNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest)
 Obtain handle for a place entered as guest. More...
 
const struct
GNUNET_CRYPTO_EddsaPublicKey
GNUNET_SOCIAL_place_get_pub_key (const struct GNUNET_SOCIAL_Place *plc)
 Get the public key of a place. More...
 
void GNUNET_SOCIAL_place_msg_proc_set (struct GNUNET_SOCIAL_Place *plc, const char *method_prefix, enum GNUNET_SOCIAL_MsgProcFlags flags)
 Set message processing flags for a method_prefix. More...
 
void GNUNET_SOCIAL_place_msg_proc_clear (struct GNUNET_SOCIAL_Place *plc)
 Clear all message processing flags previously set for this place. More...
 
struct
GNUNET_SOCIAL_HistoryRequest
GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc, uint64_t start_message_id, uint64_t end_message_id, const char *method_prefix, uint32_t flags, struct GNUNET_PSYC_Slicer *slicer, GNUNET_ResultCallback result_cb, void *cls)
 Learn about the history of a place. More...
 
struct
GNUNET_SOCIAL_HistoryRequest
GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc, uint64_t message_limit, const char *method_prefix, uint32_t flags, struct GNUNET_PSYC_Slicer *slicer, GNUNET_ResultCallback result_cb, void *cls)
 Learn about the history of a place. More...
 
void GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist)
 Cancel learning about the history of a place. More...
 
struct GNUNET_SOCIAL_LookHandleGNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc, const char *full_name, GNUNET_PSYC_StateVarCallback var_cb, GNUNET_ResultCallback result_cb, void *cls)
 Look at a particular object in the place. More...
 
struct GNUNET_SOCIAL_LookHandleGNUNET_SOCIAL_place_look_for (struct GNUNET_SOCIAL_Place *plc, const char *name_prefix, GNUNET_PSYC_StateVarCallback var_cb, GNUNET_ResultCallback result_cb, void *cls)
 Look for objects in the place with a matching name prefix. More...
 
void GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh)
 Stop looking at objects. More...
 
int GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app, const struct GNUNET_SOCIAL_Ego *ego, const char *name, const char *password, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, const struct GNUNET_PeerIdentity *origin, uint32_t relay_count, const struct GNUNET_PeerIdentity *relays, struct GNUNET_TIME_Absolute expiration_time, GNUNET_ResultCallback result_cb, void *result_cls)
 Advertise a place in the GNS zone of ego. More...
 
int GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app, const struct GNUNET_SOCIAL_Ego *ego, const char *name, const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key, struct GNUNET_TIME_Absolute expiration_time, GNUNET_ResultCallback result_cb, void *result_cls)
 Add public key to the GNS zone of the ego. More...
 

Detailed Description

Social interactions through the PSYC service.

Overview

The social service provides an API for social interactions based on a one-to-many messaging model. It manages subscriptions of applications to places, provides messaging functionality in places, allows access to the local message history and manages the GNS zone of egos (user identities).

The service stores private and public keys of subscribed places, as well as files received in subscribed places.

Concepts and terminology

Ego, Nym

An ego is an identity of a user, a private-public key pair. A nym is an identity of another user in the network, identified by its public key. Each user can have multiple identities.

struct GNUNET_SOCIAL_Ego and struct GNUNET_SOCIAL_Nym represents one of these identities.

Place, Host, Guest

A place is where social interactions happen. It is owned and created by an ego. Creating a new place happens by an ego entering a new place as a host, where guests can enter later to receive messages sent to the place.

A place is identified by its public key.

History

Messages sent to places are stored locally by the PSYCstore service, and can be queried any time. GNUNET_SOCIAL_history_replay_latest() retrieves the latest N messages sent to the place, while GNUNET_SOCIAL_history_replay() is used to query a given message ID range.

GNU Name System

The GNU Name System is used for assigning human-readable names to nyms and places. There's a GNS zone corresponding to each nym. An ego can publish PKEY and PLACE records in its own zone, pointing to nyms and places, respectively.

Announcement, talk request

The host can announce messages to the place, using GNUNET_SOCIAL_host_announce(). Guests can send talk requests to the host, using GNUNET_SOCIAL_guest_talk(). The host receives talk requests of guests and can relay them to the place, or process it using a message handler function.

Using the API

Connecting to the service

A client first establishes an application connection to the service using GNUNET_SOCIAL_app_connect() providing its application ID, then receives the public keys of subscribed places and available egos in response.

Reconnecting to places

Then the application can reconnect to its subscribed places by establishing place connections with GNUNET_SOCIAL_host_enter_reconnect() and GNUNET_SOCIAL_guest_enter_reconnect().

Subscribing to a place

Entering and subscribing a new host or guest place is done using GNUNET_SOCIAL_host_enter() and GNUNET_SOCIAL_guest_enter().

Disconnecting from a place

An application can disconnect from a place while the social service keeps its network connection active, using GNUNET_SOCIAL_host_disconnect() and GNUNET_SOCIAL_guest_disconnect().

Leaving a place

To permanently leave a place, see GNUNET_SOCIAL_host_leave() and GNUNET_SOCIAL_guest_leave(). When leaving a place its network connections are closed and all applications are unsubscribed from the place.

Message methods

_converse

Human conversation in a private or public place.

Environment

_id_reply

Message ID this message is in reply to.

_id_thread

Thread ID, the first message ID in the thread.

_nym_author

Nym of the author.

FIXME: Are nyms a different data type from egos and person entities? Do they have a different format than any other entity address? Questions and thoughts on how to fix this in "questions.org"

_sig_author

Signature of the message body and its variables by the author.

Data

Message body.

_notice_place

Notification about a place.

TODO: Applications can decide to auto-subscribe to certain places, e.g. files under a given size.

Environment

Using GNS

_gns_place

GNS name of the place in a globally unique .zkey zone

FIXME: A custom _gns PSYC data type should be avoidable by parsing and interpreting PSYC uniforms appropriately. Thoughts on this in "questions.org"

Without GNS

_key_pub_place

Public key of place

FIXME: _key_pub can't be the data type for GNUnet-specific cryptographic addressing. Questions and thoughts on how to fix this in "questions.org"

_peer_origin

Peer ID of origin

_list_peer_relays

List of peer IDs of relays

_notice_place_file

Notification about a place hosting a file.

Environment

The environment of _notice_place above, plus the following:

_size_file

Size of file

_type_file

MIME type of file

_name_file

Name of file

_description_file

Description of file

_file

Messages with a _file method contain a file, which is saved to disk upon reception at the following location: $GNUNET_DATA_HOME/social/files/<H(place_pub)>/<H(message_id)>

Environment

_size_file

Size of file

_type_file

MIME type of file

_name_file

Name of file

_description_file

Description of file

Macro Definition Documentation

#define GNUNET_SOCIAL_VERSION   0x00000000

Version number of GNUnet Social API.

Definition at line 239 of file gnunet_social_service.h.

#define GNUNET_SOCIAL_APP_MAX_ID_SIZE   256

Maximum size of client ID including '\0' terminator.

Definition at line 244 of file gnunet_social_service.h.

Referenced by GNUNET_SOCIAL_app_connect().

Typedef Documentation

typedef void(* GNUNET_SOCIAL_AppEgoCallback)(void *cls, struct GNUNET_SOCIAL_Ego *ego, const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key, const char *name)

Notification about an available identity.

Parameters
clsClosure.
pub_keyPublic key of ego.
nameName of ego.

Definition at line 303 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_AppConnectedCallback)(void *cls)

Called after receiving initial list of egos and places.

Definition at line 340 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_AppHostPlaceCallback)(void *cls, struct GNUNET_SOCIAL_HostConnection *hconn, struct GNUNET_SOCIAL_Ego *ego, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, enum GNUNET_SOCIAL_AppPlaceState place_state)

Notification about a home.

Parameters
clsClosure.
hconnHost connection, to be used with GNUNET_SOCIAL_host_enter_reconnect()
egoEgo used to enter the place.
place_pub_keyPublic key of the place.
place_state
See also
enum GNUNET_SOCIAL_AppPlaceState

Definition at line 358 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_AppGuestPlaceCallback)(void *cls, struct GNUNET_SOCIAL_GuestConnection *gconn, struct GNUNET_SOCIAL_Ego *ego, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, enum GNUNET_SOCIAL_AppPlaceState place_state)

Notification about a place.

Parameters
clsClosure.
gconnGuest connection, to be used with GNUNET_SOCIAL_guest_enter_reconnect()
egoEgo used to enter the place.
place_pub_keyPublic key of the place.
place_state
See also
enum GNUNET_SOCIAL_AppPlaceState

Definition at line 379 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_AnswerDoorCallback)(void *cls, struct GNUNET_SOCIAL_Nym *nym, const char *method_name, struct GNUNET_PSYC_Environment *env, const void *data, size_t data_size)

Function called asking for nym to be admitted to the place.

Should call either GNUNET_SOCIAL_host_admit() or GNUNET_SOCIAL_host_reject_entry() (possibly asynchronously). If this host cannot decide, it is fine to call neither function, in which case hopefully some other host of the place exists that will make the decision. The nym reference remains valid until the GNUNET_SOCIAL_FarewellCallback is invoked for it.

Parameters
clsClosure.
nymHandle for the user who wants to enter.
method_nameMethod name in the entry request.
variable_countNumber of elements in the variables array.
variablesVariables present in the message.
dataPayload given on enter (e.g. a password).
data_sizeNumber of bytes in data.

Definition at line 508 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_FarewellCallback)(void *cls, const struct GNUNET_SOCIAL_Nym *nym, struct GNUNET_PSYC_Environment *env)

Function called when a nym leaves the place.

This is also called if the nym was never given permission to enter (i.e. the nym stopped asking to get in).

Parameters
clsClosure.
nymHandle for the user who left.

Definition at line 528 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_HostEnterCallback)(void *cls, int result, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, uint64_t max_message_id)

Function called after the host entered a home.

Parameters
clsClosure.
resultGNUNET_OK on success, or GNUNET_SYSERR on error.
place_pub_keyPublic key of home.
max_message_idLast message ID sent to the channel. Or 0 if no messages have been sent to the place yet.

Definition at line 548 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_GuestEnterCallback)(void *cls, int result, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, uint64_t max_message_id)

Function called after the guest entered the local copy of the place.

History and object query functions can be used after this call, but new messages can't be sent or received.

Parameters
clsClosure.
resultGNUNET_OK on success, or GNUNET_SYSERR on error, e.g. could not connect to the service, or could not resolve GNS name.
place_pub_keyPublic key of place.
max_message_idLast message ID sent to the place. Or 0 if no messages have been sent to the place yet.

Definition at line 857 of file gnunet_social_service.h.

typedef void(* GNUNET_SOCIAL_EntryDecisionCallback)(void *cls, int is_admitted, const struct GNUNET_PSYC_Message *entry_resp)

Function called upon a guest receives a decision about entry to the place.

Parameters
is_admittedIs the guest admitted to the place? GNUNET_YES if admitted, GNUNET_NO if refused entry, GNUNET_SYSERR if the request could not be answered.
dataEntry response message.

Definition at line 874 of file gnunet_social_service.h.

Enumeration Type Documentation

Enumerator
GNUNET_SOCIAL_MSG_PROC_NONE 
GNUNET_SOCIAL_MSG_PROC_RELAY 
GNUNET_SOCIAL_MSG_PROC_SAVE 

Definition at line 246 of file gnunet_social_service.h.

Entry status of a place per application.

Enumerator
GNUNET_SOCIAL_PLACE_STATE_ARCHIVED 

The place was once entered by the ego, but left since.

It's possible to establish a local connection to the place without re-entering to fetch history from the PSYCstore.

See also
enum GNUNET_PSYC_SlaveJoinFlags and GNUNET_SOCIAL_guest_enter()
GNUNET_SOCIAL_PLACE_STATE_ENTERED 

The place is entered by the ego, but this application is not subscribed to it.

GNUNET_SOCIAL_PLACE_STATE_SUBSCRIBED 

The place is entered by the ego and and this application is subscribed to it.

Definition at line 312 of file gnunet_social_service.h.

313 {
321 
327 
333 };
The place is entered by the ego and and this application is subscribed to it.
The place was once entered by the ego, but left since.
The place is entered by the ego, but this application is not subscribed to it.

Flags for announcements by a host.

Enumerator
GNUNET_SOCIAL_ANNOUNCE_NONE 
GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS 

Whether this announcement removes all objects from the place.

New objects can be still added to the now empty place using the env parameter of the same announcement.

Definition at line 669 of file gnunet_social_service.h.

670 {
672 
680 };
Whether this announcement removes all objects from the place.

Flags for talking to the host of a place.

Enumerator
GNUNET_SOCIAL_TALK_NONE 

Definition at line 984 of file gnunet_social_service.h.

Function Documentation

struct GNUNET_SOCIAL_App* GNUNET_SOCIAL_app_connect ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  id,
GNUNET_SOCIAL_AppEgoCallback  ego_cb,
GNUNET_SOCIAL_AppHostPlaceCallback  host_cb,
GNUNET_SOCIAL_AppGuestPlaceCallback  guest_cb,
GNUNET_SOCIAL_AppConnectedCallback  connected_cb,
void *  cls 
)

Establish application connection to the social service.

The and functions are initially called for each entered places, then later each time a new place is entered with the current app ID.

Parameters
cfgConfiguration.
ego_cbFunction to notify about an available ego.
host_cbFunction to notify about a place entered as host.
guest_cbFunction to notify about a place entered as guest.
clsClosure for the callbacks.
Returns
Handle that can be used to stop listening.

Establish application connection to the social service.

The and functions are initially called for each entered places, then later each time a new place is entered with the current application ID.

Parameters
cfgConfiguration.
idApplication ID.
ego_cbFunction to notify about an available ego.
host_cbFunction to notify about a place entered as host.
guest_cbFunction to notify about a place entered as guest.
clsClosure for the callbacks.
Returns
Handle that can be used to stop listening.

Definition at line 2630 of file social_api.c.

References app, app_connect(), GNUNET_SOCIAL_App::cb_cls, GNUNET_SOCIAL_App::cfg, cfg, GNUNET_SOCIAL_App::connect_env, GNUNET_SOCIAL_App::connected_cb, GNUNET_SOCIAL_App::ego_cb, GNUNET_SOCIAL_App::egos, GNUNET_CONTAINER_multihashmap_create(), GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_OP_create(), GNUNET_SOCIAL_APP_MAX_ID_SIZE, GNUNET_SOCIAL_App::guest_cb, GNUNET_SOCIAL_App::host_cb, GNUNET_SOCIAL_App::id, GNUNET_SOCIAL_App::op, and strnlen().

Referenced by app_connect().

2637 {
2638  uint16_t app_id_size = strnlen (id, GNUNET_SOCIAL_APP_MAX_ID_SIZE);
2639  if (GNUNET_SOCIAL_APP_MAX_ID_SIZE == app_id_size)
2640  return NULL;
2641  app_id_size++;
2642 
2643  struct GNUNET_SOCIAL_App *app = GNUNET_malloc (sizeof *app);
2644  app->cfg = cfg;
2645  app->ego_cb = ego_cb;
2646  app->host_cb = host_cb;
2647  app->guest_cb = guest_cb;
2648  app->connected_cb = connected_cb;
2649  app->cb_cls = cls;
2651  app->op = GNUNET_OP_create ();
2652  app->id = GNUNET_malloc (app_id_size);
2653  GNUNET_memcpy (app->id, id, app_id_size);
2654 
2655  struct AppConnectRequest *creq;
2656  app->connect_env = GNUNET_MQ_msg_extra (creq, app_id_size,
2658  GNUNET_memcpy (&creq[1], app->id, app_id_size);
2659 
2660  app_connect (app);
2661  return app;
2662 }
#define GNUNET_SOCIAL_APP_MAX_ID_SIZE
Maximum size of client ID including '\0' terminator.
static void app_connect(struct GNUNET_SOCIAL_App *app)
Definition: social_api.c:2574
struct GNUNET_CONTAINER_MultiHashMap * egos
Hash map of all egos.
Definition: social_api.c:115
GNUNET_SOCIAL_AppHostPlaceCallback host_cb
Definition: social_api.c:118
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
char * id
Application ID.
Definition: social_api.c:109
#define GNUNET_NO
Definition: gnunet_common.h:81
Handle for an application.
Definition: social_api.c:64
GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb
Definition: social_api.c:119
#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:51
GNUNET_SOCIAL_AppEgoCallback ego_cb
Definition: social_api.c:117
struct GNUNET_OP_Handle * GNUNET_OP_create()
Create new operations handle.
Definition: op.c:89
struct GNUNET_SOCIAL_App * app
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_MQ_Envelope * connect_env
Message to send on connect.
Definition: social_api.c:79
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:94
GNUNET_SOCIAL_AppConnectedCallback connected_cb
Definition: social_api.c:120
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:69
static size_t strnlen(const char *s, size_t n)
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT
C->S: connect application.

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_app_disconnect ( struct GNUNET_SOCIAL_App app,
GNUNET_ContinuationCallback  disconnect_cb,
void *  disconnect_cls 
)

Disconnect app.

Parameters
appApplication handle.
disconnect_cbDisconnect callback.
disconnect_clsDisconnect closure.

Disconnect app.

Parameters
appApplication handle.
disconnect_cbDisconnect callback.
disconnect_clsDisconnect closure.

Definition at line 2692 of file social_api.c.

References app_cleanup(), disconnect_cb(), GNUNET_SOCIAL_App::disconnect_cb, GNUNET_SOCIAL_App::disconnect_cls, env, GNUNET_MQ_get_last_envelope(), GNUNET_MQ_notify_sent(), and GNUNET_SOCIAL_App::mq.

Referenced by disconnect().

2695 {
2697  app->disconnect_cls = disconnect_cls;
2698 
2699  if (NULL != app->mq)
2700  {
2702  if (NULL != env)
2703  {
2705  }
2706  else
2707  {
2708  app_cleanup (app);
2709  }
2710  }
2711  else
2712  {
2713  app_cleanup (app);
2714  }
2715 }
struct GNUNET_MQ_Envelope * GNUNET_MQ_get_last_envelope(struct GNUNET_MQ_Handle *mq)
Function to obtain the last envelope in the queue.
Definition: mq.c:1024
static void app_cleanup(struct GNUNET_SOCIAL_App *app)
Definition: social_api.c:2666
struct GNUNET_MQ_Handle * mq
Client connection to the service.
Definition: social_api.c:74
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_MQ_NotifyCallback 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:814
void * disconnect_cls
Closure for disconnect_cb.
Definition: social_api.c:104
void(* GNUNET_MQ_NotifyCallback)(void *cls)
Callback used for notifications.
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.
static void disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
Function called if DV is no longer able to talk to a peer.
Definition: gnunet-dv.c:87
GNUNET_ContinuationCallback disconnect_cb
Function called after disconnected from the service.
Definition: social_api.c:99

Here is the call graph for this function:

Here is the caller graph for this function:

const struct GNUNET_CRYPTO_EcdsaPublicKey* GNUNET_SOCIAL_ego_get_pub_key ( const struct GNUNET_SOCIAL_Ego ego)

Get the public key of ego.

Parameters
egoEgo.
Returns
Public key of ego.

Definition at line 1427 of file social_api.c.

References GNUNET_SOCIAL_Ego::pub_key.

1428 {
1429  return &ego->pub_key;
1430 }
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:45
const char* GNUNET_SOCIAL_ego_get_name ( const struct GNUNET_SOCIAL_Ego ego)

Get the name of ego.

Parameters
egoEgo.
Returns
Public key of ego.

Definition at line 1457 of file social_api.c.

References GNUNET_SOCIAL_Ego::name.

1458 {
1459  return ego->name;
1460 }
const struct GNUNET_CRYPTO_EcdsaPublicKey* GNUNET_SOCIAL_nym_get_pub_key ( const struct GNUNET_SOCIAL_Nym nym)

Get the public key of a nym.

Suitable, for example, to be used with GNUNET_SOCIAL_zone_add_nym().

Parameters
nymPseudonym to map to a cryptographic identifier.
Returns
Public key of nym.

Get the public key of a nym.

Suitable, for example, to be used with GNUNET_SOCIAL_zone_add_nym().

Parameters
nymPseudonym.
Returns
Public key of nym.

Definition at line 1474 of file social_api.c.

References GNUNET_SOCIAL_Nym::pub_key.

Referenced by host_answer_door(), and host_farewell().

1475 {
1476  return &nym->pub_key;
1477 }
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:56

Here is the caller graph for this function:

const struct GNUNET_HashCode* GNUNET_SOCIAL_nym_get_pub_key_hash ( const struct GNUNET_SOCIAL_Nym nym)

Get the hash of the public key of a nym.

Parameters
nymPseudonym to map to a cryptographic identifier.
Returns
Hash of the public key of nym.

Get the hash of the public key of a nym.

Parameters
nymPseudonym.
Returns
Hash of the public key of nym.

Definition at line 1489 of file social_api.c.

References GNUNET_SOCIAL_Nym::pub_key_hash.

1490 {
1491  return &nym->pub_key_hash;
1492 }
struct GNUNET_HashCode pub_key_hash
Definition: social_api.c:57
struct GNUNET_SOCIAL_Host* GNUNET_SOCIAL_host_enter ( const struct GNUNET_SOCIAL_App app,
const struct GNUNET_SOCIAL_Ego ego,
enum GNUNET_PSYC_Policy  policy,
struct GNUNET_PSYC_Slicer slicer,
GNUNET_SOCIAL_HostEnterCallback  enter_cb,
GNUNET_SOCIAL_AnswerDoorCallback  answer_door_cb,
GNUNET_SOCIAL_FarewellCallback  farewell_cb,
void *  cls 
)

Enter a place as host.

A place is created upon first entering, and it is active until permanently left using GNUNET_SOCIAL_host_leave().

Parameters
cfgConfiguration to contact the social service.
egoIdentity of the host.
place_keyPrivate-public key pair of the place. NULL for ephemeral places.
policyPolicy specifying entry and history restrictions for the place.
slicerSlicer to handle incoming messages.
enter_cbFunction called when the place is entered and ready to use.
answer_door_cbFunction to handle new nyms that want to enter.
farewell_cbFunction to handle departing nyms.
clsClosure for the callbacks.
Returns
Handle for the host.

A place is created upon first entering, and it is active until permanently left using GNUNET_SOCIAL_host_leave().

Parameters
appApplication handle.
egoIdentity of the host.
policyPolicy specifying entry and history restrictions for the place.
slicerSlicer to handle incoming messages.
enter_cbFunction called when the place is entered and ready to use.
answer_door_cbFunction to handle new nyms that want to enter.
farewell_cbFunction to handle departing nyms.
clsClosure for the callbacks.
Returns
Handle for the host. This handle contains the pubkey.

Definition at line 1233 of file social_api.c.

References GNUNET_SOCIAL_Host::answer_door_cb, GNUNET_SOCIAL_Host::cb_cls, GNUNET_SOCIAL_App::cfg, GNUNET_SOCIAL_Place::cfg, GNUNET_SOCIAL_Place::connect_env, HostEnterRequest::ego_pub_key, GNUNET_SOCIAL_Host::enter_cb, GNUNET_SOCIAL_Host::farewell_cb, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, GNUNET_MQ_msg_extra, GNUNET_OP_create(), GNUNET_PSYC_slicer_create(), GNUNET_PSYC_slicer_method_add(), GNUNET_YES, host_connect(), host_recv_notice_place_leave_eom(), host_recv_notice_place_leave_method(), host_recv_notice_place_leave_modifier(), hst, GNUNET_SOCIAL_App::id, GNUNET_SOCIAL_Place::is_host, GNUNET_SOCIAL_Place::op, plc, GNUNET_SOCIAL_Host::plc, HostEnterRequest::policy, GNUNET_SOCIAL_Ego::pub_key, slicer, GNUNET_SOCIAL_Place::slicer, and GNUNET_SOCIAL_Host::slicer.

Referenced by host_enter().

1241 {
1242  struct GNUNET_SOCIAL_Host *hst = GNUNET_malloc (sizeof (*hst));
1243  struct GNUNET_SOCIAL_Place *plc = &hst->plc;
1244 
1245  plc->cfg = app->cfg;
1246  plc->is_host = GNUNET_YES;
1247  plc->slicer = slicer;
1248 
1249  hst->enter_cb = enter_cb;
1250  hst->answer_door_cb = answer_door_cb;
1251  hst->farewell_cb = farewell_cb;
1252  hst->cb_cls = cls;
1253 
1254  plc->op = GNUNET_OP_create ();
1255 
1257  GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave", NULL,
1261 
1262  uint16_t app_id_size = strlen (app->id) + 1;
1263  struct HostEnterRequest *hreq;
1264  plc->connect_env = GNUNET_MQ_msg_extra (hreq, app_id_size,
1266  hreq->policy = policy;
1267  hreq->ego_pub_key = ego->pub_key;
1268  GNUNET_memcpy (&hreq[1], app->id, app_id_size);
1269 
1270  host_connect (hst);
1271  return hst;
1272 }
Handle for a place where social interactions happen.
Definition: social_api.c:144
struct GNUNET_PSYC_Slicer * slicer
void * cb_cls
Closure for callbacks.
Definition: social_api.c:234
struct GNUNET_PSYC_Slicer * slicer
Slicer for processing incoming messages from guests.
Definition: social_api.c:223
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:149
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
char * id
Application ID.
Definition: social_api.c:109
static void host_recv_notice_place_leave_modifier(void *cls, const struct GNUNET_PSYC_MessageHeader *msg, const struct GNUNET_MessageHeader *pmsg, uint64_t message_id, enum GNUNET_PSYC_Operator oper, const char *name, const void *value, uint16_t value_size, uint16_t full_value_size)
Definition: social_api.c:447
Host handle for a place that we entered.
Definition: social_api.c:216
struct GNUNET_MQ_Envelope * connect_env
Message to send on connect.
Definition: social_api.c:159
GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb
Definition: social_api.c:227
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:45
#define GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER
C->S: request to enter a place as the host.
void GNUNET_PSYC_slicer_method_add(struct GNUNET_PSYC_Slicer *slicer, const char *method_name, GNUNET_PSYC_MessageCallback msg_cb, GNUNET_PSYC_MethodCallback method_cb, GNUNET_PSYC_ModifierCallback modifier_cb, GNUNET_PSYC_DataCallback data_cb, GNUNET_PSYC_EndOfMessageCallback eom_cb, void *cls)
Add a method to the try-and-slice instance.
Definition: psyc_slicer.c:452
static void host_recv_notice_place_leave_eom(void *cls, const struct GNUNET_PSYC_MessageHeader *msg, const struct GNUNET_MessageHeader *pmsg, uint64_t message_id, uint8_t is_cancelled)
Definition: social_api.c:477
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:174
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:112
GNUNET_SOCIAL_HostEnterCallback enter_cb
Definition: social_api.c:225
uint32_t policy
Definition: social.h:110
#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:51
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:218
struct GNUNET_OP_Handle * GNUNET_OP_create()
Create new operations handle.
Definition: op.c:89
static void host_connect(struct GNUNET_SOCIAL_Host *hst)
Definition: social_api.c:1162
uint8_t is_host
Does this place belong to a host (GNUNET_YES) or guest (GNUNET_NO)?
Definition: social_api.c:209
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_PSYC_Slicer * GNUNET_PSYC_slicer_create(void)
Create a try-and-slice instance.
Definition: psyc_slicer.c:417
static void host_recv_notice_place_leave_method(void *cls, const struct GNUNET_PSYC_MessageHeader *msg, const struct GNUNET_PSYC_MessageMethod *meth, uint64_t message_id, const char *method_name)
_notice_place_leave from guests
Definition: social_api.c:417
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:69
struct GNUNET_SOCIAL_Host * hst
struct GNUNET_SOCIAL_Place * plc
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_PSYC_Slicer * slicer
Slicer for processing incoming messages.
Definition: social_api.c:184
GNUNET_SOCIAL_FarewellCallback farewell_cb
Definition: social_api.c:229

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_Host* GNUNET_SOCIAL_host_enter_reconnect ( struct GNUNET_SOCIAL_HostConnection hconn,
struct GNUNET_PSYC_Slicer slicer,
GNUNET_SOCIAL_HostEnterCallback  enter_cb,
GNUNET_SOCIAL_AnswerDoorCallback  answer_door_cb,
GNUNET_SOCIAL_FarewellCallback  farewell_cb,
void *  cls 
)

Reconnect to an already entered place as host.

Parameters
hconnHost connection handle.
See also
GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppHostPlaceCallback()
Parameters
slicerSlicer to handle incoming messages.
enter_cbFunction called when the place is entered and ready to use.
answer_door_cbFunction to handle new nyms that want to enter.
farewell_cbFunction to handle departing nyms.
clsClosure for the callbacks.
Returns
Handle for the host.

Definition at line 1295 of file social_api.c.

References GNUNET_SOCIAL_Host::answer_door_cb, GNUNET_SOCIAL_HostConnection::app, GNUNET_SOCIAL_Host::cb_cls, GNUNET_SOCIAL_App::cfg, GNUNET_SOCIAL_Place::cfg, GNUNET_SOCIAL_Place::connect_env, HostEnterRequest::ego_pub_key, GNUNET_SOCIAL_Place::ego_pub_key, AppPlaceMessage::ego_pub_key, GNUNET_SOCIAL_Host::enter_cb, GNUNET_SOCIAL_Host::farewell_cb, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, GNUNET_MQ_msg_extra, GNUNET_OP_create(), GNUNET_PSYC_slicer_create(), GNUNET_PSYC_slicer_method_add(), GNUNET_YES, host_connect(), host_recv_notice_place_leave_eom(), host_recv_notice_place_leave_method(), host_recv_notice_place_leave_modifier(), hst, GNUNET_SOCIAL_App::id, GNUNET_SOCIAL_Place::is_host, GNUNET_SOCIAL_Place::op, HostEnterRequest::place_pub_key, AppPlaceMessage::place_pub_key, plc, GNUNET_SOCIAL_Host::plc, GNUNET_SOCIAL_HostConnection::plc_msg, GNUNET_SOCIAL_Place::pub_key, slicer, GNUNET_SOCIAL_Place::slicer, and GNUNET_SOCIAL_Host::slicer.

Referenced by app_recv_host().

1301 {
1302  struct GNUNET_SOCIAL_Host *hst = GNUNET_malloc (sizeof (*hst));
1303  struct GNUNET_SOCIAL_Place *plc = &hst->plc;
1304 
1305  hst->enter_cb = enter_cb;
1306  hst->answer_door_cb = answer_door_cb;
1307  hst->farewell_cb = farewell_cb;
1308  hst->cb_cls = cls;
1309 
1310  plc->cfg = hconn->app->cfg;
1311  plc->is_host = GNUNET_YES;
1312  plc->slicer = slicer;
1313  plc->pub_key = hconn->plc_msg.place_pub_key;
1314  plc->ego_pub_key = hconn->plc_msg.ego_pub_key;
1315 
1316  plc->op = GNUNET_OP_create ();
1317 
1319  GNUNET_PSYC_slicer_method_add (hst->slicer, "_notice_place_leave", NULL,
1323 
1324  size_t app_id_size = strlen (hconn->app->id) + 1;
1325  struct HostEnterRequest *hreq;
1326  plc->connect_env = GNUNET_MQ_msg_extra (hreq, app_id_size,
1328  hreq->place_pub_key = hconn->plc_msg.place_pub_key;
1329  hreq->ego_pub_key = hconn->plc_msg.ego_pub_key;
1330  GNUNET_memcpy (&hreq[1], hconn->app->id, app_id_size);
1331 
1332  host_connect (hst);
1333  return hst;
1334 }
Handle for a place where social interactions happen.
Definition: social_api.c:144
struct GNUNET_PSYC_Slicer * slicer
struct AppPlaceMessage plc_msg
Definition: social_api.c:129
struct GNUNET_CRYPTO_EddsaPublicKey pub_key
Public key of the place.
Definition: social_api.c:199
void * cb_cls
Closure for callbacks.
Definition: social_api.c:234
struct GNUNET_PSYC_Slicer * slicer
Slicer for processing incoming messages from guests.
Definition: social_api.c:223
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:149
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
Definition: social.h:259
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
char * id
Application ID.
Definition: social_api.c:109
static void host_recv_notice_place_leave_modifier(void *cls, const struct GNUNET_PSYC_MessageHeader *msg, const struct GNUNET_MessageHeader *pmsg, uint64_t message_id, enum GNUNET_PSYC_Operator oper, const char *name, const void *value, uint16_t value_size, uint16_t full_value_size)
Definition: social_api.c:447
Host handle for a place that we entered.
Definition: social_api.c:216
struct GNUNET_MQ_Envelope * connect_env
Message to send on connect.
Definition: social_api.c:159
GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb
Definition: social_api.c:227
#define GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER
C->S: request to enter a place as the host.
void GNUNET_PSYC_slicer_method_add(struct GNUNET_PSYC_Slicer *slicer, const char *method_name, GNUNET_PSYC_MessageCallback msg_cb, GNUNET_PSYC_MethodCallback method_cb, GNUNET_PSYC_ModifierCallback modifier_cb, GNUNET_PSYC_DataCallback data_cb, GNUNET_PSYC_EndOfMessageCallback eom_cb, void *cls)
Add a method to the try-and-slice instance.
Definition: psyc_slicer.c:452
static void host_recv_notice_place_leave_eom(void *cls, const struct GNUNET_PSYC_MessageHeader *msg, const struct GNUNET_MessageHeader *pmsg, uint64_t message_id, uint8_t is_cancelled)
Definition: social_api.c:477
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:174
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:112
GNUNET_SOCIAL_HostEnterCallback enter_cb
Definition: social_api.c:225
#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:51
struct GNUNET_SOCIAL_App * app
Definition: social_api.c:127
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:218
struct GNUNET_OP_Handle * GNUNET_OP_create()
Create new operations handle.
Definition: op.c:89
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
Definition: social.h:114
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Public key of the ego.
Definition: social_api.c:204
static void host_connect(struct GNUNET_SOCIAL_Host *hst)
Definition: social_api.c:1162
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:257
uint8_t is_host
Does this place belong to a host (GNUNET_YES) or guest (GNUNET_NO)?
Definition: social_api.c:209
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_PSYC_Slicer * GNUNET_PSYC_slicer_create(void)
Create a try-and-slice instance.
Definition: psyc_slicer.c:417
static void host_recv_notice_place_leave_method(void *cls, const struct GNUNET_PSYC_MessageHeader *msg, const struct GNUNET_PSYC_MessageMethod *meth, uint64_t message_id, const char *method_name)
_notice_place_leave from guests
Definition: social_api.c:417
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:69
struct GNUNET_SOCIAL_Host * hst
struct GNUNET_SOCIAL_Place * plc
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_PSYC_Slicer * slicer
Slicer for processing incoming messages.
Definition: social_api.c:184
GNUNET_SOCIAL_FarewellCallback farewell_cb
Definition: social_api.c:229

Here is the call graph for this function:

Here is the caller graph for this function:

int GNUNET_SOCIAL_host_entry_decision ( struct GNUNET_SOCIAL_Host hst,
struct GNUNET_SOCIAL_Nym nym,
int  is_admitted,
const struct GNUNET_PSYC_Message entry_resp 
)

Decision whether to admit nym into the place or refuse entry.

Parameters
hstHost of the place.
nymHandle for the entity that wanted to enter.
is_admittedGNUNET_YES if nym is admitted, GNUNET_NO if nym is refused entry, GNUNET_SYSERR if we cannot answer the request.
entry_respEntry response message, or NULL.
Returns
GNUNET_OK on success, GNUNET_SYSERR if the message is too large.
Parameters
hstHost of the place.
nymHandle for the entity that wanted to enter.
is_admittedGNUNET_YES if nym is admitted, GNUNET_NO if nym is refused entry, GNUNET_SYSERR if we cannot answer the request.
method_nameMethod name for the rejection message.
envEnvironment containing variables for the message, or NULL.
dataData for the rejection message to send back.
data_sizeNumber of bytes in data for method.
Returns
GNUNET_OK on success, GNUNET_SYSERR if the message is too large.

Definition at line 1360 of file social_api.c.

References env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD, GNUNET_OK, GNUNET_SYSERR, GNUNET_PSYC_Message::header, GNUNET_PSYC_JoinDecisionMessage::is_admitted, GNUNET_SOCIAL_Place::mq, plc, GNUNET_SOCIAL_Host::plc, GNUNET_SOCIAL_Nym::pub_key, GNUNET_MessageHeader::size, and GNUNET_PSYC_JoinDecisionMessage::slave_pub_key.

Referenced by host_answer_door().

1364 {
1365  struct GNUNET_SOCIAL_Place *plc = &hst->plc;
1366  struct GNUNET_PSYC_JoinDecisionMessage *dcsn;
1367  uint16_t entry_resp_size
1368  = (NULL != entry_resp) ? ntohs (entry_resp->header.size) : 0;
1369 
1370  if (GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD < sizeof (*dcsn) + entry_resp_size)
1371  return GNUNET_SYSERR;
1372 
1373  struct GNUNET_MQ_Envelope *
1374  env = GNUNET_MQ_msg_extra (dcsn, entry_resp_size,
1376  dcsn->is_admitted = htonl (is_admitted);
1377  dcsn->slave_pub_key = nym->pub_key;
1378 
1379  if (0 < entry_resp_size)
1380  GNUNET_memcpy (&dcsn[1], entry_resp, entry_resp_size);
1381 
1382  GNUNET_MQ_send (plc->mq, env);
1383  return GNUNET_OK;
1384 }
Join decision sent in reply to a join request.
Handle for a place where social interactions happen.
Definition: social_api.c:144
#define GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD
int32_t is_admitted
GNUNET_YES if the slave was admitted.
struct GNUNET_MQ_Handle * mq
Client connection to the service.
Definition: social_api.c:154
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION
C->S->M: decision about a join request.
#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:51
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:56
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:218
struct GNUNET_MessageHeader header
Message header with size and type information.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key
Public key of the joining slave.
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.
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:354
struct GNUNET_SOCIAL_Place * plc

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_host_eject ( struct GNUNET_SOCIAL_Host hst,
const struct GNUNET_SOCIAL_Nym nym,
struct GNUNET_PSYC_Environment e 
)

Throw nym out of the place.

Sends a _notice_place_leave announcement to the home.

The nym reference will remain valid until the GNUNET_SOCIAL_FarewellCallback is invoked, which should be very soon after this call.

Parameters
hostHost of the place.
nymHandle for the entity to be ejected.
envEnvironment for the message or NULL. _nym is set to nym regardless whether an env is provided.

The nym reference will remain valid until the GNUNET_SOCIAL_FarewellCallback is invoked, which should be very soon after this call.

Parameters
hostHost of the place.
nymHandle for the entity to be ejected.
envEnvironment for the message or NULL.

Definition at line 1402 of file social_api.c.

References e, env, GNUNET_PSYC_env_add(), GNUNET_PSYC_env_create(), GNUNET_PSYC_env_destroy(), GNUNET_PSYC_OP_SET, GNUNET_SOCIAL_ANNOUNCE_NONE, GNUNET_SOCIAL_host_announce(), and GNUNET_SOCIAL_Nym::pub_key.

1405 {
1406  struct GNUNET_PSYC_Environment *env = e;
1407  if (NULL == env)
1408  env = GNUNET_PSYC_env_create ();
1410  "_nym", &nym->pub_key, sizeof (nym->pub_key));
1411  GNUNET_SOCIAL_host_announce (hst, "_notice_place_leave", env, NULL, NULL,
1413  if (NULL == e)
1415 }
struct GNUNET_PSYC_Environment * GNUNET_PSYC_env_create()
Create an environment.
Definition: psyc_env.c:52
void GNUNET_PSYC_env_destroy(struct GNUNET_PSYC_Environment *env)
Destroy an environment.
Definition: psyc_env.c:183
Environment for a message.
Definition: psyc_env.c:38
static struct Experiment * e
Set value of a transient variable.
void GNUNET_PSYC_env_add(struct GNUNET_PSYC_Environment *env, enum GNUNET_PSYC_Operator oper, const char *name, const void *value, size_t value_size)
Add a modifier to the environment.
Definition: psyc_env.c:68
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:56
struct GNUNET_SOCIAL_Announcement * GNUNET_SOCIAL_host_announce(struct GNUNET_SOCIAL_Host *hst, const char *method_name, const struct GNUNET_PSYC_Environment *env, GNUNET_PSYC_TransmitNotifyData notify_data, void *notify_data_cls, enum GNUNET_SOCIAL_AnnounceFlags flags)
Send a message to all nyms that are present in the place.
Definition: social_api.c:1512
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.

Here is the call graph for this function:

struct GNUNET_SOCIAL_Announcement* GNUNET_SOCIAL_host_announce ( struct GNUNET_SOCIAL_Host hst,
const char *  method_name,
const struct GNUNET_PSYC_Environment env,
GNUNET_PSYC_TransmitNotifyData  notify_data,
void *  notify_data_cls,
enum GNUNET_SOCIAL_AnnounceFlags  flags 
)

Send a message to all nyms that are present in the place.

This function is restricted to the host. Nyms can only send requests to the host who can decide to relay it to everyone in the place.

Parameters
hostHost of the place.
method_nameMethod to use for the announcement.
envEnvironment containing variables for the message and operations on objects of the place. Has to remain available until the first call to notify_data. Can be NULL.
notify_dataFunction to call to get the payload of the announcement.
notify_data_clsClosure for notify.
flagsFlags for this announcement.
Returns
NULL on error (another announcement already in progress?).

This function is restricted to the host. Nyms can only send requests to the host who can decide to relay it to everyone in the place.

Parameters
hostHost of the place.
method_nameMethod to use for the announcement.
envEnvironment containing variables for the message and operations on objects of the place. Can be NULL.
notifyFunction to call to get the payload of the announcement.
notify_clsClosure for notify.
flagsFlags for this announcement.
Returns
NULL on error (announcement already in progress?).

Definition at line 1512 of file social_api.c.

References GNUNET_OK, GNUNET_PSYC_transmit_message(), GNUNET_SOCIAL_Host::plc, and GNUNET_SOCIAL_Place::tmit.

Referenced by GNUNET_SOCIAL_host_eject(), GNUNET_SOCIAL_host_leave(), host_announce(), host_assign(), and host_recv_notice_place_leave_eom().

1518 {
1519  if (GNUNET_OK ==
1520  GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env,
1521  NULL, notify_data, notify_data_cls, flags))
1522  return (struct GNUNET_SOCIAL_Announcement *) hst->plc.tmit;
1523  else
1524  return NULL;
1525 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_PSYC_TransmitHandle * tmit
Transmission handle.
Definition: social_api.c:179
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:218
static int notify_data(void *cls, uint16_t *data_size, void *data)
Callback notifying about available buffer space to write message data when transmitting messages usin...
int GNUNET_PSYC_transmit_message(struct GNUNET_PSYC_TransmitHandle *tmit, const char *method_name, const struct GNUNET_PSYC_Environment *env, GNUNET_PSYC_TransmitNotifyModifier notify_mod, GNUNET_PSYC_TransmitNotifyData notify_data, void *notify_cls, uint32_t flags)
Transmit a message.
Definition: psyc_message.c:720
Handle for an announcement request.
Definition: social_api.c:269

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_host_announce_resume ( struct GNUNET_SOCIAL_Announcement a)

Resume transmitting announcement.

Parameters
aThe announcement to resume.

Definition at line 1535 of file social_api.c.

References GNUNET_PSYC_transmit_resume().

1536 {
1538 }
void GNUNET_PSYC_transmit_resume(struct GNUNET_PSYC_TransmitHandle *tmit)
Resume transmission.
Definition: psyc_message.c:791

Here is the call graph for this function:

void GNUNET_SOCIAL_host_announce_cancel ( struct GNUNET_SOCIAL_Announcement a)

Cancel announcement.

Parameters
aThe announcement to cancel.

Definition at line 1548 of file social_api.c.

References GNUNET_PSYC_transmit_cancel().

1549 {
1551 }
void GNUNET_PSYC_transmit_cancel(struct GNUNET_PSYC_TransmitHandle *tmit)
Abort transmission request.
Definition: psyc_message.c:810

Here is the call graph for this function:

void GNUNET_SOCIAL_host_relay_allow_method ( struct GNUNET_SOCIAL_Host host,
const char *  method_prefix 
)

Allow relaying messages from guests matching a given method_prefix.

Allow relaying changes to objects of the place.

Parameters
hostThe host.
method_prefixMethod prefix to allow.

Only applies to messages with an allowed method name.

See also
GNUNET_SCOIAL_host_relay_allow_method()
Parameters
hostThe host.
object_prefixObject prefix to allow modifying.
void GNUNET_SOCIAL_host_relay_stop ( struct GNUNET_SOCIAL_Host host)

Stop relaying messages from guests.

Remove all allowed relay rules.

struct GNUNET_SOCIAL_Place* GNUNET_SOCIAL_host_get_place ( struct GNUNET_SOCIAL_Host hst)

Obtain handle for a hosted place.

The returned handle can be used to access the place API.

Parameters
hostHandle for the host.
Returns
Handle for the hosted place, valid as long as host is valid.

Definition at line 1564 of file social_api.c.

References GNUNET_SOCIAL_Host::plc.

Referenced by app_recv_host(), and host_enter().

1565 {
1566  return &hst->plc;
1567 }
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:218

Here is the caller graph for this function:

void GNUNET_SOCIAL_host_disconnect ( struct GNUNET_SOCIAL_Host hst,
GNUNET_ContinuationCallback  disconnect_cb,
void *  cls 
)

Disconnect from a home.

Invalidates host handle.

Parameters
hstThe host to disconnect.
disconnect_cbFunction called after disconnected from the service.
clsClosure for disconnect_cb.

Invalidates host handle.

Parameters
hstThe host to disconnect.

Definition at line 1579 of file social_api.c.

References place_disconnect(), and GNUNET_SOCIAL_Host::plc.

Referenced by app_disconnected(), and GNUNET_SOCIAL_host_leave().

1582 {
1583  place_disconnect (&hst->plc, disconnect_cb, cls);
1584 }
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:218
void place_disconnect(struct GNUNET_SOCIAL_Place *plc, GNUNET_ContinuationCallback cb, void *cls)
Definition: social_api.c:1078
static void disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
Function called if DV is no longer able to talk to a peer.
Definition: gnunet-dv.c:87

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_host_leave ( struct GNUNET_SOCIAL_Host hst,
const struct GNUNET_PSYC_Environment env,
GNUNET_ContinuationCallback  disconnect_cb,
void *  cls 
)

Stop hosting a home.

Sends a _notice_place_closing announcement to the home. Invalidates host handle.

Parameters
hstHost leaving.
envEnvironment for the message or NULL.
disconnect_cbFunction called after the host left the place and disconnected from the service.
clsClosure for disconnect_cb.

Stop hosting a home.

Sends a _notice_place_closing announcement to the home. Invalidates host handle.

Parameters
hstThe host leaving.
envEnvironment for the message or NULL. _nym is set to nym regardless whether an env is provided.
disconnect_cbFunction called after the host left the place and disconnected from the social service.
clsClosure for disconnect_cb.

Definition at line 1605 of file social_api.c.

References GNUNET_SOCIAL_ANNOUNCE_NONE, GNUNET_SOCIAL_host_announce(), GNUNET_SOCIAL_host_disconnect(), place_leave(), and GNUNET_SOCIAL_Host::plc.

Referenced by host_leave().

1609 {
1610  GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL,
1612  place_leave (&hst->plc);
1614 }
void place_leave(struct GNUNET_SOCIAL_Place *plc)
Definition: social_api.c:1105
void GNUNET_SOCIAL_host_disconnect(struct GNUNET_SOCIAL_Host *hst, GNUNET_ContinuationCallback disconnect_cb, void *cls)
Disconnect from a home.
Definition: social_api.c:1579
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:218
struct GNUNET_SOCIAL_Announcement * GNUNET_SOCIAL_host_announce(struct GNUNET_SOCIAL_Host *hst, const char *method_name, const struct GNUNET_PSYC_Environment *env, GNUNET_PSYC_TransmitNotifyData notify_data, void *notify_data_cls, enum GNUNET_SOCIAL_AnnounceFlags flags)
Send a message to all nyms that are present in the place.
Definition: social_api.c:1512
static void disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
Function called if DV is no longer able to talk to a peer.
Definition: gnunet-dv.c:87

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_Guest* GNUNET_SOCIAL_guest_enter ( const struct GNUNET_SOCIAL_App app,
const struct GNUNET_SOCIAL_Ego ego,
const struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key,
enum GNUNET_PSYC_SlaveJoinFlags  flags,
const struct GNUNET_PeerIdentity origin,
uint32_t  relay_count,
const struct GNUNET_PeerIdentity relays,
const struct GNUNET_PSYC_Message entry_msg,
struct GNUNET_PSYC_Slicer slicer,
GNUNET_SOCIAL_GuestEnterCallback  local_enter_cb,
GNUNET_SOCIAL_EntryDecisionCallback  entry_dcsn_cb,
void *  cls 
)

Request entry to a place as a guest.

Parameters
appApplication handle.
egoIdentity of the guest.
place_pub_keyPublic key of the place to enter.
flagsFlags for the entry.
originPeer identity of the origin of the underlying multicast group.
relay_countNumber of elements in the relays array.
relaysRelays for the underlying multicast group.
entry_msgEntry message.
slicerSlicer to use for processing incoming requests from guests.
Returns
NULL on errors, otherwise handle for the guest.
Parameters
appApplication handle.
egoIdentity of the guest.
place_pub_keyPublic key of the place to enter.
flagsFlags for the entry.
originPeer identity of the origin of the underlying multicast group.
relay_countNumber of elements in the relays array.
relaysRelays for the underlying multicast group.
method_nameMethod name for the message.
envEnvironment containing variables for the message, or NULL.
dataPayload for the message to give to the enter callback.
data_sizeNumber of bytes in data.
slicerSlicer to use for processing incoming requests from guests.
Returns
NULL on errors, otherwise handle for the guest.

Definition at line 1777 of file social_api.c.

References GNUNET_SOCIAL_Guest::cb_cls, GNUNET_SOCIAL_App::cfg, GNUNET_SOCIAL_Place::cfg, GNUNET_SOCIAL_Place::connect_env, GNUNET_SOCIAL_Place::ego_pub_key, GNUNET_SOCIAL_Guest::enter_cb, GNUNET_SOCIAL_Guest::entry_dcsn_cb, GNUNET_malloc, GNUNET_NO, GNUNET_OP_create(), gst, guest_connect(), guest_enter_request_create(), GNUNET_SOCIAL_App::id, GNUNET_SOCIAL_Place::is_host, GNUNET_SOCIAL_Place::op, place_pub_key, plc, GNUNET_SOCIAL_Guest::plc, GNUNET_SOCIAL_Place::pub_key, GNUNET_SOCIAL_Ego::pub_key, slicer, and GNUNET_SOCIAL_Place::slicer.

Referenced by guest_enter().

1789 {
1790  struct GNUNET_SOCIAL_Guest *gst = GNUNET_malloc (sizeof (*gst));
1791  struct GNUNET_SOCIAL_Place *plc = &gst->plc;
1792 
1793  plc->ego_pub_key = ego->pub_key;
1794  plc->pub_key = *place_pub_key;
1795  plc->cfg = app->cfg;
1796  plc->is_host = GNUNET_NO;
1797  plc->slicer = slicer;
1798 
1799  plc->op = GNUNET_OP_create ();
1800 
1801  plc->connect_env
1802  = guest_enter_request_create (app->id, &ego->pub_key, &plc->pub_key,
1803  origin, relay_count, relays, entry_msg);
1804 
1805  gst->enter_cb = local_enter_cb;
1806  gst->entry_dcsn_cb = entry_dcsn_cb;
1807  gst->cb_cls = cls;
1808 
1809  guest_connect (gst);
1810  return gst;
1811 }
Handle for a place where social interactions happen.
Definition: social_api.c:144
void * cb_cls
Closure for callbacks.
Definition: social_api.c:255
struct GNUNET_PSYC_Slicer * slicer
struct GNUNET_CRYPTO_EddsaPublicKey pub_key
Public key of the place.
Definition: social_api.c:199
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:246
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:149
char * id
Application ID.
Definition: social_api.c:109
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_MQ_Envelope * connect_env
Message to send on connect.
Definition: social_api.c:159
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:45
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:174
GNUNET_SOCIAL_GuestEnterCallback enter_cb
Definition: social_api.c:248
static struct GNUNET_MQ_Envelope * guest_enter_request_create(const char *app_id, const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, const struct GNUNET_PeerIdentity *origin, size_t relay_count, const struct GNUNET_PeerIdentity *relays, const struct GNUNET_PSYC_Message *join_msg)
Definition: social_api.c:1710
struct GNUNET_OP_Handle * GNUNET_OP_create()
Create new operations handle.
Definition: op.c:89
Guest handle for place that we entered.
Definition: social_api.c:244
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Public key of the ego.
Definition: social_api.c:204
struct GNUNET_SOCIAL_Guest * gst
uint8_t is_host
Does this place belong to a host (GNUNET_YES) or guest (GNUNET_NO)?
Definition: social_api.c:209
GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb
Definition: social_api.c:250
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:69
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
public key of connected place
static void guest_connect(struct GNUNET_SOCIAL_Guest *gst)
Definition: social_api.c:1664
struct GNUNET_SOCIAL_Place * plc
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_PSYC_Slicer * slicer
Slicer for processing incoming messages.
Definition: social_api.c:184

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_Guest* GNUNET_SOCIAL_guest_enter_by_name ( const struct GNUNET_SOCIAL_App app,
const struct GNUNET_SOCIAL_Ego ego,
const char *  gns_name,
const char *  password,
const struct GNUNET_PSYC_Message join_msg,
struct GNUNET_PSYC_Slicer slicer,
GNUNET_SOCIAL_GuestEnterCallback  local_enter_cb,
GNUNET_SOCIAL_EntryDecisionCallback  entry_decision_cb,
void *  cls 
)

Request entry to a place by name as a guest.

Parameters
appApplication handle.
egoIdentity of the guest.
gns_nameGNS name of the place to enter. Either in the form of 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to the 'PLACE' record of the empty label ("+") in the GNS zone with the nym's public key 'NYMPUBKEY', and can be used to request entry to a pseudonym's place directly.
passwordPassword to decrypt the record, or NULL for cleartext records.
join_msgEntry request message.
slicerSlicer to use for processing incoming requests from guests.
local_enter_cbCalled upon connection established to the social service.
entry_decision_cbCalled upon receiving entry decision.
Returns
NULL on errors, otherwise handle for the guest.
Parameters
appApplication handle.
egoIdentity of the guest.
gns_nameGNS name of the place to enter. Either in the form of 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to the 'PLACE' record of the empty label ("+") in the GNS zone with the nym's public key 'NYMPUBKEY', and can be used to request entry to a pseudonym's place directly.
passwordPassword to decrypt the record, or NULL for cleartext records.
join_msgEntry request message or NULL.
slicerSlicer to use for processing incoming requests from guests.
local_enter_cbCalled upon connection established to the social service.
entry_decision_cbCalled upon receiving entry decision.
Returns
NULL on errors, otherwise handle for the guest.

Definition at line 1841 of file social_api.c.

References GNUNET_SOCIAL_Guest::cb_cls, GNUNET_SOCIAL_App::cfg, GNUNET_SOCIAL_Place::cfg, GNUNET_SOCIAL_Place::connect_env, GuestEnterByNameRequest::ego_pub_key, GNUNET_SOCIAL_Place::ego_pub_key, GNUNET_SOCIAL_Guest::enter_cb, GNUNET_SOCIAL_Guest::entry_dcsn_cb, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_OP_create(), gst, guest_connect(), GNUNET_PSYC_Message::header, GNUNET_SOCIAL_App::id, GNUNET_SOCIAL_Place::is_host, GNUNET_SOCIAL_Place::op, p, plc, GNUNET_SOCIAL_Guest::plc, GNUNET_SOCIAL_Ego::pub_key, GNUNET_MessageHeader::size, slicer, and GNUNET_SOCIAL_Place::slicer.

Referenced by guest_enter_by_name().

1850 {
1851  struct GNUNET_SOCIAL_Guest *gst = GNUNET_malloc (sizeof (*gst));
1852  struct GNUNET_SOCIAL_Place *plc = &gst->plc;
1853 
1854  if (NULL == password)
1855  password = "";
1856 
1857  uint16_t app_id_size = strlen (app->id) + 1;
1858  uint16_t gns_name_size = strlen (gns_name) + 1;
1859  uint16_t password_size = strlen (password) + 1;
1860 
1861  uint16_t join_msg_size = 0;
1862  if (NULL != join_msg)
1863  join_msg_size = ntohs (join_msg->header.size);
1864 
1865  struct GuestEnterByNameRequest *greq;
1866  plc->connect_env
1867  = GNUNET_MQ_msg_extra (greq, app_id_size + gns_name_size
1868  + password_size + join_msg_size,
1870 
1871  greq->ego_pub_key = ego->pub_key;
1872 
1873  char *p = (char *) &greq[1];
1874  GNUNET_memcpy (p, app->id, app_id_size);
1875  p += app_id_size;
1876  GNUNET_memcpy (p, gns_name, gns_name_size);
1877  p += gns_name_size;
1878  GNUNET_memcpy (p, password, password_size);
1879  p += password_size;
1880  if (NULL != join_msg)
1881  GNUNET_memcpy (p, join_msg, join_msg_size);
1882 
1883  plc->ego_pub_key = ego->pub_key;
1884  plc->cfg = app->cfg;
1885  plc->is_host = GNUNET_NO;
1886  plc->slicer = slicer;
1887 
1888  plc->op = GNUNET_OP_create ();
1889 
1890  gst->enter_cb = local_enter_cb;
1891  gst->entry_dcsn_cb = entry_decision_cb;
1892  gst->cb_cls = cls;
1893 
1894  guest_connect (gst);
1895  return gst;
1896 }
Handle for a place where social interactions happen.
Definition: social_api.c:144
void * cb_cls
Closure for callbacks.
Definition: social_api.c:255
#define GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME
C->S: request to enter a place as a guest, using a GNS address.
struct GNUNET_PSYC_Slicer * slicer
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:246
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:149
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:37
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
char * id
Application ID.
Definition: social_api.c:109
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_MQ_Envelope * connect_env
Message to send on connect.
Definition: social_api.c:159
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:45
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:174
GNUNET_SOCIAL_GuestEnterCallback enter_cb
Definition: social_api.c:248
#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:51
struct GNUNET_OP_Handle * GNUNET_OP_create()
Create new operations handle.
Definition: op.c:89
Guest handle for place that we entered.
Definition: social_api.c:244
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Public key of the ego.
Definition: social_api.c:204
struct GNUNET_MessageHeader header
Message header with size and type information.
struct GNUNET_SOCIAL_Guest * gst
uint8_t is_host
Does this place belong to a host (GNUNET_YES) or guest (GNUNET_NO)?
Definition: social_api.c:209
GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb
Definition: social_api.c:250
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:69
static void guest_connect(struct GNUNET_SOCIAL_Guest *gst)
Definition: social_api.c:1664
struct GNUNET_SOCIAL_Place * plc
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:172
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_PSYC_Slicer * slicer
Slicer for processing incoming messages.
Definition: social_api.c:184

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_Guest* GNUNET_SOCIAL_guest_enter_reconnect ( struct GNUNET_SOCIAL_GuestConnection gconn,
enum GNUNET_PSYC_SlaveJoinFlags  flags,
struct GNUNET_PSYC_Slicer slicer,
GNUNET_SOCIAL_GuestEnterCallback  local_enter_cb,
void *  cls 
)

Reconnect to an already entered place as guest.

Parameters
gconnGuest connection handle.
See also
GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback()
Parameters
flagsFlags for the entry.
slicerSlicer to use for processing incoming requests from guests.
local_enter_cbCalled upon connection established to the social service.
entry_decision_cbCalled upon receiving entry decision.
Returns
NULL on errors, otherwise handle for the guest.

Definition at line 1917 of file social_api.c.

References GNUNET_SOCIAL_GuestConnection::app, GNUNET_SOCIAL_Guest::cb_cls, GNUNET_SOCIAL_App::cfg, GNUNET_SOCIAL_Place::cfg, GNUNET_SOCIAL_Place::connect_env, GuestEnterRequest::ego_pub_key, GNUNET_SOCIAL_Place::ego_pub_key, AppPlaceMessage::ego_pub_key, GNUNET_SOCIAL_Guest::enter_cb, GuestEnterRequest::flags, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_OP_create(), gst, guest_connect(), GNUNET_SOCIAL_App::id, GNUNET_SOCIAL_Place::is_host, GNUNET_SOCIAL_Place::op, GuestEnterRequest::place_pub_key, AppPlaceMessage::place_pub_key, plc, GNUNET_SOCIAL_Guest::plc, GNUNET_SOCIAL_GuestConnection::plc_msg, GNUNET_SOCIAL_Place::pub_key, slicer, and GNUNET_SOCIAL_Place::slicer.

Referenced by app_recv_guest().

1922 {
1923  struct GNUNET_SOCIAL_Guest *gst = GNUNET_malloc (sizeof (*gst));
1924  struct GNUNET_SOCIAL_Place *plc = &gst->plc;
1925 
1926  uint16_t app_id_size = strlen (gconn->app->id) + 1;
1927  struct GuestEnterRequest *greq;
1928  plc->connect_env
1929  = GNUNET_MQ_msg_extra (greq, app_id_size,
1931  greq->ego_pub_key = gconn->plc_msg.ego_pub_key;
1932  greq->place_pub_key = gconn->plc_msg.place_pub_key;
1933  greq->flags = htonl (flags);
1934 
1935  GNUNET_memcpy (&greq[1], gconn->app->id, app_id_size);
1936 
1937  plc->cfg = gconn->app->cfg;
1938  plc->is_host = GNUNET_NO;
1939  plc->slicer = slicer;
1940  plc->pub_key = gconn->plc_msg.place_pub_key;
1941  plc->ego_pub_key = gconn->plc_msg.ego_pub_key;
1942 
1943  plc->op = GNUNET_OP_create ();
1944 
1945  gst->enter_cb = local_enter_cb;
1946  gst->cb_cls = cls;
1947 
1948  guest_connect (gst);
1949  return gst;
1950 }
Handle for a place where social interactions happen.
Definition: social_api.c:144
void * cb_cls
Closure for callbacks.
Definition: social_api.c:255
struct GNUNET_PSYC_Slicer * slicer
struct GNUNET_CRYPTO_EddsaPublicKey pub_key
Public key of the place.
Definition: social_api.c:199
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
Definition: social.h:133
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:246
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:149
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
Definition: social.h:259
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
char * id
Application ID.
Definition: social_api.c:109
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_MQ_Envelope * connect_env
Message to send on connect.
Definition: social_api.c:159
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:174
GNUNET_SOCIAL_GuestEnterCallback enter_cb
Definition: social_api.c:248
#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:51
struct AppPlaceMessage plc_msg
Definition: social_api.c:137
uint32_t flags
Definition: social.h:137
struct GNUNET_OP_Handle * GNUNET_OP_create()
Create new operations handle.
Definition: op.c:89
Guest handle for place that we entered.
Definition: social_api.c:244
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Public key of the ego.
Definition: social_api.c:204
struct GNUNET_SOCIAL_App * app
Definition: social_api.c:135
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:257
struct GNUNET_SOCIAL_Guest * gst
uint8_t is_host
Does this place belong to a host (GNUNET_YES) or guest (GNUNET_NO)?
Definition: social_api.c:209
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:131
#define GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER
C->S: request to enter a place as a guest.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: social_api.c:69
static void guest_connect(struct GNUNET_SOCIAL_Guest *gst)
Definition: social_api.c:1664
struct GNUNET_SOCIAL_Place * plc
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_PSYC_Slicer * slicer
Slicer for processing incoming messages.
Definition: social_api.c:184

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_TalkRequest* GNUNET_SOCIAL_guest_talk ( struct GNUNET_SOCIAL_Guest gst,
const char *  method_name,
const struct GNUNET_PSYC_Environment env,
GNUNET_PSYC_TransmitNotifyData  notify_data,
void *  notify_data_cls,
enum GNUNET_SOCIAL_TalkFlags  flags 
)

Talk to the host of the place.

Parameters
placePlace where we want to talk to the host.
method_nameMethod to invoke on the host.
envEnvironment containing variables for the message, or NULL.
notify_dataFunction to use to get the payload for the method.
notify_data_clsClosure for notify_data.
flagsFlags for the message being sent.
Returns
NULL if we are already trying to talk to the host, otherwise handle to cancel the request.

Definition at line 1973 of file social_api.c.

References GNUNET_assert, GNUNET_OK, GNUNET_PSYC_transmit_message(), plc, GNUNET_SOCIAL_Guest::plc, and GNUNET_SOCIAL_Place::tmit.

Referenced by GNUNET_SOCIAL_guest_leave(), and guest_talk().

1979 {
1980  struct GNUNET_SOCIAL_Place *plc = &gst->plc;
1981  GNUNET_assert (NULL != plc->tmit);
1982 
1983  if (GNUNET_OK ==
1984  GNUNET_PSYC_transmit_message (plc->tmit, method_name, env,
1985  NULL, notify_data, notify_data_cls, flags))
1986  return (struct GNUNET_SOCIAL_TalkRequest *) plc->tmit;
1987  else
1988  return NULL;
1989 }
Handle for a place where social interactions happen.
Definition: social_api.c:144
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:246
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
A talk request.
Definition: social_api.c:278
struct GNUNET_PSYC_TransmitHandle * tmit
Transmission handle.
Definition: social_api.c:179
static int notify_data(void *cls, uint16_t *data_size, void *data)
Callback notifying about available buffer space to write message data when transmitting messages usin...
int GNUNET_PSYC_transmit_message(struct GNUNET_PSYC_TransmitHandle *tmit, const char *method_name, const struct GNUNET_PSYC_Environment *env, GNUNET_PSYC_TransmitNotifyModifier notify_mod, GNUNET_PSYC_TransmitNotifyData notify_data, void *notify_cls, uint32_t flags)
Transmit a message.
Definition: psyc_message.c:720
struct GNUNET_SOCIAL_Place * plc

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_guest_talk_resume ( struct GNUNET_SOCIAL_TalkRequest tr)

Resume talking to the host of the place.

Parameters
trTalk request to resume.

Definition at line 1999 of file social_api.c.

References GNUNET_PSYC_transmit_resume().

2000 {
2002 }
void GNUNET_PSYC_transmit_resume(struct GNUNET_PSYC_TransmitHandle *tmit)
Resume transmission.
Definition: psyc_message.c:791

Here is the call graph for this function:

void GNUNET_SOCIAL_guest_talk_cancel ( struct GNUNET_SOCIAL_TalkRequest tr)

Cancel talking to the host of the place.

Parameters
trTalk request to cancel.

Definition at line 2012 of file social_api.c.

References GNUNET_PSYC_transmit_cancel().

2013 {
2015 }
void GNUNET_PSYC_transmit_cancel(struct GNUNET_PSYC_TransmitHandle *tmit)
Abort transmission request.
Definition: psyc_message.c:810

Here is the call graph for this function:

void GNUNET_SOCIAL_guest_disconnect ( struct GNUNET_SOCIAL_Guest gst,
GNUNET_ContinuationCallback  disconnect_cb,
void *  cls 
)

Disconnect from a place.

Invalidates guest handle.

Parameters
gstThe guest to disconnect.
disconnect_cbFunction called after disconnected from the service.
clsClosure for disconnect_cb.

Invalidates guest handle.

Parameters
gstThe guest to disconnect.

Definition at line 2027 of file social_api.c.

References place_disconnect(), and GNUNET_SOCIAL_Guest::plc.

Referenced by app_disconnected(), and GNUNET_SOCIAL_guest_leave().

2030 {
2031  place_disconnect (&gst->plc, disconnect_cb, cls);
2032 }
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:246
void place_disconnect(struct GNUNET_SOCIAL_Place *plc, GNUNET_ContinuationCallback cb, void *cls)
Definition: social_api.c:1078
static void disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
Function called if DV is no longer able to talk to a peer.
Definition: gnunet-dv.c:87

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_guest_leave ( struct GNUNET_SOCIAL_Guest gst,
struct GNUNET_PSYC_Environment env,
GNUNET_ContinuationCallback  disconnect_cb,
void *  cls 
)

Leave a place temporarily or permanently.

Notifies the owner of the place about leaving, and destroys the place handle.

Parameters
placePlace to leave.
envOptional environment for the leave message if keep_active is GNUNET_NO. NULL if not needed.
disconnect_cbCalled upon disconnecting from the social service.

Notifies the owner of the place about leaving, and destroys the place handle.

Parameters
placePlace to leave.
keep_activeKeep place active after last application disconnected. GNUNET_YES or GNUNET_NO
envOptional environment for the leave message if keep_active is GNUNET_NO. NULL if not needed.
leave_cbCalled upon disconnecting from the social service.

Definition at line 2052 of file social_api.c.

References GNUNET_SOCIAL_guest_disconnect(), GNUNET_SOCIAL_guest_talk(), GNUNET_SOCIAL_TALK_NONE, place_leave(), and GNUNET_SOCIAL_Guest::plc.

Referenced by guest_leave().

2056 {
2057  GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL,
2059  place_leave (&gst->plc);
2061 }
void place_leave(struct GNUNET_SOCIAL_Place *plc)
Definition: social_api.c:1105
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:246
static void disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer)
Function called if DV is no longer able to talk to a peer.
Definition: gnunet-dv.c:87
struct GNUNET_SOCIAL_TalkRequest * GNUNET_SOCIAL_guest_talk(struct GNUNET_SOCIAL_Guest *gst, const char *method_name, const struct GNUNET_PSYC_Environment *env, GNUNET_PSYC_TransmitNotifyData notify_data, void *notify_data_cls, enum GNUNET_SOCIAL_TalkFlags flags)
Talk to the host of the place.
Definition: social_api.c:1973
void GNUNET_SOCIAL_guest_disconnect(struct GNUNET_SOCIAL_Guest *gst, GNUNET_ContinuationCallback disconnect_cb, void *cls)
Disconnect from a place.
Definition: social_api.c:2027

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_Place* GNUNET_SOCIAL_guest_get_place ( struct GNUNET_SOCIAL_Guest gst)

Obtain handle for a place entered as guest.

The returned handle can be used to access the place API.

Parameters
guestHandle for the guest.
Returns
Handle for the place, valid as long as guest is valid.

Definition at line 2074 of file social_api.c.

References GNUNET_SOCIAL_Guest::plc.

Referenced by app_recv_guest(), guest_enter(), and guest_enter_by_name().

2075 {
2076  return &gst->plc;
2077 }
struct GNUNET_SOCIAL_Place plc
Definition: social_api.c:246

Here is the caller graph for this function:

const struct GNUNET_CRYPTO_EddsaPublicKey* GNUNET_SOCIAL_place_get_pub_key ( const struct GNUNET_SOCIAL_Place plc)

Get the public key of a place.

Parameters
plcPlace.
Returns
Public key of the place.

Get the public key of a place.

Parameters
plcPlace.
Returns
Public key of the place.

Definition at line 2089 of file social_api.c.

References GNUNET_SOCIAL_Place::pub_key.

2090 {
2091  return &plc->pub_key;
2092 }
struct GNUNET_CRYPTO_EddsaPublicKey pub_key
Public key of the place.
Definition: social_api.c:199
void GNUNET_SOCIAL_place_msg_proc_set ( struct GNUNET_SOCIAL_Place plc,
const char *  method_prefix,
enum GNUNET_SOCIAL_MsgProcFlags  flags 
)

Set message processing flags for a method_prefix.

Parameters
plcPlace.
method_prefixMethod prefix flags apply to.
flagsThe flags that apply to a matching method_prefix.

Definition at line 2106 of file social_api.c.

References env, MsgProcRequest::flags, GNUNET_assert, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVER_MAX_MESSAGE_SIZE, GNUNET_SOCIAL_Place::mq, and strnlen().

2109 {
2110  GNUNET_assert (NULL != method_prefix);
2111  struct MsgProcRequest *mpreq;
2112  uint16_t method_size = strnlen (method_prefix,
2114  - sizeof (*mpreq)) + 1;
2115  GNUNET_assert ('\0' == method_prefix[method_size - 1]);
2116 
2117  struct GNUNET_MQ_Envelope *
2118  env = GNUNET_MQ_msg_extra (mpreq, method_size,
2120  mpreq->flags = htonl (flags);
2121  GNUNET_memcpy (&mpreq[1], method_prefix, method_size);
2122 
2123  GNUNET_MQ_send (plc->mq, env);
2124 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_SERVER_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct GNUNET_MQ_Handle * mq
Client connection to the service.
Definition: social_api.c:154
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint64_t flags
Flags that were set for this envelope by GNUNET_MQ_env_set_options().
Definition: mq.c:73
#define GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET
C->S: set message processing flags.
#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:51
uint32_t flags
Definition: social.h:97
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.
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:354
static size_t strnlen(const char *s, size_t n)

Here is the call graph for this function:

void GNUNET_SOCIAL_place_msg_proc_clear ( struct GNUNET_SOCIAL_Place plc)

Clear all message processing flags previously set for this place.

Definition at line 2131 of file social_api.c.

References env, GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR, GNUNET_MQ_msg, GNUNET_MQ_send(), and GNUNET_SOCIAL_Place::mq.

2132 {
2133  struct GNUNET_MessageHeader *req;
2134  struct GNUNET_MQ_Envelope *
2136 
2137  GNUNET_MQ_send (plc->mq, env);
2138 }
#define GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR
C->S: clear message processing flags.
struct GNUNET_MQ_Handle * mq
Client connection to the service.
Definition: social_api.c:154
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:63
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.
Header for all communications.
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:354

Here is the call graph for this function:

struct GNUNET_SOCIAL_HistoryRequest* GNUNET_SOCIAL_place_history_replay ( struct GNUNET_SOCIAL_Place plc,
uint64_t  start_message_id,
uint64_t  end_message_id,
const char *  method_prefix,
uint32_t  flags,
struct GNUNET_PSYC_Slicer slicer,
GNUNET_ResultCallback  result_cb,
void *  cls 
)

Learn about the history of a place.

Messages are returned through the slicer function and have the GNUNET_PSYC_MESSAGE_HISTORIC flag set.

Parameters
placePlace we want to learn more about.
start_message_idFirst historic message we are interested in.
end_message_idLast historic message we are interested in (inclusive).
method_prefixOnly retrieve messages with this method prefix.
flagsOR'ed GNUNET_PSYC_HistoryReplayFlags
slicerSlicer to use for retrieved messages. Can be the same as the slicer of the place.
result_cbFunction called after all messages retrieved. NULL if not needed.
clsClosure for result_cb.

Definition at line 2206 of file social_api.c.

References place_history_replay().

Referenced by history_replay().

2214 {
2215  return place_history_replay (plc, start_message_id, end_message_id, 0,
2216  method_prefix, flags, slicer, result_cb, cls);
2217 }
uint64_t flags
Flags that were set for this envelope by GNUNET_MQ_env_set_options().
Definition: mq.c:73
static struct GNUNET_SOCIAL_HistoryRequest * place_history_replay(struct GNUNET_SOCIAL_Place *plc, uint64_t start_message_id, uint64_t end_message_id, uint64_t message_limit, const char *method_prefix, uint32_t flags, struct GNUNET_PSYC_Slicer *slicer, GNUNET_ResultCallback result_cb, void *cls)
Definition: social_api.c:2142

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_HistoryRequest* GNUNET_SOCIAL_place_history_replay_latest ( struct GNUNET_SOCIAL_Place plc,
uint64_t  message_limit,
const char *  method_prefix,
uint32_t  flags,
struct GNUNET_PSYC_Slicer slicer,
GNUNET_ResultCallback  result_cb,
void *  cls 
)

Learn about the history of a place.

Sends messages through the slicer function of the place where start_message_id <= message_id <= end_message_id. The messages will have the GNUNET_PSYC_MESSAGE_HISTORIC flag set.

To get the latest message, use 0 for both the start and end message ID.

Parameters
placePlace we want to learn more about.
message_limitMaximum number of historic messages we are interested in.
result_cbFunction called after all messages retrieved. NULL if not needed.
clsClosure for result_cb.

Sends messages through the slicer function of the place where start_message_id <= message_id <= end_message_id. The messages will have the GNUNET_PSYC_MESSAGE_HISTORIC flag set.

To get the latest message, use 0 for both the start and end message ID.

Parameters
placePlace we want to learn more about.
message_limitMaximum number of historic messages we are interested in.
method_prefixOnly retrieve messages with this method prefix.
flagsOR'ed GNUNET_PSYC_HistoryReplayFlags
result_cbFunction called after all messages retrieved. NULL if not needed.
clsClosure for result_cb.

Definition at line 2243 of file social_api.c.

References place_history_replay().

Referenced by history_replay_latest().

2250 {
2251  return place_history_replay (plc, 0, 0, message_limit, method_prefix, flags,
2252  slicer, result_cb, cls);
2253 }
uint64_t flags
Flags that were set for this envelope by GNUNET_MQ_env_set_options().
Definition: mq.c:73
static struct GNUNET_SOCIAL_HistoryRequest * place_history_replay(struct GNUNET_SOCIAL_Place *plc, uint64_t start_message_id, uint64_t end_message_id, uint64_t message_limit, const char *method_prefix, uint32_t flags, struct GNUNET_PSYC_Slicer *slicer, GNUNET_ResultCallback result_cb, void *cls)
Definition: social_api.c:2142

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_place_history_replay_cancel ( struct GNUNET_SOCIAL_HistoryRequest hist)

Cancel learning about the history of a place.

Parameters
histHistory lesson to cancel.

Definition at line 2263 of file social_api.c.

References GNUNET_free, GNUNET_OP_remove(), GNUNET_SOCIAL_Place::op, GNUNET_SOCIAL_HistoryRequest::op_id, and GNUNET_SOCIAL_HistoryRequest::plc.

2264 {
2265  GNUNET_OP_remove (hist->plc->op, hist->op_id);
2266  GNUNET_free (hist);
2267 }
struct GNUNET_SOCIAL_Place * plc
Place.
Definition: social_api.c:292
uint64_t op_id
Operation ID.
Definition: social_api.c:297
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:174
int GNUNET_OP_remove(struct GNUNET_OP_Handle *h, uint64_t op_id)
Remove / cancel an operation.
Definition: op.c:326
#define GNUNET_free(ptr)
Wrapper around free.

Here is the call graph for this function:

struct GNUNET_SOCIAL_LookHandle* GNUNET_SOCIAL_place_look_at ( struct GNUNET_SOCIAL_Place plc,
const char *  full_name,
GNUNET_PSYC_StateVarCallback  var_cb,
GNUNET_ResultCallback  result_cb,
void *  cls 
)

Look at a particular object in the place.

The best matching object is returned (its name might be less specific than what was requested).

Parameters
placeThe place to look the object at.
full_nameFull name of the object.
Returns
NULL if there is no such object at this place.

The best matching object is returned (its name might be less specific than what was requested).

Parameters
placeThe place where to look.
full_nameFull name of the object.
value_sizeSet to the size of the returned value.
Returns
NULL if there is no such object at this place.

Definition at line 2316 of file social_api.c.

References GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, and place_state_get().

Referenced by look_at().

2321 {
2323  full_name, var_cb, result_cb, cls);
2324 }
#define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET
C->S: request best matching state variable from PSYCstore.
static struct GNUNET_SOCIAL_LookHandle * place_state_get(struct GNUNET_SOCIAL_Place *plc, uint16_t type, const char *name, GNUNET_PSYC_StateVarCallback var_cb, GNUNET_ResultCallback result_cb, void *cls)
Request matching state variables.
Definition: social_api.c:2274

Here is the call graph for this function:

Here is the caller graph for this function:

struct GNUNET_SOCIAL_LookHandle* GNUNET_SOCIAL_place_look_for ( struct GNUNET_SOCIAL_Place plc,
const char *  name_prefix,
GNUNET_PSYC_StateVarCallback  var_cb,
GNUNET_ResultCallback  result_cb,
void *  cls 
)

Look for objects in the place with a matching name prefix.

Parameters
placeThe place to look its objects at.
name_prefixLook at objects with names beginning with this value.
var_cbFunction to call for each object found.
clsClosure for callback function.
Returns
Handle that can be used to stop looking at objects.
Parameters
placeThe place where to look.
name_prefixLook at objects with names beginning with this value.
var_cbFunction to call for each object found.
clsClosure for callback function.
Returns
Handle that can be used to stop looking at objects.

Definition at line 2342 of file social_api.c.

References GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, and place_state_get().

Referenced by look_for().

2347 {
2349  name_prefix, var_cb, result_cb, cls);
2350 }
#define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX
C->S: request state variables with a given prefix from PSYCstore.
static struct GNUNET_SOCIAL_LookHandle * place_state_get(struct GNUNET_SOCIAL_Place *plc, uint16_t type, const char *name, GNUNET_PSYC_StateVarCallback var_cb, GNUNET_ResultCallback result_cb, void *cls)
Request matching state variables.
Definition: social_api.c:2274

Here is the call graph for this function:

Here is the caller graph for this function:

void GNUNET_SOCIAL_place_look_cancel ( struct GNUNET_SOCIAL_LookHandle look)

Stop looking at objects.

Parameters
lhLook handle to stop.

Stop looking at objects.

Parameters
srHandle for the operation to cancel.

Definition at line 2360 of file social_api.c.

References GNUNET_free, GNUNET_OP_remove(), GNUNET_SOCIAL_Place::op, GNUNET_SOCIAL_LookHandle::op_id, and GNUNET_SOCIAL_LookHandle::plc.

2361 {
2362  GNUNET_OP_remove (look->plc->op, look->op_id);
2363  GNUNET_free (look);
2364 }
struct GNUNET_SOCIAL_Place * plc
Place.
Definition: social_api.c:321
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:174
int GNUNET_OP_remove(struct GNUNET_OP_Handle *h, uint64_t op_id)
Remove / cancel an operation.
Definition: op.c:326
uint64_t op_id
Operation ID.
Definition: social_api.c:326
#define GNUNET_free(ptr)
Wrapper around free.

Here is the call graph for this function:

int GNUNET_SOCIAL_zone_add_place ( const struct GNUNET_SOCIAL_App app,
const struct GNUNET_SOCIAL_Ego ego,
const char *  name,
const char *  password,
const struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key,
const struct GNUNET_PeerIdentity origin,
uint32_t  relay_count,
const struct GNUNET_PeerIdentity relays,
struct GNUNET_TIME_Absolute  expiration_time,
GNUNET_ResultCallback  result_cb,
void *  result_cls 
)

Advertise a place in the GNS zone of ego.

Parameters
appApplication handle.
egoEgo.
place_pub_keyPublic key of place to add.
nameThe name for the PLACE record to put in the zone.
passwordPassword used to encrypt the record or NULL to keep it cleartext.
relay_countNumber of elements in the relays array.
relaysList of relays to put in the PLACE record to advertise as entry points to the place in addition to the origin.
expiration_timeExpiration time of the record, use 0 to remove the record.
result_cbFunction called with the result of the operation.
result_clsClosure for result_cb
Returns
GNUNET_OK if the request was sent, GNUNET_SYSERR on error, e.g. the name/password is too long.

Advertise a place in the GNS zone of ego.

Parameters
appApplication handle.
egoEgo.
place_pub_keyPublic key of place to add.
nameThe name for the PLACE record to put in the zone.
passwordPassword used to encrypt the record or NULL to keep it cleartext.
relay_countNumber of elements in the relays array.
relaysList of relays to put in the PLACE record to advertise as entry points to the place in addition to the origin.
expiration_timeExpiration time of the record, use 0 to remove the record.
result_cbFunction called with the result of the operation.
result_clsClosure for result_cb
Returns
GNUNET_OK if the request was sent, GNUNET_SYSERR on error, e.g. the name/password is too long.

Definition at line 2411 of file social_api.c.

References GNUNET_TIME_Absolute::abs_value_us, ZoneAddPlaceRequest::ego_pub_key, env, ZoneAddPlaceRequest::expiration_time, GNUNET_htonll(), GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_OP_add(), GNUNET_SERVER_MAX_MESSAGE_SIZE, GNUNET_SYSERR, GNUNET_SOCIAL_App::mq, GNUNET_SOCIAL_App::op, ZoneAddPlaceRequest::op_id, op_recv_zone_add_place_result(), ZoneAddPlaceRequest::origin, p, place_pub_key, ZoneAddPlaceRequest::place_pub_key, GNUNET_SOCIAL_Ego::pub_key, ZoneAddPlaceRequest::relay_count, ZoneAddPlaceHandle::result_cb, and ZoneAddPlaceHandle::result_cls.

2422 {
2423  struct ZoneAddPlaceRequest *preq;
2424  size_t name_size = strlen (name) + 1;
2425  size_t password_size = strlen (password) + 1;
2426  size_t relay_size = relay_count * sizeof (*relays);
2427  size_t payload_size = name_size + password_size + relay_size;
2428 
2429  if (GNUNET_SERVER_MAX_MESSAGE_SIZE < sizeof (*preq) + payload_size)
2430  return GNUNET_SYSERR;
2431 
2432  struct GNUNET_MQ_Envelope *
2433  env = GNUNET_MQ_msg_extra (preq, payload_size,
2435  preq->expiration_time = GNUNET_htonll (expiration_time.abs_value_us);
2436  preq->ego_pub_key = ego->pub_key;
2437  preq->place_pub_key = *place_pub_key;
2438  preq->origin = *origin;
2439  preq->relay_count = htonl (relay_count);
2440 
2441  char *p = (char *) &preq[1];
2442  GNUNET_memcpy (p, name, name_size);
2443  p += name_size;
2444  GNUNET_memcpy (p, password, password_size);
2445  p += password_size;
2446  GNUNET_memcpy (p, relays, relay_size);
2447 
2448  struct ZoneAddPlaceHandle * add_plc = GNUNET_malloc (sizeof (*add_plc));
2449  add_plc->result_cb = result_cb;
2450  add_plc->result_cls = result_cls;
2451 
2452  preq->op_id = GNUNET_htonll (GNUNET_OP_add (app->op,
2454  add_plc, NULL));
2455 
2456  GNUNET_MQ_send (app->mq, env);
2457  return GNUNET_OK;
2458 }
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
Definition: social.h:199
uint64_t op_id
Operation ID.
Definition: social.h:190
GNUNET_ResultCallback result_cb
Definition: social_api.c:362
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:37
#define GNUNET_SERVER_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:197
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:45
uint64_t abs_value_us
The actual value.
struct GNUNET_MQ_Handle * mq
Client connection to the service.
Definition: social_api.c:74
#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:51
struct GNUNET_PeerIdentity origin
Definition: social.h:201
uint64_t expiration_time
Expiration time: absolute value in us.
Definition: social.h:195
#define GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE
C->S: add place to GNS zone.
uint32_t relay_count
Definition: social.h:185
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
const char * name
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:94
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:354
uint64_t GNUNET_OP_add(struct GNUNET_OP_Handle *h, GNUNET_ResultCallback result_cb, void *cls, void *ctx)
Add a new operation.
Definition: op.c:197
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
public key of connected place
#define GNUNET_malloc(size)
Wrapper around malloc.
static void op_recv_zone_add_place_result(void *cls, int64_t result, const void *err_msg, uint16_t err_msg_size)
Definition: social_api.c:2368

Here is the call graph for this function:

int GNUNET_SOCIAL_zone_add_nym ( const struct GNUNET_SOCIAL_App app,
const struct GNUNET_SOCIAL_Ego ego,
const char *  name,
const struct GNUNET_CRYPTO_EcdsaPublicKey nym_pub_key,
struct GNUNET_TIME_Absolute  expiration_time,
GNUNET_ResultCallback  result_cb,
void *  result_cls 
)

Add public key to the GNS zone of the ego.

Parameters
cfgConfiguration.
egoEgo.
nameThe name for the PKEY record to put in the zone.
nym_pub_keyPublic key of nym to add.
expiration_timeExpiration time of the record, use 0 to remove the record.
result_cbFunction called with the result of the operation.
result_clsClosure for result_cb
Returns
GNUNET_OK if the request was sent, GNUNET_SYSERR on error, e.g. the name is too long.

Add public key to the GNS zone of the ego.

Parameters
cfgConfiguration.
egoEgo.
nameThe name for the PKEY record to put in the zone.
nym_pub_keyPublic key of nym to add.
expiration_timeExpiration time of the record, use 0 to remove the record.
result_cbFunction called with the result of the operation.
result_clsClosure for result_cb
Returns
GNUNET_OK if the request was sent, GNUNET_SYSERR on error, e.g. the name is too long.

Definition at line 2498 of file social_api.c.

References GNUNET_TIME_Absolute::abs_value_us, ZoneAddNymRequest::ego_pub_key, env, ZoneAddNymRequest::expiration_time, GNUNET_htonll(), GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_OP_add(), GNUNET_SERVER_MAX_MESSAGE_SIZE, GNUNET_SYSERR, GNUNET_SOCIAL_App::mq, ZoneAddNymRequest::nym_pub_key, GNUNET_SOCIAL_App::op, ZoneAddNymRequest::op_id, op_recv_zone_add_nym_result(), GNUNET_SOCIAL_Ego::pub_key, ZoneAddNymHandle::result_cb, and ZoneAddNymHandle::result_cls.

2505 {
2506  struct ZoneAddNymRequest *nreq;
2507 
2508  size_t name_size = strlen (name) + 1;
2509  if (GNUNET_SERVER_MAX_MESSAGE_SIZE < sizeof (*nreq) + name_size)
2510  return GNUNET_SYSERR;
2511 
2512  struct GNUNET_MQ_Envelope *
2513  env = GNUNET_MQ_msg_extra (nreq, name_size,
2515  nreq->expiration_time = GNUNET_htonll (expiration_time.abs_value_us);
2516  nreq->ego_pub_key = ego->pub_key;
2517  nreq->nym_pub_key = *nym_pub_key;
2518  GNUNET_memcpy (&nreq[1], name, name_size);
2519 
2520  struct ZoneAddNymHandle *add_nym = GNUNET_malloc (sizeof (*add_nym));
2521  add_nym->result_cb = result_cb;
2522  add_nym->result_cls = result_cls;
2523 
2524  nreq->op_id = GNUNET_htonll (GNUNET_OP_add (app->op,
2526  add_nym, NULL));
2527 
2528  GNUNET_MQ_send (app->mq, env);
2529  return GNUNET_OK;
2530 }
#define GNUNET_SERVER_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPublicKey pub_key
Definition: social_api.c:45
uint64_t abs_value_us
The actual value.
struct GNUNET_MQ_Handle * mq
Client connection to the service.
Definition: social_api.c:74
#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:51
uint64_t op_id
Operation ID.
Definition: social.h:216
#define GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM
C->S: add nym to GNS zone.
struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key
Definition: social.h:223
uint64_t expiration_time
Expiration time: absolute value in us.
Definition: social.h:221
GNUNET_ResultCallback result_cb
Definition: social_api.c:369
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
const char * name
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.
struct GNUNET_CRYPTO_EcdsaPublicKey nym_pub_key
Definition: social.h:225
struct GNUNET_OP_Handle * op
Async operations.
Definition: social_api.c:94
static void op_recv_zone_add_nym_result(void *cls, int64_t result, const void *err_msg, uint16_t err_msg_size)
Definition: social_api.c:2462
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:354
uint64_t GNUNET_OP_add(struct GNUNET_OP_Handle *h, GNUNET_ResultCallback result_cb, void *cls, void *ctx)
Add a new operation.
Definition: op.c:197
#define GNUNET_malloc(size)
Wrapper around malloc.

Here is the call graph for this function: