Skip to content
Snippets Groups Projects
Commit f6be060e authored by chrysn's avatar chrysn
Browse files

dtls.pyx: Declare exception propagation

parent 3434335e
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ DTLS_LOG_INFO = tdtls.DTLS_LOG_INFO ...@@ -19,7 +19,7 @@ DTLS_LOG_INFO = tdtls.DTLS_LOG_INFO
DTLS_LOG_DEBUG = tdtls.DTLS_LOG_DEBUG 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""" """Send data to socket"""
self = <object>(ctx.app) self = <object>(ctx.app)
data = buf[:len] data = buf[:len]
...@@ -29,7 +29,7 @@ cdef int _write(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) ...@@ -29,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) cdef int ret = self.pycb['write']((ip, port), data)
return ret 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""" """Send data to application"""
self = <object>(ctx.app) self = <object>(ctx.app)
data = buf[:len] data = buf[:len]
...@@ -39,7 +39,7 @@ cdef int _read(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len): ...@@ -39,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) cdef int ret = self.pycb['read']((ip, port), data)
return ret 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.""" """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) self = <object>(ctx.app)
if self.pycb['event'] != None: if self.pycb['event'] != None:
...@@ -54,7 +54,7 @@ cdef int _get_psk_info(dtls_context_t *ctx, ...@@ -54,7 +54,7 @@ cdef int _get_psk_info(dtls_context_t *ctx,
const unsigned char *desc_data, const unsigned char *desc_data,
size_t desc_len, size_t desc_len,
unsigned char *result_data, 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. """Called during handshake to get information related to the psk key exchange.
The type of information requested is indicated by @p type The type of information requested is indicated by @p type
......
...@@ -83,10 +83,14 @@ cdef extern from "tinydtls/dtls.h": ...@@ -83,10 +83,14 @@ cdef extern from "tinydtls/dtls.h":
unsigned char readbuf[1400] #DTLS_MAX_BUF unsigned char readbuf[1400] #DTLS_MAX_BUF
ctypedef struct dtls_handler_t: ctypedef struct dtls_handler_t:
int (*write)(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) int (*write)(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) except -1
int (*read)(dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) # Actually, the return value is ignored by tinydtls; -1 is used for errors
int (*event)(dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code) # for consistency with write and get_psk_info
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 (*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_init()
void dtls_set_handler(dtls_context_t *ctx, dtls_handler_t *h) #inline... void dtls_set_handler(dtls_context_t *ctx, dtls_handler_t *h) #inline...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment