1 /*
2 * Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <sys/ioctl.h>
19 #include <sys/poll.h>
20 #include <netdb.h>
21
22 #include <stdlib.h>
23 #include <unistd.h>
24 #include <string.h>
25 #include <stdio.h>
26
27 #include <errno.h>
28
29 #include <s2n.h>
30
31 int echo(struct s2n_connection *conn, int sockfd)
32 {
33 struct pollfd readers[2];
34
35 readers[0].fd = sockfd;
36 readers[0].events = POLLIN;
37 readers[1].fd = STDIN_FILENO;
38 readers[1].events = POLLIN;
39
40 int more;
41 do {
42 if (s2n_negotiate(conn, &more) < 0) {
43 fprintf(stderr, "Failed to negotiate: '%s' %d\n", s2n_strerror(s2n_errno, "EN"), s2n_connection_get_alert(conn));
44 exit(1);
|
1 /*
2 * Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <sys/ioctl.h>
19 #include <sys/filio.h>
20 #include <sys/poll.h>
21 #include <netdb.h>
22
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <string.h>
26 #include <stropts.h>
27 #include <stdio.h>
28
29 #include <errno.h>
30
31 #include <s2n.h>
32
33 int echo(struct s2n_connection *conn, int sockfd)
34 {
35 struct pollfd readers[2];
36
37 readers[0].fd = sockfd;
38 readers[0].events = POLLIN;
39 readers[1].fd = STDIN_FILENO;
40 readers[1].events = POLLIN;
41
42 int more;
43 do {
44 if (s2n_negotiate(conn, &more) < 0) {
45 fprintf(stderr, "Failed to negotiate: '%s' %d\n", s2n_strerror(s2n_errno, "EN"), s2n_connection_get_alert(conn));
46 exit(1);
|