diff options
Diffstat (limited to 'src/Net')
-rw-r--r-- | src/Net/ClientConnection.cpp | 6 | ||||
-rw-r--r-- | src/Net/Connection.cpp | 10 | ||||
-rw-r--r-- | src/Net/Connection.h | 24 | ||||
-rw-r--r-- | src/Net/IPAddress.h | 18 | ||||
-rw-r--r-- | src/Net/Listener.cpp | 2 | ||||
-rw-r--r-- | src/Net/Makefile.am | 6 | ||||
-rw-r--r-- | src/Net/Makefile.in | 183 | ||||
-rw-r--r-- | src/Net/Packet.cpp | 50 | ||||
-rw-r--r-- | src/Net/Packet.h | 45 | ||||
-rw-r--r-- | src/Net/Packets/CoreStatusPacket.cpp | 46 | ||||
-rw-r--r-- | src/Net/Packets/CoreStatusPacket.h | 70 | ||||
-rw-r--r-- | src/Net/Packets/Makefile.am | 4 | ||||
-rw-r--r-- | src/Net/Packets/Makefile.in | 442 | ||||
-rw-r--r-- | src/Net/ServerConnection.cpp | 6 |
14 files changed, 815 insertions, 97 deletions
diff --git a/src/Net/ClientConnection.cpp b/src/Net/ClientConnection.cpp index e0058ff..d818f7e 100644 --- a/src/Net/ClientConnection.cpp +++ b/src/Net/ClientConnection.cpp @@ -32,7 +32,7 @@ void ClientConnection::connectionHeaderReceiveHandler(const void *data, unsigned // Error... disconnect return; - const ConnectionHeader *header = reinterpret_cast<const ConnectionHeader*>(data); + const ConnectionHeader *header = (const ConnectionHeader*)(data); if(header->m != 'M' || header->a != 'A' || header->d != 'D') // Error... disconnect @@ -48,7 +48,7 @@ void ClientConnection::connectionHeaderReceiveHandler(const void *data, unsigned void ClientConnection::connectionHeader() { ConnectionHeader header = {'M', 'A', 'D', daemon ? 'D' : 'C', 0, 1, 1, 1}; - rawSend(reinterpret_cast<unsigned char*>(&header), sizeof(header)); + rawSend((uint8_t*)&header, sizeof(header)); rawReceive(sizeof(ConnectionHeader), sigc::mem_fun(this, &ClientConnection::connectionHeaderReceiveHandler)); } @@ -89,7 +89,7 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Con gnutls_init(&session, GNUTLS_CLIENT); gnutls_set_default_priority(session); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); - gnutls_transport_set_ptr(session, reinterpret_cast<gnutls_transport_ptr_t>(sock)); + gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)sock); handshake(); } diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp index cfced4f..22adeaf 100644 --- a/src/Net/Connection.cpp +++ b/src/Net/Connection.cpp @@ -74,7 +74,7 @@ void Connection::packetHeaderReceiveHandler(const void *data, unsigned long leng return; } - header = *reinterpret_cast<const Packet::Data*>(data); + header = *(const Packet::Data*)data; if(header.length == 0) { signal(this, Packet((Packet::Type)ntohs(header.type), ntohs(header.requestId))); @@ -124,7 +124,7 @@ void Connection::doReceive() { if(receiveComplete()) { // Save data pointer, as transR.notify might start a new reception - unsigned char *data = transR.data; + uint8_t *data = transR.data; transR.data = 0; transR.notify(data, transR.length); @@ -142,7 +142,7 @@ bool Connection::rawReceive(unsigned long length, if(!receiveComplete()) return false; - transR.data = new unsigned char[length]; + transR.data = new uint8_t[length]; transR.length = length; transR.transmitted = 0; transR.notify = notify; @@ -176,11 +176,11 @@ void Connection::doSend() { } } -bool Connection::rawSend(const unsigned char *data, unsigned long length) { +bool Connection::rawSend(const uint8_t *data, unsigned long length) { if(!isConnected()) return false; - Transmission trans = {length, 0, new unsigned char[length], sigc::slot<void,const void*,unsigned long>()}; + Transmission trans = {length, 0, new uint8_t[length], sigc::slot<void,const void*,unsigned long>()}; std::memcpy(trans.data, data, length); transS.push(trans); diff --git a/src/Net/Connection.h b/src/Net/Connection.h index d733ee3..0f012f1 100644 --- a/src/Net/Connection.h +++ b/src/Net/Connection.h @@ -38,7 +38,7 @@ class Connection { unsigned long length; unsigned long transmitted; - unsigned char *data; + uint8_t *data; sigc::slot<void,const void*,unsigned long> notify; }; @@ -87,15 +87,15 @@ class Connection { protected: struct ConnectionHeader { - unsigned char m; - unsigned char a; - unsigned char d; - unsigned char type; - - unsigned char versionMajor; - unsigned char versionMinor; - unsigned char protVerMin; - unsigned char protVerMax; + uint8_t m; + uint8_t a; + uint8_t d; + uint8_t type; + + uint8_t versionMajor; + uint8_t versionMinor; + uint8_t protVerMin; + uint8_t protVerMax; }; int sock; @@ -116,7 +116,7 @@ class Connection { virtual void connectionHeader() = 0; bool rawReceive(unsigned long length, const sigc::slot<void,const void*,unsigned long> ¬ify); - bool rawSend(const unsigned char *data, unsigned long length); + bool rawSend(const uint8_t *data, unsigned long length); bool enterReceiveLoop() { if(!isConnected() || isDisconnecting()) @@ -189,7 +189,7 @@ class Connection { if(!isConnected() || isConnecting() || isDisconnecting()) return false; - return rawSend(reinterpret_cast<const unsigned char*>(packet.getRawData()), packet.getRawDataLength()); + return rawSend((const uint8_t*)packet.getRawData(), packet.getRawDataLength()); } void sendReceive(short events = POLLIN|POLLOUT); diff --git a/src/Net/IPAddress.h b/src/Net/IPAddress.h index b0fad45..78b41dd 100644 --- a/src/Net/IPAddress.h +++ b/src/Net/IPAddress.h @@ -30,19 +30,19 @@ namespace Net { class IPAddress { private: - unsigned int addr; - unsigned short port; + uint32_t addr; + uint16_t port; struct sockaddr_in sa; public: // TODO Default port - IPAddress(unsigned short port0 = 6666) : addr(INADDR_ANY), port(port0) { + IPAddress(uint16_t port0 = 6666) : addr(INADDR_ANY), port(port0) { sa.sin_family = AF_INET; sa.sin_port = htons(port); sa.sin_addr.s_addr = INADDR_ANY; } - IPAddress(unsigned int address, unsigned short port0) : addr(address), port(port0) { + IPAddress(uint32_t address, uint16_t port0) : addr(address), port(port0) { sa.sin_family = AF_INET; sa.sin_port = htons(port); sa.sin_addr.s_addr = htonl(addr); @@ -77,7 +77,7 @@ class IPAddress { addr = ntohl(sa.sin_addr.s_addr); } - IPAddress(const std::string &address, unsigned short port0) throw(InvalidAddressException) : port(port0) { + IPAddress(const std::string &address, uint16_t port0) throw(InvalidAddressException) : port(port0) { sa.sin_family = AF_INET; sa.sin_port = htons(port); @@ -92,18 +92,18 @@ class IPAddress { addr = ntohl(sa.sin_addr.s_addr); } - unsigned int getAddress() const {return addr;} - unsigned short getPort() const {return port;} + uint32_t getAddress() const {return addr;} + uint16_t getPort() const {return port;} std::string getAddressString() const { char buf[INET_ADDRSTRLEN]; - unsigned int address = htonl(addr); + uint32_t address = htonl(addr); inet_ntop(AF_INET, &address, buf, sizeof(buf)); return std::string(buf); } - struct sockaddr* getSockAddr() {return reinterpret_cast<struct sockaddr*>(&sa);} + struct sockaddr* getSockAddr() {return (struct sockaddr*)&sa;} socklen_t getSockAddrLength() const {return sizeof(sa);} }; diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp index 892ec9d..954129a 100644 --- a/src/Net/Listener.cpp +++ b/src/Net/Listener.cpp @@ -98,7 +98,7 @@ ServerConnection* Listener::getConnection(const std::map<int,const short*> &poll socklen_t addrlen = sizeof(sa); - while((sd = accept(sock, reinterpret_cast<struct sockaddr*>(&sa), &addrlen)) >= 0) { + while((sd = accept(sock, (struct sockaddr*)&sa, &addrlen)) >= 0) { connections.push_back(new ServerConnection(sd, IPAddress(sa), dh_params, x905CertFile, x905KeyFile)); addrlen = sizeof(sa); diff --git a/src/Net/Makefile.am b/src/Net/Makefile.am index c7f58da..2fd4f12 100644 --- a/src/Net/Makefile.am +++ b/src/Net/Makefile.am @@ -1,6 +1,8 @@ -noinst_LTLIBRARIES = libnet.la +SUBDIRS = Packets -libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp +noinst_LTLIBRARIES = libnet.la +libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp Packet.cpp +libnet_la_LIBADD = Packets/libpackets.la noinst_HEADERS = ClientConnection.h ServerConnection.h Connection.h Exception.h ConnectionException.h \ InvalidAddressException.h IPAddress.h Listener.h Packet.h diff --git a/src/Net/Makefile.in b/src/Net/Makefile.in index 9ce9a8e..e813a71 100644 --- a/src/Net/Makefile.in +++ b/src/Net/Makefile.in @@ -44,9 +44,9 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) -libnet_la_LIBADD = +libnet_la_DEPENDENCIES = Packets/libpackets.la am_libnet_la_OBJECTS = ClientConnection.lo ServerConnection.lo \ - Connection.lo Listener.lo + Connection.lo Listener.lo Packet.lo libnet_la_OBJECTS = $(am_libnet_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -62,9 +62,19 @@ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libnet_la_SOURCES) DIST_SOURCES = $(libnet_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive HEADERS = $(noinst_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -180,12 +190,14 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +SUBDIRS = Packets noinst_LTLIBRARIES = libnet.la -libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp +libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp Packet.cpp +libnet_la_LIBADD = Packets/libpackets.la noinst_HEADERS = ClientConnection.h ServerConnection.h Connection.h Exception.h ConnectionException.h \ InvalidAddressException.h IPAddress.h Listener.h Packet.h -all: all-am +all: all-recursive .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj @@ -239,6 +251,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClientConnection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Listener.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Packet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerConnection.Plo@am__quote@ .cpp.o: @@ -268,6 +281,76 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -278,10 +361,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) mkid -fID $$unique tags: TAGS -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ @@ -294,7 +390,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $$tags $$unique; \ fi ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -341,19 +437,37 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done check-am: all-am -check: check-am +check: check-recursive all-am: Makefile $(LTLIBRARIES) $(HEADERS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ @@ -369,69 +483,71 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -clean: clean-am +clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am -distclean: distclean-am +distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -html: html-am +html: html-recursive -info: info-am +info: info-recursive info-am: install-data-am: -install-dvi: install-dvi-am +install-dvi: install-dvi-recursive install-exec-am: -install-html: install-html-am +install-html: install-html-recursive -install-info: install-info-am +install-info: install-info-recursive install-man: -install-pdf: install-pdf-am +install-pdf: install-pdf-recursive -install-ps: install-ps-am +install-ps: install-ps-recursive installcheck-am: -maintainer-clean: maintainer-clean-am +maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool -pdf: pdf-am +pdf: pdf-recursive pdf-am: -ps: ps-am +ps: ps-recursive ps-am: uninstall-am: -.MAKE: install-am install-strip +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLTLIBRARIES ctags distclean \ +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + clean-noinstLTLIBRARIES ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ @@ -439,9 +555,10 @@ uninstall-am: install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/Net/Packet.cpp b/src/Net/Packet.cpp new file mode 100644 index 0000000..9e05f24 --- /dev/null +++ b/src/Net/Packet.cpp @@ -0,0 +1,50 @@ +/* + * Packet.cpp + * + * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#include "Packet.h" + +namespace Mad { +namespace Net { + +Packet::Packet(Type type, uint16_t requestId, const void *data, uint16_t length) { + rawData = (Data*)std::malloc(sizeof(Data)+length); + + rawData->type = htons(type); + rawData->requestId = htons(requestId); + rawData->reserved = 0; + rawData->length = htons(length); + + if(length) + std::memcpy(rawData->data, data, length); +} + +Packet& Packet::operator=(const Packet &p) { + if(&p == this) + return *this; + + std::free(rawData); + + rawData = (Data*)std::malloc(p.getRawDataLength()); + std::memcpy(rawData, p.rawData, p.getRawDataLength()); + + return *this; +} + +} +} diff --git a/src/Net/Packet.h b/src/Net/Packet.h index 1062d4a..e64f37b 100644 --- a/src/Net/Packet.h +++ b/src/Net/Packet.h @@ -23,6 +23,7 @@ #include <cstdlib> #include <cstring> #include <netinet/in.h> +#include <stdint.h> namespace Mad { namespace Net { @@ -36,63 +37,49 @@ class Packet { }; struct Data { - unsigned short type; - unsigned short requestId; - unsigned short reserved; - unsigned short length; - unsigned char data[0]; + uint16_t type; + uint16_t requestId; + uint16_t reserved; + uint16_t length; + uint8_t data[0]; }; protected: Data *rawData; - public: - Packet(Type type, unsigned short requestId, const void *data = NULL, unsigned short length = 0) { - rawData = (Data*)std::malloc(sizeof(Data)+length); - - rawData->type = htons(type); - rawData->requestId = htons(requestId); - rawData->reserved = 0; + void setLength(uint16_t length) { rawData->length = htons(length); - if(length) - std::memcpy(rawData->data, data, length); - } - - Packet(const Packet &p) { - rawData = (Data*)std::malloc(p.getRawDataLength()); - std::memcpy(rawData, p.rawData, p.getRawDataLength()); + rawData = (Data*)std::realloc(rawData, getRawDataLength()); } - Packet& operator=(Packet &p) { - if(&p == this) - return *this; - - std::free(rawData); + public: + Packet(Type type, uint16_t requestId, const void *data = 0, uint16_t length = 0); + Packet(const Packet &p) { rawData = (Data*)std::malloc(p.getRawDataLength()); std::memcpy(rawData, p.rawData, p.getRawDataLength()); - - return *this; } virtual ~Packet() { std::free(rawData); } + Packet& operator=(const Packet &p); + Type getType() const { return (Type)ntohs(rawData->type); } - unsigned short getRequestId() const { + uint16_t getRequestId() const { return ntohs(rawData->requestId); } - unsigned short getLength() const { + uint16_t getLength() const { return ntohs(rawData->length); } - const unsigned char* getData() const { + const uint8_t* getData() const { return rawData->data; } diff --git a/src/Net/Packets/CoreStatusPacket.cpp b/src/Net/Packets/CoreStatusPacket.cpp new file mode 100644 index 0000000..4397fa8 --- /dev/null +++ b/src/Net/Packets/CoreStatusPacket.cpp @@ -0,0 +1,46 @@ +/* + * CoreStatusPacket.cpp + * + * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#include "CoreStatusPacket.h" + + +namespace Mad { +namespace Net { +namespace Packets { + +CoreStatusPacket::CoreStatusPacket(Type type, uint16_t requestId, uint32_t uptime, uint32_t idleTime) : Packet(type, requestId) { + setLength(sizeof(CoreStatusData)); + coreStatusData = (CoreStatusData*)&rawData->data; + + coreStatusData->uptime = htonl(uptime); + coreStatusData->idleTime = htonl(idleTime); +} + +CoreStatusPacket& CoreStatusPacket::operator=(const Packet &p) { + Packet::operator=(p); + + setLength(sizeof(CoreStatusData)); + coreStatusData = (CoreStatusData*)&rawData->data; + + return *this; +} + +} +} +} diff --git a/src/Net/Packets/CoreStatusPacket.h b/src/Net/Packets/CoreStatusPacket.h new file mode 100644 index 0000000..14b022e --- /dev/null +++ b/src/Net/Packets/CoreStatusPacket.h @@ -0,0 +1,70 @@ +/* + * CoreStatusPacket.h + * + * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MAD_NET_PACKETS_CORESTATUSPACKET_H_ +#define MAD_NET_PACKETS_CORESTATUSPACKET_H_ + +#include "../Packet.h" + +namespace Mad { +namespace Net { +namespace Packets { + +class CoreStatusPacket : public Packet { + protected: + struct CoreStatusData { + uint32_t uptime; + uint32_t idleTime; + }; + + CoreStatusData *coreStatusData; + + public: + CoreStatusPacket(Type type, uint16_t requestId, uint32_t uptime = 0, uint32_t idleTime = 0); + + CoreStatusPacket(const Packet &p) : Packet(p) { + setLength(sizeof(CoreStatusData)); + coreStatusData = (CoreStatusData*)&rawData->data; + } + + CoreStatusPacket(const CoreStatusPacket &p) : Packet(p) { + setLength(sizeof(CoreStatusData)); + coreStatusData = (CoreStatusData*)&rawData->data; + } + + CoreStatusPacket& operator=(const Packet &p); + + CoreStatusPacket& operator=(const CoreStatusPacket &p) { + return (*this = (Packet)p); + } + + uint32_t getUptime() const { + return ntohl(coreStatusData->uptime); + } + + uint32_t getIdleTime() const { + return ntohl(coreStatusData->idleTime); + } +}; + +} +} +} + +#endif /* MAD_NET_PACKETS_CORESTATUSPACKET_H_ */ diff --git a/src/Net/Packets/Makefile.am b/src/Net/Packets/Makefile.am new file mode 100644 index 0000000..344a764 --- /dev/null +++ b/src/Net/Packets/Makefile.am @@ -0,0 +1,4 @@ +noinst_LTLIBRARIES = libpackets.la +libpackets_la_SOURCES = CoreStatusPacket.cpp + +noinst_HEADERS = CoreStatusPacket.h diff --git a/src/Net/Packets/Makefile.in b/src/Net/Packets/Makefile.in new file mode 100644 index 0000000..8fa55b0 --- /dev/null +++ b/src/Net/Packets/Makefile.in @@ -0,0 +1,442 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/Net/Packets +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libpackets_la_LIBADD = +am_libpackets_la_OBJECTS = CoreStatusPacket.lo +libpackets_la_OBJECTS = $(am_libpackets_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libpackets_la_SOURCES) +DIST_SOURCES = $(libpackets_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +GnuTLS_CFLAGS = @GnuTLS_CFLAGS@ +GnuTLS_LIBS = @GnuTLS_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sigc_CFLAGS = @sigc_CFLAGS@ +sigc_LIBS = @sigc_LIBS@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LTLIBRARIES = libpackets.la +libpackets_la_SOURCES = CoreStatusPacket.cpp +noinst_HEADERS = CoreStatusPacket.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Net/Packets/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Net/Packets/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libpackets.la: $(libpackets_la_OBJECTS) $(libpackets_la_DEPENDENCIES) + $(CXXLINK) $(libpackets_la_OBJECTS) $(libpackets_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoreStatusPacket.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/Net/ServerConnection.cpp b/src/Net/ServerConnection.cpp index 0c35991..fbdd69f 100644 --- a/src/Net/ServerConnection.cpp +++ b/src/Net/ServerConnection.cpp @@ -32,7 +32,7 @@ void ServerConnection::connectionHeaderReceiveHandler(const void *data, unsigned // Error... disconnect return; - const ConnectionHeader *header = reinterpret_cast<const ConnectionHeader*>(data); + const ConnectionHeader *header = (const ConnectionHeader*)data; if(header->m != 'M' || header->a != 'A' || header->d != 'D') // Error... disconnect @@ -52,7 +52,7 @@ void ServerConnection::connectionHeaderReceiveHandler(const void *data, unsigned ConnectionHeader header2 = {'M', 'A', 'D', 0, 0, 1, 1, 0}; - rawSend(reinterpret_cast<unsigned char*>(&header2), sizeof(header2)); + rawSend((uint8_t*)&header2, sizeof(header2)); enterReceiveLoop(); } @@ -69,7 +69,7 @@ ServerConnection::ServerConnection(int sock0, const IPAddress &address, gnutls_d gnutls_init(&session, GNUTLS_SERVER); gnutls_set_default_priority(session); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); - gnutls_transport_set_ptr(session, reinterpret_cast<gnutls_transport_ptr_t>(sock)); + gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)sock); handshake(); } |