Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DEBUG_LEVEL 0
- #include "mbed.h"
- #include "NetworkStack.h"
- #include "EthernetInterface.h"
- #include "TCPSocket.h"
- #include <string>
- #include "mbedtls/platform.h"
- #include "mbedtls/ssl.h"
- #include "mbedtls/entropy.h"
- #include "mbedtls/ctr_drbg.h"
- #include "mbedtls/net_sockets.h"
- #include "mbedtls/error.h"
- #include <stdlib.h>
- #include <string.h>
- #if DEBUG_LEVEL > 0
- #include "mbedtls/debug.h"
- #endif
- #if defined(MBEDTLS_SSL_CACHE_C)
- #include "mbedtls/ssl_cache.h"
- #endif
- #if !defined(MBEDTLS_CONFIG_FILE)
- #include "mbedtls/config.h"
- #else
- #include MBEDTLS_CONFIG_FILE
- #endif
- #define mbedtls_time time
- #define mbedtls_time_t time_t
- #define mbedtls_fprintf fprintf
- #define mbedtls_printf printf
- #define RESPONSE "WINWINWIN"
- static void my_debug( void *ctx, int level,
- const char *file, int line,
- const char *str )
- {
- ((void) level);
- mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
- fflush( (FILE *) ctx );
- }
- void server_func(void)
- {
- int ret, len;
- mbedtls_net_context listen_fd, client_fd;
- unsigned char buf[1024];
- const char *pers = "ssl_server";
- mbedtls_entropy_context entropy;
- mbedtls_ctr_drbg_context ctr_drbg;
- mbedtls_ssl_context ssl;
- mbedtls_ssl_config conf;
- mbedtls_x509_crt srvcert;
- mbedtls_pk_context pkey;
- #if defined(MBEDTLS_SSL_CACHE_C)
- mbedtls_ssl_cache_context cache;
- #endif
- mbedtls_net_init( &listen_fd );
- mbedtls_net_init( &client_fd );
- mbedtls_ssl_init( &ssl );
- mbedtls_ssl_config_init( &conf );
- #if defined(MBEDTLS_SSL_CACHE_C)
- mbedtls_ssl_cache_init( &cache );
- #endif
- mbedtls_x509_crt_init( &srvcert );
- mbedtls_pk_init( &pkey );
- mbedtls_entropy_init( &entropy );
- mbedtls_ctr_drbg_init( &ctr_drbg );
- }
Advertisement
Add Comment
Please, Sign In to add comment