1 module bindbc.gnutls.dtls; 2 3 import bindbc.gnutls.gnutls; 4 5 enum GNUTLS_COOKIE_KEY_SIZE = 16; 6 7 struct gnutls_dtls_prestate_st 8 { 9 uint record_seq; 10 uint hsk_read_seq; 11 uint hsk_write_seq; 12 } 13 14 version (BindGnuTLS_Static) 15 { 16 extern (System) @nogc nothrow @system: 17 18 void gnutls_dtls_set_timeouts (gnutls_session_t session, uint retrans_timeout, uint total_timeout); 19 uint gnutls_dtls_get_mtu (gnutls_session_t session); 20 uint gnutls_dtls_get_data_mtu (gnutls_session_t session); 21 void gnutls_dtls_set_mtu (gnutls_session_t session, uint mtu); 22 int gnutls_dtls_set_data_mtu (gnutls_session_t session, uint mtu); 23 uint gnutls_dtls_get_timeout (gnutls_session_t session); 24 int gnutls_dtls_cookie_send (gnutls_datum_t* key, void* client_data, size_t client_data_size, gnutls_dtls_prestate_st* prestate, gnutls_transport_ptr_t ptr, gnutls_push_func push_func); 25 int gnutls_dtls_cookie_verify (gnutls_datum_t* key, void* client_data, size_t client_data_size, void* _msg, size_t msg_size, gnutls_dtls_prestate_st* prestate); 26 void gnutls_dtls_prestate_set (gnutls_session_t session, gnutls_dtls_prestate_st* prestate); 27 uint gnutls_record_get_discarded (gnutls_session_t session); 28 } 29 else 30 { 31 extern (System) @nogc nothrow @system 32 { 33 alias pgnutls_dtls_set_timeouts = void function (gnutls_session_t session, uint retrans_timeout, uint total_timeout); 34 alias pgnutls_dtls_get_mtu = uint function (gnutls_session_t session); 35 alias pgnutls_dtls_get_data_mtu = uint function (gnutls_session_t session); 36 alias pgnutls_dtls_set_mtu = void function (gnutls_session_t session, uint mtu); 37 alias pgnutls_dtls_set_data_mtu = int function (gnutls_session_t session, uint mtu); 38 alias pgnutls_dtls_get_timeout = uint function (gnutls_session_t session); 39 alias pgnutls_dtls_cookie_send = int function (gnutls_datum_t* key, void* client_data, size_t client_data_size, gnutls_dtls_prestate_st* prestate, gnutls_transport_ptr_t ptr, gnutls_push_func push_func); 40 alias pgnutls_dtls_cookie_verify = int function (gnutls_datum_t* key, void* client_data, size_t client_data_size, void* _msg, size_t msg_size, gnutls_dtls_prestate_st* prestate); 41 alias pgnutls_dtls_prestate_set = void function (gnutls_session_t session, gnutls_dtls_prestate_st* prestate); 42 alias pgnutls_record_get_discarded = uint function (gnutls_session_t session); 43 } 44 45 __gshared 46 { 47 pgnutls_dtls_set_timeouts gnutls_dtls_set_timeouts; 48 pgnutls_dtls_get_mtu gnutls_dtls_get_mtu; 49 pgnutls_dtls_get_data_mtu gnutls_dtls_get_data_mtu; 50 pgnutls_dtls_set_mtu gnutls_dtls_set_mtu; 51 pgnutls_dtls_set_data_mtu gnutls_dtls_set_data_mtu; 52 pgnutls_dtls_get_timeout gnutls_dtls_get_timeout; 53 pgnutls_dtls_cookie_send gnutls_dtls_cookie_send; 54 pgnutls_dtls_cookie_verify gnutls_dtls_cookie_verify; 55 pgnutls_dtls_prestate_set gnutls_dtls_prestate_set; 56 pgnutls_record_get_discarded gnutls_record_get_discarded; 57 } 58 59 import bindbc.loader : SharedLib, bindSymbol_stdcall; 60 void bindDtls(SharedLib lib) 61 { 62 lib.bindSymbol_stdcall(gnutls_dtls_set_timeouts, "gnutls_dtls_set_timeouts"); 63 lib.bindSymbol_stdcall(gnutls_dtls_get_mtu, "gnutls_dtls_get_mtu"); 64 lib.bindSymbol_stdcall(gnutls_dtls_get_data_mtu, "gnutls_dtls_get_data_mtu"); 65 lib.bindSymbol_stdcall(gnutls_dtls_set_mtu, "gnutls_dtls_set_mtu"); 66 lib.bindSymbol_stdcall(gnutls_dtls_set_data_mtu, "gnutls_dtls_set_data_mtu"); 67 lib.bindSymbol_stdcall(gnutls_dtls_get_timeout, "gnutls_dtls_get_timeout"); 68 lib.bindSymbol_stdcall(gnutls_dtls_cookie_send, "gnutls_dtls_cookie_send"); 69 lib.bindSymbol_stdcall(gnutls_dtls_cookie_verify, "gnutls_dtls_cookie_verify"); 70 lib.bindSymbol_stdcall(gnutls_dtls_prestate_set, "gnutls_dtls_prestate_set"); 71 lib.bindSymbol_stdcall(gnutls_record_get_discarded, "gnutls_record_get_discarded"); 72 } 73 }