Version 0.53
- code cleanup (mostly doxygen tags) - added doxygen file
This commit is contained in:
parent
7f0b2fd78f
commit
861d41be08
|
@ -1,3 +1,7 @@
|
||||||
|
* Tue 19 Apr 2005 Olaf Rempel <razzor@kopf-tisch.de> 0.53
|
||||||
|
- code cleanup (mostly doxygen tags)
|
||||||
|
- added doxygen file
|
||||||
|
|
||||||
* Thu 31 Mar 2005 Olaf Rempel <razzor@kopf-tisch.de> 0.52
|
* Thu 31 Mar 2005 Olaf Rempel <razzor@kopf-tisch.de> 0.52
|
||||||
- games added: avp2, bfv, igi2, jk2, jk3, rtcw, ut2k3, ut2k4
|
- games added: avp2, bfv, igi2, jk2, jk3, rtcw, ut2k3, ut2k4
|
||||||
- sendqueue removed (no need to do ratelimiting)
|
- sendqueue removed (no need to do ratelimiting)
|
||||||
|
|
|
@ -2,4 +2,4 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||||
|
|
||||||
SUBDIRS = src plugins tools
|
SUBDIRS = src plugins tools
|
||||||
|
|
||||||
EXTRA_DIST = TODO autogen.sh hlswmaster.conf
|
EXTRA_DIST = TODO autogen.sh hlswmaster.conf contrib
|
||||||
|
|
|
@ -174,7 +174,7 @@ sysconfdir = @sysconfdir@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
AUTOMAKE_OPTIONS = foreign no-dependencies
|
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||||
SUBDIRS = src plugins tools
|
SUBDIRS = src plugins tools
|
||||||
EXTRA_DIST = TODO autogen.sh hlswmaster.conf
|
EXTRA_DIST = TODO autogen.sh hlswmaster.conf contrib
|
||||||
all: config.h
|
all: config.h
|
||||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.59 for hlswmaster 0.52.
|
# Generated by GNU Autoconf 2.59 for hlswmaster 0.53.
|
||||||
#
|
#
|
||||||
# Report bugs to <Olaf Rempel <razzor@kopf-tisch.de>>.
|
# Report bugs to <Olaf Rempel <razzor@kopf-tisch.de>>.
|
||||||
#
|
#
|
||||||
|
@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='hlswmaster'
|
PACKAGE_NAME='hlswmaster'
|
||||||
PACKAGE_TARNAME='hlswmaster'
|
PACKAGE_TARNAME='hlswmaster'
|
||||||
PACKAGE_VERSION='0.52'
|
PACKAGE_VERSION='0.53'
|
||||||
PACKAGE_STRING='hlswmaster 0.52'
|
PACKAGE_STRING='hlswmaster 0.53'
|
||||||
PACKAGE_BUGREPORT='Olaf Rempel <razzor@kopf-tisch.de>'
|
PACKAGE_BUGREPORT='Olaf Rempel <razzor@kopf-tisch.de>'
|
||||||
|
|
||||||
# Factoring default headers for most tests.
|
# Factoring default headers for most tests.
|
||||||
|
@ -953,7 +953,7 @@ if test "$ac_init_help" = "long"; then
|
||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# Omit some internal or obsolete options to make the list less imposing.
|
||||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures hlswmaster 0.52 to adapt to many kinds of systems.
|
\`configure' configures hlswmaster 0.53 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ fi
|
||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of hlswmaster 0.52:";;
|
short | recursive ) echo "Configuration of hlswmaster 0.53:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
|
@ -1160,7 +1160,7 @@ fi
|
||||||
test -n "$ac_init_help" && exit 0
|
test -n "$ac_init_help" && exit 0
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
hlswmaster configure 0.52
|
hlswmaster configure 0.53
|
||||||
generated by GNU Autoconf 2.59
|
generated by GNU Autoconf 2.59
|
||||||
|
|
||||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||||
|
@ -1174,7 +1174,7 @@ cat >&5 <<_ACEOF
|
||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by hlswmaster $as_me 0.52, which was
|
It was created by hlswmaster $as_me 0.53, which was
|
||||||
generated by GNU Autoconf 2.59. Invocation command line was
|
generated by GNU Autoconf 2.59. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
|
@ -1818,7 +1818,7 @@ fi
|
||||||
|
|
||||||
# Define the identity of the package.
|
# Define the identity of the package.
|
||||||
PACKAGE=hlswmaster
|
PACKAGE=hlswmaster
|
||||||
VERSION=0.52
|
VERSION=0.53
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
@ -21419,7 +21419,7 @@ _ASBOX
|
||||||
} >&5
|
} >&5
|
||||||
cat >&5 <<_CSEOF
|
cat >&5 <<_CSEOF
|
||||||
|
|
||||||
This file was extended by hlswmaster $as_me 0.52, which was
|
This file was extended by hlswmaster $as_me 0.53, which was
|
||||||
generated by GNU Autoconf 2.59. Invocation command line was
|
generated by GNU Autoconf 2.59. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
|
@ -21482,7 +21482,7 @@ _ACEOF
|
||||||
|
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF
|
cat >>$CONFIG_STATUS <<_ACEOF
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
hlswmaster config.status 0.52
|
hlswmaster config.status 0.53
|
||||||
configured by $0, generated by GNU Autoconf 2.59,
|
configured by $0, generated by GNU Autoconf 2.59,
|
||||||
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
dnl projekname, version, bugsto
|
dnl projekname, version, bugsto
|
||||||
AC_INIT(hlswmaster, 0.52, [Olaf Rempel <razzor@kopf-tisch.de>])
|
AC_INIT(hlswmaster, 0.53, [Olaf Rempel <razzor@kopf-tisch.de>])
|
||||||
|
|
||||||
dnl same for automake
|
dnl same for automake
|
||||||
AM_INIT_AUTOMAKE(hlswmaster, 0.52)
|
AM_INIT_AUTOMAKE(hlswmaster, 0.53)
|
||||||
|
|
||||||
dnl do not rebuild configure
|
dnl do not rebuild configure
|
||||||
AM_MAINTAINER_MODE
|
AM_MAINTAINER_MODE
|
||||||
|
|
|
@ -0,0 +1,217 @@
|
||||||
|
# Doxyfile 1.3.9.1
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Project related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
PROJECT_NAME = hlswmaster
|
||||||
|
PROJECT_NUMBER = 0.53
|
||||||
|
OUTPUT_DIRECTORY = ../doc
|
||||||
|
CREATE_SUBDIRS = NO
|
||||||
|
OUTPUT_LANGUAGE = English
|
||||||
|
USE_WINDOWS_ENCODING = NO
|
||||||
|
BRIEF_MEMBER_DESC = NO
|
||||||
|
REPEAT_BRIEF = NO
|
||||||
|
ABBREVIATE_BRIEF =
|
||||||
|
ALWAYS_DETAILED_SEC = NO
|
||||||
|
INLINE_INHERITED_MEMB = NO
|
||||||
|
FULL_PATH_NAMES = YES
|
||||||
|
STRIP_FROM_PATH =
|
||||||
|
STRIP_FROM_INC_PATH =
|
||||||
|
SHORT_NAMES = NO
|
||||||
|
JAVADOC_AUTOBRIEF = NO
|
||||||
|
MULTILINE_CPP_IS_BRIEF = NO
|
||||||
|
DETAILS_AT_TOP = NO
|
||||||
|
INHERIT_DOCS = YES
|
||||||
|
DISTRIBUTE_GROUP_DOC = NO
|
||||||
|
TAB_SIZE = 8
|
||||||
|
ALIASES =
|
||||||
|
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||||
|
OPTIMIZE_OUTPUT_JAVA = NO
|
||||||
|
SUBGROUPING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Build related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
EXTRACT_ALL = YES
|
||||||
|
EXTRACT_PRIVATE = YES
|
||||||
|
EXTRACT_STATIC = YES
|
||||||
|
EXTRACT_LOCAL_CLASSES = YES
|
||||||
|
EXTRACT_LOCAL_METHODS = YES
|
||||||
|
HIDE_UNDOC_MEMBERS = NO
|
||||||
|
HIDE_UNDOC_CLASSES = NO
|
||||||
|
HIDE_FRIEND_COMPOUNDS = NO
|
||||||
|
HIDE_IN_BODY_DOCS = NO
|
||||||
|
INTERNAL_DOCS = NO
|
||||||
|
CASE_SENSE_NAMES = YES
|
||||||
|
HIDE_SCOPE_NAMES = NO
|
||||||
|
SHOW_INCLUDE_FILES = NO
|
||||||
|
INLINE_INFO = YES
|
||||||
|
SORT_MEMBER_DOCS = NO
|
||||||
|
SORT_BRIEF_DOCS = NO
|
||||||
|
SORT_BY_SCOPE_NAME = NO
|
||||||
|
GENERATE_TODOLIST = YES
|
||||||
|
GENERATE_TESTLIST = YES
|
||||||
|
GENERATE_BUGLIST = YES
|
||||||
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
|
ENABLED_SECTIONS =
|
||||||
|
MAX_INITIALIZER_LINES = 30
|
||||||
|
SHOW_USED_FILES = YES
|
||||||
|
SHOW_DIRECTORIES = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to warning and progress messages
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
QUIET = NO
|
||||||
|
WARNINGS = YES
|
||||||
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
|
WARN_IF_DOC_ERROR = YES
|
||||||
|
WARN_FORMAT = "$file:$line: $text"
|
||||||
|
WARN_LOGFILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the input files
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
INPUT = ../src \
|
||||||
|
../include \
|
||||||
|
../plugins/skel.c
|
||||||
|
FILE_PATTERNS = *.c \
|
||||||
|
*.h
|
||||||
|
RECURSIVE = NO
|
||||||
|
EXCLUDE =
|
||||||
|
EXCLUDE_SYMLINKS = NO
|
||||||
|
EXCLUDE_PATTERNS =
|
||||||
|
EXAMPLE_PATH =
|
||||||
|
EXAMPLE_PATTERNS =
|
||||||
|
EXAMPLE_RECURSIVE = NO
|
||||||
|
IMAGE_PATH =
|
||||||
|
INPUT_FILTER =
|
||||||
|
FILTER_PATTERNS =
|
||||||
|
FILTER_SOURCE_FILES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to source browsing
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SOURCE_BROWSER = YES
|
||||||
|
INLINE_SOURCES = NO
|
||||||
|
STRIP_CODE_COMMENTS = YES
|
||||||
|
REFERENCED_BY_RELATION = YES
|
||||||
|
REFERENCES_RELATION = NO
|
||||||
|
VERBATIM_HEADERS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the alphabetical class index
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ALPHABETICAL_INDEX = NO
|
||||||
|
COLS_IN_ALPHA_INDEX = 5
|
||||||
|
IGNORE_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the HTML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
HTML_OUTPUT = html
|
||||||
|
HTML_FILE_EXTENSION = .html
|
||||||
|
HTML_HEADER =
|
||||||
|
HTML_FOOTER =
|
||||||
|
HTML_STYLESHEET =
|
||||||
|
HTML_ALIGN_MEMBERS = YES
|
||||||
|
GENERATE_HTMLHELP = NO
|
||||||
|
CHM_FILE =
|
||||||
|
HHC_LOCATION =
|
||||||
|
GENERATE_CHI = NO
|
||||||
|
BINARY_TOC = NO
|
||||||
|
TOC_EXPAND = NO
|
||||||
|
DISABLE_INDEX = NO
|
||||||
|
ENUM_VALUES_PER_LINE = 4
|
||||||
|
GENERATE_TREEVIEW = NO
|
||||||
|
TREEVIEW_WIDTH = 250
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the LaTeX output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
LATEX_OUTPUT = latex
|
||||||
|
LATEX_CMD_NAME = latex
|
||||||
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
|
COMPACT_LATEX = NO
|
||||||
|
PAPER_TYPE = a4wide
|
||||||
|
EXTRA_PACKAGES =
|
||||||
|
LATEX_HEADER =
|
||||||
|
PDF_HYPERLINKS = NO
|
||||||
|
USE_PDFLATEX = NO
|
||||||
|
LATEX_BATCHMODE = NO
|
||||||
|
LATEX_HIDE_INDICES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the RTF output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_RTF = NO
|
||||||
|
RTF_OUTPUT = rtf
|
||||||
|
COMPACT_RTF = NO
|
||||||
|
RTF_HYPERLINKS = NO
|
||||||
|
RTF_STYLESHEET_FILE =
|
||||||
|
RTF_EXTENSIONS_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the man page output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_MAN = NO
|
||||||
|
MAN_OUTPUT = man
|
||||||
|
MAN_EXTENSION = .3
|
||||||
|
MAN_LINKS = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the XML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_XML = NO
|
||||||
|
XML_OUTPUT = xml
|
||||||
|
XML_SCHEMA =
|
||||||
|
XML_DTD =
|
||||||
|
XML_PROGRAMLISTING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options for the AutoGen Definitions output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the Perl module output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_PERLMOD = NO
|
||||||
|
PERLMOD_LATEX = NO
|
||||||
|
PERLMOD_PRETTY = YES
|
||||||
|
PERLMOD_MAKEVAR_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the preprocessor
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ENABLE_PREPROCESSING = YES
|
||||||
|
MACRO_EXPANSION = NO
|
||||||
|
EXPAND_ONLY_PREDEF = NO
|
||||||
|
SEARCH_INCLUDES = YES
|
||||||
|
INCLUDE_PATH =
|
||||||
|
INCLUDE_FILE_PATTERNS =
|
||||||
|
PREDEFINED =
|
||||||
|
EXPAND_AS_DEFINED =
|
||||||
|
SKIP_FUNCTION_MACROS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to external references
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
TAGFILES =
|
||||||
|
GENERATE_TAGFILE =
|
||||||
|
ALLEXTERNALS = NO
|
||||||
|
EXTERNAL_GROUPS = YES
|
||||||
|
PERL_PATH = /usr/bin/perl
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the dot tool
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
CLASS_DIAGRAMS = YES
|
||||||
|
HIDE_UNDOC_RELATIONS = YES
|
||||||
|
HAVE_DOT = NO
|
||||||
|
CLASS_GRAPH = YES
|
||||||
|
COLLABORATION_GRAPH = YES
|
||||||
|
UML_LOOK = NO
|
||||||
|
TEMPLATE_RELATIONS = NO
|
||||||
|
INCLUDE_GRAPH = YES
|
||||||
|
INCLUDED_BY_GRAPH = YES
|
||||||
|
CALL_GRAPH = NO
|
||||||
|
GRAPHICAL_HIERARCHY = YES
|
||||||
|
DOT_IMAGE_FORMAT = png
|
||||||
|
DOT_PATH =
|
||||||
|
DOTFILE_DIRS =
|
||||||
|
MAX_DOT_GRAPH_WIDTH = 1024
|
||||||
|
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||||
|
MAX_DOT_GRAPH_DEPTH = 0
|
||||||
|
GENERATE_LEGEND = YES
|
||||||
|
DOT_CLEANUP = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to the search engine
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SEARCHENGINE = NO
|
|
@ -1,22 +1,22 @@
|
||||||
[global]
|
[global]
|
||||||
# broadcast scan source IP & PORT (udp)
|
# broadcast scan source IP & PORT (udp)
|
||||||
#scan_ip 0.0.0.0
|
scan_ip 0.0.0.0
|
||||||
#scan_port 7130
|
scan_port 7130
|
||||||
|
|
||||||
# broadcast scan every X seconds
|
# broadcast scan every X seconds
|
||||||
#scan_interval 30
|
scan_interval 30
|
||||||
|
|
||||||
# serverlist rebuild every X seconds
|
# serverlist rebuild every X seconds
|
||||||
#serverlist_interval 5
|
serverlist_interval 5
|
||||||
|
|
||||||
# server timeout after X seconds
|
# server timeout after X seconds
|
||||||
#serverlist_timeout 30
|
serverlist_timeout 30
|
||||||
|
|
||||||
# plugin data timeout every X seconds
|
# plugin data timeout every X seconds
|
||||||
#plugin_timeout 30
|
plugin_timeout 30
|
||||||
|
|
||||||
# master answers with this source IP
|
# master answers with this source IP
|
||||||
#master_ip 0.0.0.0
|
master_ip 0.0.0.0
|
||||||
|
|
||||||
# load these plugins
|
# load these plugins
|
||||||
plugin plugins/.libs/hlswproxy.so
|
plugin plugins/.libs/hlswproxy.so
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
#define _LIST_H
|
#define _LIST_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** stolen from linux kernel (2.6.11)
|
* stolen from linux kernel (2.6.11)
|
||||||
** linux/include/linux/stddef.h (offsetoff)
|
* linux/include/linux/stddef.h (offsetoff)
|
||||||
** linux/include/linux/kernel.h (container_of)
|
* linux/include/linux/kernel.h (container_of)
|
||||||
** linux/include/linux/list.h (*list*)
|
* linux/include/linux/list.h (*list*)
|
||||||
** linux/include/linux/netfilter_ipv4/listhelp.h (LIST_FIND)
|
* linux/include/linux/netfilter_ipv4/listhelp.h (LIST_FIND)
|
||||||
**
|
*
|
||||||
** modified by Olaf Rempel
|
* modified by Olaf Rempel
|
||||||
*/
|
*/
|
||||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||||
|
|
||||||
#define container_of(ptr, type, member) ({ \
|
#define container_of(ptr, type, member) ({ \
|
||||||
|
@ -45,7 +45,7 @@ static inline void __list_add(struct list_head *new,
|
||||||
prev->next = new;
|
prev->next = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_add - add a new entry
|
* list_add - add a new entry
|
||||||
* @new: new entry to be added
|
* @new: new entry to be added
|
||||||
* @head: list head to add it after
|
* @head: list head to add it after
|
||||||
|
@ -58,7 +58,7 @@ static inline void list_add(struct list_head *new, struct list_head *head)
|
||||||
__list_add(new, head, head->next);
|
__list_add(new, head, head->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_add_tail - add a new entry
|
* list_add_tail - add a new entry
|
||||||
* @new: new entry to be added
|
* @new: new entry to be added
|
||||||
* @head: list head to add it before
|
* @head: list head to add it before
|
||||||
|
@ -71,7 +71,7 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)
|
||||||
__list_add(new, head->prev, head);
|
__list_add(new, head->prev, head);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Delete a list entry by making the prev/next entries
|
* Delete a list entry by making the prev/next entries
|
||||||
* point to each other.
|
* point to each other.
|
||||||
*
|
*
|
||||||
|
@ -84,7 +84,7 @@ static inline void __list_del(struct list_head * prev, struct list_head * next)
|
||||||
prev->next = next;
|
prev->next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_del - deletes entry from list.
|
* list_del - deletes entry from list.
|
||||||
* @entry: the element to delete from the list.
|
* @entry: the element to delete from the list.
|
||||||
* Note: list_empty on entry does not return true after this, the entry is
|
* Note: list_empty on entry does not return true after this, the entry is
|
||||||
|
@ -97,9 +97,9 @@ static inline void list_del(struct list_head *entry)
|
||||||
entry->prev = NULL;
|
entry->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_del_init - deletes entry from list and reinitialize it.
|
* list_del_init - deletes entry from list and reinitialize it.
|
||||||
* @entry: the element to delete from the list.
|
* entry: the element to delete from the list.
|
||||||
*/
|
*/
|
||||||
static inline void list_del_init(struct list_head *entry)
|
static inline void list_del_init(struct list_head *entry)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ static inline void list_del_init(struct list_head *entry)
|
||||||
INIT_LIST_HEAD(entry);
|
INIT_LIST_HEAD(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_move - delete from one list and add as another's head
|
* list_move - delete from one list and add as another's head
|
||||||
* @list: the entry to move
|
* @list: the entry to move
|
||||||
* @head: the head that will precede our entry
|
* @head: the head that will precede our entry
|
||||||
|
@ -118,7 +118,7 @@ static inline void list_move(struct list_head *list, struct list_head *head)
|
||||||
list_add(list, head);
|
list_add(list, head);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_move_tail - delete from one list and add as another's tail
|
* list_move_tail - delete from one list and add as another's tail
|
||||||
* @list: the entry to move
|
* @list: the entry to move
|
||||||
* @head: the head that will follow our entry
|
* @head: the head that will follow our entry
|
||||||
|
@ -130,7 +130,7 @@ static inline void list_move_tail(struct list_head *list,
|
||||||
list_add_tail(list, head);
|
list_add_tail(list, head);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_empty - tests whether a list is empty
|
* list_empty - tests whether a list is empty
|
||||||
* @head: the list to test.
|
* @head: the list to test.
|
||||||
*/
|
*/
|
||||||
|
@ -153,7 +153,7 @@ static inline void __list_splice(struct list_head *list,
|
||||||
at->prev = last;
|
at->prev = last;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_splice - join two lists
|
* list_splice - join two lists
|
||||||
* @list: the new list to add.
|
* @list: the new list to add.
|
||||||
* @head: the place to add it in the first list.
|
* @head: the place to add it in the first list.
|
||||||
|
@ -164,7 +164,7 @@ static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||||
__list_splice(list, head);
|
__list_splice(list, head);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_splice_init - join two lists and reinitialise the emptied list.
|
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||||
* @list: the new list to add.
|
* @list: the new list to add.
|
||||||
* @head: the place to add it in the first list.
|
* @head: the place to add it in the first list.
|
||||||
|
@ -180,7 +180,7 @@ static inline void list_splice_init(struct list_head *list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_entry - get the struct for this entry
|
* list_entry - get the struct for this entry
|
||||||
* @ptr: the &struct list_head pointer.
|
* @ptr: the &struct list_head pointer.
|
||||||
* @type: the type of the struct this is embedded in.
|
* @type: the type of the struct this is embedded in.
|
||||||
|
@ -189,7 +189,7 @@ static inline void list_splice_init(struct list_head *list,
|
||||||
#define list_entry(ptr, type, member) \
|
#define list_entry(ptr, type, member) \
|
||||||
container_of(ptr, type, member)
|
container_of(ptr, type, member)
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_for_each - iterate over a list
|
* list_for_each - iterate over a list
|
||||||
* @pos: the &struct list_head to use as a loop counter.
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
* @head: the head for your list.
|
* @head: the head for your list.
|
||||||
|
@ -197,7 +197,7 @@ static inline void list_splice_init(struct list_head *list,
|
||||||
#define list_for_each(pos, head) \
|
#define list_for_each(pos, head) \
|
||||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_for_each_prev - iterate over a list backwards
|
* list_for_each_prev - iterate over a list backwards
|
||||||
* @pos: the &struct list_head to use as a loop counter.
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
* @head: the head for your list.
|
* @head: the head for your list.
|
||||||
|
@ -205,7 +205,7 @@ static inline void list_splice_init(struct list_head *list,
|
||||||
#define list_for_each_prev(pos, head) \
|
#define list_for_each_prev(pos, head) \
|
||||||
for (pos = (head)->prev; pos != (head); pos = pos->prev)
|
for (pos = (head)->prev; pos != (head); pos = pos->prev)
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_for_each_safe - iterate over a list safe against removal of list entry
|
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||||
* @pos: the &struct list_head to use as a loop counter.
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
* @n: another &struct list_head to use as temporary storage
|
* @n: another &struct list_head to use as temporary storage
|
||||||
|
@ -215,7 +215,7 @@ static inline void list_splice_init(struct list_head *list,
|
||||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||||
pos = n, n = pos->next)
|
pos = n, n = pos->next)
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_for_each_entry - iterate over list of given type
|
* list_for_each_entry - iterate over list of given type
|
||||||
* @pos: the type * to use as a loop counter.
|
* @pos: the type * to use as a loop counter.
|
||||||
* @head: the head for your list.
|
* @head: the head for your list.
|
||||||
|
@ -226,7 +226,7 @@ static inline void list_splice_init(struct list_head *list,
|
||||||
&pos->member != (head); \
|
&pos->member != (head); \
|
||||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_for_each_entry_reverse - iterate backwards over list of given type.
|
* list_for_each_entry_reverse - iterate backwards over list of given type.
|
||||||
* @pos: the type * to use as a loop counter.
|
* @pos: the type * to use as a loop counter.
|
||||||
* @head: the head for your list.
|
* @head: the head for your list.
|
||||||
|
@ -237,7 +237,7 @@ static inline void list_splice_init(struct list_head *list,
|
||||||
&pos->member != (head); \
|
&pos->member != (head); \
|
||||||
pos = list_entry(pos->member.prev, typeof(*pos), member))
|
pos = list_entry(pos->member.prev, typeof(*pos), member))
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||||
* @pos: the type * to use as a loop counter.
|
* @pos: the type * to use as a loop counter.
|
||||||
* @n: another type * to use as temporary storage
|
* @n: another type * to use as temporary storage
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* scan()
|
* scan()
|
||||||
* wird periodisch aufgerufen um server querys loszuschicken.
|
* wird periodisch aufgerufen um server querys loszuschicken.
|
||||||
*
|
*
|
||||||
* @return int false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
static int scan(void) {
|
static int scan(void) {
|
||||||
char myscan[] = "hallo"
|
char myscan[] = "hallo"
|
||||||
|
@ -56,8 +56,8 @@ static int scan(void) {
|
||||||
* Wenn das Paket fuer diesen Plugin einen Sinn ergibt,
|
* Wenn das Paket fuer diesen Plugin einen Sinn ergibt,
|
||||||
* wird true zurueckgegeben.
|
* wird true zurueckgegeben.
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt - Pointer auf das empfangene Paket
|
* @param *pkt empfangenes Paket
|
||||||
* @return int true wenn das Plugin das Paket parsen konnte
|
* @return true wenn das Plugin das Paket parsen konnte
|
||||||
*/
|
*/
|
||||||
static int parse(struct net_pkt *pkt) {
|
static int parse(struct net_pkt *pkt) {
|
||||||
/* checken ob das paket vom richtigen port kommt: */
|
/* checken ob das paket vom richtigen port kommt: */
|
||||||
|
@ -110,7 +110,7 @@ static int parse(struct net_pkt *pkt) {
|
||||||
* im Configfile uebergeben, die in der Configsection des Plugins
|
* im Configfile uebergeben, die in der Configsection des Plugins
|
||||||
* stehen ([Section] == Pluginname)
|
* stehen ([Section] == Pluginname)
|
||||||
*
|
*
|
||||||
* @param struct conf_section *section
|
* @param *section config section
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
static int init(struct conf_section *section) {
|
static int init(struct conf_section *section) {
|
||||||
|
@ -136,7 +136,7 @@ static int fini() {
|
||||||
* wird periodisch aufgerufen um Plugin interne Daten aufzufrischen
|
* wird periodisch aufgerufen um Plugin interne Daten aufzufrischen
|
||||||
* als Parameter wird der plugin_timeout Wert uebergeben
|
* als Parameter wird der plugin_timeout Wert uebergeben
|
||||||
*
|
*
|
||||||
* @param int timeout
|
* @param timeout timeout in sekunden
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
static int gc(int timeout) {
|
static int gc(int timeout) {
|
||||||
|
|
87
src/client.c
87
src/client.c
|
@ -42,61 +42,64 @@ struct client_pkt {
|
||||||
unsigned char buf[0];
|
unsigned char buf[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* real und prepare list. enthalten die client-antworten */
|
/** working list (wird zu den clients gesendet) */
|
||||||
static LIST_HEAD(client_pkt_list);
|
static LIST_HEAD(client_pkt_list);
|
||||||
|
|
||||||
|
/** prepare list (wird im hintergrund zusammengebaut) */
|
||||||
static LIST_HEAD(client_pkt_prepare);
|
static LIST_HEAD(client_pkt_prepare);
|
||||||
|
|
||||||
/* sichert die real list ab */
|
/** sichert die work list ab */
|
||||||
static pthread_mutex_t pkt_list_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t client_pkt_list_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pkt_not_full()
|
* client_pkt_not_full()
|
||||||
* LIST_FIND helper
|
* prueft ob ein client-paket komplett belegt ist
|
||||||
*
|
*
|
||||||
* @param struct client_pkt *a
|
* @param *cpkt pointer auf paket das getestet wird
|
||||||
* @param void *b
|
* @param *unused
|
||||||
* @return true wenn das paket noch nicht voll ist
|
* @return true wenn das paket noch nicht voll ist
|
||||||
*/
|
*/
|
||||||
static inline int cpkt_not_full(const struct client_pkt *a, void *b) {
|
static inline int client_pkt_not_full(const struct client_pkt *cpkt, void *unused) {
|
||||||
return (a->size <= (MAX_PKT_LEN - HLSW_ENTRY_LEN));
|
return (cpkt->size > (MAX_PKT_LEN - HLSW_ENTRY_LEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* client_pkt_add_real()
|
* client_pkt_add_real()
|
||||||
* erzeugt eine neues client_pkt und fuegt es einer liste hinzu
|
* erzeugt eine neues client_pkt und fuegt es einer liste hinzu
|
||||||
* gibt einen pointer auf das neue client_pkt zurueck
|
|
||||||
*
|
*
|
||||||
* @param struct list_head *list
|
* @param *list liste die das neue paket aufnimmt
|
||||||
* @return struct client_pkt * or NULL on error
|
* @return pointer auf ein neues paket oder NULL bei fehler
|
||||||
*/
|
*/
|
||||||
static struct client_pkt * client_pkt_add_real(struct list_head *list) {
|
static struct client_pkt * client_pkt_add_real(struct list_head *list) {
|
||||||
struct client_pkt *pkt;
|
struct client_pkt *cpkt;
|
||||||
|
|
||||||
pkt = malloc(sizeof(struct client_pkt) + MAX_PKT_LEN);
|
cpkt = malloc(sizeof(struct client_pkt) + MAX_PKT_LEN);
|
||||||
if (pkt) {
|
if (cpkt) {
|
||||||
INIT_LIST_HEAD(&pkt->list);
|
INIT_LIST_HEAD(&cpkt->list);
|
||||||
|
|
||||||
/* kopier den hlsw header in das client paket */
|
/* kopier den hlsw header in das client paket */
|
||||||
memcpy(pkt->buf, HLSW_HEADER, HLSW_HEADER_LEN);
|
memcpy(cpkt->buf, HLSW_HEADER, HLSW_HEADER_LEN);
|
||||||
pkt->size = HLSW_HEADER_LEN;
|
cpkt->size = HLSW_HEADER_LEN;
|
||||||
|
|
||||||
list_add_tail(&pkt->list, list);
|
/* am anfang eingliedern! */
|
||||||
|
list_add(&cpkt->list, list);
|
||||||
}
|
}
|
||||||
return pkt;
|
return cpkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* client_pkt_add()
|
* client_pkt_add()
|
||||||
* fuegt dem freien client_pkt der prepare-liste ein Spiel hinzu
|
* fuegt der client_pkt liste einen server hinzu, wenn kein platz
|
||||||
* wenn kein platz vorhanden ist, wird ein neues paket erzeugt
|
* im aktuellen paket vorhanden ist, wird ein neues paket allokiert
|
||||||
*
|
*
|
||||||
* @param struct game_server *server
|
* @param *server pointer den server
|
||||||
* @return false bei fehler (malloc)
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
int client_pkt_add(struct game_server *server) {
|
int client_pkt_add(struct game_server *server) {
|
||||||
struct client_pkt *cpkt;
|
struct client_pkt *cpkt;
|
||||||
|
|
||||||
cpkt = LIST_FIND(&client_pkt_prepare, cpkt_not_full, struct client_pkt *, NULL);
|
/* sucht ein freies paket, oder erzeugt eins */
|
||||||
|
cpkt = LIST_FIND(&client_pkt_prepare, client_pkt_not_full, struct client_pkt *, NULL);
|
||||||
if (!cpkt && !(cpkt = client_pkt_add_real(&client_pkt_prepare)))
|
if (!cpkt && !(cpkt = client_pkt_add_real(&client_pkt_prepare)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -109,21 +112,21 @@ int client_pkt_add(struct game_server *server) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* client_pkt_commit()
|
* client_pkt_commit()
|
||||||
* die prepare liste wird die echte liste und
|
* die prepare liste und die work liste werden ausgetauscht
|
||||||
* alle pakete der alten echten liste werden entfernt
|
* alle pakete der alten work liste werden entfernt
|
||||||
*
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
int client_pkt_commit() {
|
int client_pkt_commit() {
|
||||||
struct list_head old_list, *pkt, *tmp;
|
struct list_head old_list, *cpkt, *tmp;
|
||||||
|
|
||||||
/* wenn die liste leer ist, nur HLSW-header verschicken */
|
/* wenn die liste leer ist, nur HLSW-header verschicken */
|
||||||
if (list_empty(&client_pkt_prepare))
|
if (list_empty(&client_pkt_prepare))
|
||||||
client_pkt_add_real(&client_pkt_prepare);
|
client_pkt_add_real(&client_pkt_prepare);
|
||||||
|
|
||||||
pthread_mutex_lock(&pkt_list_lock);
|
pthread_mutex_lock(&client_pkt_list_lock);
|
||||||
|
|
||||||
/* old_list wird head der real list */
|
/* old_list wird head der work list */
|
||||||
list_add(&old_list, &client_pkt_list);
|
list_add(&old_list, &client_pkt_list);
|
||||||
list_del(&client_pkt_list);
|
list_del(&client_pkt_list);
|
||||||
|
|
||||||
|
@ -131,22 +134,22 @@ int client_pkt_commit() {
|
||||||
list_add(&client_pkt_list, &client_pkt_prepare);
|
list_add(&client_pkt_list, &client_pkt_prepare);
|
||||||
list_del_init(&client_pkt_prepare);
|
list_del_init(&client_pkt_prepare);
|
||||||
|
|
||||||
pthread_mutex_unlock(&pkt_list_lock);
|
pthread_mutex_unlock(&client_pkt_list_lock);
|
||||||
|
|
||||||
/* alle alten pakete entfernen */
|
/* alle alten pakete entfernen */
|
||||||
list_for_each_safe(pkt, tmp, &old_list) {
|
list_for_each_safe(cpkt, tmp, &old_list) {
|
||||||
list_del(pkt);
|
list_del(cpkt);
|
||||||
free(pkt);
|
free(cpkt);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* client_handler()
|
* client_handler()
|
||||||
* empfaengt und beantwortet die HLSW Anfragen
|
* empfaengt und beantwortet die HLSW anfragen der clients
|
||||||
*/
|
*/
|
||||||
void client_handler(void) {
|
void client_handler(void) {
|
||||||
struct client_pkt *pkt;
|
struct client_pkt *cpkt;
|
||||||
struct sockaddr_in dst;
|
struct sockaddr_in dst;
|
||||||
int sock, i;
|
int sock, i;
|
||||||
unsigned char buf[32], *ip;
|
unsigned char buf[32], *ip;
|
||||||
|
@ -177,12 +180,12 @@ void client_handler(void) {
|
||||||
if (memcmp(buf, HLSW_HEADER, HLSW_HEADER_LEN))
|
if (memcmp(buf, HLSW_HEADER, HLSW_HEADER_LEN))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pthread_mutex_lock(&pkt_list_lock);
|
pthread_mutex_lock(&client_pkt_list_lock);
|
||||||
|
|
||||||
/* pakete aus der real list senden */
|
/* pakete aus der work list senden */
|
||||||
list_for_each_entry(pkt, &client_pkt_list, list)
|
list_for_each_entry(cpkt, &client_pkt_list, list)
|
||||||
sendto(sock, pkt->buf, pkt->size, 0, (struct sockaddr *)&dst, sizeof(dst));
|
sendto(sock, cpkt->buf, cpkt->size, 0, (struct sockaddr *)&dst, sizeof(dst));
|
||||||
|
|
||||||
pthread_mutex_unlock(&pkt_list_lock);
|
pthread_mutex_unlock(&client_pkt_list_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
62
src/config.c
62
src/config.c
|
@ -28,14 +28,17 @@
|
||||||
|
|
||||||
//#define DEBUG 1
|
//#define DEBUG 1
|
||||||
|
|
||||||
/* liste config optionen */
|
/** liste der config-sections */
|
||||||
static LIST_HEAD(config_list);
|
static LIST_HEAD(config_list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config_add_section()
|
* config_add_section()
|
||||||
* fuegt der config liste ein section hinzu
|
* allokiert eine neue section und fuegt sie der config liste hinzu
|
||||||
* @param char *name
|
*
|
||||||
* @return struct conf_section *
|
* @param *name name der section
|
||||||
|
* @return pointer auf die section, oder NULL bei fehler
|
||||||
|
*
|
||||||
|
* @todo sectionname ist nicht eindeutig
|
||||||
*/
|
*/
|
||||||
static struct conf_section * config_add_section(char *name) {
|
static struct conf_section * config_add_section(char *name) {
|
||||||
struct conf_section *section;
|
struct conf_section *section;
|
||||||
|
@ -56,10 +59,11 @@ static struct conf_section * config_add_section(char *name) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config_add_tupel()
|
* config_add_tupel()
|
||||||
* fuegt einer config section ein werte tupel hinzu
|
* fuegt einer section ein config tupel hinzu
|
||||||
* @param struct conf_section *
|
*
|
||||||
* @param char *option
|
* @param *section config section
|
||||||
* @param char *parameter
|
* @param *option name der option
|
||||||
|
* @param *parameter wert der option
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
static int config_add_tupel(struct conf_section *section, char *option, char *parameter) {
|
static int config_add_tupel(struct conf_section *section, char *option, char *parameter) {
|
||||||
|
@ -104,7 +108,7 @@ static void config_free() {
|
||||||
* config_parse()
|
* config_parse()
|
||||||
* parsed die configfile
|
* parsed die configfile
|
||||||
*
|
*
|
||||||
* @param char *config
|
* @param *config filename des configfiles
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
int config_parse(char *config) {
|
int config_parse(char *config) {
|
||||||
|
@ -126,9 +130,12 @@ int config_parse(char *config) {
|
||||||
|
|
||||||
while (fgets(row, 1024, fz)) {
|
while (fgets(row, 1024, fz)) {
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
/* kommentar oder leere zeile */
|
||||||
if (row[0] == '#' || row[0] <= ' ') {
|
if (row[0] == '#' || row[0] <= ' ') {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* neue section */
|
||||||
} else if (row[0] == '[') {
|
} else if (row[0] == '[') {
|
||||||
tok = strtok(row +1, " ]\n");
|
tok = strtok(row +1, " ]\n");
|
||||||
section = config_add_section(tok);
|
section = config_add_section(tok);
|
||||||
|
@ -139,12 +146,14 @@ int config_parse(char *config) {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* option, aber es gab noch keine section */
|
||||||
} else if (!section) {
|
} else if (!section) {
|
||||||
log_print("config_parse(): missing section in row %d", i);
|
log_print("config_parse(): missing section in row %d", i);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* option */
|
||||||
if ((tok = strtok(row, " \n")) && (tok2 = strtok(NULL, " \n")))
|
if ((tok = strtok(row, " \n")) && (tok2 = strtok(NULL, " \n")))
|
||||||
if (!config_add_tupel(section, tok, tok2))
|
if (!config_add_tupel(section, tok, tok2))
|
||||||
log_print("config_parse(): invalid row %d", i);
|
log_print("config_parse(): invalid row %d", i);
|
||||||
|
@ -153,6 +162,7 @@ int config_parse(char *config) {
|
||||||
fclose(fz);
|
fclose(fz);
|
||||||
free(row);
|
free(row);
|
||||||
|
|
||||||
|
/* beim beenden die liste wieder freigeben */
|
||||||
if (atexit(config_free) != 0) {
|
if (atexit(config_free) != 0) {
|
||||||
log_print("config_parse(): atexit()");
|
log_print("config_parse(): atexit()");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -174,12 +184,10 @@ int config_parse(char *config) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config_get_section()
|
* config_get_section()
|
||||||
* gibt einen pointer auf die erste section mit dem
|
* gibt eine benannte section zurueck
|
||||||
* angegebenen namen zurueck
|
|
||||||
* wenn nicht vorhanden NULL
|
|
||||||
*
|
*
|
||||||
* @param char *name
|
* @param *name name der section
|
||||||
* @return struct conf_section *
|
* @return pointer auf die section, oder NULL bei fehler
|
||||||
*/
|
*/
|
||||||
struct conf_section * config_get_section(char *name) {
|
struct conf_section * config_get_section(char *name) {
|
||||||
struct conf_section *section;
|
struct conf_section *section;
|
||||||
|
@ -196,9 +204,9 @@ struct conf_section * config_get_section(char *name) {
|
||||||
* gibt den parameter der ersten passenden option
|
* gibt den parameter der ersten passenden option
|
||||||
* in einer section zurueck
|
* in einer section zurueck
|
||||||
*
|
*
|
||||||
* @param struct conf_section *section
|
* @param *section pointer auf die section
|
||||||
* @param char *option
|
* @param *option option name
|
||||||
* @return char *
|
* @return pointer auf den parameter string oder NULL bei fehler
|
||||||
*/
|
*/
|
||||||
char * config_get_parameter(struct conf_section *section, char *option) {
|
char * config_get_parameter(struct conf_section *section, char *option) {
|
||||||
struct conf_tupel *tupel;
|
struct conf_tupel *tupel;
|
||||||
|
@ -213,11 +221,11 @@ char * config_get_parameter(struct conf_section *section, char *option) {
|
||||||
/**
|
/**
|
||||||
* config_get_string()
|
* config_get_string()
|
||||||
* gibt den parameter des section/option tupels zurueck
|
* gibt den parameter des section/option tupels zurueck
|
||||||
* wenn nicht vorhanden, wird def zurueckgegeben
|
*
|
||||||
* @param char *section
|
* @param *section name der section
|
||||||
* @param chat *option
|
* @param *option name der option
|
||||||
* @param char *def
|
* @param *def default string
|
||||||
* @return char *
|
* @return parameter string oder default string bei fehler
|
||||||
*/
|
*/
|
||||||
char * config_get_string(char *section, char *option, char *def) {
|
char * config_get_string(char *section, char *option, char *def) {
|
||||||
struct conf_section *tmp;
|
struct conf_section *tmp;
|
||||||
|
@ -233,11 +241,11 @@ char * config_get_string(char *section, char *option, char *def) {
|
||||||
/**
|
/**
|
||||||
* config_get_int()
|
* config_get_int()
|
||||||
* gibt den parameter des section/option tupels zurueck
|
* gibt den parameter des section/option tupels zurueck
|
||||||
* wenn nicht vorhanden, wird def zurueckgegeben
|
*
|
||||||
* @param char *section
|
* @param *section name der section
|
||||||
* @param char *option
|
* @param *option name der option
|
||||||
* @param int def
|
* @param *def default wert
|
||||||
* @return int
|
* @return parameter wert oder default wert bei fehler
|
||||||
*/
|
*/
|
||||||
int config_get_int(char *section, char *option, int def) {
|
int config_get_int(char *section, char *option, int def) {
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
|
@ -33,7 +33,9 @@ static FILE *log_fd = NULL;
|
||||||
* schreibt eine Zeile ins Logfile oder auf stderr
|
* schreibt eine Zeile ins Logfile oder auf stderr
|
||||||
* wenn errno gesetzt ist, wird der error-string mit ausgegeben
|
* wenn errno gesetzt ist, wird der error-string mit ausgegeben
|
||||||
*
|
*
|
||||||
* @param variable parameterlist
|
* @param fmt variable argumentenliste (syntax wie bei printf)
|
||||||
|
*
|
||||||
|
* @todo code vereinfachen?
|
||||||
*/
|
*/
|
||||||
void log_print(const char *fmt, ...) {
|
void log_print(const char *fmt, ...) {
|
||||||
va_list az;
|
va_list az;
|
||||||
|
@ -43,6 +45,7 @@ void log_print(const char *fmt, ...) {
|
||||||
vsprintf(buffer, fmt, az);
|
vsprintf(buffer, fmt, az);
|
||||||
va_end(az);
|
va_end(az);
|
||||||
|
|
||||||
|
/* ins logfile loggen */
|
||||||
if (log_fd) {
|
if (log_fd) {
|
||||||
time_t tzgr;
|
time_t tzgr;
|
||||||
char tbuf[64];
|
char tbuf[64];
|
||||||
|
@ -54,6 +57,10 @@ void log_print(const char *fmt, ...) {
|
||||||
} else {
|
} else {
|
||||||
fprintf(log_fd, "%s %s\n", tbuf, buffer);
|
fprintf(log_fd, "%s %s\n", tbuf, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fflush(log_fd);
|
||||||
|
|
||||||
|
/* nach stderr loggen */
|
||||||
} else {
|
} else {
|
||||||
if (errno) {
|
if (errno) {
|
||||||
fprintf(stderr, "%s: %s\n", buffer, strerror(errno));
|
fprintf(stderr, "%s: %s\n", buffer, strerror(errno));
|
||||||
|
@ -62,7 +69,6 @@ void log_print(const char *fmt, ...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
fflush(log_fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,18 +81,23 @@ static void log_close() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* log_init()
|
* log_init()
|
||||||
* oeffnet das logfile
|
* initialisiert das logging
|
||||||
* wenn der prozess sich beendet, wird das logfile auch wieder geschlossen
|
*
|
||||||
|
* @param logfile filename des logfiles
|
||||||
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
int log_init(char *logfile) {
|
int log_init(char *logfile) {
|
||||||
if ((log_fd = fopen(logfile, "a" )) == NULL) {
|
if ((log_fd = fopen(logfile, "a" )) == NULL) {
|
||||||
log_print("log_open('%s'): %s", logfile);
|
log_print("log_open('%s'): %s", logfile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* beim beenden log schliessen */
|
||||||
if (atexit(log_close) != 0) {
|
if (atexit(log_close) != 0) {
|
||||||
log_print("log_open(): atexit()");
|
log_print("log_open(): atexit()");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_print("==========================");
|
log_print("==========================");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
29
src/plugin.c
29
src/plugin.c
|
@ -27,19 +27,17 @@
|
||||||
#include "netpkt.h"
|
#include "netpkt.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
/* liste der geladenen plugins */
|
/** liste der geladenen plugins */
|
||||||
static LIST_HEAD(plugin_list);
|
static LIST_HEAD(plugin_list);
|
||||||
|
|
||||||
/* sichert die plugin list UND die plugins ab */
|
/** sichert die plugin liste UND die plugins selbst ab */
|
||||||
static pthread_mutex_t plugin_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t plugin_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plugin_load()
|
* plugin_load()
|
||||||
* laedt ein shared object,
|
* laedt ein plugin und fuegt es in die plugin liste ein
|
||||||
* fuehrt wenn vorhanden init() aus
|
|
||||||
* und haengt den plugin an das ende der liste
|
|
||||||
*
|
*
|
||||||
* @param char *name
|
* @param *name filename des plugins
|
||||||
* @return false on error
|
* @return false on error
|
||||||
*/
|
*/
|
||||||
int plugin_load(char *name) {
|
int plugin_load(char *name) {
|
||||||
|
@ -49,19 +47,24 @@ int plugin_load(char *name) {
|
||||||
|
|
||||||
dlerror();
|
dlerror();
|
||||||
|
|
||||||
|
/* shared objekt oeffnen */
|
||||||
if ((tmp = dlopen(name, RTLD_NOW))) {
|
if ((tmp = dlopen(name, RTLD_NOW))) {
|
||||||
|
|
||||||
|
/* plugin struct suchen */
|
||||||
if ((plugin = dlsym(tmp, "plugin"))) {
|
if ((plugin = dlsym(tmp, "plugin"))) {
|
||||||
plugin->dlref = tmp;
|
plugin->dlref = tmp;
|
||||||
|
|
||||||
section = config_get_section(plugin->name);
|
section = config_get_section(plugin->name);
|
||||||
log_print("loading plugin '%s'", plugin->name);
|
log_print("loading plugin '%s'", plugin->name);
|
||||||
|
|
||||||
|
/* wenn vorhanden, init aufrufen */
|
||||||
if (!plugin->init || (plugin->init(section))) {
|
if (!plugin->init || (plugin->init(section))) {
|
||||||
pthread_mutex_lock(&plugin_lock);
|
pthread_mutex_lock(&plugin_lock);
|
||||||
list_add_tail(&plugin->list, &plugin_list);
|
list_add_tail(&plugin->list, &plugin_list);
|
||||||
pthread_mutex_unlock(&plugin_lock);
|
pthread_mutex_unlock(&plugin_lock);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_print("failed to load '%s'", name);
|
log_print("failed to load '%s'", name);
|
||||||
dlclose(tmp);
|
dlclose(tmp);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -96,8 +99,6 @@ int plugin_load_all() {
|
||||||
/**
|
/**
|
||||||
* plugin_unload_all()
|
* plugin_unload_all()
|
||||||
* entfernt alle plugins aus der liste,
|
* entfernt alle plugins aus der liste,
|
||||||
* ruft wenn vorhanden fini() auf
|
|
||||||
* und entlaed das shared object
|
|
||||||
*
|
*
|
||||||
* @return false on error
|
* @return false on error
|
||||||
*/
|
*/
|
||||||
|
@ -120,7 +121,7 @@ int plugin_unload_all() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plugins_scan()
|
* plugins_scan()
|
||||||
* ruft die scan() Funktionen der Plugins auf (wenn vorhanden)
|
* ruft die scan() Funktionen der Plugins auf
|
||||||
*
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
|
@ -129,6 +130,7 @@ int plugins_scan(void) {
|
||||||
|
|
||||||
pthread_mutex_lock(&plugin_lock);
|
pthread_mutex_lock(&plugin_lock);
|
||||||
list_for_each_entry(plugin, &plugin_list, list)
|
list_for_each_entry(plugin, &plugin_list, list)
|
||||||
|
/* wenn vorhanden die scan funktion aufrufen */
|
||||||
if (plugin->scan && !plugin->scan())
|
if (plugin->scan && !plugin->scan())
|
||||||
log_print("plugin %s: scan error", plugin->name);
|
log_print("plugin %s: scan error", plugin->name);
|
||||||
|
|
||||||
|
@ -138,10 +140,10 @@ int plugins_scan(void) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plugins_parse()
|
* plugins_parse()
|
||||||
* ruft die parse() Funktionen der Plugins auf (wenn vorhanden)
|
* ruft die parse() Funktionen der Plugins auf
|
||||||
* bis ein Plugin das Paket annimmt
|
* bis ein Plugin das Paket annimmt
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt das zu parsene paket
|
||||||
* @return false wenn kein Plugin das Paket angenommen hat
|
* @return false wenn kein Plugin das Paket angenommen hat
|
||||||
*/
|
*/
|
||||||
int plugins_parse(struct net_pkt *pkt) {
|
int plugins_parse(struct net_pkt *pkt) {
|
||||||
|
@ -149,6 +151,7 @@ int plugins_parse(struct net_pkt *pkt) {
|
||||||
|
|
||||||
pthread_mutex_lock(&plugin_lock);
|
pthread_mutex_lock(&plugin_lock);
|
||||||
list_for_each_entry(plugin, &plugin_list, list) {
|
list_for_each_entry(plugin, &plugin_list, list) {
|
||||||
|
/* wenn vorhanden die parse funktion aufrufen */
|
||||||
if (plugin->parse && plugin->parse(pkt)) {
|
if (plugin->parse && plugin->parse(pkt)) {
|
||||||
pthread_mutex_unlock(&plugin_lock);
|
pthread_mutex_unlock(&plugin_lock);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -161,9 +164,9 @@ int plugins_parse(struct net_pkt *pkt) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plugins_gc()
|
* plugins_gc()
|
||||||
* ruft die gc() Funktionen der Plugins auf (wenn vorhanden)
|
* ruft die gc() Funktionen der Plugins auf
|
||||||
*
|
*
|
||||||
* @param unsigned long timeout
|
* @param timeout timeout interval in sekunden
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
int plugins_gc(unsigned long timeout) {
|
int plugins_gc(unsigned long timeout) {
|
||||||
|
|
|
@ -38,31 +38,34 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pkt_queue_portarr()
|
* pkt_queue_portarr()
|
||||||
* erzeugt ein net_pkt aus den parametern und legt es in die send queue
|
* sendet an eine reihe von ports
|
||||||
*
|
*
|
||||||
* @param char *dstip - pointer auf eine IP, wenn NULL wird broadcast angenommen
|
* @param *dstip destination IP, wenn NULL wird broadcast angenommen
|
||||||
* @param struct scan_ports *port_arr
|
* @param *portarr ports an die gesendet wird
|
||||||
* @param char *buf - pointer auf den zu sendenen speicherbereich
|
* @param *buf daten die gesendet werden
|
||||||
* @param unsigned int size - groesse des speicherbereichs
|
* @param size groesse der daten
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
int pkt_send_portarr(struct in_addr *dstip, struct scan_ports *portarr, char *buf, unsigned int size) {
|
int pkt_send_portarr(struct in_addr *dstip, struct scan_ports *portarr, char *buf, unsigned int size) {
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
while (portarr && portarr->portlo) {
|
while (portarr && portarr->portlo) {
|
||||||
for (port = portarr->portlo; port <= portarr->porthi; port++)
|
for (port = portarr->portlo; port <= portarr->porthi; port++)
|
||||||
pkt_send(dstip, port, buf, size);
|
if (!pkt_send(dstip, port, buf, size))
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
portarr++;
|
portarr++;
|
||||||
}
|
}
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pkt_check_portarr()
|
* pkt_check_portarr()
|
||||||
* prueft ob der src-port des pakets in der portliste vorhanden ist
|
* prueft ob der src-port des pakets in der portliste vorhanden ist
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt paket vom gameserver
|
||||||
* @param struct scan_ports *port_arr
|
* @param *portarr ports die angenommen werden
|
||||||
* @return die gameid der portrange oder 0 wenn nicht vorhanden
|
* @return die gameid der portrange oder 0 wenn nicht vorhanden
|
||||||
*/
|
*/
|
||||||
int pkt_check_portarr(struct net_pkt *pkt, struct scan_ports *portarr) {
|
int pkt_check_portarr(struct net_pkt *pkt, struct scan_ports *portarr) {
|
||||||
|
@ -81,17 +84,20 @@ int pkt_check_portarr(struct net_pkt *pkt, struct scan_ports *portarr) {
|
||||||
* pkt_memcmp()
|
* pkt_memcmp()
|
||||||
* vergleicht das Paket mit einem Speicherbereich
|
* vergleicht das Paket mit einem Speicherbereich
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt paket vom gameserver
|
||||||
* @param unsigned int offset
|
* @param offset offset ab dem verglichen wird
|
||||||
* @param char *search
|
* @param *search daten nach denen gesucht wird
|
||||||
* @param unsigned int size
|
* @param size laenge der daten
|
||||||
* @return true wenn gleich
|
* @return true wenn gleich
|
||||||
|
*
|
||||||
|
* @todo return false wenn offset + size >= pkt->size ?
|
||||||
*/
|
*/
|
||||||
int pkt_memcmp(struct net_pkt *pkt, unsigned int offset, char *search, unsigned int size) {
|
int pkt_memcmp(struct net_pkt *pkt, unsigned int offset, char *search, unsigned int size) {
|
||||||
|
|
||||||
if (offset >= pkt->size)
|
if (offset >= pkt->size)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
/* nicht ueber das paket hinaus vergleichen */
|
||||||
if (offset + size >= pkt->size)
|
if (offset + size >= pkt->size)
|
||||||
size = pkt->size - offset;
|
size = pkt->size - offset;
|
||||||
|
|
||||||
|
@ -102,11 +108,11 @@ int pkt_memcmp(struct net_pkt *pkt, unsigned int offset, char *search, unsigned
|
||||||
* pkt_memmem()
|
* pkt_memmem()
|
||||||
* sucht einen Speicherbereich in dem Paket
|
* sucht einen Speicherbereich in dem Paket
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt paket vom gameserver
|
||||||
* @param unsigned int offset
|
* @param offset offset ab dem gesucht wird
|
||||||
* @param char *search
|
* @param *search daten nach denen gesucht wird
|
||||||
* @param unsigned int size
|
* @param size laenge der daten
|
||||||
* @return pointer auf den string im Paket
|
* @return pointer auf den string im Paket, oder NULL wenn nicht gefunden
|
||||||
*/
|
*/
|
||||||
void * pkt_memmem(struct net_pkt *pkt, unsigned int offset, char *search, unsigned int size) {
|
void * pkt_memmem(struct net_pkt *pkt, unsigned int offset, char *search, unsigned int size) {
|
||||||
if (offset >= pkt->size)
|
if (offset >= pkt->size)
|
||||||
|
@ -119,8 +125,8 @@ void * pkt_memmem(struct net_pkt *pkt, unsigned int offset, char *search, unsign
|
||||||
* server_add_pkt()
|
* server_add_pkt()
|
||||||
* fuegt der serverliste einen server hinzu
|
* fuegt der serverliste einen server hinzu
|
||||||
*
|
*
|
||||||
* @param unsigned int gameid
|
* @param gameid gameid des gameservers
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt daten vom gameserver (fuer ip/port)
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
int server_add_pkt(unsigned int gameid, struct net_pkt *pkt) {
|
int server_add_pkt(unsigned int gameid, struct net_pkt *pkt) {
|
||||||
|
@ -131,7 +137,7 @@ int server_add_pkt(unsigned int gameid, struct net_pkt *pkt) {
|
||||||
* pkt_ntoa()
|
* pkt_ntoa()
|
||||||
* gibt die IP des Pakets als String zurueck
|
* gibt die IP des Pakets als String zurueck
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt daten vom gameserver
|
||||||
* @return pointer auf String
|
* @return pointer auf String
|
||||||
*/
|
*/
|
||||||
char * pkt_ntoa(struct net_pkt *pkt) {
|
char * pkt_ntoa(struct net_pkt *pkt) {
|
||||||
|
@ -142,8 +148,8 @@ char * pkt_ntoa(struct net_pkt *pkt) {
|
||||||
* pkt_getport()
|
* pkt_getport()
|
||||||
* gibt den Port des Pakets als short zurueck
|
* gibt den Port des Pakets als short zurueck
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt daten vom gameserver
|
||||||
* @return portnr
|
* @return portnummer
|
||||||
*/
|
*/
|
||||||
unsigned short pkt_getport(struct net_pkt *pkt) {
|
unsigned short pkt_getport(struct net_pkt *pkt) {
|
||||||
return ntohs(pkt->addr.sin_port);
|
return ntohs(pkt->addr.sin_port);
|
||||||
|
@ -151,20 +157,22 @@ unsigned short pkt_getport(struct net_pkt *pkt) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pkt_atoi()
|
* pkt_atoi()
|
||||||
* gibt den integer in dem paket ab der position zurueck
|
* gibt die dezimalzahl in dem paket ab einer position zurueck
|
||||||
*
|
*
|
||||||
* @param struct net_pkt *pkt
|
* @param *pkt daten vom gameserver
|
||||||
* @return int
|
* @param *p pointer auf den begin des integers
|
||||||
|
* @return wert des integers oder 0 bei fehler
|
||||||
*/
|
*/
|
||||||
int pkt_atoi(struct net_pkt *pkt, void *p) {
|
int pkt_atoi(struct net_pkt *pkt, void *p) {
|
||||||
int val = 0;
|
int val = 0;
|
||||||
void *max = ((void *)pkt->buf + pkt->size);
|
void *max = ((void *)pkt->buf + pkt->size);
|
||||||
char *c = p;
|
char *c = p;
|
||||||
|
|
||||||
/* check lower bounds */
|
/* untere grenze abtesten */
|
||||||
if ((void *)pkt->buf > p || p > max)
|
if ((void *)pkt->buf > p || p > max)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* ziffern einlesen */
|
||||||
while (isdigit(*c) && (void *)c < max)
|
while (isdigit(*c) && (void *)c < max)
|
||||||
val = (val * 10) + (*c++ - 0x30);
|
val = (val * 10) + (*c++ - 0x30);
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
|
||||||
/* die interne serverliste */
|
/** interne serverliste */
|
||||||
static LIST_HEAD(serverlist);
|
static LIST_HEAD(serverlist);
|
||||||
|
|
||||||
/* sichert die server liste */
|
/** sichert die interne serverliste */
|
||||||
static pthread_mutex_t serverlist_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t serverlist_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
/* scan socket */
|
/* scan socket */
|
||||||
|
@ -49,8 +49,8 @@ static int scan_sock;
|
||||||
* server_cmp()
|
* server_cmp()
|
||||||
* LIST_FIND helper
|
* LIST_FIND helper
|
||||||
*
|
*
|
||||||
* @param struct game_server *a
|
* @param *a gameserver 1
|
||||||
* @param struct game_server *b
|
* @param *b gameserver 2
|
||||||
* @return true wenn es sich um den selben server handelt
|
* @return true wenn es sich um den selben server handelt
|
||||||
*/
|
*/
|
||||||
static inline int server_cmp(const struct game_server *a, struct game_server *b) {
|
static inline int server_cmp(const struct game_server *a, struct game_server *b) {
|
||||||
|
@ -60,14 +60,13 @@ static inline int server_cmp(const struct game_server *a, struct game_server *b)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* server_add()
|
* server_add()
|
||||||
* fuegt der internen serverliste einen server hinzu
|
* wenn der server noch nicht in der internen liste vorhanden ist
|
||||||
* wenn dieser server schon in der liste vorhanden ist, wird nur
|
* wird er hinzugefuegt, ansonsten nur die modtime angepasst
|
||||||
* die modtime angepasst
|
|
||||||
*
|
*
|
||||||
* @param unsigned int gameid
|
* @param gameid gameid des servers
|
||||||
* @param struct in_addr ip
|
* @param ip ip des servers
|
||||||
* @param u_int16_t port1
|
* @param port1 erster port
|
||||||
* @param u_int16_t port2
|
* @param port2 zweiter port
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
int server_add(u_int16_t gameid, u_int32_t ip, u_int16_t port1, u_int16_t port2) {
|
int server_add(u_int16_t gameid, u_int32_t ip, u_int16_t port1, u_int16_t port2) {
|
||||||
|
@ -113,7 +112,7 @@ int server_add(u_int16_t gameid, u_int32_t ip, u_int16_t port1, u_int16_t port2)
|
||||||
* loescht alte server aus der liste
|
* loescht alte server aus der liste
|
||||||
* baut aus den verbleibenden die client_liste auf
|
* baut aus den verbleibenden die client_liste auf
|
||||||
*
|
*
|
||||||
* @param long timeout
|
* @param timeout timeout in sekunden
|
||||||
*/
|
*/
|
||||||
static void serverlist_refresh(long timeout) {
|
static void serverlist_refresh(long timeout) {
|
||||||
struct game_server *server, *tmp;
|
struct game_server *server, *tmp;
|
||||||
|
@ -146,25 +145,27 @@ static void serverlist_refresh(long timeout) {
|
||||||
* pkt_send()
|
* pkt_send()
|
||||||
* schickt ein paket ab
|
* schickt ein paket ab
|
||||||
*
|
*
|
||||||
* @param struct in_addr *dstip - pointer auf eine IP, wenn NULL wird broadcast angenommen
|
* @param *dstip destination IP, wenn NULL wird broadcast angenommen
|
||||||
* @param unsigned int dstport - destination port
|
* @param dstport destination port
|
||||||
* @param char *buf - pointer auf den zu sendenen speicherbereich
|
* @param *buf datenbereich der gesendet wird
|
||||||
* @param unsigned int size - groesse des speicherbereichs
|
* @param size groesse der daten
|
||||||
* @return false bei fehler
|
* @return false bei fehler
|
||||||
*/
|
*/
|
||||||
int pkt_send(struct in_addr *dstip, unsigned int dstport, char *buf, unsigned int size) {
|
int pkt_send(struct in_addr *dstip, unsigned int dstport, char *buf, unsigned int size) {
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_port = htons(dstport);
|
addr.sin_port = htons(dstport);
|
||||||
addr.sin_addr.s_addr = (dstip ? dstip->s_addr : 0xFFFFFFFF);
|
addr.sin_addr.s_addr = (dstip ? dstip->s_addr : 0xFFFFFFFF);
|
||||||
|
|
||||||
//inet_aton("10.4.1.1", &addr.sin_addr);
|
if (sendto(scan_sock, buf, size, 0, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
||||||
|
|
||||||
if (sendto(scan_sock, buf, size, 0, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
|
||||||
log_print("scan_send(): sendto()");
|
log_print("scan_send(): sendto()");
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,6 +269,7 @@ static void scan_close() {
|
||||||
/**
|
/**
|
||||||
* scan_init()
|
* scan_init()
|
||||||
* initialisiert den socket fuer den server scan
|
* initialisiert den socket fuer den server scan
|
||||||
|
*
|
||||||
* @return false on error
|
* @return false on error
|
||||||
*/
|
*/
|
||||||
int scan_init() {
|
int scan_init() {
|
||||||
|
|
Loading…
Reference in New Issue