2006-02-02 16:29:30 +01:00
|
|
|
/***************************************************************************
|
2006-02-02 16:52:26 +01:00
|
|
|
* Copyright (C) 12/2005 by Olaf Rempel *
|
2006-02-02 16:29:30 +01:00
|
|
|
* 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>
|
2006-11-24 21:53:25 +01:00
|
|
|
#include "netpkt.h"
|
|
|
|
#include "plugin.h"
|
2006-02-02 16:43:41 +01:00
|
|
|
#include "plugin_helper.h"
|
2006-02-02 16:29:30 +01:00
|
|
|
|
2006-02-02 16:41:56 +01:00
|
|
|
static struct scan_ports port_arr[] = {
|
2006-02-02 16:31:52 +01:00
|
|
|
{ 27666, 27673, 38 }, /* Doom 3 */
|
2006-02-02 16:52:26 +01:00
|
|
|
{ 28004, 28008, 47 }, /* Quake 4 */
|
2006-02-02 16:29:30 +01:00
|
|
|
{ 0,0,0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static char scanmsg[] = "\xff\xffgetInfo";
|
|
|
|
static char replymsg[] = "\xff\xffinfoResponse";
|
|
|
|
|
2006-02-02 16:47:20 +01:00
|
|
|
static int scan(void)
|
|
|
|
{
|
2006-02-02 16:29:30 +01:00
|
|
|
pkt_send_portarr(NULL, port_arr, scanmsg, strlen(scanmsg));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-02-02 16:47:20 +01:00
|
|
|
static int parse(struct net_pkt *pkt)
|
|
|
|
{
|
2006-02-02 16:29:30 +01:00
|
|
|
int gameid;
|
|
|
|
|
|
|
|
if (!(gameid = pkt_check_portarr(pkt, port_arr)))
|
2006-02-02 16:47:20 +01:00
|
|
|
return PARSE_REJECT;
|
2006-11-24 21:53:25 +01:00
|
|
|
|
2006-02-02 16:43:41 +01:00
|
|
|
if (pkt_memcmp(pkt, 0, replymsg, strlen(replymsg)))
|
2006-02-02 16:47:20 +01:00
|
|
|
return PARSE_REJECT;
|
2006-02-02 16:29:30 +01:00
|
|
|
|
|
|
|
server_add_pkt(gameid, pkt);
|
2006-02-02 16:47:20 +01:00
|
|
|
return PARSE_ACCEPT;
|
2006-02-02 16:29:30 +01:00
|
|
|
}
|
|
|
|
|
2006-02-02 16:41:56 +01:00
|
|
|
struct hlswmaster_plugin plugin = {
|
2006-02-02 16:52:26 +01:00
|
|
|
.name = "d3engine",
|
2006-02-02 16:29:30 +01:00
|
|
|
.scan = &scan,
|
|
|
|
.parse = &parse,
|
|
|
|
};
|