Skip to content
Snippets Groups Projects
Select Git revision
2 results Searching

run_ens.jet.sh

Blame
  • net.c 20.49 KiB
    /**
     * @file    server/net.c
     * @author  Armin Luntzer (armin.luntzer@univie.ac.at)
     *
     * @copyright GPLv2
     * This program is free software; you can redistribute it and/or modify it
     * under the terms and conditions of the GNU General Public License,
     * version 2, as published by the Free Software Foundation.
     *
     * This program is distributed in the hope it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     * more details.
     *
     * @brief server networking
     *
     * @note we typically don't check for NULL pointers since we rely on glib to
     *	 work properly...
     *
     * @todo some cleanup, the logic is pretty confusing
     *
     */
    
    #include <net.h>
    #include <cfg.h>
    #include <cmd.h>
    #include <ack.h>
    #include <pkt_proc.h>
    
    #include <gio/gio.h>
    #include <glib.h>
    
    /* this number must be large enough to handle multiple subsequent submissions
     * of packets for a connection
     */
    #define SERVER_CON_POOL_SIZE 16
    
    /* max allowed client */
    #define SERVER_CON_MAX 64
    
    /* privilege range */
    #define PRIV_DEFAULT	0
    #define PRIV_CONTROL	1
    #define PRIV_FULL	2
    
    
    
    /* client connection data */
    struct con_data {
    	GSocketConnection *con;
    	GInputStream *istream;
    	gsize nbytes;
    	gint priv;
    	gchar *nick;
    	gboolean new;
    	gboolean kick;
    	GMutex lock;
    	GCancellable *ca;
    
    	GThreadPool *pool;
    };
    
    struct thread {
    	gchar *buf;
    	gsize bytes;
    };
    
    /* tracks client connections */
    static GList *con_list;