31 #if defined (ZMQ_HAVE_WINDOWS) 32 # include <winsock2.h> 33 # include <ws2tcpip.h> 35 # define close closesocket 37 # include <sys/socket.h> 38 # include <netinet/in.h> 39 # include <arpa/inet.h> 49 int rc =
zmq_bind (zap,
"inproc://zeromq.zap.01");
54 char *version =
s_recv (zap);
57 char *sequence =
s_recv (zap);
58 char *domain =
s_recv (zap);
60 char *identity =
s_recv (zap);
61 char *mechanism =
s_recv (zap);
62 char *username =
s_recv (zap);
63 char *password =
s_recv (zap);
65 assert (
streq (version,
"1.0"));
66 assert (
streq (mechanism,
"PLAIN"));
67 assert (
streq (identity,
"IDENT"));
71 if (
streq (username,
"admin")
72 &&
streq (password,
"password")) {
80 s_sendmore (zap,
"Invalid username or password");
114 rc =
zmq_bind (server,
"tcp://127.0.0.1:9998");
123 strcpy (username,
"admin");
126 strcpy (password,
"password");
150 strcpy (username,
"wronguser");
151 strcpy (password,
"wrongpass");
162 struct sockaddr_in ip4addr;
165 ip4addr.sin_family = AF_INET;
166 ip4addr.sin_port = htons (9998);
167 #if defined (ZMQ_HAVE_WINDOWS) && (_WIN32_WINNT < 0x0600) 168 ip4addr.sin_addr.s_addr = inet_addr (
"127.0.0.1");
170 inet_pton (AF_INET,
"127.0.0.1", &ip4addr.sin_addr);
173 s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
174 rc = connect (s, (
struct sockaddr*) &ip4addr,
sizeof (ip4addr));
177 send (s,
"\x01\x00", 2, 0);
179 send (s,
"\x08\x00sneaky\0", 9, 0);
182 char *buf =
s_recv (server);
184 printf (
"Received unauthenticated message: %s\n", buf);
185 assert (buf == NULL);
#define ZMQ_PLAIN_USERNAME
ZMQ_EXPORT int zmq_setsockopt(void *s, int option, const void *optval, size_t optvallen)
int s_sendmore(void *socket, const char *string)
ZMQ_EXPORT void * zmq_ctx_new(void)
void setup_test_environment(void)
void expect_bounce_fail(void *server, void *client)
#define ZMQ_PLAIN_PASSWORD
ZMQ_EXPORT void * zmq_socket(void *, int type)
ZMQ_EXPORT void zmq_threadclose(void *thread)
ZMQ_EXPORT int zmq_connect(void *s, const char *addr)
ZMQ_EXPORT int zmq_close(void *s)
char * s_recv(void *socket)
void close_zero_linger(void *socket)
void bounce(void *server, void *client)
ZMQ_EXPORT int zmq_bind(void *s, const char *addr)
ZMQ_EXPORT int zmq_ctx_term(void *context)
int s_send(void *socket, const char *string)
ZMQ_EXPORT void * zmq_threadstart(zmq_thread_fn *func, void *arg)
static void zap_handler(void *ctx)