summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-09-10 12:49:35 +0400
committerKozlov Dmitry <dima@server>2010-09-10 12:49:35 +0400
commitd0c060a39d3bf6f675666a1400b533511e24a26c (patch)
tree32d9bcd1c5cc094b868c037dcca55ce97373b1b7
parentc471cd62571f654b92bad0bd9f431927758f4d45 (diff)
downloadaccel-ppp-d0c060a39d3bf6f675666a1400b533511e24a26c.tar.gz
accel-ppp-d0c060a39d3bf6f675666a1400b533511e24a26c.zip
switching to use triton events instead of ppp_notify
-rw-r--r--accel-pptpd/CMakeLists.txt1
-rw-r--r--accel-pptpd/include/events.h13
-rw-r--r--accel-pptpd/ppp/ppp.c9
-rw-r--r--accel-pptpd/ppp/ppp.h17
-rw-r--r--accel-pptpd/ppp/ppp_auth.c2
-rw-r--r--accel-pptpd/radius/radius.c28
-rw-r--r--accel-pptpd/triton/event.c4
-rw-r--r--accel-pptpd/triton/triton.c3
8 files changed, 38 insertions, 39 deletions
diff --git a/accel-pptpd/CMakeLists.txt b/accel-pptpd/CMakeLists.txt
index a462358..9753e11 100644
--- a/accel-pptpd/CMakeLists.txt
+++ b/accel-pptpd/CMakeLists.txt
@@ -23,7 +23,6 @@ ADD_EXECUTABLE(pptpd
ppp/ipcp_opt_ipaddr.c
ppp/ipcp_opt_dns.c
ppp/ppp_ccp.c
- ppp/ppp_notify.c
log.c
pwdb.c
diff --git a/accel-pptpd/include/events.h b/accel-pptpd/include/events.h
new file mode 100644
index 0000000..85e1bc7
--- /dev/null
+++ b/accel-pptpd/include/events.h
@@ -0,0 +1,13 @@
+#ifndef __EVENTS_H
+#define __EVENTS_H
+
+#define EV_PPP_STARTING 1
+#define EV_PPP_STARTED 2
+#define EV_PPP_FINISHING 3
+#define EV_PPP_FINISHED 4
+#define EV_PPP_AUTHORIZED 5
+#define EV_IP_CHANGED 100
+#define EV_SHAPE_CHANGED 101
+
+#endif
+
diff --git a/accel-pptpd/ppp/ppp.c b/accel-pptpd/ppp/ppp.c
index 1e2ed86..8f385e7 100644
--- a/accel-pptpd/ppp/ppp.c
+++ b/accel-pptpd/ppp/ppp.c
@@ -14,6 +14,7 @@
#include "triton.h"
+#include "events.h"
#include "ppp.h"
#include "ppp_fsm.h"
#include "log.h"
@@ -157,7 +158,7 @@ int __export establish_ppp(struct ppp_t *ppp)
log_debug("ppp established\n");
- ppp_notify_starting(ppp);
+ triton_event_fire(EV_PPP_STARTING, ppp);
start_first_layer(ppp);
return 0;
@@ -190,7 +191,7 @@ static void destablish_ppp(struct ppp_t *ppp)
log_debug("ppp destablished\n");
- ppp_notify_finished(ppp);
+ triton_event_fire(EV_PPP_FINISHED, ppp);
ppp->ctrl->finished(ppp);
}
@@ -324,7 +325,7 @@ void __export ppp_layer_started(struct ppp_t *ppp, struct ppp_layer_data_t *d)
if (n->entry.next==&ppp->layers)
{
ppp->ctrl->started(ppp);
- ppp_notify_started(ppp);
+ triton_event_fire(EV_PPP_STARTED, ppp);
}else
{
n=list_entry(n->entry.next,typeof(*n),entry);
@@ -366,7 +367,7 @@ void __export ppp_terminate(struct ppp_t *ppp, int hard)
log_debug("ppp_terminate\n");
- ppp_notify_finishing(ppp);
+ triton_event_fire(EV_PPP_FINISHING, ppp);
if (hard) {
destablish_ppp(ppp);
diff --git a/accel-pptpd/ppp/ppp.h b/accel-pptpd/ppp/ppp.h
index a82e975..ce6854a 100644
--- a/accel-pptpd/ppp/ppp.h
+++ b/accel-pptpd/ppp/ppp.h
@@ -53,16 +53,6 @@ struct ppp_ctrl_t
void (*finished)(struct ppp_t*);
};
-struct ppp_notified_t
-{
- struct list_head entry;
- void (*starting)(struct ppp_notified_t *, struct ppp_t *);
- void (*started)(struct ppp_notified_t *, struct ppp_t *);
- void (*finishing)(struct ppp_notified_t *, struct ppp_t *);
- void (*finished)(struct ppp_notified_t *, struct ppp_t *);
- void (*authenticated)(struct ppp_notified_t *, struct ppp_t *);
-};
-
struct ppp_pd_t
{
struct list_head entry;
@@ -149,13 +139,6 @@ int ppp_register_layer(const char *name, struct ppp_layer_t *);
void ppp_unregister_layer(struct ppp_layer_t *);
struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *, struct ppp_layer_t *);
-void ppp_register_notified(struct ppp_notified_t *);
-void ppp_unregister_notified(struct ppp_notified_t *);
-void ppp_notify_starting(struct ppp_t *ppp);
-void ppp_notify_started(struct ppp_t *ppp);
-void ppp_notify_finishing(struct ppp_t *ppp);
-void ppp_notify_finished(struct ppp_t *ppp);
-
extern int conf_ppp_verbose;
extern int sock_fd; // internet socket for ioctls
diff --git a/accel-pptpd/ppp/ppp_auth.c b/accel-pptpd/ppp/ppp_auth.c
index 0a362e6..0a6630b 100644
--- a/accel-pptpd/ppp/ppp_auth.c
+++ b/accel-pptpd/ppp/ppp_auth.c
@@ -3,6 +3,7 @@
#include <arpa/inet.h>
#include "ppp.h"
+#include "events.h"
#include "ppp_lcp.h"
#include "log.h"
@@ -301,6 +302,7 @@ void __export auth_successed(struct ppp_t *ppp, char *username)
struct auth_layer_data_t *ad=container_of(ppp_find_layer_data(ppp,&auth_layer),typeof(*ad),ld);
log_debug("auth_layer_started\n");
ppp->username = username;
+ triton_event_fire(EV_PPP_AUTHORIZED, ppp);
ppp_layer_started(ppp,&ad->ld);
}
diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c
index 3fc1171..47a9aea 100644
--- a/accel-pptpd/radius/radius.c
+++ b/accel-pptpd/radius/radius.c
@@ -5,6 +5,7 @@
#include <unistd.h>
#include <arpa/inet.h>
+#include "events.h"
#include "log.h"
#include "ppp.h"
#include "pwdb.h"
@@ -35,7 +36,7 @@ char *conf_dm_coa_secret;
static LIST_HEAD(sessions);
static pthread_rwlock_t sessions_lock = PTHREAD_RWLOCK_INITIALIZER;
-static struct ppp_notified_t notified;
+static void *pd_key;
static struct ipdb_t ipdb;
void rad_proc_attrs(struct rad_req_t *req)
@@ -99,12 +100,12 @@ static struct ipdb_item_t *get_ip(struct ppp_t *ppp)
return NULL;
}
-static void ppp_starting(struct ppp_notified_t *n, struct ppp_t *ppp)
+static void ppp_starting(struct ppp_t *ppp)
{
struct radius_pd_t *pd = malloc(sizeof(*pd));
memset(pd, 0, sizeof(*pd));
- pd->pd.key = n;
+ pd->pd.key = pd_key;
pd->ppp = ppp;
pthread_mutex_init(&pd->lock, NULL);
list_add_tail(&pd->pd.entry, &ppp->pd_list);
@@ -114,20 +115,20 @@ static void ppp_starting(struct ppp_notified_t *n, struct ppp_t *ppp)
pthread_rwlock_unlock(&sessions_lock);
}
-static void ppp_started(struct ppp_notified_t *n, struct ppp_t *ppp)
+static void ppp_started(struct ppp_t *ppp)
{
struct radius_pd_t *rpd = find_pd(ppp);
if (rad_acct_start(rpd))
ppp_terminate(rpd->ppp, 0);
}
-static void ppp_finishing(struct ppp_notified_t *n, struct ppp_t *ppp)
+static void ppp_finishing(struct ppp_t *ppp)
{
struct radius_pd_t *rpd = find_pd(ppp);
rad_acct_stop(rpd);
}
-static void ppp_finished(struct ppp_notified_t *n, struct ppp_t *ppp)
+static void ppp_finished(struct ppp_t *ppp)
{
struct radius_pd_t *rpd = find_pd(ppp);
@@ -150,7 +151,7 @@ struct radius_pd_t *find_pd(struct ppp_t *ppp)
struct radius_pd_t *rpd;
list_for_each_entry(pd, &ppp->pd_list, entry) {
- if (pd->key == &notified) {
+ if (pd->key == pd_key) {
rpd = container_of(pd, typeof(*rpd), pd);
return rpd;
}
@@ -239,13 +240,6 @@ static struct pwdb_t pwdb = {
.check = check,
};
-static struct ppp_notified_t notified = {
- .starting = ppp_starting,
- .started = ppp_started,
- .finishing = ppp_finishing,
- .finished = ppp_finished,
-};
-
static int parse_server(const char *opt, char **name, int *port, char **secret)
{
char *str = strdup(opt);
@@ -325,6 +319,10 @@ static void __init radius_init(void)
pwdb_register(&pwdb);
ipdb_register(&ipdb);
- ppp_register_notified(&notified);
+
+ triton_event_register_handler(EV_PPP_STARTING, (triton_event_func)ppp_starting);
+ triton_event_register_handler(EV_PPP_STARTED, (triton_event_func)ppp_started);
+ triton_event_register_handler(EV_PPP_FINISHING, (triton_event_func)ppp_finishing);
+ triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ppp_finished);
}
diff --git a/accel-pptpd/triton/event.c b/accel-pptpd/triton/event.c
index 17483ec..442543f 100644
--- a/accel-pptpd/triton/event.c
+++ b/accel-pptpd/triton/event.c
@@ -26,7 +26,7 @@ int event_init(void)
return 0;
}
-int triton_event_register_handler(int ev_id, triton_event_func func)
+int __export triton_event_register_handler(int ev_id, triton_event_func func)
{
struct _triton_event_t *ev;
struct event_handler_t *h;
@@ -85,7 +85,7 @@ int triton_event_register_handler(int ev_id, triton_event_func func)
return -1;
}*/
-void triton_event_fire(int ev_id, void *arg)
+void __export triton_event_fire(int ev_id, void *arg)
{
struct _triton_event_t *ev;
struct event_handler_t *h;
diff --git a/accel-pptpd/triton/triton.c b/accel-pptpd/triton/triton.c
index 742d493..8b25f03 100644
--- a/accel-pptpd/triton/triton.c
+++ b/accel-pptpd/triton/triton.c
@@ -313,6 +313,9 @@ int __export triton_init(const char *conf_file, const char *mod_sect)
if (timer_init())
return -1;
+ if (event_init())
+ return -1;
+
if (load_modules(mod_sect))
return -1;