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

Generated by: LCOV version 1.14