diff options
25 files changed, 617 insertions, 118 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c9872890..93889cd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ IF (EXISTS ${CMAKE_HOME_DIRECTORY}/.git AND NOT IGNORE_GIT) ) STRING(STRIP ${ACCEL_PPP_VERSION} ACCEL_PPP_VERSION) ELSE (EXISTS ${CMAKE_HOME_DIRECTORY}/.git AND NOT IGNORE_GIT) - SET (ACCEL_PPP_VERSION 1.9.0) + SET (ACCEL_PPP_VERSION 1.10.0) ENDIF (EXISTS ${CMAKE_HOME_DIRECTORY}/.git AND NOT IGNORE_GIT) ADD_DEFINITIONS(-DACCEL_PPP_VERSION="${ACCEL_PPP_VERSION}") diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h index b02b2bb2..ef74d334 100644 --- a/accel-pppd/cli/cli.h +++ b/accel-pppd/cli/cli.h @@ -42,7 +42,7 @@ void cli_register_simple_cmd2( ... ); void cli_register_regexp_cmd(struct cli_regexp_cmd_t *cmd); -void cli_show_ses_register(const char *name, const char *desc, void (*print)(const struct ap_session *ses, char *buf)); +void cli_show_ses_register(const char *name, const char *desc, void (*print)(struct ap_session *ses, char *buf)); int cli_send(void *client, const char *data); int cli_sendv(void *client, const char *fmt, ...) __attribute__((format(gnu_printf, 2, 3))); diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index 6a6732b3..fd2f2b43 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -4,6 +4,7 @@ #include <unistd.h> #include <signal.h> #include <arpa/inet.h> +#include <linux/if_link.h> #include "triton.h" #include "events.h" @@ -22,7 +23,7 @@ struct column_t struct list_head entry; const char *name; const char *desc; - void (*print)(const struct ap_session *ses, char *buf); + void (*print)(struct ap_session *ses, char *buf); }; struct col_t @@ -51,7 +52,10 @@ struct cell_t static LIST_HEAD(col_list); static char *conf_def_columns = NULL; -void __export cli_show_ses_register(const char *name, const char *desc, void (*print)(const struct ap_session *ses, char *buf)) +static __thread struct rtnl_link_stats stats; +static __thread int stats_set; + +void __export cli_show_ses_register(const char *name, const char *desc, void (*print)(struct ap_session *ses, char *buf)) { struct column_t *c = malloc(sizeof(*c)); c->name = name; @@ -224,6 +228,7 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) pthread_rwlock_rdlock(&ses_lock); list_for_each_entry(ses, &ses_list, entry) { + stats_set = 0; row = _malloc(sizeof(*row)); if (!row) goto oom; @@ -374,12 +379,12 @@ early_out: goto out; } -static void print_ifname(const struct ap_session *ses, char *buf) +static void print_ifname(struct ap_session *ses, char *buf) { snprintf(buf, CELL_SIZE, "%s", ses->ifname); } -static void print_username(const struct ap_session *ses, char *buf) +static void print_username(struct ap_session *ses, char *buf) { if (ses->username) snprintf(buf, CELL_SIZE, "%s", ses->username); @@ -387,17 +392,17 @@ static void print_username(const struct ap_session *ses, char *buf) *buf = 0; } -static void print_ip(const struct ap_session *ses, char *buf) +static void print_ip(struct ap_session *ses, char *buf) { u_inet_ntoa(ses->ipv4 ? ses->ipv4->peer_addr : 0, buf); } -static void print_type(const struct ap_session *ses, char *buf) +static void print_type(struct ap_session *ses, char *buf) { snprintf(buf, CELL_SIZE, "%s", ses->ctrl->name); } -static void print_state(const struct ap_session *ses, char *buf) +static void print_state(struct ap_session *ses, char *buf) { char *state; switch (ses->state) { @@ -416,7 +421,7 @@ static void print_state(const struct ap_session *ses, char *buf) sprintf(buf, "%s", state); } -static void print_uptime(const struct ap_session *ses, char *buf) +static void print_uptime(struct ap_session *ses, char *buf) { time_t uptime; int day,hour,min,sec; @@ -441,22 +446,22 @@ static void print_uptime(const struct ap_session *ses, char *buf) sprintf(buf, "%s", time_str); } -static void print_calling_sid(const struct ap_session *ses, char *buf) +static void print_calling_sid(struct ap_session *ses, char *buf) { snprintf(buf, CELL_SIZE, "%s", ses->ctrl->calling_station_id); } -static void print_called_sid(const struct ap_session *ses, char *buf) +static void print_called_sid(struct ap_session *ses, char *buf) { snprintf(buf, CELL_SIZE, "%s", ses->ctrl->called_station_id); } -static void print_sid(const struct ap_session *ses, char *buf) +static void print_sid(struct ap_session *ses, char *buf) { snprintf(buf, CELL_SIZE, "%s", ses->sessionid); } -static void print_comp(const struct ap_session *ses, char *buf) +static void print_comp(struct ap_session *ses, char *buf) { if (ses->comp) snprintf(buf, CELL_SIZE, "%s", ses->comp); @@ -464,6 +469,86 @@ static void print_comp(const struct ap_session *ses, char *buf) buf[0] = 0; } +static void format_bytes(char *buf, unsigned long long bytes) +{ + const char *suffix; + unsigned int m; + double d; + + if (bytes < 1024) { + sprintf(buf, "%u B", (unsigned)bytes); + return; + } + + if (bytes < 1024*1024) { + suffix = "KiB"; + m = 1024; + } else if (bytes < 1024*1024*1024) { + suffix = "MiB"; + m = 1024*1024; + } else { + suffix = "GiB"; + m = 1024*1024*1024; + } + + d = (double)bytes/m; + sprintf(buf, "%.1f %s", d, suffix); +} + +static void print_rx_bytes(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + format_bytes(buf, 4294967296ll*ses->acct_input_gigawords + stats.rx_bytes); +} + +static void print_tx_bytes(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + format_bytes(buf, 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes); +} + +static void print_rx_bytes_raw(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + sprintf(buf, "%llu", 4294967296ll*ses->acct_input_gigawords + stats.rx_bytes); +} + +static void print_tx_bytes_raw(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + sprintf(buf, "%llu", 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes); +} + +static void print_rx_pkts(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + sprintf(buf, "%u", stats.rx_packets); +} + +static void print_tx_pkts(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + sprintf(buf, "%u", stats.tx_packets); +} + static void load_config(void *data) { const char *opt = NULL; @@ -501,6 +586,12 @@ static void init(void) cli_show_ses_register("called-sid", "called station id", print_called_sid); cli_show_ses_register("sid", "session id", print_sid); cli_show_ses_register("comp", "compression/ecnryption method", print_comp); + cli_show_ses_register("rx-bytes", "received bytes (human readable)", print_rx_bytes); + cli_show_ses_register("tx-bytes", "transmitted bytes (human readable)", print_tx_bytes); + cli_show_ses_register("rx-bytes-raw", "received bytes", print_rx_bytes_raw); + cli_show_ses_register("tx-bytes-raw", "transmitted bytes", print_tx_bytes_raw); + cli_show_ses_register("rx-pkts", "received packets", print_rx_pkts); + cli_show_ses_register("tx-pkts", "transmitted packets", print_tx_pkts); triton_event_register_handler(EV_CONFIG_RELOAD, load_config); } diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index 94d39175..6d0d1c9c 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.c +++ b/accel-pppd/ctrl/ipoe/dhcpv4.c @@ -692,6 +692,17 @@ int dhcpv4_packet_add_opt(struct dhcpv4_packet *pack, int type, const void *data return 0; } +static inline int dhcpv4_packet_add_opt_u8(struct dhcpv4_packet *pack, int type, uint8_t val) +{ + return dhcpv4_packet_add_opt(pack, type, &val, 1); +} + +static inline int dhcpv4_packet_add_opt_u32(struct dhcpv4_packet *pack, int type, uint32_t val) +{ + val = htonl(val); + return dhcpv4_packet_add_opt(pack, type, &val, 4); +} + int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_packet *req, uint32_t yiaddr, uint32_t siaddr, uint32_t router, uint32_t mask, int lease_time, int renew_time, struct dhcpv4_packet *relay) { struct dhcpv4_packet *pack; @@ -720,19 +731,17 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack pack->hdr->siaddr = 0; pack->hdr->giaddr = req->hdr->giaddr; - if (dhcpv4_packet_add_opt(pack, 53, &msg_type, 1)) + if (dhcpv4_packet_add_opt_u8(pack, 53, msg_type)) goto out_err; if (dhcpv4_packet_add_opt(pack, 54, &siaddr, 4)) goto out_err; - val = ntohl(lease_time); - if (dhcpv4_packet_add_opt(pack, 51, &val, 4)) + if (dhcpv4_packet_add_opt_u32(pack, 51, lease_time)) goto out_err; - val = ntohl(renew_time); - if (val > 0){ - if (dhcpv4_packet_add_opt(pack, 58, &val, 4)) + if (renew_time) { + if (dhcpv4_packet_add_opt_u32(pack, 58, renew_time)) goto out_err; } diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 14bda1f5..05a9ff53 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -367,7 +367,7 @@ static char *ipoe_session_get_username(struct ipoe_session *ses) if (!ses->dhcpv4_request) return _strdup(ses->ctrl.calling_station_id); - return _strdup(ses->ses.ifname); + return _strdup(ses->serv->ifname); } static void l4_redirect_list_add(in_addr_t addr) @@ -610,8 +610,6 @@ static void ipoe_session_start(struct ipoe_session *ses) assert(!ses->ses.username); - strncpy(ses->ses.ifname, ses->serv->ifname, AP_IFNAME_LEN); - username = ipoe_session_get_username(ses); if (!username) { @@ -958,7 +956,7 @@ static void __ipoe_session_activate(struct ipoe_session *ses) ses->timer.expire = ipoe_session_timeout; ses->timer.period = 0; - ses->timer.expire_tv.tv_sec = conf_lease_timeout ? conf_lease_timeout : ses->lease_time; + ses->timer.expire_tv.tv_sec = ses->lease_time; if (ses->timer.tpd) triton_timer_mod(&ses->timer, 0); } @@ -1202,7 +1200,9 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s ses->serv = serv; ses->dhcpv4_request = pack; - strncpy(ses->ses.ifname, serv->ifname, AP_IFNAME_LEN); + + if (!serv->opt_shared) + strncpy(ses->ses.ifname, serv->ifname, AP_IFNAME_LEN); ses->xid = pack->hdr->xid; memcpy(ses->hwaddr, pack->hdr->chaddr, 6); @@ -1815,6 +1815,9 @@ static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struc ses->yiaddr = iph->saddr; ses->UP = 1; + if (!serv->opt_shared) + strncpy(ses->ses.ifname, serv->ifname, AP_IFNAME_LEN); + ses->ctrl.called_station_id = _strdup(serv->ifname); if (conf_calling_sid == SID_MAC) { @@ -1920,6 +1923,7 @@ static void ev_radius_access_accept(struct ev_radius_t *ev) { struct ipoe_session *ses = container_of(ev->ses, typeof(*ses), ses); struct rad_attr_t *attr; + int lease_time_set = 0, renew_time_set = 0; if (ev->ses->ctrl->type != CTRL_TYPE_IPOE) return; @@ -1949,17 +1953,26 @@ static void ev_radius_access_accept(struct ev_radius_t *ev) ses->l4_redirect = 1; } else if (attr->val.integer != 0) ses->l4_redirect = 1; - } else if (attr->attr->id == conf_attr_dhcp_lease_time) + } else if (attr->attr->id == conf_attr_dhcp_lease_time) { ses->lease_time = attr->val.integer; - else if (attr->attr->id == conf_attr_dhcp_renew_time) + lease_time_set = 1; + } else if (attr->attr->id == conf_attr_dhcp_renew_time) { ses->renew_time = attr->val.integer; - else if (attr->attr->id == conf_attr_l4_redirect_table) + renew_time_set = 1; + } else if (attr->attr->id == conf_attr_l4_redirect_table) ses->l4_redirect_table = attr->val.integer; else if (attr->attr->id == conf_attr_l4_redirect_ipset) { if (attr->attr->type == ATTR_TYPE_STRING) ses->l4_redirect_ipset = _strdup(attr->val.string); } } + + if (lease_time_set && !renew_time_set) + ses->renew_time = ses->lease_time / 2; + else if (renew_time_set && ses->renew_time > ses->lease_time) { + log_ppp_warn("ipoe: overriding renew time\n"); + ses->renew_time = ses->lease_time / 2; + } } static void ev_radius_coa(struct ev_radius_t *ev) @@ -1967,6 +1980,7 @@ static void ev_radius_coa(struct ev_radius_t *ev) struct ipoe_session *ses = container_of(ev->ses, typeof(*ses), ses); struct rad_attr_t *attr; int l4_redirect; + int lease_time_set = 0, renew_time_set = 0; if (ev->ses->ctrl->type != CTRL_TYPE_IPOE) return; @@ -1982,11 +1996,13 @@ static void ev_radius_coa(struct ev_radius_t *ev) } else if (strcmp(attr->attr->name, "Framed-IP-Address") == 0) { if (ses->ses.ipv4 && ses->ses.ipv4->peer_addr != attr->val.ipaddr) ipoe_change_addr(ses, attr->val.ipaddr); - } else if (attr->attr->id == conf_attr_dhcp_lease_time) + } else if (attr->attr->id == conf_attr_dhcp_lease_time) { ses->lease_time = attr->val.integer; - else if (attr->attr->id == conf_attr_dhcp_renew_time) + lease_time_set = 1; + } else if (attr->attr->id == conf_attr_dhcp_renew_time) { ses->renew_time = attr->val.integer; - else if (attr->attr->id == conf_attr_l4_redirect_table) + renew_time_set = 1; + } else if (attr->attr->id == conf_attr_l4_redirect_table) ses->l4_redirect_table = attr->val.integer; else if (attr->attr->id == conf_attr_l4_redirect_ipset) { if (attr->attr->type == ATTR_TYPE_STRING) { @@ -1998,6 +2014,13 @@ static void ev_radius_coa(struct ev_radius_t *ev) } } + if (lease_time_set && !renew_time_set) + ses->renew_time = ses->lease_time / 2; + else if (renew_time_set && ses->renew_time > ses->lease_time) { + log_ppp_warn("ipoe: overriding renew time\n"); + ses->renew_time = ses->lease_time / 2; + } + //if (l4_redirect && !ses->l4_redirect) || (!l4_redirect && ses->l4_redirect)) if (l4_redirect != ses->l4_redirect && ev->ses->state == AP_STATE_ACTIVE) ipoe_change_l4_redirect(ses, l4_redirect); @@ -2158,6 +2181,19 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, return CLI_CMD_OK; } +static void print_session_type(struct ap_session *s, char *buf) +{ + if (s->ctrl->type == CTRL_TYPE_IPOE) { + struct ipoe_session *ses = container_of(s, typeof(*ses), ses); + + if (ses->UP) + strcpy(buf, "up"); + else + strcpy(buf, "dhcp"); + } else + *buf = 0; +} + void __export ipoe_get_stat(unsigned int **starting, unsigned int **active) { *starting = &stat_starting; @@ -2245,7 +2281,13 @@ void ipoe_vlan_mon_notify(int ifindex, int vid) svid = iplink_vlan_get_vid(ifindex); - if (make_vlan_name(conf_vlan_name, ifr.ifr_name, svid, vid, ifname)) { +#ifdef USE_LUA + if (!memcmp(conf_vlan_name, "lua:", 4)) + r = ipoe_lua_make_vlan_name(conf_vlan_name + 4, parent, svid, cvid, name); + else +#endif + r = make_vlan_name(conf_vlan_name, ifr.ifr_name, svid, vid, ifname); + if (r) { log_error("ipoe: vlan-mon: %s.%i: interface name is too long\n", ifr.ifr_name, vid); return; } @@ -2604,6 +2646,7 @@ static void load_interface(const char *opt) { const char *ptr; struct ifreq ifr; + struct ipoe_serv *serv; for (ptr = opt; *ptr && *ptr != ','; ptr++); @@ -2613,6 +2656,16 @@ static void load_interface(const char *opt) memcpy(ifr.ifr_name, opt, ptr - opt); ifr.ifr_name[ptr - opt] = 0; + list_for_each_entry(serv, &serv_list, entry) { + if (serv->active) + continue; + + if (!strcmp(serv->ifname, ifr.ifr_name)) { + add_interface(serv->ifname, serv->ifindex, opt, 0, 0); + return; + } + } + if (ioctl(sock_fd, SIOCGIFINDEX, &ifr)) { log_error("ipoe: '%s': ioctl(SIOCGIFINDEX): %s\n", ifr.ifr_name, strerror(errno)); return; @@ -2639,6 +2692,7 @@ static void load_interface_re(const char *opt) const char *ptr; int pcre_offset; struct iplink_arg arg; + struct ipoe_serv *serv; for (ptr = opt; *ptr && *ptr != ','; ptr++); @@ -2658,6 +2712,14 @@ static void load_interface_re(const char *opt) iplink_list((iplink_list_func)__load_interface_re, &arg); + list_for_each_entry(serv, &serv_list, entry) { + if (serv->active) + continue; + + if (pcre_exec(re, NULL, serv->ifname, strlen(serv->ifname), 0, 0, NULL, 0) >= 0) + add_interface(serv->ifname, serv->ifindex, opt, 0, 0); + } + pcre_free(re); _free(pattern); } @@ -3324,6 +3386,7 @@ static void ipoe_init(void) ipset_flush(conf_l4_redirect_ipset); cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat"); + cli_show_ses_register("ipoe-type", "IPoE session type", print_session_type); triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); diff --git a/accel-pppd/ctrl/ipoe/ipoe.h b/accel-pppd/ctrl/ipoe/ipoe.h index 224b9e91..cd1993df 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.h +++ b/accel-pppd/ctrl/ipoe/ipoe.h @@ -108,6 +108,7 @@ struct ipoe_session_info { #ifdef USE_LUA char *ipoe_lua_get_username(struct ipoe_session *, const char *func); +int ipoe_lua_make_vlan_name(const char *func, const char *parent, int svid, int cvid, char *name); #endif struct iphdr; diff --git a/accel-pppd/ctrl/ipoe/lua.c b/accel-pppd/ctrl/ipoe/lua.c index 84da9d12..b27b1f26 100644 --- a/accel-pppd/ctrl/ipoe/lua.c +++ b/accel-pppd/ctrl/ipoe/lua.c @@ -2,6 +2,7 @@ #include <stdio.h> #include <string.h> #include <pthread.h> +#include <net/if.h> /* Include the Lua API header files. */ #include <lua.h> @@ -268,6 +269,53 @@ out: return r; } +int ipoe_lua_make_vlan_name(const char *func, const char *parent, int svid, int cvid, char *name) +{ + int r = -1; + const char *res; + + if (file_error && serial == __serial) + return -1; + + if (L && serial != __serial) { + lua_close(L); + init_lua(); + } else if (!L) + init_lua(); + + if (!L) + return -1; + + lua_getglobal(L, func); + lua_pushstring(L, parent); + lua_pushinteger(L, svid); + lua_pushinteger(L, cvid); + + if (lua_pcall(L, 3, 1, 0)) { + log_ppp_error("ipoe: lua: %s\n", lua_tostring(L, -1)); + lua_pop(L, 1); + goto out; + } + + if (!lua_isstring(L, -1)) { + log_ppp_error("ipoe: lua: function '%s' must return a string\n", func); + goto out; + } + + res = lua_tostring(L, -1); + + if (strlen(res) >= IFNAMSIZ) + goto out; + + strcpy(name, res); + r = 0; + +out: + lua_settop(L, 0); + + return r; +} + static void load_config() { conf_filename = conf_get_opt("ipoe", "lua-file"); diff --git a/accel-pppd/extra/net-snmp/ACCEL-PPP-MIB.txt b/accel-pppd/extra/net-snmp/ACCEL-PPP-MIB.txt index 847a270d..b536a9b7 100644 --- a/accel-pppd/extra/net-snmp/ACCEL-PPP-MIB.txt +++ b/accel-pppd/extra/net-snmp/ACCEL-PPP-MIB.txt @@ -209,7 +209,11 @@ sessionEntry ::= SEQUENCE { sesState INTEGER, sesUptime TimeTicks, sesCallingSID OCTET STRING, - sesCalledSID OCTET STRING + sesCalledSID OCTET STRING, + sesRxBytes Counter64, + sesRxPkts Counter32, + sesTxBytes Counter64, + sesTxPkts Counter32 } sesSID OBJECT-TYPE @@ -294,6 +298,38 @@ sesCalledSID OBJECT-TYPE "Called-Station-ID" ::= { sessionEntry 9 } +sesRxBytes OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Received bytes" + ::= { sessionEntry 10 } + +sesRxPkts OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Received packets" + ::= { sessionEntry 11 } + +sesTxBytes OBJECT-TYPE + SYNTAX Counter64 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transmitted bytes" + ::= { sessionEntry 12 } + +sesTxPkts OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transmitted packets" + ::= { sessionEntry 13 } + -- -- Administration -- diff --git a/accel-pppd/extra/net-snmp/sessionTable.c b/accel-pppd/extra/net-snmp/sessionTable.c index 954ca1e3..dc7d62bd 100644 --- a/accel-pppd/extra/net-snmp/sessionTable.c +++ b/accel-pppd/extra/net-snmp/sessionTable.c @@ -1,6 +1,6 @@ /* * Note: this file originally auto-generated by mib2c using - * version : 14170 $ of $ + * version : 14170 $ of $ * * $Id:$ */ @@ -42,7 +42,7 @@ init_sessionTable(void) /* * TODO:300:o: Perform sessionTable one-time module initialization. */ - + /* * here we initialize all the tables we're planning on supporting */ @@ -63,7 +63,7 @@ shutdown_sessionTable(void) } /** - * Initialize the table sessionTable + * Initialize the table sessionTable * (Define its contents and how it's structured) */ void @@ -88,13 +88,13 @@ initialize_table_sessionTable(void) * string token is used to add, find or remove pointers. */ user_context = netsnmp_create_data_list("sessionTable", NULL, NULL); - + /* * No support for any flags yet, but in the future you would * set any flags here. */ flags = 0; - + /* * call interface initialization code */ @@ -102,7 +102,7 @@ initialize_table_sessionTable(void) } /* initialize_table_sessionTable */ /** - * Shutdown the table sessionTable + * Shutdown the table sessionTable */ void shutdown_table_sessionTable(void) @@ -129,7 +129,7 @@ sessionTable_rowreq_ctx_init(sessionTable_rowreq_ctx *rowreq_ctx, DEBUGMSGTL(("verbose:sessionTable:sessionTable_rowreq_ctx_init","called\n")); netsnmp_assert(NULL != rowreq_ctx); - + /* * TODO:210:o: |-> Perform extra sessionTable rowreq initialization. (eg DEFVALS) */ @@ -146,7 +146,7 @@ void sessionTable_rowreq_ctx_cleanup(sessionTable_rowreq_ctx *rowreq_ctx) DEBUGMSGTL(("verbose:sessionTable:sessionTable_rowreq_ctx_cleanup","called\n")); netsnmp_assert(NULL != rowreq_ctx); - + /* * TODO:211:o: |-> Perform extra sessionTable rowreq cleanup. */ diff --git a/accel-pppd/extra/net-snmp/sessionTable.h b/accel-pppd/extra/net-snmp/sessionTable.h index 2635f21c..31735c39 100644 --- a/accel-pppd/extra/net-snmp/sessionTable.h +++ b/accel-pppd/extra/net-snmp/sessionTable.h @@ -83,6 +83,12 @@ struct sessionTable_data_s unsigned long uptime; char *calling_sid; char *called_sid; + unsigned int rx_bytes; + unsigned int rx_gw; + unsigned int rx_pkts; + unsigned int tx_bytes; + unsigned int tx_gw; + unsigned int tx_pkts; }; typedef struct sessionTable_data_s sessionTable_data; diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_access.c b/accel-pppd/extra/net-snmp/sessionTable_data_access.c index edc5e6b2..13ddfc5d 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_data_access.c +++ b/accel-pppd/extra/net-snmp/sessionTable_data_access.c @@ -9,6 +9,8 @@ #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> +#include <linux/if_link.h> + /* include our parent header */ #include "sessionTable.h" @@ -199,6 +201,7 @@ sessionTable_container_load(netsnmp_container *container) sessionTable_rowreq_ctx *rowreq_ctx; size_t count = 0; struct ap_session *ses; + struct rtnl_link_stats stats; DEBUGMSGTL(("verbose:sessionTable:sessionTable_container_load","called\n")); @@ -233,6 +236,15 @@ sessionTable_container_load(netsnmp_container *container) rowreq_ctx->data->calling_sid = _strdup(ses->ctrl->calling_station_id); rowreq_ctx->data->called_sid = _strdup(ses->ctrl->called_station_id); + ap_session_read_stats(ses, &stats); + rowreq_ctx->data->rx_pkts = stats.rx_packets; + rowreq_ctx->data->rx_bytes = stats.rx_bytes; + rowreq_ctx->data->rx_gw = ses->acct_input_gigawords; + rowreq_ctx->data->tx_pkts = stats.tx_packets; + rowreq_ctx->data->tx_bytes = stats.tx_bytes; + rowreq_ctx->data->tx_gw = ses->acct_output_gigawords; + + CONTAINER_INSERT(container, rowreq_ctx); ++count; } diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_get.c b/accel-pppd/extra/net-snmp/sessionTable_data_get.c index e2b1cbc6..f936e125 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_data_get.c +++ b/accel-pppd/extra/net-snmp/sessionTable_data_get.c @@ -694,4 +694,194 @@ sesCalledSID_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesCalledSID_val_p return MFD_SUCCESS; } /* sesCalledSID_get */ +/*--------------------------------------------------------------------- + * ACCEL-PPP-MIB::sessionEntry.sesRxBytes + * sesRxBytes is subid 10 of sessionEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.8072.100.2.1.1.10 + * Description: +Received bytes + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the sesRxBytes data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param sesRxBytes_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +sesRxBytes_get( sessionTable_rowreq_ctx *rowreq_ctx, U64 * sesRxBytes_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != sesRxBytes_val_ptr ); + + + DEBUGMSGTL(("verbose:sessionTable:sesRxBytes_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + sesRxBytes_val_ptr->high = rowreq_ctx->data->rx_gw; + sesRxBytes_val_ptr->low = rowreq_ctx->data->rx_bytes; + + return MFD_SUCCESS; +} /* sesRxBytes_get */ + +/*--------------------------------------------------------------------- + * ACCEL-PPP-MIB::sessionEntry.sesRxPkts + * sesRxPkts is subid 11 of sessionEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.8072.100.2.1.1.11 + * Description: +Received packets + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the sesRxPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param sesRxPkts_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +sesRxPkts_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesRxPkts_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != sesRxPkts_val_ptr ); + + + DEBUGMSGTL(("verbose:sessionTable:sesRxPkts_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + *sesRxPkts_val_ptr = rowreq_ctx->data->rx_pkts; + + return MFD_SUCCESS; +} /* sesRxPkts_get */ + +/*--------------------------------------------------------------------- + * ACCEL-PPP-MIB::sessionEntry.sesTxBytes + * sesTxBytes is subid 12 of sessionEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.8072.100.2.1.1.12 + * Description: +Transmitted bytes + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the sesTxBytes data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param sesTxBytes_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +sesTxBytes_get( sessionTable_rowreq_ctx *rowreq_ctx, U64* sesTxBytes_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != sesTxBytes_val_ptr ); + + + DEBUGMSGTL(("verbose:sessionTable:sesTxBytes_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + sesTxBytes_val_ptr->high = rowreq_ctx->data->tx_gw; + sesTxBytes_val_ptr->low = rowreq_ctx->data->tx_bytes; + + return MFD_SUCCESS; +} /* sesTxBytes_get */ + +/*--------------------------------------------------------------------- + * ACCEL-PPP-MIB::sessionEntry.sesTxPkts + * sesTxPkts is subid 13 of sessionEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.8072.100.2.1.1.13 + * Description: +Transmitted packets + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * Extract the current value of the sesTxPkts data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param sesTxPkts_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +sesTxPkts_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesTxPkts_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != sesTxPkts_val_ptr ); + + + DEBUGMSGTL(("verbose:sessionTable:sesTxPkts_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + *sesTxPkts_val_ptr = rowreq_ctx->data->tx_pkts; + + return MFD_SUCCESS; +} /* sesTxPkts_get */ + /** @} */ diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_get.h b/accel-pppd/extra/net-snmp/sessionTable_data_get.h index e5a3ae62..82107200 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_data_get.h +++ b/accel-pppd/extra/net-snmp/sessionTable_data_get.h @@ -50,6 +50,10 @@ extern "C" { int sesUptime_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesUptime_val_ptr ); int sesCallingSID_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesCallingSID_val_ptr_ptr, size_t *sesCallingSID_val_ptr_len_ptr ); int sesCalledSID_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesCalledSID_val_ptr_ptr, size_t *sesCalledSID_val_ptr_len_ptr ); + int sesRxBytes_get( sessionTable_rowreq_ctx *rowreq_ctx, U64 * sesRxBytes_val_ptr ); + int sesRxPkts_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesRxPkts_val_ptr ); + int sesTxBytes_get( sessionTable_rowreq_ctx *rowreq_ctx, U64 * sesTxBytes_val_ptr ); + int sesTxPkts_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesTxPkts_val_ptr ); int sessionTable_indexes_set_tbl_idx(sessionTable_mib_index *tbl_idx, char *sesSID_val_ptr, size_t sesSID_val_ptr_len); diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_set.c b/accel-pppd/extra/net-snmp/sessionTable_data_set.c index 2f3bfa02..ebfeeeaa 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_data_set.c +++ b/accel-pppd/extra/net-snmp/sessionTable_data_set.c @@ -18,7 +18,7 @@ * * These routines are used to set the value for individual objects. The * row context is passed, along with the new value. - * + * * @{ */ /** @} */ diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_set.h b/accel-pppd/extra/net-snmp/sessionTable_data_set.h index c77b466c..70534baa 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_data_set.h +++ b/accel-pppd/extra/net-snmp/sessionTable_data_set.h @@ -1,6 +1,6 @@ /* * Note: this file originally auto-generated by mib2c using - * version : 12077 $ of $ + * version : 12077 $ of $ * * $Id:$ */ diff --git a/accel-pppd/extra/net-snmp/sessionTable_enums.h b/accel-pppd/extra/net-snmp/sessionTable_enums.h index 7897ff02..74268eef 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_enums.h +++ b/accel-pppd/extra/net-snmp/sessionTable_enums.h @@ -33,30 +33,20 @@ extern "C" { /************************************************************* * constants for enums for the MIB node - * sesType (IANAtunnelType / ASN_INTEGER) + * sesType (INTEGER / ASN_INTEGER) * * since a Textual Convention may be referenced more than once in a * MIB, protect againt redefinitions of the enum values. */ -#ifndef IANATUNNELTYPE_ENUMS -#define IANATUNNELTYPE_ENUMS +#ifndef SESTYPE_ENUMS +#define SESTYPE_ENUMS -#define IANATUNNELTYPE_OTHER 1 -#define IANATUNNELTYPE_DIRECT 2 -#define IANATUNNELTYPE_GRE 3 -#define IANATUNNELTYPE_MINIMAL 4 -#define IANATUNNELTYPE_L2TP 5 -#define IANATUNNELTYPE_PPTP 6 -#define IANATUNNELTYPE_L2F 7 -#define IANATUNNELTYPE_UDP 8 -#define IANATUNNELTYPE_ATMP 9 -#define IANATUNNELTYPE_MSDP 10 -#define IANATUNNELTYPE_SIXTOFOUR 11 -#define IANATUNNELTYPE_SIXOVERFOUR 12 -#define IANATUNNELTYPE_ISATAP 13 -#define IANATUNNELTYPE_TEREDO 14 +#define SESTYPE_PPTP 1 +#define SESTYPE_L2TP 2 +#define SESTYPE_PPPOE 3 +#define SESTYPE_IPOE 4 -#endif /* IANATUNNELTYPE_ENUMS */ +#endif /* SESTYPE_ENUMS */ /************************************************************* @@ -69,9 +59,9 @@ extern "C" { #ifndef SESSTATE_ENUMS #define SESSTATE_ENUMS -#define SESSTATE_STARTING 1 -#define SESSTATE_ACTIVE 2 -#define SESSTATE_FINISHING 3 +#define SESSTATE_STARTING 1 +#define SESSTATE_ACTIVE 2 +#define SESSTATE_FINISHING 3 #endif /* SESSTATE_ENUMS */ diff --git a/accel-pppd/extra/net-snmp/sessionTable_interface.c b/accel-pppd/extra/net-snmp/sessionTable_interface.c index 420336da..cabf9ca0 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_interface.c +++ b/accel-pppd/extra/net-snmp/sessionTable_interface.c @@ -1,6 +1,6 @@ /* * Note: this file originally auto-generated by mib2c using - * version : 15899 $ of $ + * version : 15899 $ of $ * * $Id:$ */ @@ -60,7 +60,7 @@ typedef struct sessionTable_interface_ctx_s { netsnmp_cache *cache; sessionTable_registration * user_ctx; - + netsnmp_table_registration_info tbl_info; netsnmp_baby_steps_access_methods access_multiplexer; @@ -110,7 +110,7 @@ static Netsnmp_Node_Handler _mfd_sessionTable_object_lookup; static Netsnmp_Node_Handler _mfd_sessionTable_get_values; /** * @internal - * Initialize the table sessionTable + * Initialize the table sessionTable * (Define its contents and how it's structured) */ void @@ -160,7 +160,7 @@ _sessionTable_initialize_interface(sessionTable_registration * reg_ptr, u_long snmp_log(LOG_ERR,"could not initialize container for sessionTable\n"); return; } - + /* * access_multiplexer: REQUIRED wrapper for get request handling */ @@ -179,7 +179,7 @@ _sessionTable_initialize_interface(sessionTable_registration * reg_ptr, u_long * Create a registration, save our reg data, register table. */ DEBUGMSGTL(("sessionTable:init_sessionTable", - "Registering sessionTable as a mibs-for-dummies table.\n")); + "Registering sessionTable as a mibs-for-dummies table.\n")); handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); reginfo = netsnmp_handler_registration_create("sessionTable", handler, sessionTable_oid, @@ -210,14 +210,14 @@ _sessionTable_initialize_interface(sessionTable_registration * reg_ptr, u_long mfd_modes |= BABY_STEP_PRE_REQUEST; if( access_multiplexer->post_request ) mfd_modes |= BABY_STEP_POST_REQUEST; - + if( access_multiplexer->undo_setup ) mfd_modes |= BABY_STEP_UNDO_SETUP; if( access_multiplexer->undo_cleanup ) mfd_modes |= BABY_STEP_UNDO_CLEANUP; if( access_multiplexer->undo_sets ) mfd_modes |= BABY_STEP_UNDO_SETS; - + if( access_multiplexer->row_creation ) mfd_modes |= BABY_STEP_ROW_CREATE; if( access_multiplexer->consistency_checks ) @@ -226,7 +226,7 @@ _sessionTable_initialize_interface(sessionTable_registration * reg_ptr, u_long mfd_modes |= BABY_STEP_COMMIT; if( access_multiplexer->undo_commit ) mfd_modes |= BABY_STEP_UNDO_COMMIT; - + handler = netsnmp_baby_steps_handler_get(mfd_modes); netsnmp_inject_handler(reginfo, handler); @@ -291,7 +291,7 @@ sessionTable_index_to_oid(netsnmp_index *oid_idx, sessionTable_mib_index *mib_idx) { int err = SNMP_ERR_NOERROR; - + /* * temp storage for parsing indexes */ @@ -343,7 +343,7 @@ sessionTable_index_from_oid(netsnmp_index *oid_idx, sessionTable_mib_index *mib_idx) { int err = SNMP_ERR_NOERROR; - + /* * temp storage for parsing indexes */ @@ -460,7 +460,7 @@ sessionTable_release_rowreq_ctx(sessionTable_rowreq_ctx *rowreq_ctx) DEBUGMSGTL(("internal:sessionTable:sessionTable_release_rowreq_ctx","called\n")); netsnmp_assert(NULL != rowreq_ctx); - + sessionTable_rowreq_ctx_cleanup(rowreq_ctx); /* @@ -469,7 +469,7 @@ sessionTable_release_rowreq_ctx(sessionTable_rowreq_ctx *rowreq_ctx) if ((rowreq_ctx->data) && !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) sessionTable_release_data(rowreq_ctx->data); - + /* * free index oid pointer */ @@ -493,13 +493,13 @@ _mfd_sessionTable_pre_request(netsnmp_mib_handler *handler, DEBUGMSGTL(("internal:sessionTable:_mfd_sessionTable_pre_request", "called\n")); - + if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:sessionTable", "skipping additional pre_request\n")); return SNMP_ERR_NOERROR; } - + rc = sessionTable_pre_request(sessionTable_if_ctx.user_ctx); if (MFD_SUCCESS != rc) { /* @@ -509,7 +509,7 @@ _mfd_sessionTable_pre_request(netsnmp_mib_handler *handler, "sessionTable_pre_request\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } - + return SNMP_ERR_NOERROR; } /* _mfd_sessionTable_pre_request */ @@ -544,7 +544,7 @@ _mfd_sessionTable_post_request(netsnmp_mib_handler *handler, "waiting for last post_request\n")); return SNMP_ERR_NOERROR; } - + packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); rc = sessionTable_post_request(sessionTable_if_ctx.user_ctx,packet_rc); if (MFD_SUCCESS != rc) { @@ -554,7 +554,7 @@ _mfd_sessionTable_post_request(netsnmp_mib_handler *handler, DEBUGMSGTL(("sessionTable","error %d from " "sessionTable_post_request\n", rc)); } - + return SNMP_ERR_NOERROR; } /* _mfd_sessionTable_post_request */ @@ -571,7 +571,7 @@ _mfd_sessionTable_object_lookup(netsnmp_mib_handler *handler, int rc = SNMP_ERR_NOERROR; sessionTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); - + DEBUGMSGTL(("internal:sessionTable:_mfd_sessionTable_object_lookup","called\n")); /* @@ -606,7 +606,7 @@ _sessionTable_get_column( sessionTable_rowreq_ctx *rowreq_ctx, netsnmp_variable_list *var, int column ) { int rc = SNMPERR_SUCCESS; - + DEBUGMSGTL(("internal:sessionTable:_mfd_sessionTable_get_column", "called for %d\n", column)); @@ -681,6 +681,34 @@ rc = sesCallingSID_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); rc = sesCalledSID_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); break; + /* sesRxBytes(10)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h */ + case COLUMN_SESRXBYTES: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; +rc = sesRxBytes_get(rowreq_ctx, (U64 *)var->val.string ); + break; + + /* sesRxPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */ + case COLUMN_SESRXPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; +rc = sesRxPkts_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* sesTxBytes(12)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h */ + case COLUMN_SESTXBYTES: + var->val_len = sizeof(U64); + var->type = ASN_COUNTER64; +rc = sesTxBytes_get(rowreq_ctx, (U64 *)var->val.string ); + break; + + /* sesTxPkts(13)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */ + case COLUMN_SESTXPKTS: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; +rc = sesTxPkts_get(rowreq_ctx, (u_long *)var->val.string ); + break; + default: if (SESSIONTABLE_MIN_COL <= column && column <= SESSIONTABLE_MAX_COL) { DEBUGMSGTL(("internal:sessionTable:_mfd_sessionTable_get_column", @@ -712,7 +740,7 @@ _mfd_sessionTable_get_values(netsnmp_mib_handler *handler, DEBUGMSGTL(("internal:sessionTable:_mfd_sessionTable_get_values","called\n")); netsnmp_assert(NULL != rowreq_ctx); - + for(;requests; requests = requests->next) { /* * save old pointer, so we can free it if replaced @@ -734,7 +762,7 @@ _mfd_sessionTable_get_values(netsnmp_mib_handler *handler, tri = netsnmp_extract_table_info(requests); if(NULL == tri) continue; - + rc = _sessionTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); if(rc) { if(MFD_SKIP == rc) { @@ -798,7 +826,7 @@ _cache_load(netsnmp_cache *cache, void *vmagic) /** should only be called for an invalid or expired cache */ netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); - + /* * call user code */ @@ -856,7 +884,7 @@ _container_free(netsnmp_container *container) * call user code */ sessionTable_container_free(container); - + /* * free all items. inefficient, but easy. */ diff --git a/accel-pppd/extra/net-snmp/sessionTable_interface.h b/accel-pppd/extra/net-snmp/sessionTable_interface.h index 2b99dde6..ebd1143d 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_interface.h +++ b/accel-pppd/extra/net-snmp/sessionTable_interface.h @@ -9,7 +9,7 @@ * \warning This code should not be modified, called directly, * or used to interpret functionality. It is subject to * change at any time. - * + * * @{ */ /* diff --git a/accel-pppd/extra/net-snmp/sessionTable_oids.h b/accel-pppd/extra/net-snmp/sessionTable_oids.h index 0fc5c284..01d84b60 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_oids.h +++ b/accel-pppd/extra/net-snmp/sessionTable_oids.h @@ -1,6 +1,6 @@ /* * Note: this file originally auto-generated by mib2c using - * : generic-table-oids.m2c 12855 2005-09-27 15:56:08Z rstory $ + * : generic-table-oids.m2c 17548 2009-04-23 16:35:18Z hardaker $ * * $Id:$ */ @@ -15,28 +15,37 @@ extern "C" { /* column number definitions for table sessionTable */ #define SESSIONTABLE_OID 1,3,6,1,4,1,8072,100,2,1 -#define COLUMN_SESSID 1 +#define COLUMN_SESSID 1 + #define COLUMN_SESIFNAME 2 - + #define COLUMN_SESUSERNAME 3 - + #define COLUMN_SESIP 4 - + #define COLUMN_SESTYPE 5 - + #define COLUMN_SESSTATE 6 - + #define COLUMN_SESUPTIME 7 - + #define COLUMN_SESCALLINGSID 8 - + #define COLUMN_SESCALLEDSID 9 - + +#define COLUMN_SESRXBYTES 10 + +#define COLUMN_SESRXPKTS 11 + +#define COLUMN_SESTXBYTES 12 + +#define COLUMN_SESTXPKTS 13 + #define SESSIONTABLE_MIN_COL COLUMN_SESSID -#define SESSIONTABLE_MAX_COL COLUMN_SESCALLEDSID - +#define SESSIONTABLE_MAX_COL COLUMN_SESTXPKTS + #ifdef __cplusplus diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index 25223a87..2928899c 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -401,7 +401,7 @@ static void write_radattr(struct pppd_compat_pd *pd, struct rad_packet_t *pack) struct ap_session *ses = pd->ses; struct rad_attr_t *attr; struct rad_dict_value_t *val; - FILE *f; + FILE *f = NULL; char *fname1, *fname2 = NULL; int i; in_addr_t addr; @@ -424,15 +424,22 @@ static void write_radattr(struct pppd_compat_pd *pd, struct rad_packet_t *pack) if (ses->state == AP_STATE_ACTIVE) { sprintf(fname1, "%s.%s", conf_radattr_prefix, ses->ifname); sprintf(fname2, "%s_old.%s", conf_radattr_prefix, ses->ifname); - if (rename(fname1, fname2)) { + if (rename(fname1, fname2)) log_ppp_warn("pppd_compat: rename: %s\n", strerror(errno)); - } + + f = fopen(fname1, "w"); } else { + int fd; + sprintf(fname1, "%s.XXXXXX", conf_radattr_prefix); - mkstemp(fname1); + + fd = mkstemp(fname1); + if (fd < 0) + log_ppp_warn("pppd_compat: mkstemp: %s\n", strerror(errno)); + else + f = fdopen(fd, "w"); } - f = fopen(fname1, "w"); if (f) { list_for_each_entry(attr, &pack->attrs, entry) { fprintf(f, "%s ", attr->attr->name); diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index e1ec11ee..213b58fd 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -619,7 +619,7 @@ static int shaper_restore_exec(const char *cmd, char * const *f, int f_cnt, void return CLI_CMD_OK; } -static void print_rate(const struct ap_session *ses, char *buf) +static void print_rate(struct ap_session *ses, char *buf) { struct shaper_pd_t *pd = find_pd((struct ap_session *)ses, 0); diff --git a/cmake/cpack.cmake b/cmake/cpack.cmake index a7606e8c..5b180bf5 100644 --- a/cmake/cpack.cmake +++ b/cmake/cpack.cmake @@ -1,7 +1,7 @@ INCLUDE(InstallRequiredSystemLibraries) SET(CPACK_PACKAGE_VERSION_MAJOR "1") -SET(CPACK_PACKAGE_VERSION_MINOR "9") +SET(CPACK_PACKAGE_VERSION_MINOR "10") SET(CPACK_PACKAGE_VERSION_PATCH "0") SET(CPACK_PACKAGE_NAME "accel-ppp") @@ -27,4 +27,9 @@ IF(CPACK_TYPE STREQUAL Debian7) INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Debian7) +IF(CPACK_TYPE STREQUAL Debian8) + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.19), libssl1.0.0 (>= 1.0.1k), libpcre3 (>= 8.35)") + INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) +ENDIF(CPACK_TYPE STREQUAL Debian8) + INCLUDE(CPack) diff --git a/cmake/debian/debian.cmake b/cmake/debian/debian.cmake index c02a4a41..858f053b 100644 --- a/cmake/debian/debian.cmake +++ b/cmake/debian/debian.cmake @@ -27,13 +27,13 @@ if (BUILD_DRIVER_ONLY) else (BUILD_DRIVER_ONLY) SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/conffiles") - if (CPACK_TYPE STREQUAL Debian7) - INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/accel-pppd/accel-ppp.conf DESTINATION /etc RENAME accel-ppp.conf.dist) - INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/contrib/debian/accel-ppp-init DESTINATION /etc/init.d RENAME accel-ppp) - INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/contrib/debian/accel-ppp-default DESTINATION /etc/default RENAME accel-ppp) - else (CPACK_TYPE STREQUAL Debian7) + if (CPACK_TYPE STREQUAL Debian6) INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/accel-pppd/accel-ppp.conf DESTINATION ${CMAKE_BINARY_DIR}/_CPack_Packages/Linux/DEB/${CPACK_PACKAGE_FILE_NAME}/etc RENAME accel-ppp.conf.dist) INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/contrib/debian/accel-ppp-init DESTINATION ${CMAKE_BINARY_DIR}/_CPack_Packages/Linux/DEB/${CPACK_PACKAGE_FILE_NAME}/etc/init.d RENAME accel-ppp) INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/contrib/debian/accel-ppp-default DESTINATION ${CMAKE_BINARY_DIR}/_CPack_Packages/Linux/DEB/${CPACK_PACKAGE_FILE_NAME}/etc/default RENAME accel-ppp) - endif (CPACK_TYPE STREQUAL Debian7) + else (CPACK_TYPE STREQUAL Debian6) + INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/accel-pppd/accel-ppp.conf DESTINATION /etc RENAME accel-ppp.conf.dist) + INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/contrib/debian/accel-ppp-init DESTINATION /etc/init.d RENAME accel-ppp) + INSTALL(FILES ${CMAKE_HOME_DIRECTORY}/contrib/debian/accel-ppp-default DESTINATION /etc/default RENAME accel-ppp) + endif (CPACK_TYPE STREQUAL Debian6) endif (BUILD_DRIVER_ONLY) diff --git a/contrib/debian/accel-ppp-init b/contrib/debian/accel-ppp-init index cc625256..a7e2bc0d 100755 --- a/contrib/debian/accel-ppp-init +++ b/contrib/debian/accel-ppp-init @@ -2,8 +2,8 @@ # /etc/init.d/accel-pppd: set up the accel-ppp server ### BEGIN INIT INFO # Provides: accel-ppp -# Required-Start: $networking -# Required-Stop: $networking +# Required-Start: $remote_fs $syslog $network $time +# Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO diff --git a/drivers/ipoe/CMakeLists.txt b/drivers/ipoe/CMakeLists.txt index 14ac12eb..6f4f043a 100644 --- a/drivers/ipoe/CMakeLists.txt +++ b/drivers/ipoe/CMakeLists.txt @@ -14,6 +14,6 @@ ADD_CUSTOM_TARGET(ipoe_drv ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/driver/ipoe.ko ) - -INSTALL(CODE "EXECUTE_PROCESS(COMMAND make -C ${KDIR} M=${CMAKE_CURRENT_BINARY_DIR}/drivers/ipoe modules_install)") - +IF (NOT DEFINED CPACK_TYPE) + INSTALL(CODE "EXECUTE_PROCESS(COMMAND make -C ${KDIR} M=${CMAKE_CURRENT_BINARY_DIR}/drivers/ipoe modules_install)") +ENDIF() |