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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
36 deletions
+34
-36
address.cpp
src/address.cpp
+9
-8
ipc_address.cpp
src/ipc_address.cpp
+11
-12
ipc_address.hpp
src/ipc_address.hpp
+1
-1
tcp_address.cpp
src/tcp_address.cpp
+2
-2
tipc_address.cpp
src/tipc_address.cpp
+10
-12
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 (
...
@@ -32,7 +32,7 @@ zmq::address_t::address_t (
:
protocol
(
protocol_
),
:
protocol
(
protocol_
),
address
(
address_
)
address
(
address_
)
{
{
memset
(
&
resolved
,
0
,
sizeof
(
resolved
)
);
memset
(
&
resolved
,
0
,
sizeof
resolved
);
}
}
zmq
::
address_t
::~
address_t
()
zmq
::
address_t
::~
address_t
()
...
@@ -53,7 +53,8 @@ zmq::address_t::~address_t ()
...
@@ -53,7 +53,8 @@ zmq::address_t::~address_t ()
}
}
#endif
#endif
#if defined ZMQ_HAVE_TIPC
#if defined ZMQ_HAVE_TIPC
else
if
(
protocol
==
"tipc"
)
{
else
if
(
protocol
==
"tipc"
)
{
if
(
resolved
.
tipc_addr
)
{
if
(
resolved
.
tipc_addr
)
{
delete
resolved
.
tipc_addr
;
delete
resolved
.
tipc_addr
;
resolved
.
tipc_addr
=
0
;
resolved
.
tipc_addr
=
0
;
...
@@ -66,20 +67,20 @@ int zmq::address_t::to_string (std::string &addr_) const
...
@@ -66,20 +67,20 @@ int zmq::address_t::to_string (std::string &addr_) const
{
{
if
(
protocol
==
"tcp"
)
{
if
(
protocol
==
"tcp"
)
{
if
(
resolved
.
tcp_addr
)
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
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
else
else
if
(
protocol
==
"ipc"
)
{
if
(
protocol
==
"ipc"
)
{
if
(
resolved
.
ipc_addr
)
if
(
resolved
.
ipc_addr
)
return
resolved
.
ipc_addr
->
to_string
(
addr_
);
return
resolved
.
ipc_addr
->
to_string
(
addr_
);
}
}
#endif
#endif
#if defined ZMQ_HAVE_TIPC
#if defined ZMQ_HAVE_TIPC
else
if
(
protocol
==
"tipc"
)
{
else
if
(
resolved
.
tipc_addr
)
{
if
(
protocol
==
"tipc"
)
{
return
resolved
.
tipc_addr
->
to_string
(
addr_
);
if
(
resolved
.
tipc_addr
)
}
return
resolved
.
tipc_addr
->
to_string
(
addr_
);
}
}
#endif
#endif
...
...
src/ipc_address.cpp
View file @
079ff8b7
...
@@ -28,17 +28,16 @@
...
@@ -28,17 +28,16 @@
zmq
::
ipc_address_t
::
ipc_address_t
()
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
::
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
)
);
memset
(
&
address
,
0
,
sizeof
address
);
if
(
sa
->
sa_family
==
AF_UNIX
)
{
if
(
sa
->
sa_family
==
AF_UNIX
)
memcpy
(
&
address
,
sa
,
sa_len
);
memcpy
(
&
address
,
sa
,
sa_len
);
}
}
}
zmq
::
ipc_address_t
::~
ipc_address_t
()
zmq
::
ipc_address_t
::~
ipc_address_t
()
...
@@ -47,11 +46,11 @@ 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_
)
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
;
errno
=
ENAMETOOLONG
;
return
-
1
;
return
-
1
;
}
}
if
(
path_
[
0
]
==
'@'
&&
!
path_
[
1
])
{
if
(
path_
[
0
]
==
'@'
&&
!
path_
[
1
])
{
errno
=
EINVAL
;
errno
=
EINVAL
;
return
-
1
;
return
-
1
;
}
}
...
@@ -59,7 +58,7 @@ int zmq::ipc_address_t::resolve (const char *path_)
...
@@ -59,7 +58,7 @@ int zmq::ipc_address_t::resolve (const char *path_)
address
.
sun_family
=
AF_UNIX
;
address
.
sun_family
=
AF_UNIX
;
strcpy
(
address
.
sun_path
,
path_
);
strcpy
(
address
.
sun_path
,
path_
);
/* Abstract sockets start with '\0' */
/* Abstract sockets start with '\0' */
if
(
path_
[
0
]
==
'@'
)
if
(
path_
[
0
]
==
'@'
)
*
address
.
sun_path
=
'\0'
;
*
address
.
sun_path
=
'\0'
;
return
0
;
return
0
;
}
}
...
@@ -73,7 +72,7 @@ int zmq::ipc_address_t::to_string (std::string &addr_)
...
@@ -73,7 +72,7 @@ int zmq::ipc_address_t::to_string (std::string &addr_)
std
::
stringstream
s
;
std
::
stringstream
s
;
s
<<
"ipc://"
;
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
;
s
<<
"@"
<<
address
.
sun_path
+
1
;
else
else
s
<<
address
.
sun_path
;
s
<<
address
.
sun_path
;
...
@@ -88,9 +87,9 @@ const sockaddr *zmq::ipc_address_t::addr () const
...
@@ -88,9 +87,9 @@ const sockaddr *zmq::ipc_address_t::addr () const
socklen_t
zmq
::
ipc_address_t
::
addrlen
()
const
socklen_t
zmq
::
ipc_address_t
::
addrlen
()
const
{
{
if
(
!
address
.
sun_path
[
0
]
&&
address
.
sun_path
[
1
])
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
)
strlen
(
address
.
sun_path
+
1
)
+
sizeof
(
sa_family_t
)
+
1
;
return
(
socklen_t
)
sizeof
(
address
)
;
return
(
socklen_t
)
sizeof
address
;
}
}
#endif
#endif
src/ipc_address.hpp
View file @
079ff8b7
...
@@ -41,7 +41,7 @@ namespace zmq
...
@@ -41,7 +41,7 @@ namespace zmq
~
ipc_address_t
();
~
ipc_address_t
();
// This function sets up the address for UNIX domain transport.
// This function sets up the address for UNIX domain transport.
int
resolve
(
const
char
*
path_
);
int
resolve
(
const
char
*
path_
);
// The opposite to resolve()
// The opposite to resolve()
int
to_string
(
std
::
string
&
addr_
);
int
to_string
(
std
::
string
&
addr_
);
...
...
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_
...
@@ -116,7 +116,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_
(
void
)
ipv6_
;
(
void
)
ipv6_
;
// Create a socket.
// 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
);
errno_assert
(
sd
!=
-
1
);
struct
ifreq
ifr
;
struct
ifreq
ifr
;
...
@@ -125,7 +125,7 @@ int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_
...
@@ -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
);
strncpy
(
ifr
.
ifr_name
,
nic_
,
sizeof
ifr
.
ifr_name
);
// Fetch interface address.
// 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.
// Clean up.
close
(
sd
);
close
(
sd
);
...
...
src/tipc_address.cpp
View file @
079ff8b7
...
@@ -28,17 +28,16 @@
...
@@ -28,17 +28,16 @@
zmq
::
tipc_address_t
::
tipc_address_t
()
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
::
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
));
memset
(
&
address
,
0
,
sizeof
address
);
if
(
sa
->
sa_family
==
AF_TIPC
)
{
if
(
sa
->
sa_family
==
AF_TIPC
)
memcpy
(
&
address
,
sa
,
sa_len
);
memcpy
(
&
address
,
sa
,
sa_len
);
}
}
}
zmq
::
tipc_address_t
::~
tipc_address_t
()
zmq
::
tipc_address_t
::~
tipc_address_t
()
...
@@ -47,15 +46,15 @@ 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
zmq
::
tipc_address_t
::
resolve
(
const
char
*
name
)
{
{
int
res
;
unsigned
int
type
=
0
;
unsigned
int
type
=
0
;
unsigned
int
lower
=
0
;
unsigned
int
lower
=
0
;
unsigned
int
upper
=
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
)
if
(
res
==
3
)
goto
nameseq
;
goto
nameseq
;
else
if
(
res
==
2
&&
type
>
TIPC_RESERVED_TYPES
)
{
else
if
(
res
==
2
&&
type
>
TIPC_RESERVED_TYPES
)
{
address
.
family
=
AF_TIPC
;
address
.
family
=
AF_TIPC
;
address
.
addrtype
=
TIPC_ADDR_NAME
;
address
.
addrtype
=
TIPC_ADDR_NAME
;
address
.
addr
.
name
.
name
.
type
=
type
;
address
.
addr
.
name
.
name
.
type
=
type
;
...
@@ -63,7 +62,7 @@ int zmq::tipc_address_t::resolve (const char *name)
...
@@ -63,7 +62,7 @@ int zmq::tipc_address_t::resolve (const char *name)
/* Since we can't specify lookup domain when connecting
/* Since we can't specify lookup domain when connecting
* (and we're not sure that we want it to be configurable)
* (and we're not sure that we want it to be configurable)
* Change from 'closest first' approach, to search entire zone */
* 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
;
address
.
scope
=
0
;
return
0
;
return
0
;
}
}
...
@@ -102,8 +101,7 @@ const sockaddr *zmq::tipc_address_t::addr () const
...
@@ -102,8 +101,7 @@ const sockaddr *zmq::tipc_address_t::addr () const
socklen_t
zmq
::
tipc_address_t
::
addrlen
()
const
socklen_t
zmq
::
tipc_address_t
::
addrlen
()
const
{
{
return
(
socklen_t
)
sizeof
(
address
)
;
return
(
socklen_t
)
sizeof
address
;
}
}
#endif
#endif
src/tipc_address.hpp
View file @
079ff8b7
...
@@ -41,7 +41,7 @@ namespace zmq
...
@@ -41,7 +41,7 @@ namespace zmq
~
tipc_address_t
();
~
tipc_address_t
();
// This function sets up the address "{type, lower, upper}" for TIPC transport
// 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()
// The opposite to resolve()
int
to_string
(
std
::
string
&
addr_
);
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