Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
079ff8b7
Commit
079ff8b7
authored
Jul 01, 2014
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
fa3ae974
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
39 deletions
+37
-39
address.cpp
src/address.cpp
+10
-9
ipc_address.cpp
src/ipc_address.cpp
+11
-12
ipc_address.hpp
src/ipc_address.hpp
+2
-2
tcp_address.cpp
src/tcp_address.cpp
+2
-2
tipc_address.cpp
src/tipc_address.cpp
+11
-13
tipc_address.hpp
src/tipc_address.hpp
+1
-1
No files found.
src/address.cpp
View file @
079ff8b7
...
...
@@ -32,7 +32,7 @@ zmq::address_t::address_t (
:
protocol
(
protocol_
),
address
(
address_
)
{
memset
(
&
resolved
,
0
,
sizeof
(
resolved
)
);
memset
(
&
resolved
,
0
,
sizeof
resolved
);
}
zmq
::
address_t
::~
address_t
()
...
...
@@ -53,7 +53,8 @@ zmq::address_t::~address_t ()
}
#endif
#if defined ZMQ_HAVE_TIPC
else
if
(
protocol
==
"tipc"
)
{
else
if
(
protocol
==
"tipc"
)
{
if
(
resolved
.
tipc_addr
)
{
delete
resolved
.
tipc_addr
;
resolved
.
tipc_addr
=
0
;
...
...
@@ -66,20 +67,20 @@ int zmq::address_t::to_string (std::string &addr_) const
{
if
(
protocol
==
"tcp"
)
{
if
(
resolved
.
tcp_addr
)
return
resolved
.
tcp_addr
->
to_string
(
addr_
);
return
resolved
.
tcp_addr
->
to_string
(
addr_
);
}
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
else
else
if
(
protocol
==
"ipc"
)
{
if
(
resolved
.
ipc_addr
)
return
resolved
.
ipc_addr
->
to_string
(
addr_
);
return
resolved
.
ipc_addr
->
to_string
(
addr_
);
}
#endif
#if defined ZMQ_HAVE_TIPC
else
if
(
protocol
==
"tipc"
)
{
if
(
resolved
.
tipc_addr
)
{
return
resolved
.
tipc_addr
->
to_string
(
addr_
);
}
else
if
(
protocol
==
"tipc"
)
{
if
(
resolved
.
tipc_addr
)
return
resolved
.
tipc_addr
->
to_string
(
addr_
);
}
#endif
...
...
src/ipc_address.cpp
View file @
079ff8b7
...
...
@@ -28,17 +28,16 @@
zmq
::
ipc_address_t
::
ipc_address_t
()
{
memset
(
&
address
,
0
,
sizeof
(
address
)
);
memset
(
&
address
,
0
,
sizeof
address
);
}
zmq
::
ipc_address_t
::
ipc_address_t
(
const
sockaddr
*
sa
,
socklen_t
sa_len
)
{
zmq_assert
(
sa
&&
sa_len
>
0
);
zmq_assert
(
sa
&&
sa_len
>
0
);
memset
(
&
address
,
0
,
sizeof
(
address
)
);
if
(
sa
->
sa_family
==
AF_UNIX
)
{
memset
(
&
address
,
0
,
sizeof
address
);
if
(
sa
->
sa_family
==
AF_UNIX
)
memcpy
(
&
address
,
sa
,
sa_len
);
}
}
zmq
::
ipc_address_t
::~
ipc_address_t
()
...
...
@@ -47,11 +46,11 @@ zmq::ipc_address_t::~ipc_address_t ()
int
zmq
::
ipc_address_t
::
resolve
(
const
char
*
path_
)
{
if
(
strlen
(
path_
)
>=
sizeof
(
address
.
sun_path
)
)
{
if
(
strlen
(
path_
)
>=
sizeof
address
.
sun_path
)
{
errno
=
ENAMETOOLONG
;
return
-
1
;
}
if
(
path_
[
0
]
==
'@'
&&
!
path_
[
1
])
{
if
(
path_
[
0
]
==
'@'
&&
!
path_
[
1
])
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
@@ -59,7 +58,7 @@ int zmq::ipc_address_t::resolve (const char *path_)
address
.
sun_family
=
AF_UNIX
;
strcpy
(
address
.
sun_path
,
path_
);
/* Abstract sockets start with '\0' */
if
(
path_
[
0
]
==
'@'
)
if
(
path_
[
0
]
==
'@'
)
*
address
.
sun_path
=
'\0'
;
return
0
;
}
...
...
@@ -73,7 +72,7 @@ int zmq::ipc_address_t::to_string (std::string &addr_)
std
::
stringstream
s
;
s
<<
"ipc://"
;
if
(
!
address
.
sun_path
[
0
]
&&
address
.
sun_path
[
1
])
if
(
!
address
.
sun_path
[
0
]
&&
address
.
sun_path
[
1
])
s
<<
"@"
<<
address
.
sun_path
+
1
;
else
s
<<
address
.
sun_path
;
...
...
@@ -88,9 +87,9 @@ const sockaddr *zmq::ipc_address_t::addr () const
socklen_t
zmq
::
ipc_address_t
::
addrlen
()
const
{
if
(
!
address
.
sun_path
[
0
]
&&
address
.
sun_path
[
1
])
return
(
socklen_t
)
strlen
(
address
.
sun_path
+
1
)
+
sizeof
(
sa_family_t
)
+
1
;
return
(
socklen_t
)
sizeof
(
address
)
;
if
(
!
address
.
sun_path
[
0
]
&&
address
.
sun_path
[
1
])
return
(
socklen_t
)
strlen
(
address
.
sun_path
+
1
)
+
sizeof
(
sa_family_t
)
+
1
;
return
(
socklen_t
)
sizeof
address
;
}
#endif
src/ipc_address.hpp
View file @
079ff8b7
...
...
@@ -41,7 +41,7 @@ namespace zmq
~
ipc_address_t
();
// This function sets up the address for UNIX domain transport.
int
resolve
(
const
char
*
path_
);
int
resolve
(
const
char
*
path_
);
// The opposite to resolve()
int
to_string
(
std
::
string
&
addr_
);
...
...
@@ -56,7 +56,7 @@ namespace zmq
ipc_address_t
(
const
ipc_address_t
&
);
const
ipc_address_t
&
operator
=
(
const
ipc_address_t
&
);
};
}
#endif
...
...
src/tcp_address.cpp
View file @
079ff8b7
...
...
@@ -116,7 +116,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_
(
void
)
ipv6_
;
// Create a socket.
int
sd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
const
int
sd
=
open_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
errno_assert
(
sd
!=
-
1
);
struct
ifreq
ifr
;
...
...
@@ -125,7 +125,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_
strncpy
(
ifr
.
ifr_name
,
nic_
,
sizeof
ifr
.
ifr_name
);
// Fetch interface address.
int
rc
=
ioctl
(
sd
,
SIOCGIFADDR
,
(
caddr_t
)
&
ifr
,
sizeof
(
struct
ifreq
)
);
const
int
rc
=
ioctl
(
sd
,
SIOCGIFADDR
,
(
caddr_t
)
&
ifr
,
sizeof
ifr
);
// Clean up.
close
(
sd
);
...
...
src/tipc_address.cpp
View file @
079ff8b7
...
...
@@ -28,17 +28,16 @@
zmq
::
tipc_address_t
::
tipc_address_t
()
{
memset
(
&
address
,
0
,
sizeof
(
address
)
);
memset
(
&
address
,
0
,
sizeof
address
);
}
zmq
::
tipc_address_t
::
tipc_address_t
(
const
sockaddr
*
sa
,
socklen_t
sa_len
)
{
zmq_assert
(
sa
&&
sa_len
>
0
);
zmq_assert
(
sa
&&
sa_len
>
0
);
memset
(
&
address
,
0
,
sizeof
(
address
));
if
(
sa
->
sa_family
==
AF_TIPC
)
{
memcpy
(
&
address
,
sa
,
sa_len
);
}
memset
(
&
address
,
0
,
sizeof
address
);
if
(
sa
->
sa_family
==
AF_TIPC
)
memcpy
(
&
address
,
sa
,
sa_len
);
}
zmq
::
tipc_address_t
::~
tipc_address_t
()
...
...
@@ -47,15 +46,15 @@ zmq::tipc_address_t::~tipc_address_t ()
int
zmq
::
tipc_address_t
::
resolve
(
const
char
*
name
)
{
int
res
;
unsigned
int
type
=
0
;
unsigned
int
lower
=
0
;
unsigned
int
upper
=
0
;
res
=
sscanf
(
name
,
"{%u,%u,%u}"
,
&
type
,
&
lower
,
&
upper
);
const
int
res
=
sscanf
(
name
,
"{%u,%u,%u}"
,
&
type
,
&
lower
,
&
upper
);
if
(
res
==
3
)
goto
nameseq
;
else
if
(
res
==
2
&&
type
>
TIPC_RESERVED_TYPES
)
{
else
if
(
res
==
2
&&
type
>
TIPC_RESERVED_TYPES
)
{
address
.
family
=
AF_TIPC
;
address
.
addrtype
=
TIPC_ADDR_NAME
;
address
.
addr
.
name
.
name
.
type
=
type
;
...
...
@@ -63,7 +62,7 @@ int zmq::tipc_address_t::resolve (const char *name)
/* Since we can't specify lookup domain when connecting
* (and we're not sure that we want it to be configurable)
* Change from 'closest first' approach, to search entire zone */
address
.
addr
.
name
.
domain
=
tipc_addr
(
1
,
0
,
0
);
address
.
addr
.
name
.
domain
=
tipc_addr
(
1
,
0
,
0
);
address
.
scope
=
0
;
return
0
;
}
...
...
@@ -71,7 +70,7 @@ int zmq::tipc_address_t::resolve (const char *name)
return
EINVAL
;
nameseq
:
if
(
type
<
TIPC_RESERVED_TYPES
||
upper
<
lower
)
return
EINVAL
;
return
EINVAL
;
address
.
family
=
AF_TIPC
;
address
.
addrtype
=
TIPC_ADDR_NAMESEQ
;
address
.
addr
.
nameseq
.
type
=
type
;
...
...
@@ -102,8 +101,7 @@ const sockaddr *zmq::tipc_address_t::addr () const
socklen_t
zmq
::
tipc_address_t
::
addrlen
()
const
{
return
(
socklen_t
)
sizeof
(
address
)
;
return
(
socklen_t
)
sizeof
address
;
}
#endif
src/tipc_address.hpp
View file @
079ff8b7
...
...
@@ -41,7 +41,7 @@ namespace zmq
~
tipc_address_t
();
// This function sets up the address "{type, lower, upper}" for TIPC transport
int
resolve
(
const
char
*
name
);
int
resolve
(
const
char
*
name
);
// The opposite to resolve()
int
to_string
(
std
::
string
&
addr_
);
...
...
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