Skip to content

Commit

Permalink
Merge branch 'hi1_timers' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
salcock committed Oct 10, 2023
2 parents 25efdd8 + a7c9ea3 commit bd91cf6
Show file tree
Hide file tree
Showing 10 changed files with 876 additions and 322 deletions.
3 changes: 2 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ openliprovisioner_SOURCES=provisioner/provisioner.c provisioner/provisioner.h \
provisioner/updateserver.h \
provisioner/updateserver_jsonparsing.c \
provisioner/updateserver_jsoncreation.c \
provisioner/hup_reload.c
provisioner/hup_reload.c \
provisioner/intercept_timers.c provisioner/intercept_timers.h

openliprovisioner_LDFLAGS = -lpthread @PROVISIONER_LIBS@
openliprovisioner_LDADD = @ADD_LIBS@
Expand Down
67 changes: 31 additions & 36 deletions src/configparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,31 @@ static void parse_intercept_common_fields(intercept_common_t *common,
}
}

static inline void init_intercept_common(intercept_common_t *common,
void *parent, openli_intercept_types_t intercept_type) {
prov_intercept_data_t *local;

common->liid = NULL;
common->liid_len = 0;
common->authcc = NULL;
common->authcc_len = 0;
common->delivcc = NULL;
common->delivcc_len = 0;
common->destid = 0;
common->targetagency = NULL;
common->encryptkey = NULL;
common->tostart_time = 0;
common->toend_time = 0;
common->tomediate = OPENLI_INTERCEPT_OUTPUTS_ALL;
common->encrypt = OPENLI_PAYLOAD_ENCRYPTION_NONE;
common->hi1_seqno = 0;
common->local = calloc(1, sizeof(prov_intercept_data_t));

local = (prov_intercept_data_t *)(common->local);
local->intercept_type = intercept_type;
local->intercept_ref = (void *)parent;
}

