Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jkonra2m/tinydtls-cython
1 result
Show changes
Commits on Source (4)
# cython: language_level=2
cimport tdtls
from tdtls cimport dtls_context_t, dtls_handler_t, session_t, dtls_alert_level_t, dtls_credentials_type_t
from libc.stdint cimport uint8_t
......@@ -18,7 +19,7 @@ DTLS_LOG_INFO = tdtls.DTLS_LOG_INFO
DTLS_LOG_DEBUG = tdtls.DTLS_LOG_DEBUG
cdef int _write(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len):
cdef int _write(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) except -1:
"""Send data to socket"""
self = <object>(ctx.app)
data = buf[:len]
......@@ -28,7 +29,7 @@ cdef int _write(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len)
cdef int ret = self.pycb['write']((ip, port), data)
return ret
cdef int _read(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len):
cdef int _read(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) except -1:
"""Send data to application"""
self = <object>(ctx.app)
data = buf[:len]
......@@ -38,7 +39,7 @@ cdef int _read(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len):
cdef int ret = self.pycb['read']((ip, port), data)
return ret
cdef int _event(dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code):
cdef int _event(dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code) except -1:
"""The event handler is called when a message from the alert protocol is received or the state of the DTLS session changes."""
self = <object>(ctx.app)
if self.pycb['event'] != None:
......@@ -53,7 +54,7 @@ cdef int _get_psk_info(dtls_context_t *ctx,
const unsigned char *desc_data,
size_t desc_len,
unsigned char *result_data,
size_t result_length):
size_t result_length) except -1:
"""Called during handshake to get information related to the psk key exchange.
The type of information requested is indicated by @p type
......
......@@ -83,10 +83,14 @@ cdef extern from "tinydtls/dtls.h":
unsigned char readbuf[1400] #DTLS_MAX_BUF
ctypedef struct dtls_handler_t:
int (*write)(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len)
int (*read)(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len)
int (*event)(dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code)
int (*get_psk_info)(dtls_context_t *ctx, const session_t *session, dtls_credentials_type_t type, const unsigned char *desc, size_t desc_len, unsigned char *result, size_t result_length)
int (*write)(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) except -1
# Actually, the return value is ignored by tinydtls; -1 is used for errors
# for consistency with write and get_psk_info
int (*read)(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) except -1
# Actually, the return value is ignored by tinydtls; -1 is used for errors
# for consistency with write and get_psk_info
int (*event)(dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code) except -1
int (*get_psk_info)(dtls_context_t *ctx, const session_t *session, dtls_credentials_type_t type, const unsigned char *desc, size_t desc_len, unsigned char *result, size_t result_length) except -1
void dtls_init()
void dtls_set_handler(dtls_context_t *ctx, dtls_handler_t *h) #inline...
......
......@@ -32,7 +32,7 @@ with open("README.md", "r") as fh:
setup(
name="DTLSSocket",
version='0.1.16',
version='0.1.17',
description = "DTLSSocket is a cython wrapper for tinydtls with a Socket like interface",
long_description=long_description,
long_description_content_type="text/markdown",
......