File: ClntMsg.h

package info (click to toggle)
dibbler 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 13,352 kB
  • sloc: cpp: 60,323; ansic: 12,235; sh: 11,951; yacc: 3,418; lex: 969; makefile: 940; perl: 319; xml: 116; python: 74
file content (75 lines) | stat: -rw-r--r-- 2,315 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * Dibbler - a portable DHCPv6
 *
 * authors: Tomasz Mrugalski <thomson@klub.com.pl>
 *          Marek Senderski <msend@o2.pl>
 * changes: Michal Kowalczuk <michal@kowalczuk.eu>
 *
 * released under GNU GPL v2 only licence
 */

#ifndef CLNTMSG_H
#define CLNTMSG_H

#include "Msg.h"
#include "ClntIfaceMgr.h"
#include "ClntTransMgr.h"
#include "ClntCfgMgr.h"
#include "ClntAddrMgr.h"
#include "SmartPtr.h"
#include "Opt.h"


class TClntMsg : public TMsg
{
public:
    TClntMsg(int iface, SPtr<TIPv6Addr> addr, char* buf, int bufSize);
    
    TClntMsg(int iface, SPtr<TIPv6Addr> addr, int msgType);
    ~TClntMsg();
    unsigned long getTimeout();
    void send();
    SPtr<TOpt> parseExtraOption(const char *buf, unsigned int code, unsigned int length);

    //answer for a specific message
    virtual void doDuties() = 0;
    virtual bool check() = 0;
    void setIface(int iface); // used to override when we have received msg via loopback interface.

    void copyAAASPI(SPtr<TClntMsg> q);
    void appendTAOptions(bool switchToInProcess); // append all TAs, which are currently in the NOTCONFIGURED state
//    void appendPDOptions(bool switchToInProcess); // append all PDs, which are currently in the NOTCONFIGURED state

    void appendAuthenticationOption();
    void appendElapsedOption();
    void appendRequestedOptions();
    bool checkReceivedAuthOption();

    bool validateReplayDetection();

    // virtual std::string getName() = 0;
    virtual void answer(SPtr<TClntMsg> reply);

    void getReconfKeyFromAddrMgr();
    void deletePD(SPtr<TOpt> pd_);

 protected:
    bool check(bool clntIDmandatory, bool srvIDmandatory);
    bool appendClientID();

    long IRT;           // Initial Retransmission Time
    long MRT;           // Maximum Retransmission Time
    long MRC;           // Maximum Retransmission Count
    long MRD;           // Maximum Retransmission Duration
    int RC;             // Retransmission counter (counts to 0)
    int RT;             // Retransmission timeout (in seconds)
    int FirstTimeStamp; // timestamp of the first transmission
    int LastTimeStamp;  // timestamp of the last transmission

 private:
    void setDefaults();
    void invalidAllowOptInMsg(int msg, int opt);
    void invalidAllowOptInOpt(int msg, int parentOpt, int childOpt);
};

#endif