2006-02-02 16:29:30 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 03/2005 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>
|
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:43:41 +01:00
|
|
|
{ 27960, 27969, 6 }, /* q3(6), ef(7), et25), rtcw(8) */
|
|
|
|
{ 28070, 28070, 12 }, /* jk2(12) TODO: UNTESTED */
|
|
|
|
{ 28960, 28963, 31 }, /* cod(31), cod:uo(42) */
|
|
|
|
{ 29070, 29070, 27 }, /* jk3(27) TODO: UNTESTED */
|
2006-02-02 16:29:30 +01:00
|
|
|
{ 0,0,0 }
|
|
|
|
};
|
|
|
|
|
2006-02-02 16:31:52 +01:00
|
|
|
static char scanmsg[] = "\xff\xff\xff\xffgetStatus";
|
|
|
|
static char replymsg[] = "\xff\xff\xff\xffstatusResponse";
|
2006-02-02 16:29:30 +01:00
|
|
|
|
2006-02-02 16:34:11 +01:00
|
|
|
static char q3_reply[] = "\\version\\Q3 ";
|
2006-02-02 16:43:41 +01:00
|
|
|
static char ef_reply[] = "\\version\\ST:V HM ";
|
|
|
|
static char rtcw_reply[] = "\\version\\Wolf ";
|
2006-02-02 16:34:11 +01:00
|
|
|
static char et_reply[] = "\\version\\ET ";
|
2006-02-02 16:43:41 +01:00
|
|
|
static char jk2_reply[] = "\\version\\JK2MP ";
|
|
|
|
static char jk3_reply[] = "\\version\\JAmp ";
|
2006-02-02 16:34:11 +01:00
|
|
|
static char cod_reply[] = "\\gamename\\Call of Duty\\";
|
|
|
|
static char coduo_reply[] = "\\gamename\\CoD:United Offensive\\";
|
|
|
|
|
2006-02-02 16:41:56 +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:41:56 +01:00
|
|
|
static int parse(struct net_pkt *pkt) {
|
2006-02-02 16:29:30 +01:00
|
|
|
int gameid;
|
|
|
|
|
2006-02-02 16:31:52 +01:00
|
|
|
if (!(gameid = pkt_check_portarr(pkt, port_arr)))
|
|
|
|
return 0;
|
|
|
|
|
2006-02-02 16:29:30 +01:00
|
|
|
if (pkt_memcmp(pkt, 0, replymsg, strlen(replymsg)))
|
|
|
|
return 0;
|
|
|
|
|
2006-02-02 16:34:11 +01:00
|
|
|
switch (gameid) {
|
2006-02-02 16:43:41 +01:00
|
|
|
case 6: /* q3, ef, et, rtcw */
|
2006-02-02 16:34:11 +01:00
|
|
|
if (pkt_memmem(pkt, 0, q3_reply, strlen(q3_reply))) {
|
2006-02-02 16:31:52 +01:00
|
|
|
gameid = 6;
|
|
|
|
|
2006-02-02 16:34:11 +01:00
|
|
|
} else if (pkt_memmem(pkt, 0, ef_reply, strlen(ef_reply))) {
|
2006-02-02 16:31:52 +01:00
|
|
|
gameid = 7;
|
|
|
|
|
2006-02-02 16:43:41 +01:00
|
|
|
} else if (pkt_memmem(pkt, 0, rtcw_reply, strlen(rtcw_reply))) {
|
|
|
|
gameid = 8;
|
|
|
|
|
2006-02-02 16:34:11 +01:00
|
|
|
} else if (pkt_memmem(pkt, 0, et_reply, strlen(et_reply))) {
|
|
|
|
gameid = 25;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-02-02 16:43:41 +01:00
|
|
|
case 12: /* jedi knight 2 */
|
|
|
|
if (!pkt_memmem(pkt, 0, jk2_reply, strlen(jk2_reply)))
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 27: /* jedi knight 3 */
|
|
|
|
if (!pkt_memmem(pkt, 0, jk3_reply, strlen(jk3_reply)))
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
|
2006-02-02 16:34:11 +01:00
|
|
|
case 31: /* cod, cod:uo */
|
|
|
|
if (pkt_memmem(pkt, 0, cod_reply, strlen(cod_reply))) {
|
|
|
|
gameid = 31;
|
|
|
|
|
|
|
|
} else if (pkt_memmem(pkt, 0, coduo_reply, strlen(coduo_reply))) {
|
|
|
|
gameid = 42;
|
|
|
|
|
2006-02-02 16:31:52 +01:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-02 16:34:11 +01:00
|
|
|
break;
|
2006-02-02 16:31:52 +01:00
|
|
|
}
|
2006-02-02 16:29:30 +01:00
|
|
|
|
|
|
|
server_add_pkt(gameid, pkt);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-02-02 16:41:56 +01:00
|
|
|
struct hlswmaster_plugin plugin = {
|
2006-02-02 16:31:52 +01:00
|
|
|
.name = "q3engine",
|
2006-02-02 16:29:30 +01:00
|
|
|
.scan = &scan,
|
|
|
|
.parse = &parse,
|
|
|
|
};
|