forked from sonic-net/sonic-swss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteamsyncd.cpp
48 lines (41 loc) · 1.18 KB
/
teamsyncd.cpp
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
#include <iostream>
#include <team.h>
#include "logger.h"
#include "select.h"
#include "netdispatcher.h"
#include "netlink.h"
#include "teamsync.h"
using namespace std;
using namespace swss;
int main(int argc, char **argv)
{
swss::Logger::linkToDbNative("teamsyncd");
DBConnector db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
Select s;
TeamSync sync(&db, &stateDb, &s);
NetDispatcher::getInstance().registerMessageHandler(RTM_NEWLINK, &sync);
NetDispatcher::getInstance().registerMessageHandler(RTM_DELLINK, &sync);
while (1)
{
try
{
NetLink netlink;
netlink.registerGroup(RTNLGRP_LINK);
cout << "Listens to teamd events..." << endl;
netlink.dumpRequest(RTM_GETLINK);
s.addSelectable(&netlink);
while (true)
{
Selectable *temps;
s.select(&temps);
}
}
catch (const std::exception& e)
{
cout << "Exception \"" << e.what() << "\" had been thrown in deamon" << endl;
return 0;
}
}
return 1;
}