static int parse_emailintercept_list(emailintercept_t **mailints,
yaml_document_t *doc, yaml_node_t *inputs) {

Expand All @@ -743,17 +768,8 @@ static int parse_emailintercept_list(emailintercept_t **mailints,
unsigned int tgtcount = 0;

newcept = (emailintercept_t *)calloc(1, sizeof(emailintercept_t));
newcept->common.liid = NULL;
newcept->common.authcc = NULL;
newcept->common.delivcc = NULL;
newcept->common.destid = 0;
newcept->common.targetagency = NULL;
newcept->common.encryptkey = NULL;
newcept->common.tostart_time = 0;
newcept->common.toend_time = 0;
newcept->common.tomediate = OPENLI_INTERCEPT_OUTPUTS_ALL;
newcept->common.encrypt = OPENLI_PAYLOAD_ENCRYPTION_NONE;
newcept->common.hi1_seqno = 0;
init_intercept_common(&(newcept->common), newcept,
OPENLI_INTERCEPT_TYPE_EMAIL);
newcept->awaitingconfirm = 1;
newcept->targets = NULL;
newcept->delivercompressed = OPENLI_EMAILINT_DELIVER_COMPRESSED_DEFAULT;
Expand Down Expand Up @@ -837,25 +853,16 @@ static int parse_voipintercept_list(voipintercept_t **voipints,
newcept->internalid = nextid;
nextid ++;

newcept->common.liid = NULL;
newcept->common.authcc = NULL;
newcept->common.delivcc = NULL;
init_intercept_common(&(newcept->common), newcept,
OPENLI_INTERCEPT_TYPE_VOIP);
newcept->active_cins = NULL;
newcept->active_registrations = NULL;
newcept->cin_callid_map = NULL;
newcept->cin_sdp_map = NULL;
newcept->targets = libtrace_list_init(sizeof(openli_sip_identity_t *));
newcept->active = 1;
newcept->common.destid = 0;
newcept->common.targetagency = NULL;
newcept->common.encryptkey = NULL;
newcept->common.hi1_seqno = 0;
newcept->awaitingconfirm = 1;
newcept->options = 0;
newcept->common.tostart_time = 0;
newcept->common.toend_time = 0;
newcept->common.tomediate = OPENLI_INTERCEPT_OUTPUTS_ALL;
newcept->common.encrypt = OPENLI_PAYLOAD_ENCRYPTION_NONE;

/* Mappings describe the parameters for each intercept */
for (pair = node->data.mapping.pairs.start;
Expand Down Expand Up @@ -917,28 +924,16 @@ static int parse_ipintercept_list(ipintercept_t **ipints, yaml_document_t *doc,

/* Each sequence item is a new intercept */
newcept = (ipintercept_t *)malloc(sizeof(ipintercept_t));
init_intercept_common(&(newcept->common), newcept,
OPENLI_INTERCEPT_TYPE_IP);

newcept->common.liid = NULL;
newcept->common.authcc = NULL;
newcept->common.delivcc = NULL;
newcept->username = NULL;
newcept->common.destid = 0;
newcept->common.targetagency = NULL;
newcept->common.encryptkey = NULL;
newcept->common.hi1_seqno = 0;
newcept->awaitingconfirm = 1;
newcept->common.liid_len = 0;
newcept->username_len = 0;
newcept->common.authcc_len = 0;
newcept->common.delivcc_len = 0;
newcept->vendmirrorid = OPENLI_VENDOR_MIRROR_NONE;
newcept->accesstype = INTERNET_ACCESS_TYPE_UNDEFINED;
newcept->statics = NULL;
newcept->options = 0;
newcept->common.tostart_time = 0;
newcept->common.toend_time = 0;
newcept->common.tomediate = OPENLI_INTERCEPT_OUTPUTS_ALL;
newcept->common.encrypt = OPENLI_PAYLOAD_ENCRYPTION_NONE;

/* Mappings describe the parameters for each intercept */
for (pair = node->data.mapping.pairs.start;
Expand Down
14 changes: 14 additions & 0 deletions src/intercept.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@

#define OPENLI_VENDOR_MIRROR_NONE (0xffffffff)

typedef enum {
OPENLI_INTERCEPT_TYPE_UNKNOWN = 0,
OPENLI_INTERCEPT_TYPE_IP = 1,
OPENLI_INTERCEPT_TYPE_VOIP = 2,
OPENLI_INTERCEPT_TYPE_EMAIL = 3,
} openli_intercept_types_t;

typedef enum {
INTERNET_ACCESS_TYPE_UNDEFINED = 0,
INTERNET_ACCESS_TYPE_DIALUP = 1,
Expand Down Expand Up @@ -114,6 +121,13 @@ typedef struct intercept_common {
intercept_outputs_t tomediate;
payload_encryption_method_t encrypt;
char *encryptkey;

/** A pointer to use for storing "local" data against an instance of
* an intercept, i.e. the provisioner might want to associate
* certain data against each intercept that is not required by the
* collector or mediator.
*/
void *local;
} intercept_common_t;

typedef struct hi1_notify_data {
Expand Down
38 changes: 37 additions & 1 deletion src/provisioner/clientupdates.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,49 @@ int announce_hi1_notification_to_mediators(provision_state_t *state,

hi1_notify_data_t ndata;
struct timeval tv;
prov_intercept_data_t *ceptdata = (prov_intercept_data_t *)(intcomm->local);

if (intcomm == NULL) {
return -1;
}

gettimeofday(&tv, NULL);

if (ceptdata && not_type == HI1_LI_ACTIVATED) {
if (ceptdata->start_hi1_sent) {
return 0;
}
if (intcomm->tostart_time > tv.tv_sec) {
return 0;
}
ceptdata->start_hi1_sent = 1;
ceptdata->end_hi1_sent = 0;
} else if (ceptdata && not_type == HI1_LI_DEACTIVATED) {
if (ceptdata->end_hi1_sent) {
return 0;
}
if (!ceptdata->start_hi1_sent) {
return 0;
}
ceptdata->end_hi1_sent = 1;
ceptdata->start_hi1_sent = 0;
} else if (ceptdata && not_type == HI1_LI_MODIFIED) {
if (ceptdata->end_hi1_sent) {
return 0;
}
if (!ceptdata->start_hi1_sent) {
if (intcomm->tostart_time > tv.tv_sec) {
return 0;
} else {
/* shouldn't get here ideally, but just in case we do then
* let's send an activated message instead.
*/
not_type = HI1_LI_ACTIVATED;
ceptdata->start_hi1_sent = 1;
}
}
}

ndata.notify_type = not_type;
ndata.liid = intcomm->liid;
ndata.authcc = intcomm->authcc;
Expand All @@ -423,7 +459,7 @@ int announce_hi1_notification_to_mediators(provision_state_t *state,
}
SEND_ALL_MEDIATORS_END
intcomm->hi1_seqno ++;
return 0;
return 1;
}

int remove_liid_mapping(provision_state_t *state,
Expand Down
Loading

0 comments on commit bd91cf6

Please sign in to comment.