LCOV - code coverage report
Current view: top level - xmpp - xmpp_session.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 2 2 100.0 %
Date: 2026-11-09 02:10:49 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef __XMPP_SESSION_H__
       7             : #define __XMPP_SESSION_H__
       8             : 
       9             : #include <string>
      10             : #include "base/regex.h"
      11             : #include "io/ssl_server.h"
      12             : #include "io/ssl_session.h"
      13             : 
      14             : class XmppServer;
      15             : class XmppConnection;
      16             : class XmppConnectionManager;
      17             : class XmppRegexMock;
      18             : 
      19             : class XmppSession : public SslSession {
      20             : public:
      21             :     XmppSession(XmppConnectionManager *manager, SslSocket *sock,
      22             :         bool async_ready = true);
      23             :     virtual ~XmppSession();
      24             : 
      25             :     void SetConnection(XmppConnection *connection);
      26             :     void ClearConnection();
      27     9642047 :     XmppConnection *Connection() { return connection_; }
      28             : 
      29             :     virtual void WriteReady(const boost::system::error_code &error);
      30             :     void ProcessWriteReady();
      31             : 
      32             :     typedef std::pair<uint64_t, uint64_t> StatsPair; // (packets, bytes)
      33             :     StatsPair Stats(unsigned int message_type) const;
      34             :     void IncStats(unsigned int message_type, uint64_t bytes);
      35             : 
      36             :     static const int kMaxMessageSize = 4096;
      37             :     friend class XmppRegexMock;
      38             : 
      39     1165142 :     virtual int GetSessionInstance() const { return task_instance_; }
      40             : 
      41             :     boost::system::error_code EnableTcpKeepalive(int tcp_hold_time);
      42             : 
      43             : protected:
      44             :     std::string jid;
      45             :     virtual void OnRead(Buffer buffer);
      46             : 
      47             : private:
      48             :     // eg: if tcp_hold_time is 30sec,
      49             :     //        keepalive_idle_time_ = 30/3 = 10s
      50             :     //        keepalive_interval_ = (30-10) / keepalive_probes_ = 20s/3 = 6s
      51             :     //        i.e socket empty - idle timeout (30 sec)
      52             :     //            socket tx buffer not empty - tcp user timeout (30 sec)
      53             :     static const int kSessionKeepaliveProbes = 3; // # unack probe
      54             :     typedef std::deque<Buffer> BufferQueue;
      55             : 
      56             :     contrail::regex tag_to_pattern(const char *);
      57             :     int MatchRegex(const contrail::regex &patt);
      58             :     bool Match(Buffer buffer, int *result, bool NewBuf);
      59             :     void SetBuf(const std::string &);
      60             :     void ReplaceBuf(const std::string &);
      61             :     bool LeftOver() const;
      62             : 
      63             :     XmppConnectionManager *manager_;
      64             :     XmppConnection *connection_;
      65             :     BufferQueue queue_;
      66             :     std::string begin_tag_;
      67             :     std::string buf_;
      68             :     std::string::const_iterator offset_;
      69             :     int tag_known_;
      70             :     int task_instance_;
      71             :     boost::match_results<std::string::const_iterator> res_;
      72             :     std::vector<StatsPair> stats_; // packet count
      73             :     int keepalive_idle_time_;
      74             :     int keepalive_interval_;
      75             :     int keepalive_probes_;
      76             :     int tcp_user_timeout_;
      77             :     bool stream_open_matched_;
      78             : 
      79             :     static const contrail::regex patt_;
      80             :     static const contrail::regex stream_patt_;
      81             :     static const contrail::regex stream_res_end_;
      82             :     static const contrail::regex whitespace_;
      83             :     static const contrail::regex stream_features_patt_;
      84             :     static const contrail::regex starttls_patt_;
      85             :     static const contrail::regex proceed_patt_;
      86             :     static const contrail::regex end_patt_;
      87             : 
      88             :     DISALLOW_COPY_AND_ASSIGN(XmppSession);
      89             : };
      90             : 
      91             : #endif // __XMPP_SESSION_H__

Generated by: LCOV version 1.14