comparison tests/testsctp.c @ 1186:56c36d1007b4

Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
author Sebastien Decugis <sdecugis@freediameter.net>
date Fri, 07 Jun 2013 18:48:34 +0800
parents 4a9f08d6b6ba
children f937feb72734
comparison
equal deleted inserted replaced
1185:23695957bfc0 1186:56c36d1007b4
58 struct cnxctx cli, srv; /* we use only their cc_socket & cc_state */ 58 struct cnxctx cli, srv; /* we use only their cc_socket & cc_state */
59 int sock; 59 int sock;
60 char buf1[]="abcdef"; 60 char buf1[]="abcdef";
61 char *buf2; 61 char *buf2;
62 size_t sz; 62 size_t sz;
63 struct iovec iov;
63 struct fd_list eps = FD_LIST_INITIALIZER(eps); 64 struct fd_list eps = FD_LIST_INITIALIZER(eps);
64 uint16_t str; 65 uint16_t str;
65 int ev; 66 int ev;
66 67
67 /* Initialize the server addresses */ 68 /* Initialize the server addresses */
101 102
102 /* Accept this connection */ 103 /* Accept this connection */
103 srv.cc_socket = accept(sock, NULL, NULL); 104 srv.cc_socket = accept(sock, NULL, NULL);
104 105
105 /* Send a first message */ 106 /* Send a first message */
106 CHECK( 0, fd_sctp_sendstr(&srv, 1, (uint8_t *)buf1, sizeof(buf1) ) ); 107 iov.iov_base = buf1;
108 iov.iov_len = sizeof(buf1);
109 CHECK( sizeof(buf1), fd_sctp_sendstrv(&srv, 1, &iov, 1 ) );
107 CHECK( 0, srv.cc_state); 110 CHECK( 0, srv.cc_state);
108 111
109 /* Receive this message */ 112 /* Receive this message */
110 redo1: 113 redo1:
111 CHECK( 0, fd_sctp_recvmeta(&cli, &str, (uint8_t **)&buf2, &sz, &ev) ); 114 CHECK( 0, fd_sctp_recvmeta(&cli, &str, (uint8_t **)&buf2, &sz, &ev) );
117 CHECK( sizeof(buf1), sz ); 120 CHECK( sizeof(buf1), sz );
118 CHECK( 0, memcmp(buf1, buf2, sz) ); 121 CHECK( 0, memcmp(buf1, buf2, sz) );
119 free(buf2); buf2 = NULL; 122 free(buf2); buf2 = NULL;
120 123
121 /* Send in the other direction */ 124 /* Send in the other direction */
122 CHECK( 0, fd_sctp_sendstr(&cli, 2, (uint8_t *)buf1, sizeof(buf1)) ); 125 CHECK( sizeof(buf1), fd_sctp_sendstrv(&cli, 2, &iov, 1) );
123 CHECK( 0, cli.cc_state); 126 CHECK( 0, cli.cc_state);
124 127
125 /* Receive this message */ 128 /* Receive this message */
126 redo2: 129 redo2:
127 CHECK( 0, fd_sctp_recvmeta(&srv, &str, (uint8_t **)&buf2, &sz, &ev) ); 130 CHECK( 0, fd_sctp_recvmeta(&srv, &str, (uint8_t **)&buf2, &sz, &ev) );
"Welcome to our mercurial repository"