mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[bittorrent] enum bittorrent_message_id -> bittorrent_message_id_T
This commit is contained in:
parent
23d687d7f6
commit
04b2dce53f
@ -57,10 +57,10 @@ get_peer_id(bittorrent_id_T peer_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
get_peer_message(enum bittorrent_message_id message_id)
|
get_peer_message(bittorrent_message_id_T message_id)
|
||||||
{
|
{
|
||||||
static struct {
|
static struct {
|
||||||
enum bittorrent_message_id message_id;
|
bittorrent_message_id_T message_id;
|
||||||
char *name;
|
char *name;
|
||||||
} messages[] = {
|
} messages[] = {
|
||||||
{ BITTORRENT_MESSAGE_INCOMPLETE, "incomplete" },
|
{ BITTORRENT_MESSAGE_INCOMPLETE, "incomplete" },
|
||||||
|
@ -100,6 +100,8 @@ enum bittorrent_message_id {
|
|||||||
BITTORRENT_MESSAGE_CANCEL = 8,
|
BITTORRENT_MESSAGE_CANCEL = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef char bittorrent_message_id_T;
|
||||||
|
|
||||||
/** The peer request matches information sent in the request and cancel messages
|
/** The peer request matches information sent in the request and cancel messages
|
||||||
* in the peer-wire protocol. See the piece cache header file (cache.h) for more
|
* in the peer-wire protocol. See the piece cache header file (cache.h) for more
|
||||||
* information about the cloned flag. */
|
* information about the cloned flag. */
|
||||||
@ -112,7 +114,7 @@ struct bittorrent_peer_request {
|
|||||||
|
|
||||||
uint16_t block; /**< The block index in the piece. */
|
uint16_t block; /**< The block index in the piece. */
|
||||||
|
|
||||||
enum bittorrent_message_id id; /**< ID of queued pending message. */
|
bittorrent_message_id_T id; /**< ID of queued pending message. */
|
||||||
|
|
||||||
unsigned int cloned:1; /**< The request was cloned. */
|
unsigned int cloned:1; /**< The request was cloned. */
|
||||||
unsigned int requested:1; /**< Whether it has been requested. */
|
unsigned int requested:1; /**< Whether it has been requested. */
|
||||||
@ -397,7 +399,7 @@ void done_bittorrent_message(struct bittorrent_message *message);
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
char *get_peer_id(bittorrent_id_T peer);
|
char *get_peer_id(bittorrent_id_T peer);
|
||||||
char *get_peer_message(enum bittorrent_message_id message_id);
|
char *get_peer_message(bittorrent_message_id_T message_id);
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* Peer request management: */
|
/* Peer request management: */
|
||||||
|
@ -363,7 +363,7 @@ do_send_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
|||||||
* connection struct to disappear from under us. */
|
* connection struct to disappear from under us. */
|
||||||
void
|
void
|
||||||
send_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
send_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
||||||
enum bittorrent_message_id message_id, ...)
|
bittorrent_message_id_T message_id, ...)
|
||||||
{
|
{
|
||||||
struct bittorrent_peer_request message_store, *message = &message_store;
|
struct bittorrent_peer_request message_store, *message = &message_store;
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -430,12 +430,12 @@ get_bittorrent_peer_integer(struct read_buffer *buffer, int offset)
|
|||||||
return ntohl(*((uint32_t *) (buffer->data + offset)));
|
return ntohl(*((uint32_t *) (buffer->data + offset)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum bittorrent_message_id
|
static bittorrent_message_id_T
|
||||||
check_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
check_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
||||||
struct read_buffer *buffer, uint32_t *length)
|
struct read_buffer *buffer, uint32_t *length)
|
||||||
{
|
{
|
||||||
uint32_t message_length;
|
uint32_t message_length;
|
||||||
enum bittorrent_message_id message_id;
|
bittorrent_message_id_T message_id;
|
||||||
|
|
||||||
*length = 0;
|
*length = 0;
|
||||||
|
|
||||||
@ -464,7 +464,7 @@ check_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
|||||||
|
|
||||||
static enum bittorrent_state
|
static enum bittorrent_state
|
||||||
read_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
read_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
||||||
enum bittorrent_message_id message_id,
|
bittorrent_message_id_T message_id,
|
||||||
struct read_buffer *buffer, uint32_t message_length,
|
struct read_buffer *buffer, uint32_t message_length,
|
||||||
int *write_errno)
|
int *write_errno)
|
||||||
{
|
{
|
||||||
@ -641,7 +641,7 @@ read_bittorrent_peer_data(struct socket *socket, struct read_buffer *buffer)
|
|||||||
|
|
||||||
/* All messages atleast contains an integer prefix. */
|
/* All messages atleast contains an integer prefix. */
|
||||||
while (buffer->length > sizeof(uint32_t)) {
|
while (buffer->length > sizeof(uint32_t)) {
|
||||||
enum bittorrent_message_id message_id;
|
bittorrent_message_id_T message_id;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
int write_errno = 0;
|
int write_errno = 0;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ update_bittorrent_peer_connection_stats(struct bittorrent_peer_connection *peer,
|
|||||||
|
|
||||||
void
|
void
|
||||||
send_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
send_bittorrent_peer_message(struct bittorrent_peer_connection *peer,
|
||||||
enum bittorrent_message_id message_id, ...);
|
bittorrent_message_id_T message_id, ...);
|
||||||
|
|
||||||
static void inline
|
static void inline
|
||||||
set_bittorrent_peer_interested(struct bittorrent_peer_connection *peer)
|
set_bittorrent_peer_interested(struct bittorrent_peer_connection *peer)
|
||||||
|
Loading…
Reference in New Issue
Block a user