summaryrefslogtreecommitdiff
path: root/accel-pppd/extra
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2012-06-19 19:06:06 +0400
committerKozlov Dmitry <xeb@mail.ru>2012-06-19 19:06:06 +0400
commit02b3fb2b24aacd90d535c2136a055f529d722974 (patch)
tree6243dd815869add07be2bad5846e7817b732ac59 /accel-pppd/extra
parentc553a7bbbc96d36ba4d0999bb172c7a926518eb1 (diff)
downloadaccel-ppp-02b3fb2b24aacd90d535c2136a055f529d722974.tar.gz
accel-ppp-02b3fb2b24aacd90d535c2136a055f529d722974.zip
general preparation for IPoE integration
Diffstat (limited to 'accel-pppd/extra')
-rw-r--r--accel-pppd/extra/chap-secrets.c36
-rw-r--r--accel-pppd/extra/ippool.c16
-rw-r--r--accel-pppd/extra/ipv6pool.c8
-rw-r--r--accel-pppd/extra/logwtmp.c12
-rw-r--r--accel-pppd/extra/net-snmp/sessionTable.h6
-rw-r--r--accel-pppd/extra/net-snmp/sessionTable_data_access.c32
-rw-r--r--accel-pppd/extra/net-snmp/statPPP.c6
-rw-r--r--accel-pppd/extra/net-snmp/terminate.c60
-rw-r--r--accel-pppd/extra/pppd_compat.c104
-rw-r--r--accel-pppd/extra/shaper_tbf.c44
10 files changed, 162 insertions, 162 deletions
diff --git a/accel-pppd/extra/chap-secrets.c b/accel-pppd/extra/chap-secrets.c
index db1bbb2f..c0e620b1 100644
--- a/accel-pppd/extra/chap-secrets.c
+++ b/accel-pppd/extra/chap-secrets.c
@@ -23,7 +23,7 @@ static struct ipdb_t ipdb;
struct cs_pd_t
{
- struct ppp_pd_t pd;
+ struct ap_private pd;
struct ipv4db_item_t ip;
char *passwd;
char *rate;
@@ -93,7 +93,7 @@ static int split(char *buf, char **ptr)
}
-static struct cs_pd_t *create_pd(struct ppp_t *ppp, const char *username)
+static struct cs_pd_t *create_pd(struct ap_session *ses, const char *username)
{
FILE *f;
char *buf;
@@ -161,7 +161,7 @@ found:
if (n >= 4)
pd->rate = _strdup(ptr[3]);
- list_add_tail(&pd->pd.entry, &ppp->pd_list);
+ list_add_tail(&pd->pd.entry, &ses->pd_list);
fclose(f);
_free(buf);
@@ -169,11 +169,11 @@ found:
return pd;
}
-static struct cs_pd_t *find_pd(struct ppp_t *ppp)
+static struct cs_pd_t *find_pd(struct ap_session *ses)
{
- struct ppp_pd_t *pd;
+ struct ap_private *pd;
- list_for_each_entry(pd, &ppp->pd_list, entry) {
+ list_for_each_entry(pd, &ses->pd_list, entry) {
if (pd->key == &pd_key) {
return container_of(pd, typeof(struct cs_pd_t), pd);
}
@@ -182,9 +182,9 @@ static struct cs_pd_t *find_pd(struct ppp_t *ppp)
return NULL;
}
-static void ev_ppp_finished(struct ppp_t *ppp)
+static void ev_ses_finished(struct ap_session *ses)
{
- struct cs_pd_t *pd = find_pd(ppp);
+ struct cs_pd_t *pd = find_pd(ses);
if (!pd)
return;
@@ -196,11 +196,11 @@ static void ev_ppp_finished(struct ppp_t *ppp)
_free(pd);
}
-static void ev_ppp_pre_up(struct ppp_t *ppp)
+static void ev_ses_pre_up(struct ap_session *ses)
{
- struct cs_pd_t *pd = find_pd(ppp);
+ struct cs_pd_t *pd = find_pd(ses);
struct ev_shaper_t ev = {
- .ppp = ppp,
+ .ses = ses,
};
if (!pd)
@@ -212,14 +212,14 @@ static void ev_ppp_pre_up(struct ppp_t *ppp)
}
}
-static struct ipv4db_item_t *get_ip(struct ppp_t *ppp)
+static struct ipv4db_item_t *get_ip(struct ap_session *ses)
{
struct cs_pd_t *pd;
if (!conf_gw_ip_address)
return NULL;
- pd = find_pd(ppp);
+ pd = find_pd(ses);
if (!pd)
return NULL;
@@ -230,12 +230,12 @@ static struct ipv4db_item_t *get_ip(struct ppp_t *ppp)
return &pd->ip;
}
-static char* get_passwd(struct pwdb_t *pwdb, struct ppp_t *ppp, const char *username)
+static char* get_passwd(struct pwdb_t *pwdb, struct ap_session *ses, const char *username)
{
- struct cs_pd_t *pd = find_pd(ppp);
+ struct cs_pd_t *pd = find_pd(ses);
if (!pd)
- pd = create_pd(ppp, username);
+ pd = create_pd(ses, username);
if (!pd)
return NULL;
@@ -275,8 +275,8 @@ static void init(void)
pwdb_register(&pwdb);
ipdb_register(&ipdb);
- triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ev_ppp_finished);
- triton_event_register_handler(EV_PPP_PRE_UP, (triton_event_func)ev_ppp_pre_up);
+ triton_event_register_handler(EV_SES_FINISHED, (triton_event_func)ev_ses_finished);
+ triton_event_register_handler(EV_SES_PRE_UP, (triton_event_func)ev_ses_pre_up);
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
diff --git a/accel-pppd/extra/ippool.c b/accel-pppd/extra/ippool.c
index fc4fd182..ab2dfb25 100644
--- a/accel-pppd/extra/ippool.c
+++ b/accel-pppd/extra/ippool.c
@@ -205,13 +205,13 @@ static void generate_pool(struct ippool_t *p)
}
}
-static struct ipv4db_item_t *get_ip(struct ppp_t *ppp)
+static struct ipv4db_item_t *get_ip(struct ap_session *ses)
{
struct ippool_item_t *it;
struct ippool_t *p;
- if (ppp->ipv4_pool_name)
- p = find_pool(ppp->ipv4_pool_name, 0);
+ if (ses->ipv4_pool_name)
+ p = find_pool(ses->ipv4_pool_name, 0);
else
p = def_pool;
@@ -229,7 +229,7 @@ static struct ipv4db_item_t *get_ip(struct ppp_t *ppp)
return it ? &it->it : NULL;
}
-static void put_ip(struct ppp_t *ppp, struct ipv4db_item_t *it)
+static void put_ip(struct ap_session *ses, struct ipv4db_item_t *it)
{
struct ippool_item_t *pit = container_of(it, typeof(*pit), it);
@@ -244,12 +244,12 @@ static struct ipdb_t ipdb = {
};
#ifdef RADIUS
-static int parse_attr(struct ppp_t *ppp, struct rad_attr_t *attr)
+static int parse_attr(struct ap_session *ses, struct rad_attr_t *attr)
{
if (attr->len > sizeof("ip:addr-pool=") && memcmp(attr->val.string, "ip:addr-pool=", sizeof("ip:addr-pool=") - 1) == 0)
- ppp->ipv4_pool_name = _strdup(attr->val.string + sizeof("ip:addr-pool=") - 1);
+ ses->ipv4_pool_name = _strdup(attr->val.string + sizeof("ip:addr-pool=") - 1);
else if (!attr->vendor)
- ppp->ipv4_pool_name = _strdup(attr->val.string);
+ ses->ipv4_pool_name = _strdup(attr->val.string);
else
return -1;
@@ -269,7 +269,7 @@ static void ev_radius_access_accept(struct ev_radius_t *ev)
continue;
if (attr->attr->id != conf_attr)
continue;
- if (parse_attr(ev->ppp, attr))
+ if (parse_attr(ev->ses, attr))
continue;
break;
}
diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c
index 59bda253..5a9dde96 100644
--- a/accel-pppd/extra/ipv6pool.c
+++ b/accel-pppd/extra/ipv6pool.c
@@ -129,7 +129,7 @@ err:
_free(val);
}
-static struct ipv6db_item_t *get_ip(struct ppp_t *ppp)
+static struct ipv6db_item_t *get_ip(struct ap_session *ses)
{
struct ippool_item_t *it;
@@ -146,7 +146,7 @@ static struct ipv6db_item_t *get_ip(struct ppp_t *ppp)
return it ? &it->it : NULL;
}
-static void put_ip(struct ppp_t *ppp, struct ipv6db_item_t *it)
+static void put_ip(struct ap_session *ses, struct ipv6db_item_t *it)
{
struct ippool_item_t *pit = container_of(it, typeof(*pit), it);
@@ -155,7 +155,7 @@ static void put_ip(struct ppp_t *ppp, struct ipv6db_item_t *it)
spin_unlock(&pool_lock);
}
-static struct ipv6db_prefix_t *get_dp(struct ppp_t *ppp)
+static struct ipv6db_prefix_t *get_dp(struct ap_session *ses)
{
struct dppool_item_t *it;
@@ -170,7 +170,7 @@ static struct ipv6db_prefix_t *get_dp(struct ppp_t *ppp)
return it ? &it->it : NULL;
}
-static void put_dp(struct ppp_t *ppp, struct ipv6db_prefix_t *it)
+static void put_dp(struct ap_session *ses, struct ipv6db_prefix_t *it)
{
struct dppool_item_t *pit = container_of(it, typeof(*pit), it);
diff --git a/accel-pppd/extra/logwtmp.c b/accel-pppd/extra/logwtmp.c
index 5848102e..9f31d694 100644
--- a/accel-pppd/extra/logwtmp.c
+++ b/accel-pppd/extra/logwtmp.c
@@ -14,20 +14,20 @@
#include "memdebug.h"
-static void ev_ppp_started(struct ppp_t *ppp)
+static void ev_ses_started(struct ap_session *ses)
{
- logwtmp(ppp->ifname, ppp->username, ppp->ctrl->calling_station_id);
+ logwtmp(ses->ifname, ses->username, ses->ctrl->calling_station_id);
}
-static void ev_ppp_finished(struct ppp_t *ppp)
+static void ev_ses_finished(struct ap_session *ses)
{
- logwtmp(ppp->ifname, "", "");
+ logwtmp(ses->ifname, "", "");
}
static void init(void)
{
- triton_event_register_handler(EV_PPP_STARTED, (triton_event_func)ev_ppp_started);
- triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ev_ppp_finished);
+ triton_event_register_handler(EV_SES_STARTED, (triton_event_func)ev_ses_started);
+ triton_event_register_handler(EV_SES_FINISHED, (triton_event_func)ev_ses_finished);
}
DEFINE_INIT(200, init);
diff --git a/accel-pppd/extra/net-snmp/sessionTable.h b/accel-pppd/extra/net-snmp/sessionTable.h
index f5619d98..645ddd35 100644
--- a/accel-pppd/extra/net-snmp/sessionTable.h
+++ b/accel-pppd/extra/net-snmp/sessionTable.h
@@ -75,7 +75,7 @@ typedef netsnmp_data_list sessionTable_registration;
*/
struct sessionTable_data_s
{
- char ifname[PPP_IFNAME_LEN];
+ char ifname[AP_IFNAME_LEN];
char *username;
in_addr_t peer_addr;
int type;
@@ -96,7 +96,7 @@ typedef struct sessionTable_mib_index_s {
/*
* sesSID(1)/OCTETSTR/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/h
*/
- char sesSID[PPP_SESSIONID_LEN];
+ char sesSID[AP_SESSIONID_LEN];
size_t sesSID_len;
@@ -111,7 +111,7 @@ typedef struct sessionTable_mib_index_s {
* POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX!
* Guessing 128 - col/entry(2) - oid len(10)
*/
-#define MAX_sessionTable_IDX_LEN PPP_SESSIONID_LEN + 1
+#define MAX_sessionTable_IDX_LEN AP_SESSIONID_LEN + 1
/* *********************************************************************
diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_access.c b/accel-pppd/extra/net-snmp/sessionTable_data_access.c
index 0d38e5df..4821d38d 100644
--- a/accel-pppd/extra/net-snmp/sessionTable_data_access.c
+++ b/accel-pppd/extra/net-snmp/sessionTable_data_access.c
@@ -197,23 +197,23 @@ sessionTable_container_load(netsnmp_container *container)
{
sessionTable_rowreq_ctx *rowreq_ctx;
size_t count = 0;
- struct ppp_t *ppp;
+ struct ap_session *ses;
time_t t;
time(&t);
DEBUGMSGTL(("verbose:sessionTable:sessionTable_container_load","called\n"));
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(ppp, &ppp_list, entry) {
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
rowreq_ctx = sessionTable_allocate_rowreq_ctx(NULL, NULL);
if (NULL == rowreq_ctx) {
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
snmp_log(LOG_ERR, "memory allocation failed\n");
return MFD_RESOURCE_UNAVAILABLE;
}
if(MFD_SUCCESS != sessionTable_indexes_set(rowreq_ctx
- , ppp->sessionid, PPP_SESSIONID_LEN
+ , ses->sessionid, AP_SESSIONID_LEN
)) {
snmp_log(LOG_ERR,"error setting index while loading "
"sessionTable data->\n");
@@ -221,24 +221,24 @@ sessionTable_container_load(netsnmp_container *container)
continue;
}
- strcpy(rowreq_ctx->data->ifname, ppp->ifname);
+ strcpy(rowreq_ctx->data->ifname, ses->ifname);
- if (ppp->username)
- rowreq_ctx->data->username = strdup(ppp->username);
+ if (ses->username)
+ rowreq_ctx->data->username = strdup(ses->username);
else
- ppp->username = strdup("");
+ ses->username = strdup("");
- rowreq_ctx->data->peer_addr = ppp->ipv4 ? ppp->ipv4->peer_addr : 0;
- rowreq_ctx->data->type = ppp->ctrl->type;
- rowreq_ctx->data->state = ppp->state;
- rowreq_ctx->data->uptime = (ppp->stop_time ? ppp->stop_time : t) - ppp->start_time;
- rowreq_ctx->data->calling_sid = strdup(ppp->ctrl->calling_station_id);
- rowreq_ctx->data->called_sid = strdup(ppp->ctrl->called_station_id);
+ rowreq_ctx->data->peer_addr = ses->ipv4 ? ses->ipv4->peer_addr : 0;
+ rowreq_ctx->data->type = ses->ctrl->type;
+ rowreq_ctx->data->state = ses->state;
+ rowreq_ctx->data->uptime = (ses->stop_time ? ses->stop_time : t) - ses->start_time;
+ rowreq_ctx->data->calling_sid = strdup(ses->ctrl->calling_station_id);
+ rowreq_ctx->data->called_sid = strdup(ses->ctrl->called_station_id);
CONTAINER_INSERT(container, rowreq_ctx);
++count;
}
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
DEBUGMSGT(("verbose:sessionTable:sessionTable_container_load",
"inserted %d records\n", count));
diff --git a/accel-pppd/extra/net-snmp/statPPP.c b/accel-pppd/extra/net-snmp/statPPP.c
index 7199b570..db8918b7 100644
--- a/accel-pppd/extra/net-snmp/statPPP.c
+++ b/accel-pppd/extra/net-snmp/statPPP.c
@@ -53,7 +53,7 @@ init_statPPP(void)
statPPPStarting_oid, OID_LENGTH(statPPPStarting_oid),
HANDLER_CAN_RONLY);
winfo = netsnmp_create_watcher_info(
- &ppp_stat.starting, sizeof(ppp_stat.starting),
+ &ap_session_stat.starting, sizeof(ap_session_stat.starting),
ASN_INTEGER, WATCHER_FIXED_SIZE);
if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched statPPPStarting" );
@@ -67,7 +67,7 @@ init_statPPP(void)
statPPPActive_oid, OID_LENGTH(statPPPActive_oid),
HANDLER_CAN_RONLY);
winfo = netsnmp_create_watcher_info(
- &ppp_stat.active, sizeof(ppp_stat.active),
+ &ap_session_stat.active, sizeof(ap_session_stat.active),
ASN_INTEGER, WATCHER_FIXED_SIZE);
if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched statPPPActive" );
@@ -81,7 +81,7 @@ init_statPPP(void)
statPPPFinishing_oid, OID_LENGTH(statPPPFinishing_oid),
HANDLER_CAN_RONLY);
winfo = netsnmp_create_watcher_info(
- &ppp_stat.finishing, sizeof(ppp_stat.finishing),
+ &ap_session_stat.finishing, sizeof(ap_session_stat.finishing),
ASN_INTEGER, WATCHER_FIXED_SIZE);
if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched statPPPFinishing" );
diff --git a/accel-pppd/extra/net-snmp/terminate.c b/accel-pppd/extra/net-snmp/terminate.c
index abe92df0..23d355a2 100644
--- a/accel-pppd/extra/net-snmp/terminate.c
+++ b/accel-pppd/extra/net-snmp/terminate.c
@@ -16,81 +16,81 @@
#include "terminate.h"
-static void __terminate(struct ppp_t *ppp)
+static void __terminate(struct ap_session *ses)
{
- ppp_terminate(ppp, TERM_ADMIN_RESET, 0);
+ ap_session_terminate(ses, TERM_ADMIN_RESET, 0);
}
static void terminate_by_sid(const char *val)
{
- struct ppp_t *ppp;
+ struct ap_session *ses;
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(ppp, &ppp_list, entry) {
- if (strncmp(ppp->sessionid, val, PPP_SESSIONID_LEN))
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (strncmp(ses->sessionid, val, AP_SESSIONID_LEN))
continue;
- triton_context_call(ppp->ctrl->ctx, (triton_event_func)__terminate, ppp);
+ triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate, ses);
break;
}
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
}
static void terminate_by_ifname(const char *val, size_t len)
{
- struct ppp_t *ppp;
+ struct ap_session *ses;
size_t n;
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(ppp, &ppp_list, entry) {
- n = strlen(ppp->ifname);
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ n = strlen(ses->ifname);
if (n != len)
continue;
- if (strncmp(ppp->ifname, val, len))
+ if (strncmp(ses->ifname, val, len))
continue;
- triton_context_call(ppp->ctrl->ctx, (triton_event_func)__terminate, ppp);
+ triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate, ses);
break;
}
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
}
static void terminate_by_ip(const char *val, size_t len)
{
char str[len + 1];
in_addr_t addr;
- struct ppp_t *ppp;
+ struct ap_session *ses;
strncpy(str, val, len);
str[len] = 0;
addr = inet_addr(str);
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(ppp, &ppp_list, entry) {
- if (!ppp->ipv4 || ppp->ipv4->peer_addr != addr)
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (!ses->ipv4 || ses->ipv4->peer_addr != addr)
continue;
- triton_context_call(ppp->ctrl->ctx, (triton_event_func)__terminate, ppp);
+ triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate, ses);
break;
}
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
}
static void terminate_by_username(const char *val, size_t len)
{
- struct ppp_t *ppp;
+ struct ap_session *ses;
size_t n;
- pthread_rwlock_rdlock(&ppp_lock);
- list_for_each_entry(ppp, &ppp_list, entry) {
- if (!ppp->username)
+ pthread_rwlock_rdlock(&ses_lock);
+ list_for_each_entry(ses, &ses_list, entry) {
+ if (!ses->username)
continue;
- n = strlen(ppp->username);
+ n = strlen(ses->username);
if (n != len)
continue;
- if (strncmp(ppp->username, val, len))
+ if (strncmp(ses->username, val, len))
continue;
- triton_context_call(ppp->ctrl->ctx, (triton_event_func)__terminate, ppp);
+ triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate, ses);
}
- pthread_rwlock_unlock(&ppp_lock);
+ pthread_rwlock_unlock(&ses_lock);
}
@@ -154,7 +154,7 @@ handle_termBySID(netsnmp_mib_handler *handler,
*/
case MODE_SET_RESERVE1:
/* or you could use netsnmp_check_vb_type_and_size instead */
- ret = netsnmp_check_vb_type_and_size(requests->requestvb, ASN_OCTET_STR, PPP_SESSIONID_LEN);
+ ret = netsnmp_check_vb_type_and_size(requests->requestvb, ASN_OCTET_STR, AP_SESSIONID_LEN);
if ( ret != SNMP_ERR_NOERROR ) {
netsnmp_set_request_error(reqinfo, requests, ret );
}
diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c
index d89a6a6a..4ed7824e 100644
--- a/accel-pppd/extra/pppd_compat.c
+++ b/accel-pppd/extra/pppd_compat.c
@@ -36,8 +36,8 @@ static void *pd_key;
struct pppd_compat_pd_t
{
- struct ppp_pd_t pd;
- struct ppp_t *ppp;
+ struct ap_private pd;
+ struct ap_session *ses;
struct sigchld_handler_t ip_pre_up_hnd;
struct sigchld_handler_t ip_up_hnd;
struct sigchld_handler_t ip_change_hnd;
@@ -53,31 +53,31 @@ struct pppd_compat_pd_t
in_addr_t ipv4_peer_addr;
};
-static struct pppd_compat_pd_t *find_pd(struct ppp_t *ppp);
+static struct pppd_compat_pd_t *find_pd(struct ap_session *ses);
static void fill_argv(char **argv, struct pppd_compat_pd_t *pd, char *path);
static void fill_env(char **env, struct pppd_compat_pd_t *pd);
#ifdef RADIUS
-static void remove_radattr(struct ppp_t *ppp);
-static void write_radattr(struct ppp_t *ppp, struct rad_packet_t *pack, int save_old);
+static void remove_radattr(struct ap_session *ses);
+static void write_radattr(struct ap_session *ses, struct rad_packet_t *pack, int save_old);
#endif
static void ip_pre_up_handler(struct sigchld_handler_t *h, int status)
{
struct pppd_compat_pd_t *pd = container_of(h, typeof(*pd), ip_pre_up_hnd);
if (conf_verbose) {
- log_switch(NULL, pd->ppp);
+ log_switch(NULL, pd->ses);
log_ppp_info2("pppd_compat: ip-pre-up finished (%i)\n", status);
}
sched_yield();
pd->res = status;
- triton_context_wakeup(pd->ppp->ctrl->ctx);
+ triton_context_wakeup(pd->ses->ctrl->ctx);
}
static void ip_up_handler(struct sigchld_handler_t *h, int status)
{
struct pppd_compat_pd_t *pd = container_of(h, typeof(*pd), ip_up_hnd);
if (conf_verbose) {
- log_switch(NULL, pd->ppp);
+ log_switch(NULL, pd->ses);
log_ppp_info2("pppd_compat: ip-up finished (%i)\n", status);
}
}
@@ -86,26 +86,26 @@ static void ip_down_handler(struct sigchld_handler_t *h, int status)
{
struct pppd_compat_pd_t *pd = container_of(h, typeof(*pd), ip_down_hnd);
if (conf_verbose) {
- log_switch(NULL, pd->ppp);
+ log_switch(NULL, pd->ses);
log_ppp_info2("pppd_compat: ip-down finished (%i)\n", status);
}
sched_yield();
- triton_context_wakeup(pd->ppp->ctrl->ctx);
+ triton_context_wakeup(pd->ses->ctrl->ctx);
}
static void ip_change_handler(struct sigchld_handler_t *h, int status)
{
struct pppd_compat_pd_t *pd = container_of(h, typeof(*pd), ip_change_hnd);
if (conf_verbose) {
- log_switch(NULL, pd->ppp);
+ log_switch(NULL, pd->ses);
log_ppp_info2("pppd_compat: ip-change finished (%i)\n", status);
}
sched_yield();
pd->res = status;
- triton_context_wakeup(pd->ppp->ctrl->ctx);
+ triton_context_wakeup(pd->ses->ctrl->ctx);
}
-static void ev_ppp_starting(struct ppp_t *ppp)
+static void ev_ses_starting(struct ap_session *ses)
{
struct pppd_compat_pd_t *pd = _malloc(sizeof(*pd));
@@ -116,15 +116,15 @@ static void ev_ppp_starting(struct ppp_t *ppp)
memset(pd, 0, sizeof(*pd));
pd->pd.key = &pd_key;
- pd->ppp = ppp;
+ pd->ses = ses;
pd->ip_pre_up_hnd.handler = ip_pre_up_handler;
pd->ip_up_hnd.handler = ip_up_handler;
pd->ip_down_hnd.handler = ip_down_handler;
pd->ip_change_hnd.handler = ip_change_handler;
- list_add_tail(&pd->pd.entry, &ppp->pd_list);
+ list_add_tail(&pd->pd.entry, &ses->pd_list);
}
-static void ev_ppp_pre_up(struct ppp_t *ppp)
+static void ev_ses_pre_up(struct ap_session *ses)
{
pid_t pid;
char *argv[8];
@@ -132,14 +132,14 @@ static void ev_ppp_pre_up(struct ppp_t *ppp)
char ipaddr[17];
char peer_ipaddr[17];
char peername[64];
- struct pppd_compat_pd_t *pd = find_pd(ppp);
+ struct pppd_compat_pd_t *pd = find_pd(ses);
if (!pd)
return;
- if (ppp->ipv4) {
- pd->ipv4_addr = ppp->ipv4->addr;
- pd->ipv4_peer_addr = ppp->ipv4->peer_addr;
+ if (ses->ipv4) {
+ pd->ipv4_addr = ses->ipv4->addr;
+ pd->ipv4_peer_addr = ses->ipv4->peer_addr;
}
argv[4] = ipaddr;
@@ -163,7 +163,7 @@ static void ev_ppp_pre_up(struct ppp_t *ppp)
pthread_mutex_lock(&pd->ip_pre_up_hnd.lock);
pthread_mutex_unlock(&pd->ip_pre_up_hnd.lock);
if (pd->res != 0) {
- ppp_terminate(ppp, pd->res > 127 ? TERM_NAS_ERROR : TERM_ADMIN_RESET, 0);
+ ap_session_terminate(ses, pd->res > 127 ? TERM_NAS_ERROR : TERM_ADMIN_RESET, 0);
return;
}
} else if (pid == 0) {
@@ -179,7 +179,7 @@ static void ev_ppp_pre_up(struct ppp_t *ppp)
}
}
-static void ev_ppp_started(struct ppp_t *ppp)
+static void ev_ses_started(struct ap_session *ses)
{
pid_t pid;
char *argv[8];
@@ -187,7 +187,7 @@ static void ev_ppp_started(struct ppp_t *ppp)
char ipaddr[17];
char peer_ipaddr[17];
char peername[64];
- struct pppd_compat_pd_t *pd = find_pd(ppp);
+ struct pppd_compat_pd_t *pd = find_pd(ses);
if (!pd)
return;
@@ -224,17 +224,17 @@ static void ev_ppp_started(struct ppp_t *ppp)
pd->started = 1;
}
-static void ev_ppp_finishing(struct ppp_t *ppp)
+static void ev_ses_finishing(struct ap_session *ses)
{
struct ifpppstatsreq ifreq;
- struct pppd_compat_pd_t *pd = find_pd(ppp);
+ struct pppd_compat_pd_t *pd = find_pd(ses);
if (!pd)
return;
memset(&ifreq, 0, sizeof(ifreq));
ifreq.stats_ptr = (void *)&ifreq.stats;
- strcpy(ifreq.ifr__name, ppp->ifname);
+ strcpy(ifreq.ifr__name, ses->ifname);
if (ioctl(sock_fd, SIOCGPPPSTATS, &ifreq)) {
log_ppp_error("pppd_compat: failed to get ppp statistics: %s\n", strerror(errno));
@@ -245,7 +245,7 @@ static void ev_ppp_finishing(struct ppp_t *ppp)
pd->bytes_rcvd = ifreq.stats.p.ppp_ibytes;
}
-static void ev_ppp_finished(struct ppp_t *ppp)
+static void ev_ses_finished(struct ap_session *ses)
{
pid_t pid;
char *argv[8];
@@ -256,7 +256,7 @@ static void ev_ppp_finished(struct ppp_t *ppp)
char connect_time[24];
char bytes_sent[24];
char bytes_rcvd[24];
- struct pppd_compat_pd_t *pd = find_pd(ppp);
+ struct pppd_compat_pd_t *pd = find_pd(ses);
if (!pd)
return;
@@ -319,7 +319,7 @@ static void ev_ppp_finished(struct ppp_t *ppp)
skip:
#ifdef RADIUS
if (pd->radattr_saved)
- remove_radattr(ppp);
+ remove_radattr(ses);
#endif
list_del(&pd->pd.entry);
@@ -329,9 +329,9 @@ skip:
#ifdef RADIUS
static void ev_radius_access_accept(struct ev_radius_t *ev)
{
- struct pppd_compat_pd_t *pd = find_pd(ev->ppp);
+ struct pppd_compat_pd_t *pd = find_pd(ev->ses);
- write_radattr(ev->ppp, ev->reply, 0);
+ write_radattr(ev->ses, ev->reply, 0);
pd->radattr_saved = 1;
}
@@ -344,12 +344,12 @@ static void ev_radius_coa(struct ev_radius_t *ev)
char ipaddr[17];
char peer_ipaddr[17];
char peername[64];
- struct pppd_compat_pd_t *pd = find_pd(ev->ppp);
+ struct pppd_compat_pd_t *pd = find_pd(ev->ses);
if (!pd)
return;
- write_radattr(ev->ppp, ev->request, 1);
+ write_radattr(ev->ses, ev->request, 1);
argv[4] = ipaddr;
argv[5] = peer_ipaddr;
@@ -378,7 +378,7 @@ static void ev_radius_coa(struct ev_radius_t *ev)
log_error("pppd_compat: fork: %s\n", strerror(errno));
}
-static void remove_radattr(struct ppp_t *ppp)
+static void remove_radattr(struct ap_session *ses)
{
char *fname;
@@ -388,17 +388,17 @@ static void remove_radattr(struct ppp_t *ppp)
return;
}
- sprintf(fname, "%s.%s", conf_radattr_prefix, ppp->ifname);
+ sprintf(fname, "%s.%s", conf_radattr_prefix, ses->ifname);
if (unlink(fname)) {
log_ppp_warn("pppd_compat: failed to remove '%s': %s\n", fname, strerror(errno));
}
- sprintf(fname, "%s_old.%s", conf_radattr_prefix, ppp->ifname);
+ sprintf(fname, "%s_old.%s", conf_radattr_prefix, ses->ifname);
unlink(fname);
_free(fname);
}
-static void write_radattr(struct ppp_t *ppp, struct rad_packet_t *pack, int save_old)
+static void write_radattr(struct ap_session *ses, struct rad_packet_t *pack, int save_old)
{
struct rad_attr_t *attr;
struct rad_dict_value_t *val;
@@ -421,9 +421,9 @@ static void write_radattr(struct ppp_t *ppp, struct rad_packet_t *pack, int save
}
}
- sprintf(fname1, "%s.%s", conf_radattr_prefix, ppp->ifname);
+ sprintf(fname1, "%s.%s", conf_radattr_prefix, ses->ifname);
if (save_old) {
- sprintf(fname2, "%s_old.%s", conf_radattr_prefix, ppp->ifname);
+ sprintf(fname2, "%s_old.%s", conf_radattr_prefix, ses->ifname);
if (rename(fname1, fname2)) {
log_ppp_warn("pppd_compat: rename: %s\n", strerror(errno));
}
@@ -467,12 +467,12 @@ static void write_radattr(struct ppp_t *ppp, struct rad_packet_t *pack, int save
}
#endif
-static struct pppd_compat_pd_t *find_pd(struct ppp_t *ppp)
+static struct pppd_compat_pd_t *find_pd(struct ap_session *ses)
{
- struct ppp_pd_t *pd;
+ struct ap_private *pd;
struct pppd_compat_pd_t *cpd;
- list_for_each_entry(pd, &ppp->pd_list, entry) {
+ list_for_each_entry(pd, &ses->pd_list, entry) {
if (pd->key == &pd_key) {
cpd = container_of(pd, typeof(*cpd), pd);
return cpd;
@@ -486,21 +486,21 @@ static struct pppd_compat_pd_t *find_pd(struct ppp_t *ppp)
static void fill_argv(char **argv, struct pppd_compat_pd_t *pd, char *path)
{
argv[0] = path;
- argv[1] = pd->ppp->ifname;
+ argv[1] = pd->ses->ifname;
argv[2] = "none";
argv[3] = "0";
u_inet_ntoa(pd->ipv4_addr, argv[4]);
u_inet_ntoa(pd->ipv4_peer_addr, argv[5]);
- argv[6] = pd->ppp->ctrl->calling_station_id;
+ argv[6] = pd->ses->ctrl->calling_station_id;
argv[7] = NULL;
}
static void fill_env(char **env, struct pppd_compat_pd_t *pd)
{
- snprintf(env[0], 64, "PEERNAME=%s", pd->ppp->username);
+ snprintf(env[0], 64, "PEERNAME=%s", pd->ses->username);
- if (pd->ppp->stop_time && env[1]) {
- snprintf(env[1], 24, "CONNECT_TIME=%lu", pd->ppp->stop_time - pd->ppp->start_time);
+ if (pd->ses->stop_time && env[1]) {
+ snprintf(env[1], 24, "CONNECT_TIME=%lu", pd->ses->stop_time - pd->ses->start_time);
snprintf(env[2], 24, "BYTES_SENT=%u", pd->bytes_sent);
snprintf(env[3], 24, "BYTES_RCVD=%u", pd->bytes_rcvd);
}
@@ -534,11 +534,11 @@ static void init(void)
if (opt && atoi(opt) > 0)
conf_verbose = 1;
- triton_event_register_handler(EV_PPP_STARTING, (triton_event_func)ev_ppp_starting);
- triton_event_register_handler(EV_PPP_PRE_UP, (triton_event_func)ev_ppp_pre_up);
- triton_event_register_handler(EV_PPP_STARTED, (triton_event_func)ev_ppp_started);
- triton_event_register_handler(EV_PPP_FINISHING, (triton_event_func)ev_ppp_finishing);
- triton_event_register_handler(EV_PPP_PRE_FINISHED, (triton_event_func)ev_ppp_finished);
+ triton_event_register_handler(EV_SES_STARTING, (triton_event_func)ev_ses_starting);
+ triton_event_register_handler(EV_SES_PRE_UP, (triton_event_func)ev_ses_pre_up);
+ triton_event_register_handler(EV_SES_STARTED, (triton_event_func)ev_ses_started);
+ triton_event_register_handler(EV_SES_FINISHING, (triton_event_func)ev_ses_finishing);
+ triton_event_register_handler(EV_SES_PRE_FINISHED, (triton_event_func)ev_ses_finished);
#ifdef RADIUS
if (triton_module_loaded("radius")) {
triton_event_register_handler(EV_RADIUS_ACCESS_ACCEPT, (triton_event_func)ev_radius_access_accept);
diff --git a/accel-pppd/extra/shaper_tbf.c b/accel-pppd/extra/shaper_tbf.c
index 718a5c58..7c16475d 100644
--- a/accel-pppd/extra/shaper_tbf.c
+++ b/accel-pppd/extra/shaper_tbf.c
@@ -58,7 +58,7 @@ struct shaper_pd_t
{
struct list_head entry;
struct ppp_t *ppp;
- struct ppp_pd_t pd;
+ struct ap_private pd;
int temp_down_speed;
int temp_up_speed;
int down_speed;
@@ -427,7 +427,7 @@ out:
static struct shaper_pd_t *find_pd(struct ppp_t *ppp, int create)
{
- struct ppp_pd_t *pd;
+ struct ap_private *pd;
struct shaper_pd_t *spd;
list_for_each_entry(pd, &ppp->pd_list, entry) {
@@ -732,7 +732,7 @@ static void ev_radius_access_accept(struct ev_radius_t *ev)
}
if (down_speed > 0 && up_speed > 0) {
- if (!install_shaper(ev->ppp->ifname, down_speed, down_burst, up_speed, up_burst)) {
+ if (!install_shaper(ev->ppp->ses.ifname, down_speed, down_burst, up_speed, up_burst)) {
if (conf_verbose)
log_ppp_info2("tbf: installed shaper %i/%i (Kbit)\n", down_speed, up_speed);
}
@@ -760,7 +760,7 @@ static void ev_radius_coa(struct ev_radius_t *ev)
pd->up_speed = 0;
if (conf_verbose)
log_ppp_info2("tbf: removed shaper\n");
- remove_shaper(ev->ppp->ifname);
+ remove_shaper(ev->ppp->ses.ifname);
}
return;
}
@@ -769,13 +769,13 @@ static void ev_radius_coa(struct ev_radius_t *ev)
pd->down_speed = pd->cur_tr->down_speed;
pd->up_speed = pd->cur_tr->up_speed;
- if (remove_shaper(ev->ppp->ifname)) {
+ if (remove_shaper(ev->ppp->ses.ifname)) {
ev->res = -1;
return;
}
if (pd->down_speed > 0 || pd->up_speed > 0) {
- if (install_shaper(ev->ppp->ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst)) {
+ if (install_shaper(ev->ppp->ses.ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst)) {
ev->res= -1;
return;
} else {
@@ -827,7 +827,7 @@ static void ev_shaper(struct ev_shaper_t *ev)
}
if (pd->down_speed > 0 && pd->up_speed > 0) {
- if (!install_shaper(ev->ppp->ifname, down_speed, down_burst, up_speed, up_burst)) {
+ if (!install_shaper(ev->ppp->ses.ifname, down_speed, down_burst, up_speed, up_burst)) {
if (conf_verbose)
log_ppp_info2("tbf: installed shaper %i/%i (Kbit)\n", down_speed, up_speed);
}
@@ -845,7 +845,7 @@ static void ev_ppp_pre_up(struct ppp_t *ppp)
pd->temp_up_speed = temp_up_speed;
pd->down_speed = temp_down_speed;
pd->up_speed = temp_up_speed;
- if (!install_shaper(ppp->ifname, temp_down_speed, 0, temp_up_speed, 0)) {
+ if (!install_shaper(ppp->ses.ifname, temp_down_speed, 0, temp_up_speed, 0)) {
if (conf_verbose)
log_ppp_info2("tbf: installed shaper %i/%i (Kbit)\n", temp_down_speed, temp_up_speed);
}
@@ -875,16 +875,16 @@ static void shaper_change_help(char * const *f, int f_cnt, void *cli)
static void shaper_change(struct shaper_pd_t *pd)
{
if (pd->down_speed || pd->up_speed)
- remove_shaper(pd->ppp->ifname);
+ remove_shaper(pd->ppp->ses.ifname);
if (pd->temp_down_speed || pd->temp_up_speed) {
pd->down_speed = pd->temp_down_speed;
pd->up_speed = pd->temp_up_speed;
- install_shaper(pd->ppp->ifname, pd->temp_down_speed, 0, pd->temp_up_speed, 0);
+ install_shaper(pd->ppp->ses.ifname, pd->temp_down_speed, 0, pd->temp_up_speed, 0);
} else if (pd->cur_tr->down_speed || pd->cur_tr->up_speed) {
pd->down_speed = pd->cur_tr->down_speed;
pd->up_speed = pd->cur_tr->up_speed;
- install_shaper(pd->ppp->ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst);
+ install_shaper(pd->ppp->ses.ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst);
}
}
@@ -921,7 +921,7 @@ static int shaper_change_exec(const char *cmd, char * const *f, int f_cnt, void
pthread_rwlock_rdlock(&shaper_lock);
list_for_each_entry(pd, &shaper_list, entry) {
- if (all || !strcmp(f[2], pd->ppp->ifname)) {
+ if (all || !strcmp(f[2], pd->ppp->ses.ifname)) {
if (temp) {
pd->temp_down_speed = down_speed;
pd->temp_up_speed = up_speed;
@@ -935,7 +935,7 @@ static int shaper_change_exec(const char *cmd, char * const *f, int f_cnt, void
pd->cur_tr->up_speed = up_speed;
pd->cur_tr->up_burst = up_burst;
}
- triton_context_call(pd->ppp->ctrl->ctx, (triton_event_func)shaper_change, pd);
+ triton_context_call(pd->ppp->ses.ctrl->ctx, (triton_event_func)shaper_change, pd);
if (!all) {
found = 1;
break;
@@ -958,12 +958,12 @@ static void shaper_restore_help(char * const *f, int f_cnt, void *cli)
static void shaper_restore(struct shaper_pd_t *pd)
{
- remove_shaper(pd->ppp->ifname);
+ remove_shaper(pd->ppp->ses.ifname);
if (pd->cur_tr) {
pd->down_speed = pd->cur_tr->down_speed;
pd->up_speed = pd->cur_tr->up_speed;
- install_shaper(pd->ppp->ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst);
+ install_shaper(pd->ppp->ses.ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst);
} else {
pd->down_speed = 0;
pd->up_speed = 0;
@@ -991,10 +991,10 @@ static int shaper_restore_exec(const char *cmd, char * const *f, int f_cnt, void
list_for_each_entry(pd, &shaper_list, entry) {
if (!pd->temp_down_speed)
continue;
- if (all || !strcmp(f[2], pd->ppp->ifname)) {
+ if (all || !strcmp(f[2], pd->ppp->ses.ifname)) {
pd->temp_down_speed = 0;
pd->temp_up_speed = 0;
- triton_context_call(pd->ppp->ctrl->ctx, (triton_event_func)shaper_restore, pd);
+ triton_context_call(pd->ppp->ses.ctrl->ctx, (triton_event_func)shaper_restore, pd);
if (!all) {
found = 1;
break;
@@ -1056,13 +1056,13 @@ static void update_shaper_tr(struct shaper_pd_t *pd)
if (pd->down_speed || pd->up_speed) {
if (pd->cur_tr && pd->down_speed == pd->cur_tr->down_speed && pd->up_speed == pd->cur_tr->up_speed)
return;
- remove_shaper(pd->ppp->ifname);
+ remove_shaper(pd->ppp->ses.ifname);
}
if (pd->cur_tr && (pd->cur_tr->down_speed || pd->cur_tr->up_speed)) {
pd->down_speed = pd->cur_tr->down_speed;
pd->up_speed = pd->cur_tr->up_speed;
- if (!install_shaper(pd->ppp->ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst)) {
+ if (!install_shaper(pd->ppp->ses.ifname, pd->cur_tr->down_speed, pd->cur_tr->down_burst, pd->cur_tr->up_speed, pd->cur_tr->up_burst)) {
if (conf_verbose)
log_ppp_info2("tbf: changed shaper %i/%i (Kbit)\n", pd->cur_tr->down_speed, pd->cur_tr->up_speed);
}
@@ -1082,7 +1082,7 @@ static void time_range_begin_timer(struct triton_timer_t *t)
pthread_rwlock_rdlock(&shaper_lock);
list_for_each_entry(pd, &shaper_list, entry)
- triton_context_call(pd->ppp->ctrl->ctx, (triton_event_func)update_shaper_tr, pd);
+ triton_context_call(pd->ppp->ses.ctrl->ctx, (triton_event_func)update_shaper_tr, pd);
pthread_rwlock_unlock(&shaper_lock);
}
@@ -1096,7 +1096,7 @@ static void time_range_end_timer(struct triton_timer_t *t)
pthread_rwlock_rdlock(&shaper_lock);
list_for_each_entry(pd, &shaper_list, entry)
- triton_context_call(pd->ppp->ctrl->ctx, (triton_event_func)update_shaper_tr, pd);
+ triton_context_call(pd->ppp->ses.ctrl->ctx, (triton_event_func)update_shaper_tr, pd);
pthread_rwlock_unlock(&shaper_lock);
}
@@ -1336,7 +1336,7 @@ static void init(void)
triton_event_register_handler(EV_RADIUS_COA, (triton_event_func)ev_radius_coa);
}
#endif
- triton_event_register_handler(EV_PPP_PRE_UP, (triton_event_func)ev_ppp_pre_up);
+ triton_event_register_handler(EV_SES_PRE_UP, (triton_event_func)ev_ppp_pre_up);
triton_event_register_handler(EV_CTRL_FINISHED, (triton_event_func)ev_ctrl_finished);
triton_event_register_handler(EV_SHAPER, (triton_event_func)ev_shaper);
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);