| 1 |
/*
|
| 2 |
* Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu)
|
| 3 |
*
|
| 4 |
* This program is free software; you can redistribute it and/or
|
| 5 |
* modify it under the terms of the GNU General Public License
|
| 6 |
* as published by the Free Software Foundation; either version 2
|
| 7 |
* of the License, or (at your option) any later version.
|
| 8 |
*
|
| 9 |
* This program is distributed in the hope that it will be useful,
|
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
* GNU General Public License for more details.
|
| 13 |
*
|
| 14 |
* You should have received a copy of the GNU General Public License
|
| 15 |
* along with this program; if not, write to the Free Software
|
| 16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 17 |
*/
|
| 18 |
#ifndef INCLUDED_VIRTCONN_TYPES
|
| 19 |
#define INCLUDED_VIRTCONN_TYPES
|
| 20 |
|
| 21 |
typedef enum
|
| 22 |
{
|
| 23 |
virtconn_class_bnet,
|
| 24 |
virtconn_class_file,
|
| 25 |
virtconn_class_bot,
|
| 26 |
virtconn_class_none
|
| 27 |
} t_virtconn_class;
|
| 28 |
|
| 29 |
typedef enum
|
| 30 |
{
|
| 31 |
virtconn_state_empty,
|
| 32 |
virtconn_state_initial,
|
| 33 |
virtconn_state_connected,
|
| 34 |
virtconn_state_connecting
|
| 35 |
} t_virtconn_state;
|
| 36 |
|
| 37 |
#ifdef VIRTCONN_INTERNAL_ACCESS
|
| 38 |
#ifdef JUST_NEED_TYPES
|
| 39 |
#include "common/queue.h"
|
| 40 |
#else
|
| 41 |
#define JUST_NEED_TYPES
|
| 42 |
#include "common/queue.h"
|
| 43 |
#undef JUST_NEED_TYPES
|
| 44 |
#endif
|
| 45 |
#endif
|
| 46 |
|
| 47 |
typedef struct virtconn
|
| 48 |
#ifdef VIRTCONN_INTERNAL_ACCESS
|
| 49 |
{
|
| 50 |
int csd; /* client side socket descriptor */
|
| 51 |
int ssd; /* server side socket descriptor */
|
| 52 |
t_virtconn_class class; /* normal, file, or bot */
|
| 53 |
t_virtconn_state state; /* initial, connected, etc */
|
| 54 |
unsigned short udpport; /* real port # to send UDP to */
|
| 55 |
unsigned int udpaddr; /* real IP # to send UDP to */
|
| 56 |
t_queue * coutqueue; /* client packets waiting to be sent */
|
| 57 |
unsigned int coutsize; /* client amount sent from the current output packet */
|
| 58 |
t_queue * cinqueue; /* client packet waiting to be processed */
|
| 59 |
unsigned int cinsize; /* client amount received into the current input packet */
|
| 60 |
t_queue * soutqueue; /* server packets waiting to be sent */
|
| 61 |
unsigned int soutsize; /* server amount sent from the current output packet */
|
| 62 |
t_queue * sinqueue; /* server packet waiting to be processed */
|
| 63 |
unsigned int sinsize; /* server amount received into the current input packet */
|
| 64 |
unsigned int fileleft; /* number of bytes in file download from server left */
|
| 65 |
}
|
| 66 |
#endif
|
| 67 |
t_virtconn;
|
| 68 |
|
| 69 |
#endif
|
| 70 |
|
| 71 |
#ifndef JUST_NEED_TYPES
|
| 72 |
#ifndef INCLUDED_VIRTCONN_PROTOS
|
| 73 |
#define INCLUDED_VIRTCONN_PROTOS
|
| 74 |
|
| 75 |
#define JUST_NEED_TYPES
|
| 76 |
#include "common/packet.h"
|
| 77 |
#include "common/queue.h"
|
| 78 |
#include "common/list.h"
|
| 79 |
#undef JUST_NEED_TYPES
|
| 80 |
|
| 81 |
extern t_virtconn * virtconn_create(int csd, int ssd, unsigned int udpaddr, unsigned short udpport) ;
|
| 82 |
extern void virtconn_destroy(t_virtconn * vc);
|
| 83 |
extern t_virtconn_class virtconn_get_class(t_virtconn const * vc);
|
| 84 |
extern void virtconn_set_class(t_virtconn * vc, t_virtconn_class class);
|
| 85 |
extern t_virtconn_state virtconn_get_state(t_virtconn const * vc);
|
| 86 |
extern void virtconn_set_state(t_virtconn * vc, t_virtconn_state state);
|
| 87 |
extern unsigned int virtconn_get_udpaddr(t_virtconn const * vc);
|
| 88 |
extern unsigned short virtconn_get_udpport(t_virtconn const * vc);
|
| 89 |
extern t_queue * * virtconn_get_clientin_queue(t_virtconn * vc);
|
| 90 |
extern int virtconn_get_clientin_size(t_virtconn const * vc);
|
| 91 |
extern void virtconn_set_clientin_size(t_virtconn * vc, unsigned int size);
|
| 92 |
extern t_queue * * virtconn_get_clientout_queue(t_virtconn * vc);
|
| 93 |
extern int virtconn_get_clientout_size(t_virtconn const * vc);
|
| 94 |
extern void virtconn_set_clientout_size(t_virtconn * vc, unsigned int size);
|
| 95 |
extern int virtconn_get_client_socket(t_virtconn const * vc);
|
| 96 |
extern t_queue * * virtconn_get_serverin_queue(t_virtconn * vc);
|
| 97 |
extern int virtconn_get_serverin_size(t_virtconn const * vc);
|
| 98 |
extern void virtconn_set_serverin_size(t_virtconn * vc, unsigned int size);
|
| 99 |
extern t_queue * * virtconn_get_serverout_queue(t_virtconn * vc);
|
| 100 |
extern int virtconn_get_serverout_size(t_virtconn const * vc);
|
| 101 |
extern void virtconn_set_serverout_size(t_virtconn * vc, unsigned int size);
|
| 102 |
extern int virtconn_get_server_socket(t_virtconn const * vc);
|
| 103 |
extern void virtconn_set_fileleft(t_virtconn * vc, unsigned int size);
|
| 104 |
extern unsigned int virtconn_get_fileleft(t_virtconn const * vc);
|
| 105 |
|
| 106 |
extern int virtconnlist_create(void);
|
| 107 |
extern int virtconnlist_destroy(void);
|
| 108 |
extern t_list * virtconnlist(void);
|
| 109 |
|
| 110 |
#endif
|
| 111 |
#endif
|