~ubuntu-branches/ubuntu/vivid/gloox/vivid-proposed

« back to all changes in this revision

Viewing changes to src/jingleiceudp.h

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2014-03-16 17:34:43 UTC
  • mfrom: (12.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20140316173443-4s177dovzaz5dm8o
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (c) 2013 by Jakob Schroeter <js@camaya.net>
 
3
  This file is part of the gloox library. http://camaya.net/gloox
 
4
 
 
5
  This software is distributed under a license. The full license
 
6
  agreement can be found in the file LICENSE in this distribution.
 
7
  This software may not be copied, modified, sold or distributed
 
8
  other than expressed in the named license agreement.
 
9
 
 
10
  This software is distributed without any warranty.
 
11
*/
 
12
 
 
13
 
 
14
#ifndef JINGLEICEUDP_H__
 
15
#define JINGLEICEUDP_H__
 
16
 
 
17
#include "jingleplugin.h"
 
18
 
 
19
#include <string>
 
20
#include <list>
 
21
 
 
22
namespace gloox
 
23
{
 
24
 
 
25
  class Tag;
 
26
 
 
27
  namespace Jingle
 
28
  {
 
29
 
 
30
    /**
 
31
     * @brief An abstraction of the signaling part of Jingle ICE-UDP Transport Method (@xep{0176}).
 
32
     *
 
33
     * XEP Version: 1.0
 
34
     *
 
35
     * @author Jakob Schroeter <js@camaya.net>
 
36
     * @since 1.0.7
 
37
     */
 
38
    class ICEUDP : public Plugin
 
39
    {
 
40
      public:
 
41
        /**
 
42
         * Describes the candidate type.
 
43
         */
 
44
        enum Type
 
45
        {
 
46
          Host,                     /**< A host candidate. */
 
47
          PeerReflexive,            /**< A peer reflexive candidate. */
 
48
          Relayed,                  /**< A relayed candidate. */
 
49
          ServerReflexive           /**< A server reflexive candidate. */
 
50
        };
 
51
 
 
52
        /**
 
53
         * Describes a single transport candidate.
 
54
         */
 
55
        struct Candidate
 
56
        {
 
57
          std::string component;    /**< A Component ID as defined in ICE-CORE. */
 
58
          std::string foundation;   /**< A Foundation as defined in ICE-CORE.*/
 
59
          std::string generation;   /**< An index, starting at 0, that enables the parties to keep track of
 
60
                                         updates to the candidate throughout the life of the session. */
 
61
          std::string id;           /**< A unique identifier for the candidate. */
 
62
          std::string ip;           /**< The IP address for the candidate transport mechanism. */
 
63
          std::string network;      /**< An index, starting at 0, referencing which network this candidate is on for a given peer. */
 
64
          int port;                 /**< The port at the candidate IP address. */
 
65
          int priority;             /**< A Priority as defined in ICE-CORE. */
 
66
          std::string protocol;     /**< The protocol to be used. Should be @b udp. */
 
67
          std::string rel_addr;     /**< A related address as defined in ICE-CORE. */
 
68
          int rel_port;             /**< A related port as defined in ICE-CORE. */
 
69
          Type type;                /**< A Candidate Type as defined in ICE-CORE. */
 
70
        };
 
71
 
 
72
        /** A list of transport candidates. */
 
73
        typedef std::list<Candidate> CandidateList;
 
74
 
 
75
        /**
 
76
         * Constructs a new instance.
 
77
         * @param pwd The @c pwd value.
 
78
         * @param ufrag The @c ufrag value.
 
79
         * @param candidates A list of connection candidates.
 
80
         */
 
81
        ICEUDP( const std::string& pwd, const std::string& ufrag, CandidateList& candidates );
 
82
 
 
83
        /**
 
84
         * Constructs a new instance from the given tag.
 
85
         * @param tag The Tag to parse.
 
86
         */
 
87
        ICEUDP( const Tag* tag = 0 );
 
88
 
 
89
        /**
 
90
         * Virtual destructor.
 
91
         */
 
92
        virtual ~ICEUDP() {}
 
93
 
 
94
        /**
 
95
         * Returns the @c pwd value.
 
96
         * @return The @c pwd value.
 
97
         */
 
98
        const std::string& pwd() const { return m_pwd; }
 
99
 
 
100
        /**
 
101
         * Returns the @c ufrag value.
 
102
         * @return The @c ufrag value.
 
103
         */
 
104
        const std::string& ufrag() const { return m_ufrag; }
 
105
 
 
106
        /**
 
107
         * Returns the list of connection candidates.
 
108
         * @return The list of connection candidates.
 
109
         */
 
110
        const CandidateList& candidates() const { return m_candidates; }
 
111
 
 
112
        // reimplemented from Plugin
 
113
        virtual const StringList features() const;
 
114
 
 
115
        // reimplemented from Plugin
 
116
        virtual const std::string& filterString() const;
 
117
 
 
118
        // reimplemented from Plugin
 
119
        virtual Tag* tag() const;
 
120
 
 
121
        // reimplemented from Plugin
 
122
        virtual Plugin* newInstance( const Tag* tag ) const;
 
123
 
 
124
        // reimplemented from Plugin
 
125
        virtual Plugin* clone() const
 
126
        {
 
127
          return new ICEUDP( *this );
 
128
        }
 
129
 
 
130
      private:
 
131
        std::string m_pwd;
 
132
        std::string m_ufrag;
 
133
        CandidateList m_candidates;
 
134
 
 
135
    };
 
136
 
 
137
  }
 
138
 
 
139
}
 
140
 
 
141
#endif // JINGLEICEUDP_H__