diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-06-19 19:06:06 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-06-19 19:06:06 +0400 |
commit | 02b3fb2b24aacd90d535c2136a055f529d722974 (patch) | |
tree | 6243dd815869add07be2bad5846e7817b732ac59 /accel-pppd/extra/net-snmp | |
parent | c553a7bbbc96d36ba4d0999bb172c7a926518eb1 (diff) | |
download | accel-ppp-02b3fb2b24aacd90d535c2136a055f529d722974.tar.gz accel-ppp-02b3fb2b24aacd90d535c2136a055f529d722974.zip |
general preparation for IPoE integration
Diffstat (limited to 'accel-pppd/extra/net-snmp')
-rw-r--r-- | accel-pppd/extra/net-snmp/sessionTable.h | 6 | ||||
-rw-r--r-- | accel-pppd/extra/net-snmp/sessionTable_data_access.c | 32 | ||||
-rw-r--r-- | accel-pppd/extra/net-snmp/statPPP.c | 6 | ||||
-rw-r--r-- | accel-pppd/extra/net-snmp/terminate.c | 60 |
4 files changed, 52 insertions, 52 deletions
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 ); } |