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
783bb890
Commit
783bb890
authored
Jul 01, 2013
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check socket types during mechanism handshake
parent
58b10824
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
51 additions
and
59 deletions
+51
-59
curve_client.cpp
src/curve_client.cpp
+0
-9
curve_client.hpp
src/curve_client.hpp
+0
-3
curve_server.cpp
src/curve_server.cpp
+0
-9
curve_server.hpp
src/curve_server.hpp
+0
-3
mechanism.cpp
src/mechanism.cpp
+44
-4
mechanism.hpp
src/mechanism.hpp
+4
-0
null_mechanism.cpp
src/null_mechanism.cpp
+0
-9
null_mechanism.hpp
src/null_mechanism.hpp
+0
-4
plain_mechanism.cpp
src/plain_mechanism.cpp
+0
-9
plain_mechanism.hpp
src/plain_mechanism.hpp
+0
-5
test_raw_sock.cpp
tests/test_raw_sock.cpp
+1
-1
test_stream.cpp
tests/test_stream.cpp
+2
-3
No files found.
src/curve_client.cpp
View file @
783bb890
...
...
@@ -404,13 +404,4 @@ int zmq::curve_client_t::process_ready (msg_t *msg_)
return
rc
;
}
int
zmq
::
curve_client_t
::
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
)
{
if
(
name
==
"Socket-Type"
)
{
// TODO: Implement socket type checking
}
return
0
;
}
#endif
src/curve_client.hpp
View file @
783bb890
...
...
@@ -100,9 +100,6 @@ namespace zmq
int
process_welcome
(
msg_t
*
msg_
);
int
initiate_msg
(
msg_t
*
msg_
);
int
process_ready
(
msg_t
*
msg_
);
virtual
int
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
);
};
}
...
...
src/curve_server.cpp
View file @
783bb890
...
...
@@ -543,15 +543,6 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
errno_assert
(
rc
==
0
);
}
int
zmq
::
curve_server_t
::
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
)
{
if
(
name
==
"Socket-Type"
)
{
// TODO: Implement socket type checking
}
return
0
;
}
int
zmq
::
curve_server_t
::
receive_and_process_zap_reply
()
{
int
rc
=
0
;
...
...
src/curve_server.hpp
View file @
783bb890
...
...
@@ -107,9 +107,6 @@ namespace zmq
void
send_zap_request
(
const
uint8_t
*
key
);
int
receive_and_process_zap_reply
();
virtual
int
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
);
};
}
...
...
src/mechanism.cpp
View file @
783bb890
...
...
@@ -100,12 +100,21 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
ptr_
+=
value_length
;
bytes_left
-=
value_length
;
const
int
rc
=
property
(
name
,
value
,
value_length
);
if
(
rc
==
-
1
)
return
-
1
;
if
(
name
==
"Identity"
&&
options
.
recv_identity
)
set_peer_identity
(
value
,
value_length
);
else
if
(
name
==
"Socket-Type"
)
{
const
std
::
string
socket_type
((
char
*
)
value
,
value_length
);
if
(
!
check_socket_type
(
socket_type
))
{
errno
=
EINVAL
;
return
-
1
;
}
}
else
{
const
int
rc
=
property
(
name
,
value
,
value_length
);
if
(
rc
==
-
1
)
return
-
1
;
}
}
if
(
bytes_left
>
0
)
{
errno
=
EPROTO
;
...
...
@@ -121,3 +130,34 @@ int zmq::mechanism_t::property (const std::string name_,
// property values and returns 0 to signal success.
return
0
;
}
bool
zmq
::
mechanism_t
::
check_socket_type
(
const
std
::
string
type_
)
const
{
switch
(
options
.
type
)
{
case
ZMQ_REQ
:
return
type_
==
"REP"
||
type_
==
"ROUTER"
;
case
ZMQ_REP
:
return
type_
==
"REQ"
||
type_
==
"DEALER"
;
case
ZMQ_DEALER
:
return
type_
==
"REP"
||
type_
==
"DEALER"
||
type_
==
"ROUTER"
;
case
ZMQ_ROUTER
:
return
type_
==
"REQ"
||
type_
==
"DEALER"
||
type_
==
"ROUTER"
;
case
ZMQ_PUSH
:
return
type_
==
"PULL"
;
case
ZMQ_PULL
:
return
type_
==
"PUSH"
;
case
ZMQ_PUB
:
return
type_
==
"SUB"
||
type_
==
"XSUB"
;
case
ZMQ_SUB
:
return
type_
==
"PUB"
||
type_
==
"XPUB"
;
case
ZMQ_XPUB
:
return
type_
==
"SUB"
||
type_
==
"XSUB"
;
case
ZMQ_XSUB
:
return
type_
==
"PUB"
||
type_
==
"XPUB"
;
case
ZMQ_PAIR
:
return
type_
==
"PAIR"
;
default
:
break
;
}
return
false
;
}
src/mechanism.hpp
View file @
783bb890
...
...
@@ -90,6 +90,10 @@ namespace zmq
private
:
blob_t
identity
;
// Returns true iff socket associated with the mechanism
// is compatible with a given socket type 'type_'.
bool
check_socket_type
(
const
std
::
string
type_
)
const
;
};
}
...
...
src/null_mechanism.cpp
View file @
783bb890
...
...
@@ -116,12 +116,3 @@ bool zmq::null_mechanism_t::is_handshake_complete () const
{
return
ready_command_received
&&
ready_command_sent
;
}
int
zmq
::
null_mechanism_t
::
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
)
{
if
(
name
==
"Socket-Type"
)
{
// TODO: Implement socket type checking
}
return
0
;
}
src/null_mechanism.hpp
View file @
783bb890
...
...
@@ -40,10 +40,6 @@ namespace zmq
virtual
int
process_handshake_message
(
msg_t
*
msg_
);
virtual
bool
is_handshake_complete
()
const
;
protected
:
virtual
int
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
);
private
:
bool
ready_command_sent
;
...
...
src/plain_mechanism.cpp
View file @
783bb890
...
...
@@ -452,12 +452,3 @@ error:
return
rc
;
}
int
zmq
::
plain_mechanism_t
::
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
)
{
if
(
name
==
"Socket-Type"
)
{
// TODO: Implement socket type checking
}
return
0
;
}
src/plain_mechanism.hpp
View file @
783bb890
...
...
@@ -43,11 +43,6 @@ namespace zmq
virtual
int
zap_msg_available
();
virtual
bool
is_handshake_complete
()
const
;
protected
:
virtual
int
property
(
const
std
::
string
name
,
const
void
*
value
,
size_t
length
);
private
:
enum
state_t
{
...
...
tests/test_raw_sock.cpp
View file @
783bb890
...
...
@@ -118,7 +118,7 @@ int main (void)
// Announce we are ready
memcpy
(
buffer
,
"
\0\51
READY
\0
"
,
8
);
memcpy
(
buffer
+
8
,
"
\13
Socket-Type
\0\0\0\6
STREAM
"
,
22
);
memcpy
(
buffer
+
8
,
"
\13
Socket-Type
\0\0\0\6
ROUTER
"
,
22
);
memcpy
(
buffer
+
30
,
"
\10
Identity
\0\0\0\0
"
,
13
);
// Send Ready command
...
...
tests/test_stream.cpp
View file @
783bb890
...
...
@@ -115,7 +115,7 @@ test_stream_to_dealer (void)
// Announce we are ready
memcpy
(
buffer
,
"
\0\51
READY
\0
"
,
8
);
memcpy
(
buffer
+
8
,
"
\13
Socket-Type
\0\0\0\6
STREAM
"
,
22
);
memcpy
(
buffer
+
8
,
"
\13
Socket-Type
\0\0\0\6
ROUTER
"
,
22
);
memcpy
(
buffer
+
30
,
"
\10
Identity
\0\0\0\0
"
,
13
);
// Send Ready command
...
...
@@ -224,4 +224,4 @@ int main (void)
{
test_stream_to_dealer
();
test_stream_to_stream
();
}
\ No newline at end of file
}
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