Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
Olaf Rempel | 3ea2f29ba1 | |
Olaf Rempel | 49b9cf7135 | |
Olaf Rempel | 68fea83c6f | |
Olaf Rempel | 7811f0ab16 | |
Olaf Rempel | 2fd676eb7d | |
Olaf Rempel | a19a7bee92 | |
Olaf Rempel | ab6f8ca480 | |
Olaf Rempel | 46cbeabad5 | |
Olaf Rempel | 9e6e2a4d32 | |
Olaf Rempel | 6cd4589640 | |
Olaf Rempel | 02f775d7c2 |
|
@ -2,6 +2,7 @@
|
|||
*.d
|
||||
hlswmaster
|
||||
hlswmaster.log
|
||||
doc
|
||||
doc/*
|
||||
masterquery
|
||||
hlswmaster-ng.tar.gz
|
||||
hlswmaster-ng-*.tar.gz
|
||||
|
|
|
@ -0,0 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
19
Makefile
19
Makefile
|
@ -1,14 +1,14 @@
|
|||
VERSION := '"v1.00"'
|
||||
VERSION := v1.01
|
||||
|
||||
CFLAGS := -O2 -pipe -Wall -DVERSION=$(VERSION)
|
||||
CXXFLAGS := -O2 -pipe -Wall -Wunused -Wno-deprecated -DVERSION=$(VERSION)
|
||||
CFLAGS := -O2 -pipe -Wall -DVERSION='"$(VERSION)"'
|
||||
CXXFLAGS := -O2 -pipe -Wall -Wunused -Wno-deprecated -DVERSION='"$(VERSION)"'
|
||||
LIBS := -lpthread
|
||||
|
||||
HLSWMASTER_SRC := config.o gameentry.o gamelist.o gameparser.o gamescanner.o \
|
||||
hlswmaster.o hlswserver.o logging.o modhelper.o modulelist.o \
|
||||
multisock.o netpkt.o recvqueue.o socket.o timerservice.o thread.o \
|
||||
multisock.o netpkt.o socket.o timerservice.o thread.o \
|
||||
mod_d3engine.o mod_gamespy1.o mod_gamespy2.o mod_halflife.o \
|
||||
mod_hlswproxy.o mod_q3engine.o mod_quake2.o mod_ut.o
|
||||
mod_q3engine.o mod_quake2.o mod_ut.o
|
||||
|
||||
all: hlswmaster masterquery
|
||||
|
||||
|
@ -26,16 +26,17 @@ masterquery: masterquery.o
|
|||
|
||||
dist: clean
|
||||
ln -s . hlswmaster-ng
|
||||
tar -czhf hlswmaster-ng.tar.gz hlswmaster-ng/ \
|
||||
tar -czhf hlswmaster-ng-$(VERSION).tar.gz hlswmaster-ng/ \
|
||||
--exclude hlswmaster-ng/.git \
|
||||
--exclude hlswmaster-ng/.gitignore \
|
||||
--exclude hlswmaster-ng/hlswmaster-ng.tar.gz \
|
||||
--exclude hlswmaster-ng/hlswmaster-ng
|
||||
--exclude hlswmaster-ng/doc \
|
||||
--exclude hlswmaster-ng/hlswmaster-ng-$(VERSION).tar.gz \
|
||||
--exclude hlswmaster-ng/hlswmaster-ng
|
||||
rm hlswmaster-ng
|
||||
|
||||
clean:
|
||||
rm -f hlswmaster masterquery *.d *.o *.log \
|
||||
hlswmaster-ng hlswmaster-ng.tar.gz
|
||||
hlswmaster-ng hlswmaster-ng-$(VERSION).tar.gz
|
||||
|
||||
##DEPS := $(wildcard *.cpp)
|
||||
##-include $(DEPS:.cpp=.d)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
linux HLSWMASTER-NG
|
||||
===================
|
||||
|
||||
howto use it:
|
||||
$ make all
|
||||
$ ./hlswmaster
|
22
config.cpp
22
config.cpp
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
@ -141,6 +160,7 @@ bool Config::parseFile(const char* name)
|
|||
|
||||
if (!(fz = fopen(name, "r"))) {
|
||||
LogSystem::log(LOG_ERROR, "config_parse(): can not open %s", name);
|
||||
delete [] row;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -179,7 +199,7 @@ bool Config::parseFile(const char* name)
|
|||
}
|
||||
|
||||
fclose(fz);
|
||||
delete row;
|
||||
delete [] row;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,33 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "gameentry.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "gameentry.h"
|
||||
|
||||
GameEntry::GameEntry(int gameid, NetPkt* pkt, int port2)
|
||||
: port2(port2), gameid(gameid)
|
||||
GameEntry::GameEntry(int gameid, struct in_addr *addr, int port1, int port2)
|
||||
: port1(port1), port2(port2), gameid(gameid)
|
||||
{
|
||||
memcpy(&addr, &pkt->getAddress()->sin_addr, sizeof(addr));
|
||||
this->port1 = pkt->getPort();
|
||||
memcpy(&this->addr, addr, sizeof(this->addr));
|
||||
|
||||
if (port2 != 0) {
|
||||
this->port2 = this->port1;
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
#ifndef _GAMEENTRY_H_
|
||||
#define _GAMEENTRY_H_
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "netpkt.h"
|
||||
#include "list.h"
|
||||
|
||||
class GameEntry : private ListEntry<GameEntry> {
|
||||
public:
|
||||
GameEntry(int gameid, NetPkt* pkt, int port2);
|
||||
GameEntry(int gameid, struct in_addr *addr, int port1, int port2);
|
||||
~GameEntry() {}
|
||||
|
||||
int compare(const GameEntry* ge);
|
||||
|
|
28
gamelist.cpp
28
gamelist.cpp
|
@ -1,5 +1,24 @@
|
|||
#include "logging.h"
|
||||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "gamelist.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define DEFAULT_TIMEOUT 180
|
||||
|
||||
|
@ -40,7 +59,12 @@ void GameList::cleanup()
|
|||
|
||||
void GameList::addGame(int gameid, NetPkt* pkt, int port2)
|
||||
{
|
||||
GameEntry* ge = new GameEntry(gameid, pkt, port2);
|
||||
addGame(gameid, &pkt->getAddress()->sin_addr, pkt->getPort(), port2);
|
||||
}
|
||||
|
||||
void GameList::addGame(int gameid, struct in_addr *addr, int port1, int port2)
|
||||
{
|
||||
GameEntry* ge = new GameEntry(gameid, addr, port1, port2);
|
||||
int hash = ge->hash(MAX_BUCKETS);
|
||||
bool found = false;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _GAMELIST_H_
|
||||
#define _GAMELIST_H_
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "netpkt.h"
|
||||
#include "gameentry.h"
|
||||
|
@ -18,6 +20,7 @@ public:
|
|||
|
||||
void cleanup();
|
||||
void addGame(int gameid, NetPkt* pkt, int port2 = 0);
|
||||
void addGame(int gameid, struct in_addr *addr, int port1, int port2 = 0);
|
||||
Iterator<GameEntry>* createIterator();
|
||||
|
||||
protected:
|
||||
|
@ -55,6 +58,8 @@ private:
|
|||
List<GameEntry> buckets[MAX_BUCKETS];
|
||||
|
||||
int timeout;
|
||||
|
||||
friend class GameList::GameListIterator;
|
||||
};
|
||||
|
||||
#endif // _GAMELIST_H_
|
||||
|
|
|
@ -1,9 +1,28 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "gameparser.h"
|
||||
#include "logging.h"
|
||||
#include "netpkt.h"
|
||||
#include "gameparser.h"
|
||||
|
||||
GameParser::GameParser(RecvQueue& rxQueue, ModuleList& modList, GameList& gameList)
|
||||
: rxQueue(rxQueue), modList(modList), gameList(gameList)
|
||||
GameParser::GameParser(GameScanner& scanner, ModuleList& modList, GameList& gameList)
|
||||
: scanner(scanner), modList(modList), gameList(gameList)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,7 +33,7 @@ int GameParser::execute(void* arg)
|
|||
int ret;
|
||||
|
||||
while (1) {
|
||||
pkt = rxQueue.getPkt();
|
||||
pkt = scanner.getPkt();
|
||||
ret = modList.parse(pkt, &gameList);
|
||||
|
||||
switch (ret) {
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
#define _GAMEPARSER_H_
|
||||
|
||||
#include "thread.h"
|
||||
#include "config.h"
|
||||
#include "recvqueue.h"
|
||||
#include "gamescanner.h"
|
||||
#include "modulelist.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class GameParser : public Thread {
|
||||
public:
|
||||
GameParser(RecvQueue& rxQueue, ModuleList& modlist, GameList& gameList);
|
||||
GameParser(GameScanner& scanner, ModuleList& modlist, GameList& gameList);
|
||||
~GameParser() {};
|
||||
|
||||
int execute(void* arg);
|
||||
|
@ -19,7 +18,7 @@ protected:
|
|||
GameParser& operator=(const GameParser& rp);
|
||||
|
||||
private:
|
||||
RecvQueue& rxQueue;
|
||||
GameScanner& scanner;
|
||||
ModuleList& modList;
|
||||
GameList& gameList;
|
||||
};
|
||||
|
|
|
@ -1,12 +1,28 @@
|
|||
#include "logging.h"
|
||||
#include "netpkt.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "gamescanner.h"
|
||||
|
||||
#define DEFAULT_SCAN_INTERVAL 30
|
||||
|
||||
GameScanner::GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue)
|
||||
: modList(modList), rxQueue(rxQueue)
|
||||
GameScanner::GameScanner(Config& conf, ModuleList& modList)
|
||||
: modList(modList)
|
||||
{
|
||||
msock = new MultiSock(conf);
|
||||
|
||||
|
@ -16,6 +32,9 @@ GameScanner::GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue)
|
|||
|
||||
GameScanner::~GameScanner()
|
||||
{
|
||||
while (!pktList.isEmpty())
|
||||
delete pktList.get();
|
||||
|
||||
delete msock;
|
||||
}
|
||||
|
||||
|
@ -23,8 +42,10 @@ int GameScanner::execute(void* arg)
|
|||
{
|
||||
while (1) {
|
||||
NetPkt* pkt = msock->recv();
|
||||
if (pkt)
|
||||
rxQueue.addPkt(pkt);
|
||||
if (pkt != NULL) {
|
||||
pktList.add(pkt);
|
||||
pktCount.post();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,3 +54,9 @@ void GameScanner::scan()
|
|||
{
|
||||
modList.scan(msock);
|
||||
}
|
||||
|
||||
NetPkt* GameScanner::getPkt()
|
||||
{
|
||||
pktCount.wait();
|
||||
return pktList.get();
|
||||
}
|
||||
|
|
|
@ -4,19 +4,22 @@
|
|||
#include "thread.h"
|
||||
#include "config.h"
|
||||
#include "modulelist.h"
|
||||
#include "recvqueue.h"
|
||||
|
||||
#include "timerservice.h"
|
||||
#include "multisock.h"
|
||||
#include "semaphore.h"
|
||||
#include "list.h"
|
||||
#include "netpkt.h"
|
||||
|
||||
class GameScanner : public Thread {
|
||||
public:
|
||||
GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue);
|
||||
GameScanner(Config& conf, ModuleList& modList);
|
||||
~GameScanner();
|
||||
|
||||
int execute(void* arg);
|
||||
void scan();
|
||||
|
||||
NetPkt* getPkt();
|
||||
|
||||
protected:
|
||||
GameScanner(const GameScanner& hs);
|
||||
GameScanner& operator=(const GameScanner& hs);
|
||||
|
@ -33,8 +36,10 @@ private:
|
|||
};
|
||||
|
||||
ModuleList& modList;
|
||||
RecvQueue& rxQueue;
|
||||
MultiSock* msock;
|
||||
|
||||
Semaphore pktCount;
|
||||
LockedList<NetPkt> pktList;
|
||||
};
|
||||
|
||||
#endif // _SCANNER_H_
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -5,7 +24,6 @@
|
|||
|
||||
#include "logging.h"
|
||||
#include "config.h"
|
||||
#include "recvqueue.h"
|
||||
#include "modulelist.h"
|
||||
#include "gamelist.h"
|
||||
#include "gamescanner.h"
|
||||
|
@ -17,7 +35,6 @@
|
|||
#include "mod_gamespy1.h"
|
||||
#include "mod_gamespy2.h"
|
||||
#include "mod_halflife.h"
|
||||
#include "mod_hlswproxy.h"
|
||||
#include "mod_q3engine.h"
|
||||
#include "mod_quake2.h"
|
||||
#include "mod_ut.h"
|
||||
|
@ -33,11 +50,6 @@ static struct option opts[] = {
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
LogSystem::init(DEFAULT_LOGPRIO, new StdErrLog());
|
||||
|
@ -90,19 +102,17 @@ int main(int argc, char *argv[])
|
|||
LogSystem::log(LOG_EVERYTIME, "hlswmaster-ng %s startup (pid:%d)", VERSION, getpid());
|
||||
conf.show();
|
||||
|
||||
RecvQueue rxQueue;
|
||||
ModuleList modList(conf);
|
||||
GameList gameList(conf);
|
||||
|
||||
GameScanner scanner(conf, modList, rxQueue);
|
||||
GameParser parser(rxQueue, modList, gameList);
|
||||
GameScanner scanner(conf, modList);
|
||||
GameParser parser(scanner, modList, gameList);
|
||||
HlswServer server(conf, gameList);
|
||||
|
||||
modList.reg(new ModD3Engine());
|
||||
modList.reg(new ModGameSpy1());
|
||||
modList.reg(new ModGameSpy2());
|
||||
modList.reg(new ModHalfLife());
|
||||
modList.reg(new ModHlswProxy(conf));
|
||||
modList.reg(new ModQ3Engine());
|
||||
modList.reg(new ModQuake2());
|
||||
modList.reg(new ModUT());
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -5,9 +24,8 @@
|
|||
#include <netinet/ip.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "logging.h"
|
||||
#include "hlswserver.h"
|
||||
#include "logging.h"
|
||||
|
||||
static const char hlsw_header[] = "\xFF\xFF\xFF\xFFHLSWLANSEARCH";
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "thread.h"
|
||||
#include "config.h"
|
||||
#include "gamelist.h"
|
||||
#include "timerservice.h"
|
||||
#include "netpkt.h"
|
||||
#include "socket.h"
|
||||
#include "mutex.h"
|
||||
|
|
166
list.h
166
list.h
|
@ -35,8 +35,13 @@ template <class T>
|
|||
class ListEntry;
|
||||
|
||||
|
||||
template <class T>
|
||||
class ListIterator;
|
||||
|
||||
|
||||
template <class T>
|
||||
class List {
|
||||
friend class ListIterator<T>;
|
||||
public:
|
||||
List() : head(0), tail(0) {}
|
||||
~List() {}
|
||||
|
@ -91,77 +96,78 @@ protected:
|
|||
List(const List& l);
|
||||
List& operator=(const List& l);
|
||||
|
||||
template <class TT>
|
||||
class ListIterator : public Iterator<TT> {
|
||||
public:
|
||||
ListIterator(List<TT>* list)
|
||||
: list(list)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
virtual ~ListIterator() {}
|
||||
|
||||
virtual bool hasNext()
|
||||
{
|
||||
return (pos == NULL) ? (list->head != NULL) : (pos->next != NULL);
|
||||
}
|
||||
|
||||
virtual TT* next()
|
||||
{
|
||||
prev = pos;
|
||||
pos = (pos == NULL) ? list->head : pos->next;
|
||||
return (TT*)pos;
|
||||
}
|
||||
|
||||
virtual void remove()
|
||||
{
|
||||
// remove pre-head -> bail out
|
||||
if (pos == NULL)
|
||||
return;
|
||||
|
||||
// remove first
|
||||
if (pos == list->head)
|
||||
list->head = pos->next;
|
||||
|
||||
// remove middle
|
||||
if (prev)
|
||||
prev->next = pos->next;
|
||||
|
||||
// remove last
|
||||
if (pos == list->tail)
|
||||
list->tail = (prev == NULL) ? NULL : prev;
|
||||
|
||||
pos = prev;
|
||||
}
|
||||
|
||||
virtual void reset()
|
||||
{
|
||||
pos = NULL;
|
||||
prev = NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
ListIterator(const ListIterator& li);
|
||||
ListIterator& operator=(const ListIterator& li);
|
||||
|
||||
List<TT>* list;
|
||||
|
||||
private:
|
||||
ListEntry<TT>* pos;
|
||||
ListEntry<TT>* prev;
|
||||
};
|
||||
|
||||
private:
|
||||
ListEntry<T> *head;
|
||||
ListEntry<T> *tail;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class ListIterator : public Iterator<T> {
|
||||
public:
|
||||
ListIterator(List<T>* list)
|
||||
: list(list)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
virtual ~ListIterator() {}
|
||||
|
||||
virtual bool hasNext()
|
||||
{
|
||||
return (pos == NULL) ? (list->head != NULL) : (pos->next != NULL);
|
||||
}
|
||||
|
||||
virtual T* next()
|
||||
{
|
||||
prev = pos;
|
||||
pos = (pos == NULL) ? list->head : pos->next;
|
||||
return (T*)pos;
|
||||
}
|
||||
|
||||
virtual void remove()
|
||||
{
|
||||
// remove pre-head -> bail out
|
||||
if (pos == NULL)
|
||||
return;
|
||||
|
||||
// remove first
|
||||
if (pos == list->head)
|
||||
list->head = pos->next;
|
||||
|
||||
// remove middle
|
||||
if (prev)
|
||||
prev->next = pos->next;
|
||||
|
||||
// remove last
|
||||
if (pos == list->tail)
|
||||
list->tail = (prev == NULL) ? NULL : prev;
|
||||
|
||||
pos = prev;
|
||||
}
|
||||
|
||||
virtual void reset()
|
||||
{
|
||||
pos = NULL;
|
||||
prev = NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
ListIterator(const ListIterator& li);
|
||||
ListIterator& operator=(const ListIterator& li);
|
||||
|
||||
List<T>* list;
|
||||
|
||||
private:
|
||||
ListEntry<T>* pos;
|
||||
ListEntry<T>* prev;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class ListEntry {
|
||||
friend class List<T>;
|
||||
friend class List<T>::ListIterator<T>;
|
||||
friend class ListIterator<T>;
|
||||
public:
|
||||
ListEntry() {}
|
||||
~ListEntry() {}
|
||||
|
@ -171,8 +177,13 @@ private:
|
|||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class LockedListIterator;
|
||||
|
||||
|
||||
template <class T>
|
||||
class LockedList : private List<T> {
|
||||
friend class LockedListIterator<T>;
|
||||
public:
|
||||
LockedList() {}
|
||||
~LockedList() {}
|
||||
|
@ -210,22 +221,23 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
template <class TT>
|
||||
class LockedListIterator : public List<TT>::ListIterator<TT> {
|
||||
public:
|
||||
LockedListIterator(LockedList<TT>* list)
|
||||
: List<TT>::ListIterator<TT>(list)
|
||||
{
|
||||
list->mutex.lock();
|
||||
}
|
||||
|
||||
virtual ~LockedListIterator()
|
||||
{
|
||||
((LockedList<TT>*)list)->mutex.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
Mutex mutex;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class LockedListIterator : public ListIterator<T> {
|
||||
public:
|
||||
LockedListIterator(LockedList<T>* list)
|
||||
: ListIterator<T>(list)
|
||||
{
|
||||
list->mutex.lock();
|
||||
}
|
||||
|
||||
virtual ~LockedListIterator()
|
||||
{
|
||||
((LockedList<T>*)list)->mutex.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
#endif //_LIST_H_
|
||||
|
|
34
logging.cpp
34
logging.cpp
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
@ -7,18 +26,13 @@
|
|||
|
||||
#include "logging.h"
|
||||
|
||||
/* we need this for packet dumps! */
|
||||
#define BUFLEN 8192
|
||||
|
||||
LogSystem::LogSystem() : output(0), priority(0)
|
||||
LogSystem::LogSystem()
|
||||
: output(0), priority(0)
|
||||
{
|
||||
buffer = new char[BUFLEN];
|
||||
}
|
||||
|
||||
LogSystem::~LogSystem()
|
||||
{
|
||||
delete buffer;
|
||||
|
||||
if (output)
|
||||
delete output;
|
||||
}
|
||||
|
@ -76,13 +90,13 @@ void LogSystem::log(int prio, const char* fmt, ...)
|
|||
int len;
|
||||
|
||||
va_start(az, fmt);
|
||||
len = vsnprintf(ls->buffer, BUFLEN, fmt, az);
|
||||
len = vsnprintf(ls->buffer, sizeof(ls->buffer), fmt, az);
|
||||
va_end(az);
|
||||
|
||||
if (errno) {
|
||||
strncpy(ls->buffer + len, ": ", BUFLEN - len);
|
||||
strncpy(ls->buffer + len, ": ", sizeof(ls->buffer) - len);
|
||||
len += 2;
|
||||
strncpy(ls->buffer + len, strerror(errno), BUFLEN - len);
|
||||
strncpy(ls->buffer + len, strerror(errno), sizeof(ls->buffer) - len);
|
||||
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ private:
|
|||
|
||||
LogOutput *output;
|
||||
int priority;
|
||||
char* buffer;
|
||||
char buffer[8192]; // we need this for (large) packet dumps!
|
||||
};
|
||||
|
||||
class StdErrLog : public LogOutput {
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include "netpkt.h"
|
||||
#include "modhelper.h"
|
||||
#include "mod_d3engine.h"
|
||||
#include "modhelper.h"
|
||||
|
||||
static struct game_ports port_arr[] = {
|
||||
{ 27666, 27673, ID_D3 }, // Doom 3
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define _MODD3ENGINE_H_
|
||||
|
||||
#include "module.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class ModD3Engine : public Module {
|
||||
public:
|
||||
|
|
|
@ -1,7 +1,26 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include "logging.h"
|
||||
#include "modhelper.h"
|
||||
#include "mod_gamespy1.h"
|
||||
#include "modhelper.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define MODGS1_GC_TIMEOUT 5
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
#ifndef _MODGAMESPY1_H_
|
||||
#define _MODGAMESPY1_H_
|
||||
|
||||
#include "list.h"
|
||||
#include "module.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
#include "list.h"
|
||||
#include "timerservice.h"
|
||||
|
||||
class ModGameSpy1 : public Module {
|
||||
public:
|
||||
|
|
|
@ -1,7 +1,26 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include "logging.h"
|
||||
#include "modhelper.h"
|
||||
#include "mod_gamespy2.h"
|
||||
#include "modhelper.h"
|
||||
#include "logging.h"
|
||||
|
||||
static struct game_ports port_arr[] = {
|
||||
{ 2302, 2302, ID_HALO },
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define _MODGAMESPY2_H_
|
||||
|
||||
#include "module.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class ModGameSpy2 : public Module {
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,25 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include "modhelper.h"
|
||||
#include "mod_halflife.h"
|
||||
#include "modhelper.h"
|
||||
|
||||
static struct game_ports port_arr[] = {
|
||||
{ 27015, 27024, ID_HL },
|
||||
|
@ -64,9 +83,7 @@ int ModHalfLife::parse(NetPkt* pkt, GameList* glist)
|
|||
glist->addGame(ID_HL, pkt);
|
||||
|
||||
} else {
|
||||
// TODO: implement
|
||||
glist->addGame(ID_HL, pkt);
|
||||
//glist->add(ID_HL, &tmp, port, false);
|
||||
glist->addGame(ID_HL, &tmp, port);
|
||||
}
|
||||
|
||||
return PARSE_ACCEPT;
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define _MODHALFLIFE_H_
|
||||
|
||||
#include "module.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class ModHalfLife : public Module {
|
||||
public:
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#include <string.h>
|
||||
#include "netpkt.h"
|
||||
#include "modhelper.h"
|
||||
#include "mod_hlswproxy.h"
|
||||
|
||||
ModHlswProxy::ModHlswProxy(Config& conf)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
ModHlswProxy::~ModHlswProxy()
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void ModHlswProxy::scan(MultiSock* msock)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
int ModHlswProxy::parse(NetPkt* pkt, GameList* glist)
|
||||
{
|
||||
// TODO: implement
|
||||
return PARSE_REJECT;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef _MODHLSWPROXY_H_
|
||||
#define _MODHLSWPROXY_H_
|
||||
|
||||
#include "config.h"
|
||||
#include "module.h"
|
||||
|
||||
class ModHlswProxy : public Module {
|
||||
public:
|
||||
ModHlswProxy(Config& conf);
|
||||
~ModHlswProxy();
|
||||
|
||||
void scan(MultiSock* msock);
|
||||
int parse(NetPkt* pkt, GameList* glist);
|
||||
|
||||
const char* getName() { return "HlswProxy"; }
|
||||
};
|
||||
|
||||
#endif // _MODHLSWPROXY_H_
|
|
@ -1,6 +1,25 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include "modhelper.h"
|
||||
#include "mod_q3engine.h"
|
||||
#include "modhelper.h"
|
||||
|
||||
static struct game_ports port_arr[] = {
|
||||
{ 27960, 27969, ID_Q3A }, // q3(6), ef(7), et25), rtcw(8)
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define _MODQ3ENGINE_H_
|
||||
|
||||
#include "module.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class ModQ3Engine : public Module {
|
||||
public:
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include "netpkt.h"
|
||||
#include "modhelper.h"
|
||||
#include "mod_quake2.h"
|
||||
#include "modhelper.h"
|
||||
|
||||
#define QUAKE2_PORT 27910
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define _MODQUAKE2_H_
|
||||
|
||||
#include "module.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class ModQuake2 : public Module {
|
||||
public:
|
||||
|
|
28
mod_ut.cpp
28
mod_ut.cpp
|
@ -1,10 +1,28 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <string.h>
|
||||
#include "netpkt.h"
|
||||
#include "modhelper.h"
|
||||
#include "mod_ut.h"
|
||||
#include "modhelper.h"
|
||||
|
||||
static struct game_ports port_arr[] = {
|
||||
{ 7777, 7788, 0 },
|
||||
{ 7777, 7788, 0 },
|
||||
{ 10777, 10777, 0 },
|
||||
{ 0,0,0 }
|
||||
};
|
||||
|
@ -20,7 +38,7 @@ void ModUT::scan(MultiSock* msock)
|
|||
|
||||
int ModUT::parse(NetPkt* pkt, GameList* glist)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
int gameid;
|
||||
gameid = ModHelper::checkPorts(pkt, port_arr);
|
||||
if (!gameid)
|
||||
|
@ -30,7 +48,7 @@ int ModUT::parse(NetPkt* pkt, GameList* glist)
|
|||
glist->addGame(ID_UT2K3, pkt);
|
||||
return PARSE_ACCEPT;
|
||||
}
|
||||
|
||||
|
||||
if (pkt->compare(0, scanmsg_ut2k4, sizeof(scanmsg_ut2k4))) {
|
||||
glist->addGame(ID_UT2K4, pkt);
|
||||
return PARSE_ACCEPT;
|
||||
|
|
3
mod_ut.h
3
mod_ut.h
|
@ -2,6 +2,9 @@
|
|||
#define _MODUT_H_
|
||||
|
||||
#include "module.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class ModUT : public Module {
|
||||
public:
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "modhelper.h"
|
||||
|
||||
void ModHelper::send(MultiSock* msock, int port, const char* data, int size)
|
||||
|
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
#include "module.h"
|
||||
|
||||
struct game_ports {
|
||||
int portlo;
|
||||
int porthi;
|
||||
int gameid;
|
||||
};
|
||||
|
||||
class ModHelper {
|
||||
public:
|
||||
|
|
7
module.h
7
module.h
|
@ -1,6 +1,7 @@
|
|||
#ifndef _MODULE_H_
|
||||
#define _MODULE_H_
|
||||
|
||||
#include "list.h"
|
||||
#include "config.h"
|
||||
#include "multisock.h"
|
||||
#include "netpkt.h"
|
||||
|
@ -58,12 +59,6 @@ enum {
|
|||
ID_COD2 // "Call of Duty 2"
|
||||
};
|
||||
|
||||
struct game_ports {
|
||||
int portlo;
|
||||
int porthi;
|
||||
int gameid;
|
||||
};
|
||||
|
||||
class Module : private ListEntry<Module> {
|
||||
public:
|
||||
virtual ~Module() {};
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
#include "logging.h"
|
||||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "modulelist.h"
|
||||
#include "logging.h"
|
||||
|
||||
ModuleList::ModuleList(Config& conf)
|
||||
: conf(conf)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "netpkt.h"
|
||||
#include "gamelist.h"
|
||||
#include "module.h"
|
||||
#include "list.h"
|
||||
|
||||
class ModuleList {
|
||||
public:
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -9,8 +28,8 @@
|
|||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "multisock.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define DEFAULT_PORT 7130
|
||||
|
||||
|
@ -28,7 +47,7 @@ MultiSock::MultiSock(Config& conf)
|
|||
FILE* fp = fopen(DEVFILE, "r");
|
||||
if (fp == NULL) {
|
||||
LogSystem::log(LOG_CRIT, "MultiSock(): can not open " DEVFILE);
|
||||
free(buf);
|
||||
delete [] buf;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +85,7 @@ MultiSock::MultiSock(Config& conf)
|
|||
delete it;
|
||||
|
||||
fclose(fp);
|
||||
delete buf;
|
||||
delete [] buf;
|
||||
|
||||
if (ifaceList.isEmpty())
|
||||
LogSystem::log(LOG_CRIT, "No useable Interfaces found!");
|
||||
|
|
26
netpkt.cpp
26
netpkt.cpp
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -16,9 +35,8 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "module.h"
|
||||
#include "netpkt.h"
|
||||
#include "logging.h"
|
||||
|
||||
NetPkt::NetPkt(const char* data, int size)
|
||||
: data(data), size(size), alloc(0)
|
||||
|
@ -34,7 +52,7 @@ NetPkt::NetPkt(int alloc)
|
|||
NetPkt::~NetPkt()
|
||||
{
|
||||
if (alloc > 0)
|
||||
delete data;
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
int NetPkt::show(char* buf, int size)
|
||||
|
@ -171,7 +189,7 @@ void NetPkt::merge(NetPkt* pkt)
|
|||
memcpy(new_data, data, size);
|
||||
|
||||
if (alloc)
|
||||
delete data;
|
||||
delete [] data;
|
||||
|
||||
data = new_data;
|
||||
alloc = new_alloc;
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#include "recvqueue.h"
|
||||
|
||||
RecvQueue::~RecvQueue()
|
||||
{
|
||||
while (!pktList.isEmpty())
|
||||
delete pktList.get();
|
||||
}
|
||||
|
||||
void RecvQueue::addPkt(NetPkt* pkt)
|
||||
{
|
||||
if (pkt != NULL) {
|
||||
pktList.add(pkt);
|
||||
pktCount.post();
|
||||
}
|
||||
}
|
||||
|
||||
NetPkt* RecvQueue::getPkt()
|
||||
{
|
||||
pktCount.wait();
|
||||
return pktList.get();
|
||||
}
|
25
recvqueue.h
25
recvqueue.h
|
@ -1,25 +0,0 @@
|
|||
#ifndef _RECVQUEUE_H_
|
||||
#define _RECVQUEUE_H_
|
||||
|
||||
#include "netpkt.h"
|
||||
#include "semaphore.h"
|
||||
#include "list.h"
|
||||
|
||||
class RecvQueue {
|
||||
public:
|
||||
RecvQueue() {};
|
||||
~RecvQueue();
|
||||
|
||||
void addPkt(NetPkt* pkt);
|
||||
NetPkt* getPkt();
|
||||
|
||||
protected:
|
||||
RecvQueue(const RecvQueue& rq);
|
||||
RecvQueue& operator=(const RecvQueue& rq);
|
||||
|
||||
private:
|
||||
Semaphore pktCount;
|
||||
LockedList<NetPkt> pktList;
|
||||
};
|
||||
|
||||
#endif // _RECVQUEUE_H_
|
21
socket.cpp
21
socket.cpp
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -9,8 +28,8 @@
|
|||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "socket.h"
|
||||
#include "logging.h"
|
||||
|
||||
Socket::Socket()
|
||||
{
|
||||
|
|
19
thread.cpp
19
thread.cpp
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "thread.h"
|
||||
|
||||
#define THREAD_STACKSIZE 65536
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 04/2006 by Olaf Rempel *
|
||||
* razzor@kopf-tisch.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <time.h>
|
||||
|
||||
#include "timerservice.h"
|
||||
|
|
Loading…
Reference in New Issue