gnugk compile error - fixed
Kluba Patrik
pajko at kukac.halom.u-szeged.hu
Sun Dec 11 09:20:03 UTC 2005
Hello!
The recent version of gnugk cannot be compiled with GCC4. The compiler complains
about incorrect use of the struct gkDestAnalysis or something. And yes, its
true, there's only a single line
class gkDestAnalysis;
in RasTbl.h, some other parts of the code (for eg. at line 382, 384 in
RasTbl.h) try to access its methods, but the class itself isn't implemented
anywhere.
GCC3 doesn't even give a warning. Although I haven't managed to get a binary out
of it (the linker complains about missing std::__alloc_template...., I think
it's because pwlib & openh323 are compiled with GCC4, and I even needed to
change
#define P_NEEDS_GNU_CXX_NAMESPACE 1 to
#undef P_NEEDS_GNU_CXX_NAMESPACE
in /usr/share/pwlib/include/ptbuildopts.h), I doubt any GCC3 compiled binary
will work as it should.
Something bad has happened between 2.1 and 2.2 releases. Somebody just stripped
non-working or non-comiling code without checking the dependencies.
What I did is that took the 2.1 CVS source and put back the relevant parts to
2.2. The files were originally gkDestAnalysis.h and gkDestAnalysis.cxx, and
these included RasTbl.h. RasTbl.h needs to include gkDestAnalysis.h but it is
not possible because it would cause a loop. So I moved the needed parts directly
to RasTbl.h & RasTbl.cxx, this way everything compiles OK.
Bye,
Patrik
-------------- next part --------------
diff -Naurp gnugk_2.2.3-2-1/RasTbl.cxx gnugk_2.2.3-2-1-fixed/RasTbl.cxx
--- gnugk_2.2.3-2-1/RasTbl.cxx 2005-08-09 14:48:47.000000000 +0200
+++ gnugk_2.2.3-2-1-fixed/RasTbl.cxx 2005-12-11 09:53:29.000000000 +0100
@@ -2286,3 +2286,149 @@ PString CallTable::PrintStatistics() con
m_CallCount, m_successCall, m_neighborCall, m_parentCall);
}
+//////////////// included relevant part of gkDestAnalysis.cxx ///////////////////////
+
+//////////////////////////////////////////////////////////////////
+//
+// gkDestAnalysis.cxx
+//
+// This work is published under the GNU Public License (GPL)
+// see file COPYING for details.
+// We also explicitely grant the right to link this code
+// with the OpenH323 library.
+//
+// History:
+// 2002/01/23 initial version (Markus Muehlenbernd)
+//
+//////////////////////////////////////////////////////////////////
+
+//#ifdef WITH_DEST_ANALYSIS_LIST
+
+#ifdef P_SOLARIS
+#define map stl_map
+#endif
+
+#include <map>
+#include <list>
+
+#ifndef lint
+// mark object with version info in such a way that it is retrievable by
+// the std. version/revision control tools like RCS/CVS ident cmd. At
+// least the strings cmd will extract this info.
+static const char gkid[] = "???";
+static const char vcid[] = "@(#) $Id: gkDestAnalysis.cxx,v 1.32 2003/04/02 07:15:36 nilsb Exp $";
+static const char vcHid[] = "???";
+#endif /* lint */
+
+
+using std::map;
+using std::list;
+
+const char *GK_DEST_ANALYSIS_SECTION_NAME = "Gatekeeper::DestAnalysis";
+
+GkDestAnalysis *GkDestAnalysis::head = 0;
+
+static GkDestAnalysisInit<GkDestAnalysis> _defaultGKDA_("default");
+
+GkDestAnalysis::GkDestAnalysis(PConfig *cfg, const char *destAnalysisName) : config(cfg), name(destAnalysisName), checkFlag(e_ALL)
+{
+ PStringArray control(config->GetString(GK_DEST_ANALYSIS_SECTION_NAME, name, "").Tokenise(";,"));
+ if (PString(name) == "default")
+ controlFlag = e_Sufficient,
+ defaultStatus = Toolkit::AsBool(control[0]) ? e_ok : e_fail;
+ else if (control[0] *= "optional")
+ controlFlag = e_Optional, defaultStatus = e_next;
+ else if (control[0] *= "alternative")
+ controlFlag = e_Alternative, defaultStatus = e_next;
+ else if (control[0] *= "required")
+ controlFlag = e_Required, defaultStatus = e_fail;
+ else
+ controlFlag = e_Sufficient, defaultStatus = e_fail;
+
+ if (control.GetSize() > 1) {
+ checkFlag = 0;
+ map<PString, int> msgmap;
+ msgmap["ARQ"] = e_ARQ;
+ msgmap["LRQ"] = e_LRQ;
+ for (PINDEX i=1; i < control.GetSize(); ++i) {
+ if (msgmap.find(control[i]) != msgmap.end())
+ checkFlag |= msgmap[control[i]];
+ }
+ }
+
+ next = head;
+ head = this;
+
+ PTRACE(1, "GkDestAnalysis\tAdd " << name << " rule with flag " << hex << checkFlag << dec);
+}
+
+GkDestAnalysis::~GkDestAnalysis()
+{
+ deleteMutex.Wait();
+ PTRACE(1, "GkDestAnalysis\tRemove " << name << " rule");
+ delete next; // delete whole list recursively
+}
+
+int GkDestAnalysis::getDestination(const H225_AdmissionRequest &, list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock, endptr & cgEP, endptr & cdEP, unsigned & reason)
+{
+ PTRACE(1, "called GkDestAnalysis::getDestination()");
+ return defaultStatus;
+}
+
+int GkDestAnalysis::getDestination(const H225_LocationRequest &, list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock, endptr & cgEP, endptr & cdEP, unsigned & reason)
+{
+ PTRACE(1, "called GkDestAnalysis::getDestination()");
+ return defaultStatus;
+}
+
+int GkDestAnalysis::getDestination(const H225_AliasAddress &, list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock, const endptr & cgEP, endptr & cdEP, unsigned & reason)
+{
+ PTRACE(1, "called GkDestAnalysis::getDestination()");
+ return defaultStatus;
+}
+
+static list<GkDestAnalysisInitializer *> *destAnalysisNameList;
+
+GkDestAnalysisInitializer::GkDestAnalysisInitializer(const char *n) : name(n)
+{
+ static list<GkDestAnalysisInitializer *> aList;
+ destAnalysisNameList = &aList;
+
+ destAnalysisNameList->push_back(this);
+}
+
+GkDestAnalysisInitializer::~GkDestAnalysisInitializer()
+{
+}
+
+bool GkDestAnalysisInitializer::Compare(PString n) const
+{
+ return n == name;
+}
+
+GkDestAnalysisList::GkDestAnalysisList(PConfig *cfg)
+{
+ PStringList destAnalysisList(cfg->GetKeys(GK_DEST_ANALYSIS_SECTION_NAME));
+
+ for (PINDEX i=destAnalysisList.GetSize(); i-- > 0; ) {
+ PString destAnalysisName(destAnalysisList[i]);
+ std::list<GkDestAnalysisInitializer *>::iterator Iter =
+ find_if(destAnalysisNameList->begin(), destAnalysisNameList->end(),
+ bind2nd(mem_fun(&GkDestAnalysisInitializer::Compare), destAnalysisName));
+ if (Iter != destAnalysisNameList->end())
+ (*Iter)->CreateDestAnalysis(cfg);
+#ifdef PTRACING
+ else
+ PTRACE(1, "GkDestAnalysis\tUnknown destAnalysis " << destAnalysisName << ", ignore!");
+#endif
+ }
+}
+
+GkDestAnalysisList::~GkDestAnalysisList()
+{
+ delete GkDestAnalysis::head;
+ GkDestAnalysis::head = 0;
+}
diff -Naurp gnugk_2.2.3-2-1/RasTbl.h gnugk_2.2.3-2-1-fixed/RasTbl.h
--- gnugk_2.2.3-2-1/RasTbl.h 2005-12-11 08:28:07.000000000 +0100
+++ gnugk_2.2.3-2-1-fixed/RasTbl.h 2005-12-11 09:54:58.000000000 +0100
@@ -28,7 +28,6 @@
#pragma warning( disable : 4800 )
#endif
-class GkDestAnalysisList;
class USocket;
class CallSignalSocket;
class RasServer;
@@ -258,6 +257,146 @@ protected:
typedef EndpointRec::Ptr endptr;
+/////////// include file gkDestAnalysis.h //////////////////////
+
+class H225_AdmissionRequest;
+
+class GkDestAnalysis {
+public:
+ enum Control {
+ e_Optional,
+ e_Alternative,
+ e_Required,
+ e_Sufficient
+ };
+
+ enum Status {
+ e_ok = 1, // the request is ok
+ e_fail = -1, // the request should be rejected
+ e_next = 0 // the request is undetermined
+ };
+
+ enum {
+ e_ARQ = 0x0001,
+ e_LRQ = 0x0002,
+ e_ALL = 0x00FF
+ };
+
+ GkDestAnalysis(PConfig *, const char *authName = "default");
+ virtual ~GkDestAnalysis();
+
+ /** Returns the destination endpoint of the message.
+ The calling endpoint must be given if MsgType == H225_AliasAddress. In
+ all other cases it can also be NULL.
+ */
+ template<class MsgType> bool getMsgDestination(const MsgType & req, list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock, endptr & cgEP, endptr & cdEP, unsigned & reason)
+ {
+ PWaitAndSignal lock(deleteMutex);
+ if (checkFlag & MsgValue(req)) {
+ int r = getDestination(req, EPList, listLock, cgEP, cdEP, reason);
+ if (r == e_ok) {
+ PTRACE(4, "GkDestAnalysis\t" << name << " check ok");
+ if (controlFlag != e_Required)
+ return true;
+ } else if (r == e_fail) {
+ PTRACE(2, "GkDestAnalysis\t" << name << " check failed");
+ if (controlFlag != e_Alternative)
+ return false;
+ }
+ }
+ // try next rule
+ //if(!next)
+ return (next) ? next->getMsgDestination(req, EPList, listLock, cgEP, cdEP, reason) : true;
+ }
+
+ const char *GetName() { return name; }
+
+
+
+protected:
+ /** Returns the destination endpoint of an ARQ.
+ The calling endpoint is optional.
+ */
+ virtual int getDestination(const H225_AdmissionRequest &, list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock, endptr & cgEP, endptr & cdEP, unsigned & reason);
+
+ /** Returns the destination endpoint of an LRQ.
+ The calling endpoint is optional.
+ */
+ virtual int getDestination(const H225_LocationRequest &, list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock, endptr & cgEP, endptr & cdEP, unsigned & reason);
+
+ /** Returns the destination endpoint of an ARQ.
+ The calling endpoint must be given!
+ */
+ virtual int getDestination(const H225_AliasAddress &, list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock, const endptr & cgEP, endptr & cdEP, unsigned & reason);
+
+ int MsgValue(const H225_AdmissionRequest &) { return e_ARQ; }
+ int MsgValue(const H225_LocationRequest &) { return e_LRQ; }
+ int MsgValue(const H225_AliasAddress &) {return 1;}
+
+ Control controlFlag;
+ Status defaultStatus;
+ PConfig *config;
+ mutable PMutex deleteMutex;
+
+private:
+ const char *name;
+ int checkFlag;
+
+ GkDestAnalysis *next;
+ static GkDestAnalysis *head;
+
+ GkDestAnalysis(const GkDestAnalysis &);
+ GkDestAnalysis & operator=(const GkDestAnalysis &);
+
+ friend class GkDestAnalysisList;
+};
+
+
+class GkDestAnalysisInitializer {
+public:
+ GkDestAnalysisInitializer(const char *);
+ virtual ~GkDestAnalysisInitializer();
+ // virtual constructor
+ virtual GkDestAnalysis *CreateDestAnalysis(PConfig *) = 0;
+ bool Compare(PString n) const;
+
+protected:
+ const char *name;
+};
+
+template<class GkDestAnalysisT> class GkDestAnalysisInit : public GkDestAnalysisInitializer {
+public:
+ GkDestAnalysisInit(const char *n) : GkDestAnalysisInitializer(n) {}
+ virtual GkDestAnalysis *CreateDestAnalysis(PConfig *config)
+ { return new GkDestAnalysisT(config, name); }
+};
+
+class GkDestAnalysisList {
+public:
+ GkDestAnalysisList(PConfig *);
+ virtual ~GkDestAnalysisList();
+
+ template<class MsgType> bool getMsgDestination(const MsgType & req,
+ list<EndpointRec *> & EPList,
+ PReadWriteMutex & listLock,
+ endptr & cgEP, endptr & cdEP,
+ unsigned & reason)
+ {
+ return (GkDestAnalysis::head) ?
+ GkDestAnalysis::head->getMsgDestination(req, EPList, listLock,
+ cgEP, cdEP, reason) : true;
+ }
+
+private:
+ GkDestAnalysisList(const GkDestAnalysisList &);
+ GkDestAnalysisList & operator=(const GkDestAnalysisList &);
+};
+
+///////////////// end include ////////////////////
class GatewayRec : public EndpointRec {
public:
More information about the Pkg-voip-maintainers
mailing list