Crossfire Server, Trunk
init.c File Reference
#include "global.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h>
#include "image.h"
#include "newserver.h"
#include "sproto.h"
+ Include dependency graph for init.c:

Go to the source code of this file.

Functions

void final_free_player (player *pl)
 
void free_all_newserver (void)
 
void free_newsocket (socket_struct *ns)
 
void init_connection (socket_struct *ns, const char *from_ip)
 
void init_listening_socket (socket_struct *ns)
 
void init_server (void)
 
static void set_output_sock_buf (socket_struct *ns, int bufsize)
 

Variables

socket_structinit_sockets
 
Socket_Info socket_info
 

Detailed Description

Socket general functions

Date
2003-12-02

Mainly deals with initialization and higher level socket maintenance (checking for lost connections and if data has arrived.) The reading of data is handled in loop.c

Definition in file init.c.

Function Documentation

◆ final_free_player()

void final_free_player ( player pl)

Sends the 'goodbye' command to the player, and closes connection.

Definition at line 444 of file init.c.

References free_newsocket(), free_player(), Send_With_Handling(), pl::socket, SockList_AddString(), SockList_Init(), and SockList_Term().

Referenced by check_login(), and do_server().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_all_newserver()

void free_all_newserver ( void  )

Free's all the memory that ericserver allocates.

Definition at line 395 of file init.c.

References Socket_Info::allocated_sockets, init_sockets, socket_struct::listen, llevDebug, LOG(), and socket_info.

Referenced by cleanup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_newsocket()

void free_newsocket ( socket_struct ns)

Frees a socket. Basically, all we need to do here is free all data structures that might be associated with the socket. It is up to the caller to update the list

Definition at line 412 of file init.c.

References account_char_free(), account_char_save(), socket_struct::account_chars, socket_struct::account_name, socket_struct::fd, FREE_AND_CLEAR, statsinfo::god, socket_struct::host, socket_struct::inbuf, llevDebug, LOG(), statsinfo::range, SockList_Term(), socket_struct::stats, and statsinfo::title.

Referenced by do_server(), and final_free_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_connection()

void init_connection ( socket_struct ns,
const char *  from_ip 
)

Initializes a connection. Really, it just sets up the data structure, socket setup is handled elsewhere. We do send a version to the client.

Definition at line 85 of file init.c.

References socket_struct::account_chars, socket_struct::account_name, Socket_Info::allocated_sockets, socket_struct::anims_sent, SockList::buf, socket_struct::container_position, cst_lst, cst_tot, socket_struct::darkness, DEFAULT_NUM_LOOK_OBJECTS, socket_struct::extended_stats, socket_struct::facecache, socket_struct::faces_sent, socket_struct::faces_sent_len, socket_struct::faceset, socket_struct::fd, get_faces_count(), socket_struct::heartbeat, socket_struct::host, socket_struct::inbuf, socket_struct::is_bot, socket_struct::lastmap, llevError, LOG(), socket_struct::login_method, socket_struct::look_position, socket_struct::map_scroll_x, socket_struct::map_scroll_y, socket_struct::mapx, socket_struct::mapy, CS_Stats::max_conn, socket_struct::monitor_spells, socket_struct::notifications, Ns_Add, NS_FACESENT_FACE, socket_struct::num_look_objects, socket_struct::password_fails, Send_With_Handling(), set_output_sock_buf(), socket_info, SOCKETBUFSIZE, SockList_AddPrintf(), SockList_Init(), SockList_ResetRead(), SockList_Term(), socket_struct::sound, socket_struct::sounds_this_tick, socket_struct::stats, socket_struct::status, strdup_local, guildbuy::temp, socket_struct::tick, socket_struct::update_inventory, socket_struct::update_look, VERSION_CS, VERSION_INFO, VERSION_SC, and socket_struct::want_pickup.

Referenced by new_connection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_listening_socket()

void init_listening_socket ( socket_struct ns)

This opens *ns for listening to connections. The structure must be allocated already and ns->listen must be initialized. No other variable is changed.

Definition at line 173 of file init.c.

References listen_info::addr, listen_info::addrlen, listen_info::family, fatal(), socket_struct::fd, log_login::ip, socket_struct::listen, llevError, LOG(), MAX_BUF, Ns_Add, Ns_Dead, listen_info::protocol, SEE_LAST_ERROR, listen_info::socktype, socket_struct::status, and Ice::tmp.

Referenced by do_server(), and init_server().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_server()

void init_server ( void  )

◆ set_output_sock_buf()

static void set_output_sock_buf ( socket_struct ns,
int  bufsize 
)
static

Definition at line 60 of file init.c.

References socket_struct::fd, llevDebug, llevError, LOG(), and socklen_t.

Referenced by init_connection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ init_sockets

socket_struct* init_sockets

Established connections for clients not yet playing. See the page on the login process for a description of its use. Socket at index 0 is the socket listening for connections, and must not be freed. If this socket becomes invalid, then the server will try to reopen it.

Definition at line 58 of file init.c.

Referenced by account_get_logged_in_init_socket(), block_until_new_connection(), do_server(), free_all_newserver(), init_server(), and new_connection().

◆ socket_info