24 ts->
fd = vppcom_session_create (VPPCOM_PROTO_TCP, 0 );
27 vterr (
"vppcom_session_create()", ts->
fd);
32 rv = vppcom_session_connect (ts->
fd, endpt);
35 vterr (
"vppcom_session_connect()",
rv);
42 flen =
sizeof (
flags);
43 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_FLAGS, &
flags, &flen);
54 ts->
fd = vppcom_session_create (VPPCOM_PROTO_TCP, 1 );
57 vterr (
"vppcom_session_create()", ts->
fd);
61 rv = vppcom_session_bind (ts->
fd, endpt);
64 vterr (
"vppcom_session_bind()",
rv);
68 rv = vppcom_session_listen (ts->
fd, 10);
71 vterr (
"vppcom_session_listen()",
rv);
83 client_fd = vppcom_session_accept (listen_fd, &ts->
endpt, 0);
86 vterr (
"vppcom_session_accept()", client_fd);
108 uint32_t
flags, flen;
111 ts->
fd = vppcom_session_create (VPPCOM_PROTO_UDP, 0 );
114 vterr (
"vppcom_session_create()", ts->
fd);
119 rv = vppcom_session_connect (ts->
fd, endpt);
122 vterr (
"vppcom_session_connect()",
rv);
129 flen =
sizeof (
flags);
130 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_FLAGS, &
flags, &flen);
141 ts->
fd = vppcom_session_create (VPPCOM_PROTO_UDP, 1 );
144 vterr (
"vppcom_session_create()", ts->
fd);
148 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_CONNECTED, 0, 0);
151 rv = vppcom_session_bind (ts->
fd, endpt);
154 vterr (
"vppcom_session_bind()",
rv);
166 client_fd = vppcom_session_accept (listen_fd, &ts->
endpt, 0);
169 vterr (
"vppcom_session_accept()", client_fd);
192 "-----BEGIN CERTIFICATE-----\r\n"
193 "MIID5zCCAs+gAwIBAgIJALeMYCEHrTtJMA0GCSqGSIb3DQEBCwUAMIGJMQswCQYD\r\n"
194 "VQQGEwJVUzELMAkGA1UECAwCQ0ExETAPBgNVBAcMCFNhbiBKb3NlMQ4wDAYDVQQK\r\n"
195 "DAVDaXNjbzEOMAwGA1UECww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1c2M5rHDTrOKG\r\n"
210 "rK0hbkSFBo+i6I8u4HiiQ4rYmG0Hv6+sXn3of0HsbtDPGgWZoipPWDljPYEURu3e\r\n"
211 "3HRe/Dtsj9CakBoSDzs8ndWaBR+f4sM9Tk1cjD46Gq2T/qpSPXqKxEUXlzhdCAn4\r\n"
212 "twub17Bq2kykHpppCwPg5M+v30tHG/R2Go15MeFWbEJthFk3TZMjKL7UFs7fH+x2\r\n"
213 "wSonXb++jY+KmCb93C+soABBizE57g/KmiR2IxQ/LMjDik01RSUIaM0lLA==\r\n"
214 "-----END CERTIFICATE-----\r\n";
218 "-----BEGIN PRIVATE KEY-----\r\n"
219 "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDgLWTxrUO5K2CC\r\n"
220 "CpPijT18/2wnZ0LnhvGFL9eTZUR9ohnbbZZKjhf+zJFV9XL1hqFykjXMn9EPFplI\r\n"
221 "WGAD6c9kGsUyytQuSt0A6k5WPx4MSn0m5Z07Y4NKgWcK8vFxhYFhzmQevImkRoYm\r\n"
222 "XWwVBJ6yfMwW3L/n21rSy2TQWnyvk2EiNa9Ki8bM+joGHP5VLZx5shmHjHW3aEdo\r\n"
223 "VyCbSomgnoNx5F5YJbzD7I5Wi9OiUYar5ulvYefsydFJnYrY10v5otemRltL8A4M\r\n"
224 "/UUXa9M7WZgvb3Qs7v/nW8mY9c0pINgzLkS8guvn9Wq2OwULBEtDiNwz/4Z4dIAV\r\n"
225 "bHioi/QHAgMBAAECggEBAMzGipP8+oT166U+NlJXRFifFVN1DvdhG9PWnOxGL+c3\r\n"
226 "ILmBBC08WQzmHshPemBvR6DZkA1H23cV5JTiLWrFtC00CvhXsLRMrE5+uWotI6yE\r\n"
227 "iofybMroHvD6/X5R510UX9hQ6MHu5ShLR5VZ9zXHz5MpTmB/60jG5dLx+jgcwBK8\r\n"
228 "LuGv2YB/WCUwT9QJ3YU2eaingnXtz/MrFbkbltrqlnBdlD+kTtw6Yac9y1Xuu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8yYkHAnXYW3tNoweDIwixE0hkPR1bc\r\n"
244 "oEjPLVNtx8SOj/M4rhaPT3I=\r\n"
245 "-----END PRIVATE KEY-----\r\n";
252 vppcom_cert_key_pair_t ckpair;
255 vtinf (
"Adding tls certs ...");
261 ckp_index = vppcom_add_cert_key_pair (&ckpair);
264 vterr (
"vppcom_add_cert_key_pair()", ckp_index);
282 uint32_t
flags, flen, ckp_len;
285 ts->
fd = vppcom_session_create (VPPCOM_PROTO_TLS, 0 );
288 vterr (
"vppcom_session_create()", ts->
fd);
293 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_CKPAIR, &vt->
ckpair_index,
297 rv = vppcom_session_connect (ts->
fd, endpt);
300 vterr (
"vppcom_session_connect()",
rv);
307 flen =
sizeof (
flags);
308 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_FLAGS, &
flags, &flen);
321 ts->
fd = vppcom_session_create (VPPCOM_PROTO_TLS, 1 );
324 vterr (
"vppcom_session_create()", ts->
fd);
329 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_CKPAIR, &vt->
ckpair_index,
332 rv = vppcom_session_bind (ts->
fd, endpt);
335 vterr (
"vppcom_session_bind()",
rv);
339 rv = vppcom_session_listen (ts->
fd, 10);
342 vterr (
"vppcom_session_listen()",
rv);
354 client_fd = vppcom_session_accept (listen_fd, &ts->
endpt, 0);
357 vterr (
"vppcom_session_accept()", client_fd);
387 uint32_t
flags, flen, ckp_len;
390 ts->
fd = vppcom_session_create (VPPCOM_PROTO_DTLS, 0 );
393 vterr (
"vppcom_session_create()", ts->
fd);
398 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_CKPAIR, &vt->
ckpair_index,
402 rv = vppcom_session_connect (ts->
fd, endpt);
405 vterr (
"vppcom_session_connect()",
rv);
412 flen =
sizeof (
flags);
413 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_FLAGS, &
flags, &flen);
426 ts->
fd = vppcom_session_create (VPPCOM_PROTO_DTLS, 1 );
429 vterr (
"vppcom_session_create()", ts->
fd);
434 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_CKPAIR, &vt->
ckpair_index,
437 rv = vppcom_session_bind (ts->
fd, endpt);
440 vterr (
"vppcom_session_bind()",
rv);
444 rv = vppcom_session_listen (ts->
fd, 10);
447 vterr (
"vppcom_session_listen()",
rv);
459 client_fd = vppcom_session_accept (listen_fd, &ts->
endpt, 0);
462 vterr (
"vppcom_session_accept()", client_fd);
495 vppcom_endpt_t *endpt)
519 vterr (
"failed to alloc Qsessions", -errno);
525 tq = &
wrk->qsessions[
i];
527 vppcom_session_create (VPPCOM_PROTO_QUIC, 0 );
531 vterr (
"vppcom_session_create()", tq->
fd);
536 vppcom_session_attr (tq->
fd, VPPCOM_ATTR_SET_CKPAIR, &vt->
ckpair_index,
540 rv = vppcom_session_connect (tq->
fd, endpt);
543 vterr (
"vppcom_session_connect()",
rv);
547 flen =
sizeof (
flags);
548 vppcom_session_attr (tq->
fd, VPPCOM_ATTR_SET_FLAGS, &
flags, &flen);
549 vtinf (
"Test Qsession %d (fd %d) connected.",
i, tq->
fd);
560 uint32_t wrk_index,
flags, flen;
566 wrk = &vt->
wrk[wrk_index];
571 ts->
fd = vppcom_session_create (VPPCOM_PROTO_QUIC, 0 );
574 vterr (
"vppcom_session_create()", ts->
fd);
581 rv = vppcom_session_stream_connect (ts->
fd, tq->
fd);
584 vterr (
"vppcom_session_stream_connect()",
rv);
589 flen =
sizeof (
flags);
590 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_FLAGS, &
flags, &flen);
608 ts->
fd = vppcom_session_create (VPPCOM_PROTO_QUIC, 1 );
611 vterr (
"vppcom_session_create()", ts->
fd);
616 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_CKPAIR, &vt->
ckpair_index,
619 rv = vppcom_session_bind (ts->
fd, endpt);
622 vterr (
"vppcom_session_bind()",
rv);
626 rv = vppcom_session_listen (ts->
fd, 10);
629 vterr (
"vppcom_session_listen()",
rv);
641 client_fd = vppcom_session_accept (listen_fd, &ts->
endpt, 0);
644 vterr (
"vppcom_session_accept()", client_fd);
658 int listener_fd = vppcom_session_listener (ts->
fd);
660 if ((vppcom_session_n_accepted (listener_fd) == 0) &
661 vppcom_session_is_connectable_listener (listener_fd))
663 vtinf (
"Connected Listener fd %x has no more sessions", listener_fd);
664 vppcom_session_close (listener_fd);
681 0xe1, 0xf9, 0x7a, 0x0d, 0x3e, 0x01, 0x8b, 0xe0, 0xd6, 0x4f, 0xa3, 0x2c,
682 0x06, 0xde, 0x41, 0x39, 0x0e, 0xc6, 0x75, 0xad, 0x49, 0x8a, 0xfe, 0xeb,
683 0xb6, 0x96, 0x0b, 0x3a, 0xab, 0xe6, 0xc1, 0x73, 0xc3, 0x17, 0xf2, 0xda,
684 0xbe, 0x35, 0x77, 0x93, 0xb6, 0x96, 0x0b, 0x3a, 0xab, 0xe6
689 unsigned char cc : 4;
693 unsigned char pt : 7;
726 uint32_t rx_ssrc, tx_ssrc;
729 rx_ssrc = is_connect ? 0xcafebeef : 0xbeefcafe;
730 tx_ssrc = is_connect ? 0xbeefcafe : 0xcafebeef;
733 srtp_cfg =
malloc (cfg_size);
734 memset (srtp_cfg, 0, cfg_size);
736 test_policy = &srtp_cfg->
policy[0];
744 test_policy = &srtp_cfg->
policy[1];
752 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_ENDPT_EXT_CFG, srtp_cfg,
760 uint32_t rx_ssrc, tx_ssrc;
764 rx_ssrc = is_connect ? 0xcafebeef : 0xbeefcafe;
765 tx_ssrc = is_connect ? 0xbeefcafe : 0xcafebeef;
768 memset (rtp_hdrs, 0,
sizeof (*rtp_hdrs));
780 hdr->
ssrc = htonl (rx_ssrc);
791 hdr->
ssrc = htonl (tx_ssrc);
797 int tx_bytes = 0, nbytes_left = nbytes,
rv;
803 hdr->
ts = htonl (ntohl (hdr->
ts) + 1);
805 memcpy (
buf, hdr,
sizeof (*hdr));
810 rv = vppcom_session_write (ts->
fd,
buf, nbytes_left);
813 if ((
rv == VPPCOM_EAGAIN ||
rv == VPPCOM_EWOULDBLOCK))
818 nbytes_left = nbytes_left -
rv;
822 while (tx_bytes != nbytes);
827 stats->tx_bytes += tx_bytes;
840 rx_bytes = vppcom_session_read (ts->
fd,
buf, nbytes);
844 if (rx_bytes == VPPCOM_EAGAIN || rx_bytes == VPPCOM_EWOULDBLOCK)
850 if (rx_bytes < nbytes)
853 stats->rx_bytes += rx_bytes;
864 uint32_t
flags, flen;
867 ts->
fd = vppcom_session_create (VPPCOM_PROTO_SRTP, 0 );
870 vterr (
"vppcom_session_create()", ts->
fd);
877 rv = vppcom_session_connect (ts->
fd, endpt);
880 vterr (
"vppcom_session_connect()",
rv);
887 flen =
sizeof (
flags);
888 vppcom_session_attr (ts->
fd, VPPCOM_ATTR_SET_FLAGS, &
flags, &flen);
901 ts->
fd = vppcom_session_create (VPPCOM_PROTO_SRTP, 1 );
904 vterr (
"vppcom_session_create()", ts->
fd);
910 rv = vppcom_session_bind (ts->
fd, endpt);
913 vterr (
"vppcom_session_bind()",
rv);
917 rv = vppcom_session_listen (ts->
fd, 10);
920 vterr (
"vppcom_session_listen()",
rv);
932 client_fd = vppcom_session_accept (listen_fd, &ts->
endpt, 0);
935 vterr (
"vppcom_session_accept()", client_fd);