Freeciv-3.3: /fast/freeciv/nightly/main/common/networking/packets.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Macros | Functions | Variables
packets.c File Reference
`#include "fc_prehdrs.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <limits.h>`
`#include "capability.h"`
`#include "fc_cmdline.h"`
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "support.h"`
`#include "dataio.h"`
`#include "game.h"`
`#include "events.h"`
`#include "map.h"`
`#include "packets.h"`
`#include "spechash.h"`

Go to the source code of this file.

## Macros

#define | PACKET_SIZE_STATISTICS 0
#define | SPECHASH_TAG packet_handler
#define | SPECHASH_ASTR_KEY_TYPE
#define | SPECHASH_IDATA_TYPE struct packet_handlers *
#define | SPECHASH_IDATA_FREE (packet_handler_hash_data_free_fn_t) free

## Functions

bool | conn_compression_thaw (struct connection *pconn)
int | send_packet_data (struct connection *pc, unsigned char *data, int len, enum packet_type packet_type)
void * | get_packet_from_connection_raw (struct connection *pc, enum packet_type *ptype)
void | remove_packet_from_buffer (struct socket_packet_buffer *buffer)
void | packet_header_init (struct packet_header *packet_header)
static void | packet_header_set (struct packet_header *packet_header)
void | post_send_packet_server_join_reply (struct connection *pconn, const struct packet_server_join_reply *packet)
void | post_receive_packet_server_join_reply (struct connection *pconn, const struct packet_server_join_reply *packet)
bool | packet_check (struct data_in *din, struct connection *pc)
void | generic_handle_player_attribute_chunk (struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
void | send_attribute_block (const struct player *pplayer, struct connection *pconn)
void | pre_send_packet_player_attribute_chunk (struct connection *pc, struct packet_player_attribute_chunk *packet)
static void | packet_handlers_free (void)
const struct packet_handlers * | packet_handlers_initial (void)
const struct packet_handlers * | packet_handlers_get (const char *capability)
void | packets_deinit (void)

## Variables

const char *const | packet_functional_capability
static struct packet_handler_hash * | packet_handlers = NULL

## Macro Definition Documentation

## ◆ PACKET_SIZE_STATISTICS

#define PACKET_SIZE_STATISTICS 0

Definition at line 76 of file packets.c.

## ◆ SPECHASH_ASTR_KEY_TYPE

#define SPECHASH_ASTR_KEY_TYPE

Definition at line 81 of file packets.c.

## ◆ SPECHASH_IDATA_FREE

#define SPECHASH_IDATA_FREE (packet_handler_hash_data_free_fn_t) free

Definition at line 83 of file packets.c.

## ◆ SPECHASH_IDATA_TYPE

#define SPECHASH_IDATA_TYPE struct packet_handlers *

Definition at line 82 of file packets.c.

## ◆ SPECHASH_TAG

#define SPECHASH_TAG packet_handler

Definition at line 80 of file packets.c.

## Function Documentation

## ◆ conn_compression_thaw()

bool conn_compression_thaw | ( | struct connection * | pconn | ) |

Thaw the connection. Then maybe compress the data waiting to send them to the connection. Returns TRUE on success. See also conn_compression_freeze().

Definition at line 194 of file packets.c.

Referenced by conn_list_compression_thaw(), connection_attach_real(), establish_new_connection(), and finish_processing_request().

## ◆ generic_handle_player_attribute_chunk()

void generic_handle_player_attribute_chunk | ( | struct player * | pplayer,
|  | const struct packet_player_attribute_chunk * | chunk
| ) |  |

Updates pplayer->attribute_block according to the given packet.

Definition at line 690 of file packets.c.

Referenced by handle_player_attribute_chunk(), and handle_player_attribute_chunk().

## ◆ get_packet_from_connection_raw()

void * get_packet_from_connection_raw | ( | struct connection * | pc,
|  | enum packet_type * | ptype
| ) |  |

Read and return a packet from the connection 'pc'. The type of the packet is written in 'ptype'. On error, the connection is closed and the function returns NULL.

Definition at line 373 of file packets.c.

## ◆ packet_check()

bool packet_check | ( | struct data_in * | din,
|  | struct connection * | pc
| ) |  |

Sanity check packet

Definition at line 665 of file packets.c.

## ◆ packet_handlers_free()

static void packet_handlers_free | ( | void |  | ) |

static

Destroy the packet handler hash table.

Definition at line 812 of file packets.c.

Referenced by packets_deinit().

## ◆ packet_handlers_get()

const struct packet_handlers * packet_handlers_get | ( | const char * | capability | ) |

Returns the packet handlers variant for 'capability'.

Definition at line 840 of file packets.c.

Referenced by conn_set_capability().

## ◆ packet_handlers_initial()

const struct packet_handlers * packet_handlers_initial | ( | void |  | ) |

Returns the packet handlers variant with no special capability.

Definition at line 823 of file packets.c.

Referenced by init_packet_hashes(), and packet_handlers_get().

## ◆ packet_header_init()

void packet_header_init | ( | struct packet_header * | packet_header | ) |

Set the packet header field lengths used for the login protocol, before the capability of the connection could be checked.

NB: These values cannot be changed for backward compatibility reasons.

Definition at line 617 of file packets.c.

Referenced by connection_common_init().

## ◆ packet_header_set()

static void packet_header_set | ( | struct packet_header * | packet_header | ) |

inlinestatic

Set the packet header field lengths used after the login protocol, after the capability of the connection could be checked.

Definition at line 627 of file packets.c.

Referenced by post_receive_packet_server_join_reply(), and post_send_packet_server_join_reply().

## ◆ packets_deinit()

void packets_deinit | ( | void |  | ) |

Call when there is no longer a requirement for protocol processing. All connections must have been closed.

Definition at line 900 of file packets.c.

Referenced by at_exit(), and close_connections_and_socket().

## ◆ post_receive_packet_server_join_reply()

void post_receive_packet_server_join_reply | ( | struct connection * | pconn,
|  | const struct packet_server_join_reply * | packet
| ) |  |

Modify if needed the packet header field lengths.

Definition at line 652 of file packets.c.

Referenced by receive_packet_server_join_reply_100().

## ◆ post_send_packet_server_join_reply()

void post_send_packet_server_join_reply | ( | struct connection * | pconn,
|  | const struct packet_server_join_reply * | packet
| ) |  |

Modify if needed the packet header field lengths.

Definition at line 640 of file packets.c.

Referenced by send_packet_server_join_reply_100().

## ◆ pre_send_packet_player_attribute_chunk()

void pre_send_packet_player_attribute_chunk | ( | struct connection * | pc,
|  | struct packet_player_attribute_chunk * | packet
| ) |  |

Test and log for sending player attribute_block

Definition at line 793 of file packets.c.

Referenced by send_packet_player_attribute_chunk_100().

## ◆ remove_packet_from_buffer()

void remove_packet_from_buffer | ( | struct socket_packet_buffer * | buffer | ) |

Remove the packet from the buffer

Definition at line 598 of file packets.c.

## ◆ send_attribute_block()

void send_attribute_block | ( | const struct player * | pplayer,
|  | struct connection * | pconn
| ) |  |

Split the attribute block into chunks and send them over pconn.

Definition at line 746 of file packets.c.

Referenced by attribute_flush(), handle_player_attribute_block(), and send_all_info().

## ◆ send_packet_data()

int send_packet_data | ( | struct connection * | pc,
|  | unsigned char * | data,
|  | int | len,
|  | enum packet_type packet_type packet_type |
| ) |  |

It returns the request id of the outgoing packet (or 0 if is_server()).

Definition at line 213 of file packets.c.

## Variable Documentation

## ◆ packet_functional_capability

const char* const packet_functional_capability

extern

Definition at line 30 of file packets_gen.c.

Referenced by packet_handlers_get().

## ◆ packet_handlers

struct packet_handler_hash* packet_handlers = NULL

static

Definition at line 86 of file packets.c.