Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
31dd54a0
Commit
31dd54a0
authored
Nov 30, 2012
by
JINMEI Tatuya
Browse files
[2442] added minimum definition for strToCharString and tests
parent
2c9904e1
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/Makefile.am
View file @
31dd54a0
...
...
@@ -21,6 +21,8 @@ EXTRA_DIST += rdata/ch_3/a_1.cc
EXTRA_DIST
+=
rdata/ch_3/a_1.h
EXTRA_DIST
+=
rdata/generic/cname_5.cc
EXTRA_DIST
+=
rdata/generic/cname_5.h
EXTRA_DIST
+=
rdata/generic/detail/char_string.cc
EXTRA_DIST
+=
rdata/generic/detail/char_string.h
EXTRA_DIST
+=
rdata/generic/detail/nsec_bitmap.cc
EXTRA_DIST
+=
rdata/generic/detail/nsec_bitmap.h
EXTRA_DIST
+=
rdata/generic/detail/nsec3param_common.cc
...
...
@@ -121,6 +123,8 @@ 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
libb10_dns___la_SOURCES
+=
master_loader.h
libb10_dns___la_SOURCES
+=
rdata/generic/detail/char_string.h
libb10_dns___la_SOURCES
+=
rdata/generic/detail/char_string.cc
libb10_dns___la_SOURCES
+=
rdata/generic/detail/nsec_bitmap.h
libb10_dns___la_SOURCES
+=
rdata/generic/detail/nsec_bitmap.cc
libb10_dns___la_SOURCES
+=
rdata/generic/detail/nsec3param_common.cc
...
...
src/lib/dns/rdata/generic/detail/char_string.cc
0 → 100644
View file @
31dd54a0
// Copyright (C) 2012 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 <dns/master_lexer.h>
#include <dns/rdata/generic/detail/char_string.h>
#include <vector>
#include <stdint.h>
namespace
isc
{
namespace
dns
{
namespace
rdata
{
namespace
generic
{
namespace
detail
{
void
strToCharString
(
const
MasterToken
::
StringRegion
&
str_region
,
CharString
&
result
)
{
result
.
push_back
(
0
);
size_t
n
=
str_region
.
len
;
const
char
*
s
=
str_region
.
beg
;
while
(
n
--
!=
0
)
{
const
int
c
=
(
*
s
++
)
&
0xff
;
result
.
push_back
(
c
);
}
result
[
0
]
=
str_region
.
len
;
// FIXME: this is not always correct
}
}
// end of detail
}
// end of generic
}
// end of rdata
}
// end of dns
}
// end of isc
src/lib/dns/rdata/generic/detail/char_string.h
0 → 100644
View file @
31dd54a0
// Copyright (C) 2012 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 DNS_RDATA_CHARSTRING_H
#define DNS_RDATA_CHARSTRING_H 1
#include <dns/master_lexer.h>
#include <vector>
#include <stdint.h>
namespace
isc
{
namespace
dns
{
namespace
rdata
{
namespace
generic
{
namespace
detail
{
/// \brief Type for DNS character string.
///
/// A character string can contain any unsigned 8-bit value, so this cannot
/// be the bare char basis.
typedef
std
::
vector
<
uint8_t
>
CharString
;
void
strToCharString
(
const
MasterToken
::
StringRegion
&
str_region
,
CharString
&
result
);
}
// namespace detail
}
// namespace generic
}
// namespace rdata
}
// namespace dns
}
// namespace isc
#endif // DNS_RDATA_CHARSTRING_H
// Local Variables:
// mode: c++
// End:
src/lib/dns/tests/Makefile.am
View file @
31dd54a0
...
...
@@ -36,6 +36,7 @@ run_unittests_SOURCES += opcode_unittest.cc
run_unittests_SOURCES
+=
rcode_unittest.cc
run_unittests_SOURCES
+=
rdata_unittest.h rdata_unittest.cc
run_unittests_SOURCES
+=
rdatafields_unittest.cc
run_unittests_SOURCES
+=
rdata_char_string_unittest.cc
run_unittests_SOURCES
+=
rdata_in_a_unittest.cc rdata_in_aaaa_unittest.cc
run_unittests_SOURCES
+=
rdata_ns_unittest.cc rdata_soa_unittest.cc
run_unittests_SOURCES
+=
rdata_txt_like_unittest.cc
...
...
src/lib/dns/tests/rdata_char_string_unittest.cc
0 → 100644
View file @
31dd54a0
// Copyright (C) 2012 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 <util/unittests/wiredata.h>
#include <dns/rdata/generic/detail/char_string.h>
#include <gtest/gtest.h>
#include <string>
#include <vector>
using
namespace
isc
::
dns
;
using
namespace
isc
::
dns
::
rdata
;
using
isc
::
dns
::
rdata
::
generic
::
detail
::
CharString
;
using
isc
::
dns
::
rdata
::
generic
::
detail
::
strToCharString
;
using
isc
::
util
::
unittests
::
matchWireData
;
namespace
{
const
uint8_t
test_charstr
[]
=
{
sizeof
(
"Test String"
)
-
1
,
'T'
,
'e'
,
's'
,
't'
,
' '
,
'S'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
};
class
CharStringTest
:
public
::
testing
::
Test
{
protected:
CharStringTest
()
:
test_str
(
"Test String"
)
{
str_region
.
beg
=
&
test_str
[
0
];
str_region
.
len
=
test_str
.
size
();
}
CharString
chstr
;
// placeholder
const
std
::
string
test_str
;
MasterToken
::
StringRegion
str_region
;
};
TEST_F
(
CharStringTest
,
test
)
{
strToCharString
(
str_region
,
chstr
);
matchWireData
(
test_charstr
,
sizeof
(
test_charstr
),
&
chstr
[
0
],
chstr
.
size
());
}
}
// unnamed namespace
Write
Preview
Supports
Markdown
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