diff options
Diffstat (limited to 'core/friend_requests.h')
-rw-r--r-- | core/friend_requests.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/core/friend_requests.h b/core/friend_requests.h index 3ce0df8c..2ebd557b 100644 --- a/core/friend_requests.h +++ b/core/friend_requests.h | |||
@@ -31,21 +31,37 @@ | |||
31 | extern "C" { | 31 | extern "C" { |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | typedef struct { | ||
35 | uint32_t nospam; | ||
36 | void (*handle_friendrequest)(uint8_t *, uint8_t *, uint16_t, void *); | ||
37 | uint8_t handle_friendrequest_isset; | ||
38 | void *handle_friendrequest_userdata; | ||
39 | |||
40 | /*NOTE: the following is just a temporary fix for the multiple friend requests received at the same time problem | ||
41 | TODO: Make this better (This will most likely tie in with the way we will handle spam.)*/ | ||
42 | |||
43 | #define MAX_RECEIVED_STORED 32 | ||
44 | |||
45 | uint8_t received_requests[MAX_RECEIVED_STORED][crypto_box_PUBLICKEYBYTES]; | ||
46 | uint16_t received_requests_index; | ||
47 | } Friend_Requests; | ||
48 | |||
34 | /* Try to send a friendrequest to peer with public_key | 49 | /* Try to send a friendrequest to peer with public_key |
35 | data is the data in the request and length is the length. */ | 50 | data is the data in the request and length is the length. */ |
36 | int send_friendrequest(uint8_t *public_key, uint32_t nospam_num, uint8_t *data, uint32_t length); | 51 | int send_friendrequest(DHT *dht, uint8_t *public_key, uint32_t nospam_num, uint8_t *data, uint32_t length); |
37 | /* | 52 | /* |
38 | * Set and get the nospam variable used to prevent one type of friend request spam | 53 | * Set and get the nospam variable used to prevent one type of friend request spam |
39 | */ | 54 | */ |
40 | void set_nospam(uint32_t num); | 55 | void set_nospam(Friend_Requests *fr, uint32_t num); |
41 | uint32_t get_nospam(); | 56 | uint32_t get_nospam(Friend_Requests *fr); |
42 | 57 | ||
43 | /* set the function that will be executed when a friend request for us is received. | 58 | /* set the function that will be executed when a friend request for us is received. |
44 | function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ | 59 | function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ |
45 | void callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata); | 60 | void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), |
61 | void *userdata); | ||
46 | 62 | ||
47 | /* sets up friendreq packet handlers */ | 63 | /* sets up friendreq packet handlers */ |
48 | void friendreq_init(void); | 64 | void friendreq_init(Friend_Requests *fr, Net_Crypto *c); |
49 | 65 | ||
50 | #ifdef __cplusplus | 66 | #ifdef __cplusplus |
51 | } | 67 | } |