Skip to content

Commit

Permalink
libgtp: introduce cb_recovery() callback
Browse files Browse the repository at this point in the history
The cb_recovery() callback enables the user application to detect
a change in the restart counter and thus start the appropriate
recovery procedures.
  • Loading branch information
laf0rge committed Dec 24, 2010
1 parent 944dce3 commit 629e986
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 13 additions & 4 deletions gtp/gtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ int gtp_set_cb_conf(struct gsn_t *gsn,
return 0;
}

int gtp_set_cb_recovery(struct gsn_t *gsn,
int (*cb) (struct sockaddr_in *peer,
uint8_t recovery)) {
gsn->cb_recovery = cb;
return 0;
}

extern int gtp_set_cb_data_ind(struct gsn_t *gsn,
int (*cb_data_ind) (struct pdp_t* pdp,
void* pack,
Expand Down Expand Up @@ -932,6 +939,8 @@ int gtp_echo_conf(struct gsn_t *gsn, int version, struct sockaddr_in *peer,
/* Instead we return the recovery number in the callback function */
if (gsn->cb_conf) gsn->cb_conf(type, recovery, NULL, cbp);

if (gsn->cb_recovery) gsn->cb_recovery(peer, recovery);

return 0;
}

Expand Down Expand Up @@ -1343,7 +1352,7 @@ int gtp_create_pdp_ind(struct gsn_t *gsn, int version,

/* Recovery (optional) */
if (!gtpie_gettv1(ie, GTPIE_RECOVERY, 0, &recovery)) {
/* TODO: Handle received recovery IE */
if (gsn->cb_recovery) gsn->cb_recovery(peer, recovery);
}

/* Selection mode (conditional) */
Expand Down Expand Up @@ -1619,7 +1628,7 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version,

/* Extract recovery (optional) */
if (!gtpie_gettv1(ie, GTPIE_RECOVERY, 0, &recovery)) {
/* TODO: Handle received recovery IE */
if (gsn->cb_recovery) gsn->cb_recovery(peer, recovery);
}

/* Extract protocol configuration options (optional) */
Expand Down Expand Up @@ -2001,7 +2010,7 @@ int gtp_update_pdp_ind(struct gsn_t *gsn, int version,

/* Recovery (optional) */
if (!gtpie_gettv1(ie, GTPIE_RECOVERY, 0, &recovery)) {
/* TODO: Handle received recovery IE */
if (gsn->cb_recovery) gsn->cb_recovery(peer, recovery);
}

if (version == 0) {
Expand Down Expand Up @@ -2166,7 +2175,7 @@ int gtp_update_pdp_conf(struct gsn_t *gsn, int version,

/* Extract recovery (optional) */
if (!gtpie_gettv1(ie, GTPIE_RECOVERY, 0, &recovery)) {
/* TODO: Handle received recovery IE */
if (gsn->cb_recovery) gsn->cb_recovery(peer, recovery);
}

/* Check all conditional information elements */
Expand Down
3 changes: 3 additions & 0 deletions gtp/gtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ struct gsn_t {
int (*cb_extheader_ind) (struct sockaddr_in *peer);
int (*cb_conf) (int type, int cause, struct pdp_t *pdp, void* cbp);
int (*cb_data_ind) (struct pdp_t* pdp, void* pack, unsigned len);
int (*cb_recovery) (struct sockaddr_in *peer, uint8_t recovery);

/* Counters */

Expand Down Expand Up @@ -343,6 +344,8 @@ extern int gtp_set_cb_extheader_ind(struct gsn_t *gsn,
extern int gtp_set_cb_conf(struct gsn_t *gsn,
int (*cb) (int type, int cause, struct pdp_t* pdp, void *cbp));

int gtp_set_cb_recovery(struct gsn_t *gsn,
int (*cb) (struct sockaddr_in *peer, uint8_t recovery));

/* Internal functions (not part of the API */

Expand Down

0 comments on commit 629e986

Please sign in to comment.