~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/src/sip/sdes_negotiator.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
3
 *  Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>
4
4
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
5
5
 *
32
32
#include "pattern.h"
33
33
 
34
34
#include <cstdio>
35
 
#include <tr1/memory>
 
35
#include <memory>
36
36
#include <iostream>
37
37
#include <sstream>
38
38
#include <algorithm>
61
61
    // syntax :
62
62
    //a=crypto:tag 1*WSP crypto-suite 1*WSP key-params *(1*WSP session-param)
63
63
 
64
 
    std::tr1::shared_ptr<Pattern> generalSyntaxPattern, tagPattern, cryptoSuitePattern,
 
64
    std::unique_ptr<Pattern> generalSyntaxPattern, tagPattern, cryptoSuitePattern,
65
65
        keyParamsPattern;
66
66
 
67
67
    try {
68
68
        // used to match white space (which are used as separator)
69
 
        generalSyntaxPattern.reset(new Pattern("[\x20\x09]+", "g"));
 
69
        generalSyntaxPattern.reset(new Pattern("[\x20\x09]+", true));
70
70
 
71
 
        tagPattern.reset(new Pattern("^a=crypto:(?P<tag>[0-9]{1,9})"));
 
71
        tagPattern.reset(new Pattern("^a=crypto:(?P<tag>[0-9]{1,9})", false));
72
72
 
73
73
        cryptoSuitePattern.reset(new Pattern(
74
74
            "(?P<cryptoSuite>AES_CM_128_HMAC_SHA1_80|" \
75
75
            "AES_CM_128_HMAC_SHA1_32|" \
76
76
            "F8_128_HMAC_SHA1_80|" \
77
 
            "[A-Za-z0-9_]+)")); // srtp-crypto-suite-ext
 
77
            "[A-Za-z0-9_]+)", false)); // srtp-crypto-suite-ext
78
78
 
79
79
        keyParamsPattern.reset(new Pattern(
80
80
            "(?P<srtpKeyMethod>inline|[A-Za-z0-9_]+)\\:" \
81
81
            "(?P<srtpKeyInfo>[A-Za-z0-9\x2B\x2F\x3D]+)"  \
82
82
            "(\\|2\\^(?P<lifetime>[0-9]+)\\|"            \
83
83
            "(?P<mkiValue>[0-9]+)\\:"                    \
84
 
            "(?P<mkiLength>[0-9]{1,3})\\;?)?", "g"));
 
84
            "(?P<mkiLength>[0-9]{1,3})\\;?)?", true));
85
85
 
86
86
    } catch (const CompileError& exception) {
87
87
        throw ParseError("A compile exception occured on a pattern.");
88
88
    }
89
89
 
90
 
 
91
90
    // Take each line from the vector
92
91
    // and parse its content
93
92
 
94
93
    std::vector<CryptoAttribute *> cryptoAttributeVector;
95
94
 
96
 
    for (std::vector<std::string>::iterator iter = remoteAttribute_.begin();
97
 
            iter != remoteAttribute_.end(); ++iter) {
 
95
    for (const auto &item : remoteAttribute_) {
98
96
 
99
97
        // Split the line into its component
100
98
        // that we will analyze further down.
101
99
        std::vector<std::string> sdesLine;
102
100
 
103
 
        *generalSyntaxPattern << (*iter);
 
101
        generalSyntaxPattern->updateSubject(item);
104
102
 
105
103
        try {
106
104
            sdesLine = generalSyntaxPattern->split();
113
111
 
114
112
        // Check if the attribute starts with a=crypto
115
113
        // and get the tag for this line
116
 
        *tagPattern << sdesLine.at(0);
 
114
        tagPattern->updateSubject(sdesLine.at(0));
117
115
 
118
116
        std::string tag;
119
117
 
128
126
 
129
127
        // Check if the crypto suite is valid and retreive
130
128
        // its value.
131
 
        *cryptoSuitePattern << sdesLine.at(1);
 
129
        cryptoSuitePattern->updateSubject(sdesLine.at(1));
132
130
 
133
131
        std::string cryptoSuite;
134
132
 
142
140
            return cryptoAttributeVector;
143
141
 
144
142
        // Parse one or more key-params field.
145
 
        *keyParamsPattern << sdesLine.at(2);
 
143
        keyParamsPattern->updateSubject(sdesLine.at(2));
146
144
 
147
145
        std::string srtpKeyInfo;
148
146
        std::string srtpKeyMethod;