NetBurner 3.1
autoip.h
1 /*NB_REVISION*/
2 
3 /*NB_COPYRIGHT*/
4 
5 /*
6  * Doxygen note: AutoIP is an option set in the configuration system for each interface, so no
7  * functions are used by the application and they do not need to be documented. The previous
8  * documentation is copied below for historical reference.
9  */
10 
11 #ifndef _AUTOIP_H_INC
12 #define _AUTOIP_H_INC
13 
14 #include <buffers.h>
15 #include <nettimer.h>
16 
17 #define PROBE_WAIT 1
18 #define PROBE_NUM 3
19 #define PROBE_MIN 1
20 #define PROBE_MAX 2
21 #define ANNOUNCE_WAIT 2
22 #define ANNOUNCE_NUM 2
23 #define ANNOUNCE_INTERVAL 2
24 #define MAX_CONFLICTS 10
25 #define RATE_LIMIT_INTERVAL 60
26 #define DEFEND_INTERVAL 10
27 
28 #define BASE_AUTO_IP 0xA9FE0100
29 
30 #define AUTO_IP_INIT 1
31 #define AUTO_IP_NEGOTIATING 2
32 #define AUTO_IP_CONFIGURED 3
33 #define AUTO_IP_STOPPED 4
34 #define AUTO_IP_STARTARP 5
35 #define AUTO_IP_ARPCHECKING 6
36 #define AUTO_IP_ANNOUNCING 7
37 #define AUTO_IP_CONFLICT 8
38 
39 #define NOSCHEDULE_TICK 0
40 
41 class InterfaceBlock;
42 
43 class AutoIPClient : public TimeOutElement
44 {
45  private:
46  InterfaceBlock *pIfb;
47  int AutoIPState;
48  IPADDR4 last_try;
49 
50  unsigned long nextTick;
51  int probeCount;
52  int announceCount;
53  int conflicts;
54  bool collision;
55 
56  AutoIPClient *nextIPC;
57 
58  void addressCollision();
59  IPADDR4 generateNewIPAddr();
60  void negotiate();
61  void startArp();
62  void arpCheck();
63  void announce();
64  void tickDelay(uint16_t delay);
65 
66  virtual void TimeElementEvent();
67 
68  public:
69  AutoIPClient(InterfaceBlock *ib);
70  ~AutoIPClient();
71  void start();
72  void stop();
73  void restart();
74  int getState();
75  friend void processArp(PoolPtr p, PEFRAME pF);
76  IPADDR4 cur_val();
77  void LinkNotify(bool bLink);
78 };
79 
80 AutoIPClient *AddAutoIPInterface(int InterfaceNumber = 0);
81 
82 #endif /* ----- #ifndef _AUTOIP_H_INC ----- */
NetBurner Buffers API.