summaryrefslogtreecommitdiffstats
path: root/watchlink/netlink_linkstatus.hh
blob: b4eebbce9697862e2d4ce388b655c16865df8e1d (plain)
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
/*
 * Module: netlink_linkstatus.hh
 *
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation.
 */
#ifndef __NETLINK_LINKSTATUS_HH__
#define __NETLINK_LINKSTATUS_HH__

#include <string>
#include <map>
#include "netlink_event.hh"
#include "netlink_send.hh"

class NetlinkLinkStatus
{
public:
  typedef std::map<int,bool> IfaceStateColl;
  typedef std::map<int,bool>::iterator IfaceStateIter;

public:
  NetlinkLinkStatus(int send_sock, const std::string &link_dir, bool debug);
  ~NetlinkLinkStatus();

  void
  process(const NetlinkEvent &event);

private:
  int
  process_up(const NetlinkEvent &event);
  
  int
  process_down(const NetlinkEvent &event);
  
  int
  process_going_up(const NetlinkEvent &event);
  
  int
  process_going_down(const NetlinkEvent &event);
  

private:
  NetlinkSend _nl_send;
  int _send_sock;
  std::string _link_dir;
  bool _debug;

  //keeps track of down messages where we've issued a 
  //request for addresses but haven't received msg yet.
  IfaceStateColl _iface_state_coll;
  
};

#endif //__NETLINK_LINKSTATUS_HH__