Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Adam Osuchowski
Kea
Commits
6478f4a1
Commit
6478f4a1
authored
Jan 10, 2013
by
Jelte Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2498] Remove deprecated character_string files
parent
924221ee
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
304 deletions
+0
-304
src/lib/dns/Makefile.am
src/lib/dns/Makefile.am
+0
-1
src/lib/dns/character_string.cc
src/lib/dns/character_string.cc
+0
-145
src/lib/dns/character_string.h
src/lib/dns/character_string.h
+0
-60
src/lib/dns/tests/Makefile.am
src/lib/dns/tests/Makefile.am
+0
-1
src/lib/dns/tests/character_string_unittest.cc
src/lib/dns/tests/character_string_unittest.cc
+0
-97
No files found.
src/lib/dns/Makefile.am
View file @
6478f4a1
...
...
@@ -125,7 +125,6 @@ libb10_dns___la_SOURCES += tsig.h tsig.cc
libb10_dns___la_SOURCES
+=
tsigerror.h tsigerror.cc
libb10_dns___la_SOURCES
+=
tsigkey.h tsigkey.cc
libb10_dns___la_SOURCES
+=
tsigrecord.h tsigrecord.cc
libb10_dns___la_SOURCES
+=
character_string.h character_string.cc
libb10_dns___la_SOURCES
+=
master_loader_callbacks.h master_loader_callbacks.cc
libb10_dns___la_SOURCES
+=
master_loader.h
libb10_dns___la_SOURCES
+=
rrset_collection_base.h
...
...
src/lib/dns/character_string.cc
deleted
100644 → 0
View file @
924221ee
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include "character_string.h"
#include "rdata.h"
using
namespace
std
;
using
namespace
isc
::
dns
::
rdata
;
namespace
isc
{
namespace
dns
{
namespace
{
bool
isDigit
(
char
c
)
{
return
((
'0'
<=
c
)
&&
(
c
<=
'9'
));
}
}
std
::
string
characterstr
::
getNextCharacterString
(
const
std
::
string
&
input_str
,
std
::
string
::
const_iterator
&
input_iterator
,
bool
*
quoted
)
{
string
result
;
// If the input string only contains white-spaces, it is an invalid
// <character-string>
if
(
input_iterator
>=
input_str
.
end
())
{
isc_throw
(
InvalidRdataText
,
"Invalid text format, \
<character-string> field is missing."
);
}
// Whether the <character-string> is separated with double quotes (")
bool
quotes_separated
=
(
*
input_iterator
==
'"'
);
// Whether the quotes are pared if the string is quotes separated
bool
quotes_paired
=
false
;
if
(
quotes_separated
)
{
++
input_iterator
;
}
while
(
input_iterator
<
input_str
.
end
()){
// Escaped characters processing
if
(
*
input_iterator
==
'\\'
)
{
if
(
input_iterator
+
1
==
input_str
.
end
())
{
isc_throw
(
InvalidRdataText
,
"<character-string> ended \
prematurely."
);
}
else
{
if
(
isDigit
(
*
(
input_iterator
+
1
)))
{
// \DDD where each D is a digit. It its the octet
// corresponding to the decimal number described by DDD
if
(
input_iterator
+
3
>=
input_str
.
end
())
{
isc_throw
(
InvalidRdataText
,
"<character-string> ended \
prematurely."
);
}
else
{
int
n
=
0
;
++
input_iterator
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
isDigit
(
*
input_iterator
))
{
n
=
n
*
10
+
(
*
input_iterator
-
'0'
);
++
input_iterator
;
}
else
{
isc_throw
(
InvalidRdataText
,
"Illegal decimal \
escaping series"
);
}
}
if
(
n
>
255
)
{
isc_throw
(
InvalidRdataText
,
"Illegal octet \
number"
);
}
result
.
push_back
(
n
);
continue
;
}
}
else
{
++
input_iterator
;
result
.
push_back
(
*
input_iterator
);
++
input_iterator
;
continue
;
}
}
}
if
(
quotes_separated
)
{
// If the <character-string> is seperated with quotes symbol and
// another quotes symbol is encountered, it is the end of the
// <character-string>
if
(
*
input_iterator
==
'"'
)
{
quotes_paired
=
true
;
++
input_iterator
;
// Reach the end of character string
break
;
}
}
else
if
(
*
input_iterator
==
' '
)
{
// If the <character-string> is not seperated with quotes symbol,
// it is seperated with <space> char
break
;
}
result
.
push_back
(
*
input_iterator
);
++
input_iterator
;
}
if
(
result
.
size
()
>
MAX_CHARSTRING_LEN
)
{
isc_throw
(
CharStringTooLong
,
"<character-string> is too long"
);
}
if
(
quotes_separated
&&
!
quotes_paired
)
{
isc_throw
(
InvalidRdataText
,
"The quotes are not paired"
);
}
if
(
quoted
!=
NULL
)
{
*
quoted
=
quotes_separated
;
}
return
(
result
);
}
std
::
string
characterstr
::
getNextCharacterString
(
util
::
InputBuffer
&
buffer
,
size_t
len
)
{
uint8_t
str_len
=
buffer
.
readUint8
();
size_t
pos
=
buffer
.
getPosition
();
if
(
len
-
pos
<
str_len
)
{
isc_throw
(
InvalidRdataLength
,
"Invalid string length"
);
}
uint8_t
buf
[
MAX_CHARSTRING_LEN
];
buffer
.
readData
(
buf
,
str_len
);
return
(
string
(
buf
,
buf
+
str_len
));
}
}
// end of namespace dns
}
// end of namespace isc
src/lib/dns/character_string.h
deleted
100644 → 0
View file @
924221ee
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef CHARACTER_STRING_H
#define CHARACTER_STRING_H
#include <string>
#include <exceptions/exceptions.h>
#include <util/buffer.h>
namespace
isc
{
namespace
dns
{
// \brief Some utility functions to extract <character-string> from string
// or InputBuffer
//
// <character-string> is expressed in one or two ways: as a contiguous set
// of characters without interior spaces, or as a string beginning with a "
// and ending with a ". Inside a " delimited string any character can
// occur, except for a " itself, which must be quoted using \ (back slash).
// Ref. RFC1035
namespace
characterstr
{
/// Get a <character-string> from a string
///
/// \param input_str The input string
/// \param input_iterator The iterator from which to start extracting,
/// the iterator will be updated to new position after the function
/// is returned
/// \param quoted If not \c NULL, returns \c true at this address if
/// the string is quoted, \cfalse otherwise
/// \return A std::string that contains the extracted <character-string>
std
::
string
getNextCharacterString
(
const
std
::
string
&
input_str
,
std
::
string
::
const_iterator
&
input_iterator
,
bool
*
quoted
=
NULL
);
/// Get a <character-string> from a input buffer
///
/// \param buffer The input buffer
/// \param len The input buffer total length
/// \return A std::string that contains the extracted <character-string>
std
::
string
getNextCharacterString
(
util
::
InputBuffer
&
buffer
,
size_t
len
);
}
// namespace characterstr
}
// namespace dns
}
// namespace isc
#endif // CHARACTER_STRING_H
src/lib/dns/tests/Makefile.am
View file @
6478f4a1
...
...
@@ -73,7 +73,6 @@ run_unittests_SOURCES += tsig_unittest.cc
run_unittests_SOURCES
+=
tsigerror_unittest.cc
run_unittests_SOURCES
+=
tsigkey_unittest.cc
run_unittests_SOURCES
+=
tsigrecord_unittest.cc
run_unittests_SOURCES
+=
character_string_unittest.cc
run_unittests_SOURCES
+=
master_loader_callbacks_test.cc
run_unittests_SOURCES
+=
rrset_collection_unittest.cc
run_unittests_SOURCES
+=
zone_checker_unittest.cc
...
...
src/lib/dns/tests/character_string_unittest.cc
deleted
100644 → 0
View file @
924221ee
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <gtest/gtest.h>
#include <dns/rdata.h>
#include <dns/tests/unittest_util.h>
#include <dns/character_string.h>
using
isc
::
UnitTestUtil
;
using
namespace
std
;
using
namespace
isc
;
using
namespace
isc
::
dns
;
using
namespace
isc
::
dns
::
characterstr
;
using
namespace
isc
::
dns
::
rdata
;
namespace
{
class
CharacterString
{
public:
CharacterString
(
const
string
&
str
){
string
::
const_iterator
it
=
str
.
begin
();
characterStr_
=
getNextCharacterString
(
str
,
it
,
&
is_quoted_
);
}
const
string
&
str
()
const
{
return
characterStr_
;
}
bool
quoted
()
const
{
return
(
is_quoted_
);
}
private:
string
characterStr_
;
bool
is_quoted_
;
};
TEST
(
CharacterStringTest
,
testNormalCase
)
{
CharacterString
cstr1
(
"foo"
);
EXPECT_EQ
(
string
(
"foo"
),
cstr1
.
str
());
// Test <character-string> that separated by space
CharacterString
cstr2
(
"foo bar"
);
EXPECT_EQ
(
string
(
"foo"
),
cstr2
.
str
());
EXPECT_FALSE
(
cstr2
.
quoted
());
// Test <character-string> that separated by quotes
CharacterString
cstr3
(
"
\"
foo bar
\"
"
);
EXPECT_EQ
(
string
(
"foo bar"
),
cstr3
.
str
());
EXPECT_TRUE
(
cstr3
.
quoted
());
// Test <character-string> that not separate by quotes but ended with quotes
CharacterString
cstr4
(
"foo
\"
"
);
EXPECT_EQ
(
string
(
"foo
\"
"
),
cstr4
.
str
());
EXPECT_FALSE
(
cstr4
.
quoted
());
}
TEST
(
CharacterStringTest
,
testBadCase
)
{
// The <character-string> that started with quotes should also be ended
// with quotes
EXPECT_THROW
(
CharacterString
cstr
(
"
\"
foo"
),
InvalidRdataText
);
// The string length cannot exceed 255 characters
string
str
;
for
(
int
i
=
0
;
i
<
257
;
++
i
)
{
str
+=
'A'
;
}
EXPECT_THROW
(
CharacterString
cstr
(
str
),
CharStringTooLong
);
}
TEST
(
CharacterStringTest
,
testEscapeCharacter
)
{
CharacterString
cstr1
(
"foo
\\
bar"
);
EXPECT_EQ
(
string
(
"foobar"
),
cstr1
.
str
());
CharacterString
cstr2
(
"foo
\\\\
bar"
);
EXPECT_EQ
(
string
(
"foo
\\
bar"
),
cstr2
.
str
());
CharacterString
cstr3
(
"fo
\\
111bar"
);
EXPECT_EQ
(
string
(
"foobar"
),
cstr3
.
str
());
CharacterString
cstr4
(
"fo
\\
1112bar"
);
EXPECT_EQ
(
string
(
"foo2bar"
),
cstr4
.
str
());
// There must be at least 3 digits followed by '\'
EXPECT_THROW
(
CharacterString
cstr
(
"foo
\\
98ar"
),
InvalidRdataText
);
EXPECT_THROW
(
CharacterString
cstr
(
"foo
\\
9ar"
),
InvalidRdataText
);
EXPECT_THROW
(
CharacterString
cstr
(
"foo
\\
98"
),
InvalidRdataText
);
}
}
// namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment