Changed lossy packet function names to better ones.

Fixed rtp checking the wrong return value for one.
This commit is contained in:
irungentoo 2014-05-22 10:18:22 -04:00
parent 9a33e0f3e1
commit a54d098f6f
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
3 changed files with 15 additions and 15 deletions

View File

@ -745,7 +745,7 @@ int rtp_send_msg ( RTPSession *session, Messenger *messenger, const uint8_t *dat
/*if ( full_length != sendpacket ( messenger->net, *((IP_Port*) &session->dest), _send_data, full_length) ) {*/
if ( full_length != send_custom_user_packet(messenger, session->dest, _send_data, full_length) ) {
if ( 0 != send_custom_lossy_packet(messenger, session->dest, _send_data, full_length) ) {
/*fprintf(stderr, "Rtp error: %s\n", strerror(errno));*/
rtp_free_msg ( session, msg );
return -1;
@ -818,7 +818,7 @@ RTPSession *rtp_init_session ( int payload_type,
assert(_retu);
/*networking_registerhandler(messenger->net, payload_type, rtp_handle_packet, _retu);*/
if ( -1 == custom_user_packet_registerhandler(messenger, friend_num, payload_type, rtp_handle_packet, _retu) ) {
if ( -1 == custom_lossy_packet_registerhandler(messenger, friend_num, payload_type, rtp_handle_packet, _retu) ) {
/*fprintf(stderr, "Error setting custom register handler for rtp session\n");*/
free(_retu);
return NULL;
@ -888,7 +888,7 @@ int rtp_terminate_session ( RTPSession *session, Messenger *messenger )
if ( !session )
return -1;
custom_user_packet_registerhandler(messenger, session->dest, session->prefix, NULL, NULL);
custom_lossy_packet_registerhandler(messenger, session->dest, session->prefix, NULL, NULL);
rtp_release_session_recv(session);

View File

@ -1699,7 +1699,7 @@ int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t len
return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length);
}
static int handle_custom_user_packet(void *object, int friend_num, uint8_t *packet, uint16_t length)
static int handle_custom_lossy_packet(void *object, int friend_num, uint8_t *packet, uint16_t length)
{
Messenger *m = object;
@ -1714,8 +1714,8 @@ static int handle_custom_user_packet(void *object, int friend_num, uint8_t *pack
}
int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object)
int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1731,7 +1731,7 @@ int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8
return 0;
}
int send_custom_user_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length)
int send_custom_lossy_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1781,7 +1781,7 @@ static int handle_new_connections(void *object, New_Connection *n_c)
int id = accept_crypto_connection(m->net_crypto, n_c);
connection_status_handler(m->net_crypto, id, &handle_status, m, friend_id);
connection_data_handler(m->net_crypto, id, &handle_packet, m, friend_id);
connection_lossy_data_handler(m->net_crypto, id, &handle_custom_user_packet, m, friend_id);
connection_lossy_data_handler(m->net_crypto, id, &handle_custom_lossy_packet, m, friend_id);
m->friendlist[friend_id].crypt_connection_id = id;
set_friend_status(m, friend_id, FRIEND_CONFIRMED);
return 0;
@ -2206,7 +2206,7 @@ static int friend_new_connection(Messenger *m, int32_t friendnumber, uint8_t *re
m->friendlist[friendnumber].crypt_connection_id = id;
connection_status_handler(m->net_crypto, id, &handle_status, m, friendnumber);
connection_data_handler(m->net_crypto, id, &handle_packet, m, friendnumber);
connection_lossy_data_handler(m->net_crypto, id, &handle_custom_user_packet, m, friendnumber);
connection_lossy_data_handler(m->net_crypto, id, &handle_custom_lossy_packet, m, friendnumber);
return 0;
}

View File

@ -695,20 +695,20 @@ int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t len
/**********************************************/
/* Set handlers for custom user packets (RTP packets for example.)
/* Set handlers for custom lossy packets (RTP packets for example.)
*
* return -1 on failure.
* return 0 on success.
*/
int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object);
int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object);
/* High level function to send custom user packets.
/* High level function to send custom lossy packets.
*
* return -1 on failure.
* return number of bytes sent on success.
* return 0 on success.
*/
int send_custom_user_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length);
int send_custom_lossy_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length);
/**********************************************/
/* Run this at startup.