]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/handshaketimer.cpp
814aa122c7ab8a38d95bfe426ce44a98e73733b4
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / handshaketimer.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "socket.h"
16 #include "xline.h"
17 #include "../transport.h"
18
19 #include "main.h"
20 #include "utils.h"
21 #include "treeserver.h"
22 #include "link.h"
23 #include "treesocket.h"
24 #include "handshaketimer.h"
25
26 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
27
28 HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay) : Timer(delay, Inst->Time(), true), Instance(Inst), sock(s), lnk(l), Utils(u)
29 {
30         thefd = sock->GetFd();
31 }
32
33 HandshakeTimer::~HandshakeTimer()
34 {
35         sock->hstimer = NULL;
36 }
37
38 void HandshakeTimer::Tick(time_t TIME)
39 {
40         if (!sock->GetIOHook())
41         {
42                 CancelRepeat();
43                 sock->SendCapabilities(1);
44         }
45         else if (BufferedSocketHSCompleteRequest(sock, Utils->Creator, sock->GetIOHook()).Send())
46         {
47                 CancelRepeat();
48                 BufferedSocketAttachCertRequest(sock, Utils->Creator, sock->GetIOHook()).Send();
49                 sock->SendCapabilities(1);
50         }
51         // otherwise, try again later
52 }
53