mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Astyled code.
This commit is contained in:
parent
a38d962b04
commit
750c75a47d
|
@ -68,9 +68,9 @@ typedef struct _EventHandler {
|
||||||
|
|
||||||
} EventHandler;
|
} EventHandler;
|
||||||
|
|
||||||
int throw_event( void * (func)(void *), void *arg );
|
int throw_event( void *(func)(void *), void *arg );
|
||||||
int reset_timer_event ( int id, uint32_t timeout );
|
int reset_timer_event ( int id, uint32_t timeout );
|
||||||
int throw_timer_event ( void * (func)(void *), void *arg, unsigned timeout);
|
int throw_timer_event ( void *(func)(void *), void *arg, unsigned timeout);
|
||||||
int cancel_timer_event ( int id );
|
int cancel_timer_event ( int id );
|
||||||
int execute_timer_event ( int id );
|
int execute_timer_event ( int id );
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ int pop_id ( EventContainer **event_container, size_t *counter, int id )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_event ( EventContainer **container, size_t *counter, void * (func)(void *), void *arg )
|
void push_event ( EventContainer **container, size_t *counter, void *(func)(void *), void *arg )
|
||||||
{
|
{
|
||||||
EventContainer *_new = realloc((*container ), sizeof(EventContainer) * ((*counter ) + 1));
|
EventContainer *_new = realloc((*container ), sizeof(EventContainer) * ((*counter ) + 1));
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ void *event_poll( void *arg )
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int throw_event( void * (func)(void *), void *arg )
|
int throw_event( void *(func)(void *), void *arg )
|
||||||
{
|
{
|
||||||
pthread_t _tid;
|
pthread_t _tid;
|
||||||
int _rc =
|
int _rc =
|
||||||
|
@ -242,7 +242,7 @@ int throw_event( void * (func)(void *), void *arg )
|
||||||
EventHandler event_handler;
|
EventHandler event_handler;
|
||||||
|
|
||||||
/* Place and order array of timers */
|
/* Place and order array of timers */
|
||||||
int throw_timer_event ( void * (func)(void *), void *arg, unsigned timeout)
|
int throw_timer_event ( void *(func)(void *), void *arg, unsigned timeout)
|
||||||
{
|
{
|
||||||
static int _unique_id = 1;
|
static int _unique_id = 1;
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
extern struct _Event {
|
extern struct _Event {
|
||||||
int (*rise) (void * ( func ) ( void * ), void *arg);
|
int (*rise) (void *( func ) ( void *), void *arg);
|
||||||
int (*timer_reset ) ( int id, unsigned timeout );
|
int (*timer_reset ) ( int id, unsigned timeout );
|
||||||
int (*timer_alloc) (void * ( func ) ( void * ), void *arg, unsigned timeout);
|
int (*timer_alloc) (void *( func ) ( void *), void *arg, unsigned timeout);
|
||||||
int (*timer_release) (int id);
|
int (*timer_release) (int id);
|
||||||
int (*timer_now) ( int id );
|
int (*timer_now) ( int id );
|
||||||
} event;
|
} event;
|
||||||
|
|
66
toxav/msi.c
66
toxav/msi.c
|
@ -167,11 +167,11 @@ typedef enum {
|
||||||
static inline__ const uint8_t *stringify_request ( MSIRequest request )
|
static inline__ const uint8_t *stringify_request ( MSIRequest request )
|
||||||
{
|
{
|
||||||
static const uint8_t *strings[] = {
|
static const uint8_t *strings[] = {
|
||||||
( uint8_t * ) "INVITE",
|
( uint8_t *) "INVITE",
|
||||||
( uint8_t * ) "START",
|
( uint8_t *) "START",
|
||||||
( uint8_t * ) "CANCEL",
|
( uint8_t *) "CANCEL",
|
||||||
( uint8_t * ) "REJECT",
|
( uint8_t *) "REJECT",
|
||||||
( uint8_t * ) "END"
|
( uint8_t *) "END"
|
||||||
};
|
};
|
||||||
|
|
||||||
return strings[request];
|
return strings[request];
|
||||||
|
@ -196,10 +196,10 @@ typedef enum {
|
||||||
static inline__ const uint8_t *stringify_response ( MSIResponse response )
|
static inline__ const uint8_t *stringify_response ( MSIResponse response )
|
||||||
{
|
{
|
||||||
static const uint8_t *strings[] = {
|
static const uint8_t *strings[] = {
|
||||||
( uint8_t * ) "ringing",
|
( uint8_t *) "ringing",
|
||||||
( uint8_t * ) "starting",
|
( uint8_t *) "starting",
|
||||||
( uint8_t * ) "ending",
|
( uint8_t *) "ending",
|
||||||
( uint8_t * ) "error"
|
( uint8_t *) "error"
|
||||||
};
|
};
|
||||||
|
|
||||||
return strings[response];
|
return strings[response];
|
||||||
|
@ -516,6 +516,7 @@ uint8_t *append_header_to_string (
|
||||||
|
|
||||||
|
|
||||||
_convert = htons(_i);
|
_convert = htons(_i);
|
||||||
|
|
||||||
memcpy(_getback_byte, &_convert, sizeof(_convert));
|
memcpy(_getback_byte, &_convert, sizeof(_convert));
|
||||||
|
|
||||||
/* for value part do it regulary */
|
/* for value part do it regulary */
|
||||||
|
@ -525,9 +526,10 @@ uint8_t *append_header_to_string (
|
||||||
|
|
||||||
|
|
||||||
_convert = htons(value_len);
|
_convert = htons(value_len);
|
||||||
|
|
||||||
memcpy(dest, &_convert, sizeof(_convert));
|
memcpy(dest, &_convert, sizeof(_convert));
|
||||||
|
|
||||||
dest+=2;
|
dest += 2;
|
||||||
|
|
||||||
for ( _i = value_len; _i; --_i ) {
|
for ( _i = value_len; _i; --_i ) {
|
||||||
*dest = *_hvit;
|
*dest = *_hvit;
|
||||||
|
@ -645,13 +647,13 @@ typedef enum {
|
||||||
static inline__ const uint8_t *stringify_error ( MSICallError error_code )
|
static inline__ const uint8_t *stringify_error ( MSICallError error_code )
|
||||||
{
|
{
|
||||||
static const uint8_t *strings[] = {
|
static const uint8_t *strings[] = {
|
||||||
( uint8_t * ) "",
|
( uint8_t *) "",
|
||||||
( uint8_t * ) "Using dead call",
|
( uint8_t *) "Using dead call",
|
||||||
( uint8_t * ) "Call id not set to any call",
|
( uint8_t *) "Call id not set to any call",
|
||||||
( uint8_t * ) "Call id not available",
|
( uint8_t *) "Call id not available",
|
||||||
( uint8_t * ) "No active call in session",
|
( uint8_t *) "No active call in session",
|
||||||
( uint8_t * ) "No Crypto-key set",
|
( uint8_t *) "No Crypto-key set",
|
||||||
( uint8_t * ) "Callee busy"
|
( uint8_t *) "Callee busy"
|
||||||
};
|
};
|
||||||
|
|
||||||
return strings[error_code];
|
return strings[error_code];
|
||||||
|
@ -667,13 +669,13 @@ static inline__ const uint8_t *stringify_error ( MSICallError error_code )
|
||||||
static inline__ const uint8_t *stringify_error_code ( MSICallError error_code )
|
static inline__ const uint8_t *stringify_error_code ( MSICallError error_code )
|
||||||
{
|
{
|
||||||
static const uint8_t *strings[] = {
|
static const uint8_t *strings[] = {
|
||||||
( uint8_t * ) "",
|
( uint8_t *) "",
|
||||||
( uint8_t * ) "1",
|
( uint8_t *) "1",
|
||||||
( uint8_t * ) "2",
|
( uint8_t *) "2",
|
||||||
( uint8_t * ) "3",
|
( uint8_t *) "3",
|
||||||
( uint8_t * ) "4",
|
( uint8_t *) "4",
|
||||||
( uint8_t * ) "5",
|
( uint8_t *) "5",
|
||||||
( uint8_t * ) "6"
|
( uint8_t *) "6"
|
||||||
};
|
};
|
||||||
|
|
||||||
return strings[error_code];
|
return strings[error_code];
|
||||||
|
@ -756,10 +758,10 @@ void flush_peer_type ( MSICall *call, MSIMessage *msg, int peer_id )
|
||||||
memcpy(hdrval, msg->calltype.header_value, msg->calltype.size);
|
memcpy(hdrval, msg->calltype.header_value, msg->calltype.size);
|
||||||
hdrval[msg->calltype.size] = '\0';
|
hdrval[msg->calltype.size] = '\0';
|
||||||
|
|
||||||
if ( strcmp ( ( const char * ) hdrval, CT_AUDIO_HEADER_VALUE ) == 0 ) {
|
if ( strcmp ( ( const char *) hdrval, CT_AUDIO_HEADER_VALUE ) == 0 ) {
|
||||||
call->type_peer[peer_id] = type_audio;
|
call->type_peer[peer_id] = type_audio;
|
||||||
|
|
||||||
} else if ( strcmp ( ( const char * ) hdrval, CT_VIDEO_HEADER_VALUE ) == 0 ) {
|
} else if ( strcmp ( ( const char *) hdrval, CT_VIDEO_HEADER_VALUE ) == 0 ) {
|
||||||
call->type_peer[peer_id] = type_video;
|
call->type_peer[peer_id] = type_video;
|
||||||
} else {} /* Error */
|
} else {} /* Error */
|
||||||
} else {} /* Error */
|
} else {} /* Error */
|
||||||
|
@ -831,7 +833,7 @@ int handle_error ( MSISession *session, MSICall *call, MSICallError errid, uint3
|
||||||
|
|
||||||
const uint8_t *_error_code_str = stringify_error_code ( errid );
|
const uint8_t *_error_code_str = stringify_error_code ( errid );
|
||||||
|
|
||||||
msi_msg_set_reason ( _msg_error, _error_code_str, strlen ( ( const char * ) _error_code_str ) );
|
msi_msg_set_reason ( _msg_error, _error_code_str, strlen ( ( const char *) _error_code_str ) );
|
||||||
send_message ( session, call, _msg_error, to );
|
send_message ( session, call, _msg_error, to );
|
||||||
free_message ( _msg_error );
|
free_message ( _msg_error );
|
||||||
|
|
||||||
|
@ -1325,7 +1327,7 @@ int handle_recv_error ( MSISession *session, MSICall *call, MSIMessage *msg )
|
||||||
|
|
||||||
/* Handle error accordingly */
|
/* Handle error accordingly */
|
||||||
if ( msg->reason.header_value ) {
|
if ( msg->reason.header_value ) {
|
||||||
session->last_error_id = atoi ( ( const char * ) msg->reason.header_value );
|
session->last_error_id = atoi ( ( const char *) msg->reason.header_value );
|
||||||
session->last_error_str = stringify_error ( session->last_error_id );
|
session->last_error_str = stringify_error ( session->last_error_id );
|
||||||
LOGGER_DEBUG("Error reason: %s", session->last_error_str);
|
LOGGER_DEBUG("Error reason: %s", session->last_error_str);
|
||||||
}
|
}
|
||||||
|
@ -1612,9 +1614,9 @@ int msi_invite ( MSISession *session, int32_t *call_index, MSICallType call_type
|
||||||
|
|
||||||
/* Do whatever with message */
|
/* Do whatever with message */
|
||||||
if ( call_type == type_audio ) {
|
if ( call_type == type_audio ) {
|
||||||
msi_msg_set_calltype ( _msg_invite, ( const uint8_t * ) CT_AUDIO_HEADER_VALUE, strlen ( CT_AUDIO_HEADER_VALUE ) );
|
msi_msg_set_calltype ( _msg_invite, ( const uint8_t *) CT_AUDIO_HEADER_VALUE, strlen ( CT_AUDIO_HEADER_VALUE ) );
|
||||||
} else {
|
} else {
|
||||||
msi_msg_set_calltype ( _msg_invite, ( const uint8_t * ) CT_VIDEO_HEADER_VALUE, strlen ( CT_VIDEO_HEADER_VALUE ) );
|
msi_msg_set_calltype ( _msg_invite, ( const uint8_t *) CT_VIDEO_HEADER_VALUE, strlen ( CT_VIDEO_HEADER_VALUE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
send_message ( session, _call, _msg_invite, friend_id );
|
send_message ( session, _call, _msg_invite, friend_id );
|
||||||
|
@ -1702,10 +1704,10 @@ int msi_answer ( MSISession *session, int32_t call_index, MSICallType call_type
|
||||||
|
|
||||||
if ( call_type == type_audio ) {
|
if ( call_type == type_audio ) {
|
||||||
msi_msg_set_calltype
|
msi_msg_set_calltype
|
||||||
( _msg_starting, ( const uint8_t * ) CT_AUDIO_HEADER_VALUE, strlen ( CT_AUDIO_HEADER_VALUE ) );
|
( _msg_starting, ( const uint8_t *) CT_AUDIO_HEADER_VALUE, strlen ( CT_AUDIO_HEADER_VALUE ) );
|
||||||
} else {
|
} else {
|
||||||
msi_msg_set_calltype
|
msi_msg_set_calltype
|
||||||
( _msg_starting, ( const uint8_t * ) CT_VIDEO_HEADER_VALUE, strlen ( CT_VIDEO_HEADER_VALUE ) );
|
( _msg_starting, ( const uint8_t *) CT_VIDEO_HEADER_VALUE, strlen ( CT_VIDEO_HEADER_VALUE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now set the local encryption key and pass it with STARTING message */
|
/* Now set the local encryption key and pass it with STARTING message */
|
||||||
|
|
|
@ -418,6 +418,7 @@ inline__ int toxav_send_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallTy
|
||||||
inline__ int toxav_recv_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallType type, uint8_t *dest )
|
inline__ int toxav_recv_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallType type, uint8_t *dest )
|
||||||
{
|
{
|
||||||
if ( !dest ) return ErrorInternal;
|
if ( !dest ) return ErrorInternal;
|
||||||
|
|
||||||
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
||||||
|
|
||||||
CallSpecific *call = &av->calls[call_index];
|
CallSpecific *call = &av->calls[call_index];
|
||||||
|
@ -470,6 +471,7 @@ inline__ int toxav_recv_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallTy
|
||||||
inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **output)
|
inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **output)
|
||||||
{
|
{
|
||||||
if ( !output ) return ErrorInternal;
|
if ( !output ) return ErrorInternal;
|
||||||
|
|
||||||
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
||||||
|
|
||||||
uint8_t packet [RTP_PAYLOAD_SIZE];
|
uint8_t packet [RTP_PAYLOAD_SIZE];
|
||||||
|
@ -507,6 +509,7 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out
|
||||||
inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size)
|
inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size)
|
||||||
{
|
{
|
||||||
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
||||||
|
|
||||||
return toxav_send_rtp_payload(av, call_index, TypeVideo, frame, frame_size);
|
return toxav_send_rtp_payload(av, call_index, TypeVideo, frame, frame_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,6 +570,7 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d
|
||||||
inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, int16_t *dest )
|
inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, int16_t *dest )
|
||||||
{
|
{
|
||||||
if ( !dest ) return ErrorInternal;
|
if ( !dest ) return ErrorInternal;
|
||||||
|
|
||||||
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
||||||
|
|
||||||
CallSpecific *call = &av->calls[call_index];
|
CallSpecific *call = &av->calls[call_index];
|
||||||
|
@ -609,6 +613,7 @@ inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, i
|
||||||
inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size)
|
inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size)
|
||||||
{
|
{
|
||||||
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
||||||
|
|
||||||
return toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size);
|
return toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,6 +633,7 @@ inline__ int toxav_prepare_audio_frame ( ToxAv *av, int32_t call_index, uint8_t
|
||||||
const int16_t *frame, int frame_size)
|
const int16_t *frame, int frame_size)
|
||||||
{
|
{
|
||||||
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
if (cii(call_index, av->msi_session)) return ErrorNoCall;
|
||||||
|
|
||||||
int32_t rc = opus_encode(av->calls[call_index].cs->audio_encoder, frame, frame_size, dest, dest_max);
|
int32_t rc = opus_encode(av->calls[call_index].cs->audio_encoder, frame, frame_size, dest, dest_max);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
@ -649,7 +655,8 @@ inline__ int toxav_prepare_audio_frame ( ToxAv *av, int32_t call_index, uint8_t
|
||||||
*/
|
*/
|
||||||
int toxav_get_peer_transmission_type ( ToxAv *av, int32_t call_index, int peer )
|
int toxav_get_peer_transmission_type ( ToxAv *av, int32_t call_index, int peer )
|
||||||
{
|
{
|
||||||
if ( peer < 0 || cii(call_index, av->msi_session) || !av->msi_session->calls[call_index] || av->msi_session->calls[call_index]->peer_count <= peer )
|
if ( peer < 0 || cii(call_index, av->msi_session) || !av->msi_session->calls[call_index]
|
||||||
|
|| av->msi_session->calls[call_index]->peer_count <= peer )
|
||||||
return ErrorInternal;
|
return ErrorInternal;
|
||||||
|
|
||||||
return av->msi_session->calls[call_index]->type_peer[peer];
|
return av->msi_session->calls[call_index]->type_peer[peer];
|
||||||
|
@ -667,7 +674,8 @@ int toxav_get_peer_id ( ToxAv *av, int32_t call_index, int peer )
|
||||||
{
|
{
|
||||||
assert(av->msi_session);
|
assert(av->msi_session);
|
||||||
|
|
||||||
if ( peer < 0 || cii(call_index, av->msi_session) || !av->msi_session->calls[call_index] || av->msi_session->calls[call_index]->peer_count <= peer )
|
if ( peer < 0 || cii(call_index, av->msi_session) || !av->msi_session->calls[call_index]
|
||||||
|
|| av->msi_session->calls[call_index]->peer_count <= peer )
|
||||||
return ErrorInternal;
|
return ErrorInternal;
|
||||||
|
|
||||||
return av->msi_session->calls[call_index]->peers[peer];
|
return av->msi_session->calls[call_index]->peers[peer];
|
||||||
|
|
|
@ -959,7 +959,8 @@ static int get_chat_num(Messenger *m, Group_Chat *chat)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void group_message_function(Group_Chat *chat, int peer_number, const uint8_t *message, uint16_t length, void *userdata)
|
static void group_message_function(Group_Chat *chat, int peer_number, const uint8_t *message, uint16_t length,
|
||||||
|
void *userdata)
|
||||||
{
|
{
|
||||||
Messenger *m = userdata;
|
Messenger *m = userdata;
|
||||||
int i = get_chat_num(m, chat);
|
int i = get_chat_num(m, chat);
|
||||||
|
@ -975,7 +976,8 @@ static void group_message_function(Group_Chat *chat, int peer_number, const uint
|
||||||
(*m->group_message)(m, i, peer_number, message_terminated, length, m->group_message_userdata);
|
(*m->group_message)(m, i, peer_number, message_terminated, length, m->group_message_userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void group_action_function(Group_Chat *chat, int peer_number, const uint8_t *action, uint16_t length, void *userdata)
|
static void group_action_function(Group_Chat *chat, int peer_number, const uint8_t *action, uint16_t length,
|
||||||
|
void *userdata)
|
||||||
{
|
{
|
||||||
Messenger *m = userdata;
|
Messenger *m = userdata;
|
||||||
int i = get_chat_num(m, chat);
|
int i = get_chat_num(m, chat);
|
||||||
|
|
|
@ -315,8 +315,8 @@ static int entry_heard_store(Client_entry *entry, const IPPTs *ippts)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* maps Assoc callback signature to id_closest() */
|
/* maps Assoc callback signature to id_closest() */
|
||||||
static int assoc_id_closest(const Assoc *assoc, void *callback_data, const uint8_t *client_id, const uint8_t *client_id1,
|
static int assoc_id_closest(const Assoc *assoc, void *callback_data, const uint8_t *client_id,
|
||||||
const uint8_t *client_id2)
|
const uint8_t *client_id1, const uint8_t *client_id2)
|
||||||
{
|
{
|
||||||
return id_closest(client_id, client_id1, client_id2);
|
return id_closest(client_id, client_id1, client_id2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ typedef uint64_t (*Assoc_distance_absolute_callback)(const Assoc *assoc, void *c
|
||||||
|
|
||||||
/* Central entry point for new associations: add a new candidate to the cache
|
/* Central entry point for new associations: add a new candidate to the cache
|
||||||
* returns 1 if entry is stored, 2 if existing entry was updated, 0 else */
|
* returns 1 if entry is stored, 2 if existing entry was updated, 0 else */
|
||||||
uint8_t Assoc_add_entry(Assoc *assoc, const uint8_t *id, const IPPTs *ippts_send, const IP_Port *ipp_recv, uint8_t used);
|
uint8_t Assoc_add_entry(Assoc *assoc, const uint8_t *id, const IPPTs *ippts_send, const IP_Port *ipp_recv,
|
||||||
|
uint8_t used);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
* return 0 if it sent the friend request directly to the friend.
|
* return 0 if it sent the friend request directly to the friend.
|
||||||
* return the number of peers it was routed through if it did not send it directly.
|
* return the number of peers it was routed through if it did not send it directly.
|
||||||
*/
|
*/
|
||||||
int send_friendrequest(const Onion_Client *onion_c, const uint8_t *public_key, uint32_t nospam_num, const uint8_t *data, uint32_t length)
|
int send_friendrequest(const Onion_Client *onion_c, const uint8_t *public_key, uint32_t nospam_num, const uint8_t *data,
|
||||||
|
uint32_t length)
|
||||||
{
|
{
|
||||||
if (1 + sizeof(nospam_num) + length > ONION_CLIENT_MAX_DATA_SIZE || length == 0)
|
if (1 + sizeof(nospam_num) + length > ONION_CLIENT_MAX_DATA_SIZE || length == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -51,7 +51,8 @@ typedef struct {
|
||||||
* data is the data in the request and length is the length.
|
* data is the data in the request and length is the length.
|
||||||
* Maximum length of data is MAX_FRIEND_REQUEST_DATA_SIZE.
|
* Maximum length of data is MAX_FRIEND_REQUEST_DATA_SIZE.
|
||||||
*/
|
*/
|
||||||
int send_friendrequest(const Onion_Client *onion_c, const uint8_t *public_key, uint32_t nospam_num, const uint8_t *data, uint32_t length);
|
int send_friendrequest(const Onion_Client *onion_c, const uint8_t *public_key, uint32_t nospam_num, const uint8_t *data,
|
||||||
|
uint32_t length);
|
||||||
/* Set and get the nospam variable used to prevent one type of friend request spam. */
|
/* Set and get the nospam variable used to prevent one type of friend request spam. */
|
||||||
void set_nospam(Friend_Requests *fr, uint32_t num);
|
void set_nospam(Friend_Requests *fr, uint32_t num);
|
||||||
uint32_t get_nospam(const Friend_Requests *fr);
|
uint32_t get_nospam(const Friend_Requests *fr);
|
||||||
|
|
|
@ -175,8 +175,8 @@ static int add_closepeer(Group_Chat *chat, const uint8_t *client_id, IP_Port ip_
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int send_groupchatpacket(const Group_Chat *chat, IP_Port ip_port, const uint8_t *public_key, const uint8_t *data, uint32_t length,
|
static int send_groupchatpacket(const Group_Chat *chat, IP_Port ip_port, const uint8_t *public_key, const uint8_t *data,
|
||||||
uint8_t request_id)
|
uint32_t length, uint8_t request_id)
|
||||||
{
|
{
|
||||||
if (id_equal(chat->self_public_key, public_key))
|
if (id_equal(chat->self_public_key, public_key))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -718,7 +718,8 @@ uint32_t group_numpeers(const Group_Chat *chat)
|
||||||
return chat->numpeers;
|
return chat->numpeers;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t group_client_names(const Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length)
|
uint32_t group_client_names(const Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[],
|
||||||
|
uint16_t length)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,8 @@ uint32_t group_numpeers(const Group_Chat *chat);
|
||||||
*
|
*
|
||||||
* returns the number of peers.
|
* returns the number of peers.
|
||||||
*/
|
*/
|
||||||
uint32_t group_client_names(const Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length);
|
uint32_t group_client_names(const Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[],
|
||||||
|
uint16_t length);
|
||||||
|
|
||||||
/* Kill a group chat
|
/* Kill a group chat
|
||||||
*
|
*
|
||||||
|
|
|
@ -815,7 +815,8 @@ static uint16_t get_nonce_uint16(uint8_t *nonce)
|
||||||
* return -1 on failure.
|
* return -1 on failure.
|
||||||
* return length of data on success.
|
* return length of data on success.
|
||||||
*/
|
*/
|
||||||
static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, const uint8_t *packet, uint16_t length)
|
static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, const uint8_t *packet,
|
||||||
|
uint16_t length)
|
||||||
{
|
{
|
||||||
if (length <= (1 + sizeof(uint16_t) + crypto_box_MACBYTES) || length > MAX_CRYPTO_PACKET_SIZE)
|
if (length <= (1 + sizeof(uint16_t) + crypto_box_MACBYTES) || length > MAX_CRYPTO_PACKET_SIZE)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -112,7 +112,8 @@ int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, con
|
||||||
*
|
*
|
||||||
* Format: function(void *object, IP_Port dest, uint8_t *data, uint32_t length)
|
* Format: function(void *object, IP_Port dest, uint8_t *data, uint32_t length)
|
||||||
*/
|
*/
|
||||||
void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t), void *object);
|
void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t),
|
||||||
|
void *object);
|
||||||
|
|
||||||
Onion *new_onion(DHT *dht);
|
Onion *new_onion(DHT *dht);
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,8 @@ static int cmp_entry(const void *a, const void *b)
|
||||||
* return -1 if failure
|
* return -1 if failure
|
||||||
* return position if added
|
* return position if added
|
||||||
*/
|
*/
|
||||||
static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const uint8_t *public_key, const uint8_t *data_public_key,
|
static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const uint8_t *public_key,
|
||||||
const uint8_t *ret)
|
const uint8_t *data_public_key, const uint8_t *ret)
|
||||||
{
|
{
|
||||||
|
|
||||||
int pos = in_entries(onion_a, public_key);
|
int pos = in_entries(onion_a, public_key);
|
||||||
|
|
|
@ -164,7 +164,8 @@ static int new_sendback(Onion_Client *onion_c, uint32_t num, uint8_t *public_key
|
||||||
* return ~0 on failure
|
* return ~0 on failure
|
||||||
* return num (see new_sendback(...)) on success
|
* return num (see new_sendback(...)) on success
|
||||||
*/
|
*/
|
||||||
static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, uint8_t *ret_pubkey, IP_Port *ret_ip_port)
|
static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, uint8_t *ret_pubkey,
|
||||||
|
IP_Port *ret_ip_port)
|
||||||
{
|
{
|
||||||
uint64_t sback;
|
uint64_t sback;
|
||||||
memcpy(&sback, sendback, sizeof(uint64_t));
|
memcpy(&sback, sendback, sizeof(uint64_t));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user