Commit d58451ba authored by Michal Vaner's avatar Michal Vaner
Browse files

Implemented get_sock

And fixed a test. It seems underlaying bind does not like passing NULL
pointer as address and kills program with sigterm.

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/vorner-sockcreator@3159 e5f2f494-b856-4b98-b285-d166d9295462
parent 6b09fa3b
......@@ -23,7 +23,14 @@ namespace socket_creator {
int
get_sock(const int type, struct sockaddr *bind_addr, const socklen_t addr_len)
{
// TODO Implement
int sock(socket(bind_addr->sa_family, type, 0));
if(sock == -1) {
return -1;
}
if(bind(sock, bind_addr, addr_len) == -1) {
return -2;
}
return sock;
}
int
......
......@@ -109,7 +109,9 @@ TEST(get_sock, tcp6_create) {
* is able to report error.
*/
TEST(get_sock, fail_with_nonsense) {
ASSERT_LT(get_sock(0, NULL, 0), 0);
struct sockaddr addr;
memset(&addr, 0, sizeof addr);
ASSERT_LT(get_sock(0, &addr, sizeof addr), 0);
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment