Skip to content

Commit

Permalink
Merge bb9bfbd into 751d094
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jul 9, 2018
2 parents 751d094 + bb9bfbd commit 4d4e466
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 100 deletions.
144 changes: 68 additions & 76 deletions toxcore/Messenger.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions toxcore/friend_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
#define SHARE_RELAYS_INTERVAL (5 * 60)


enum {
typedef enum Friendconn_Status {
FRIENDCONN_STATUS_NONE,
FRIENDCONN_STATUS_CONNECTING,
FRIENDCONN_STATUS_CONNECTED
};
} Friendconn_Status;

typedef struct Friend_Connections Friend_Connections;

Expand Down
4 changes: 2 additions & 2 deletions toxcore/friend_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ uint32_t get_nospam(const Friend_Requests *fr);
*/
int remove_request_received(Friend_Requests *fr, const uint8_t *real_pk);

typedef void fr_friend_request_cb(void *, const uint8_t *, const uint8_t *, size_t, void *);
typedef void fr_friend_request_cb(void *object, const uint8_t *public_key, const uint8_t *message, size_t length, void *user_data);

/* Set the function that will be executed when a friend request for us is received.
* Function format is function(uint8_t * public_key, uint8_t * data, size_t length, void * userdata)
*/
void callback_friendrequest(Friend_Requests *fr, fr_friend_request_cb *function, void *object);

typedef int filter_function_cb(const uint8_t *, void *);
typedef int filter_function_cb(const uint8_t *public_key, void *user_data);

/* Set the function used to check if a friend request should be displayed to the user or not.
* Function format is int function(uint8_t * public_key, void * userdata)
Expand Down
12 changes: 6 additions & 6 deletions toxcore/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

#include <stdint.h>

typedef struct {
uint32_t n; //number of elements
uint32_t capacity; //number of elements memory is allocated for
uint32_t element_size; //size of the elements
uint8_t *data; //array of elements
int *ids; //array of element ids
typedef struct BS_List {
uint32_t n; // number of elements
uint32_t capacity; // number of elements memory is allocated for
uint32_t element_size; // size of the elements
uint8_t *data; // array of elements
int *ids; // array of element ids
} BS_List;

/* Initialize a list, element_size is the size of the elements in the list and
Expand Down
6 changes: 3 additions & 3 deletions toxcore/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct Logger {
};

#ifdef USE_STDERR_LOGGER
static const char *logger_level_name(LOGGER_LEVEL level)
static const char *logger_level_name(Logger_Level level)
{
switch (level) {
case LOG_TRACE:
Expand All @@ -63,7 +63,7 @@ static const char *logger_level_name(LOGGER_LEVEL level)
return "<unknown>";
}

static void logger_stderr_handler(void *context, LOGGER_LEVEL level, const char *file, int line, const char *func,
static void logger_stderr_handler(void *context, Logger_Level level, const char *file, int line, const char *func,
const char *message, void *userdata)
{
// GL stands for "global logger".
Expand Down Expand Up @@ -97,7 +97,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void *
log->userdata = userdata;
}

void logger_write(const Logger *log, LOGGER_LEVEL level, const char *file, int line, const char *func,
void logger_write(const Logger *log, Logger_Level level, const char *file, int line, const char *func,
const char *format, ...)
{
if (!log) {
Expand Down
8 changes: 4 additions & 4 deletions toxcore/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
#define MIN_LOGGER_LEVEL LOG_INFO
#endif

typedef enum {
typedef enum Logger_Level {
LOG_TRACE,
LOG_DEBUG,
LOG_INFO,
LOG_WARNING,
LOG_ERROR
} LOGGER_LEVEL;
} Logger_Level;

typedef struct Logger Logger;

typedef void logger_cb(void *context, LOGGER_LEVEL level, const char *file, int line,
typedef void logger_cb(void *context, Logger_Level level, const char *file, int line,
const char *func, const char *message, void *userdata);

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void *
* assertion failure otherwise.
*/
void logger_write(
const Logger *log, LOGGER_LEVEL level, const char *file, int line, const char *func,
const Logger *log, Logger_Level level, const char *file, int line, const char *func,
const char *format, ...) GNU_PRINTF(6, 7);


Expand Down
10 changes: 5 additions & 5 deletions toxcore/onion.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

#include "DHT.h"

typedef struct {
typedef int onion_recv_1_cb(void *object, IP_Port dest, const uint8_t *data, uint16_t length);

typedef struct Onion {
DHT *dht;
Networking_Core *net;
uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE];
Expand All @@ -36,7 +38,7 @@ typedef struct {
Shared_Keys shared_keys_2;
Shared_Keys shared_keys_3;

int (*recv_1_function)(void *, IP_Port, const uint8_t *, uint16_t);
onion_recv_1_cb *recv_1_function;
void *callback_object;
} Onion;

Expand All @@ -56,7 +58,7 @@ typedef struct {

#define ONION_PATH_LENGTH 3

typedef struct {
typedef struct Onion_Path {
uint8_t shared_key1[CRYPTO_SHARED_KEY_SIZE];
uint8_t shared_key2[CRYPTO_SHARED_KEY_SIZE];
uint8_t shared_key3[CRYPTO_SHARED_KEY_SIZE];
Expand Down Expand Up @@ -150,8 +152,6 @@ int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data,
*/
int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce);

typedef int onion_recv_1_cb(void *, IP_Port, const uint8_t *, uint16_t);

/* Set the callback to be called when the dest ip_port doesn't have TOX_AF_INET6 or TOX_AF_INET as the family.
*
* Format: function(void *object, IP_Port dest, uint8_t *data, uint16_t length)
Expand Down
2 changes: 1 addition & 1 deletion toxcore/onion_announce.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define ONION_DATA_RESPONSE_MIN_SIZE (1 + CRYPTO_NONCE_SIZE + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_MAC_SIZE)

#if ONION_PING_ID_SIZE != CRYPTO_PUBLIC_KEY_SIZE
#error announce response packets assume that ONION_PING_ID_SIZE is equal to CRYPTO_PUBLIC_KEY_SIZE
#error "announce response packets assume that ONION_PING_ID_SIZE is equal to CRYPTO_PUBLIC_KEY_SIZE"
#endif

#define ONION_DATA_REQUEST_MIN_SIZE (1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_MAC_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion toxcore/onion_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "ping_array.h"

#define MAX_ONION_CLIENTS 8
#define MAX_ONION_CLIENTS_ANNOUNCE 12 /* Number of nodes to announce ourselves to. */
#define MAX_ONION_CLIENTS_ANNOUNCE 12 // Number of nodes to announce ourselves to.
#define ONION_NODE_PING_INTERVAL 15
#define ONION_NODE_TIMEOUT ONION_NODE_PING_INTERVAL

Expand Down

0 comments on commit 4d4e466

Please sign in to comment.