From 8f4860cb55c35b249f45b21e2e9fa2fab12569bc Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Mon, 14 Feb 2022 09:14:22 +0000 Subject: [PATCH] Add subclassing capability to struct trans --- common/trans.c | 6 ++++++ common/trans.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/common/trans.c b/common/trans.c index 55d2a638..7a98986c 100644 --- a/common/trans.c +++ b/common/trans.c @@ -120,6 +120,12 @@ trans_delete(struct trans *self) return; } + /* Call the user-specified destructor if one exists */ + if (self->extra_destructor != NULL) + { + self->extra_destructor(self); + } + free_stream(self->in_s); free_stream(self->out_s); diff --git a/common/trans.h b/common/trans.h index 876e8b9b..9810cefd 100644 --- a/common/trans.h +++ b/common/trans.h @@ -108,6 +108,9 @@ struct trans char port[256]; int no_stream_init_on_data_in; int extra_flags; /* user defined */ + void *extra_data; /* user defined */ + void (*extra_destructor)(struct trans *); /* user defined */ + struct ssl_tls *tls; const char *ssl_protocol; /* e.g. TLSv1, TLSv1.1, TLSv1.2, unknown */ const char *cipher_name; /* e.g. AES256-GCM-SHA384 */