hlswmaster/plugins/hlswproxy.c

65 lines
2.2 KiB
C

/***************************************************************************
* 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>
#include <stdio.h>
#include "plugin.h"
static char scanmsg[] = "\xff\xff\xff\xffHLSWLANSEARCH";
struct _entry {
u_int16_t gameid;
u_int32_t ip;
u_int16_t port1;
u_int16_t port2;
} __attribute__ ((packed));
int scan(void) {
pkt_send(NULL, 7140, scanmsg, sizeof(scanmsg));
return 1;
}
int parse(struct net_pkt *pkt) {
struct _entry *server;
if (pkt_getport(pkt) != 7140)
return 0;
server = (void *)pkt->buf + sizeof(scanmsg);
while ((void *)server < ((void *)pkt->buf + pkt->size)) {
server_add(server->gameid, server->ip, server->port1, server->port2);
server++;
}
return 1;
}
static struct hlswmaster_plugin plugin = {
.name = "hlswproxy",
.scan = &scan,
.parse = &parse,
};
void _init(void) {
register_plugin(&plugin);
}
void _fini(void) {
unregister_plugin(&plugin);
}