1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2010-2012 Licq developers <licq-dev@googlegroups.com>
4  *
5  * Licq is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Licq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 #ifndef LICQ_PACKET_H
20 #define LICQ_PACKET_H
21 
22 #include <cstdlib> // NULL
23 
24 namespace Licq
25 {
26 class Buffer;
27 class INetSocket;
28 
29 class Packet
30 {
31 public:
32   virtual ~Packet();
33 
34   virtual Buffer* getBuffer() = 0;
35 
Finalize(INetSocket *)36   virtual Buffer* Finalize(INetSocket*)
37   { return NULL; }
38 
39   virtual unsigned short Sequence() = 0;
40   virtual unsigned short SubSequence() = 0;
41   virtual unsigned short SubCommand() = 0;
42 
SNAC()43   virtual unsigned long  SNAC()      { return 0; }
ExtraInfo()44   virtual unsigned short ExtraInfo() { return 0; }
45 
SetLocalIp(unsigned long n)46   static void SetLocalIp(unsigned long n)  {  s_nLocalIp = n; }
SetLocalPort(unsigned short n)47   static void SetLocalPort(unsigned short n)  {  s_nLocalPort = n; }
SetRealIp(unsigned long n)48   static void SetRealIp(unsigned long n)  {  s_nRealIp = n; }
Firewall()49   static bool Firewall() { return s_nLocalIp != s_nRealIp; }
RealIp()50   static unsigned long RealIp() { return s_nRealIp; }
LocalIp()51   static unsigned long LocalIp() { return s_nLocalIp; }
52 
53 protected:
54   Packet();
55 
56   unsigned short m_nSize;
57 
58   static unsigned long s_nLocalIp;
59   static unsigned long s_nRealIp;
60   static unsigned short s_nLocalPort;
61 };
62 
63 } // namespace Licq
64 
65 #endif
66