diff options
Diffstat (limited to 'accel-pppd/logs')
-rw-r--r-- | accel-pppd/logs/log_file.c | 94 | ||||
-rw-r--r-- | accel-pppd/logs/log_syslog.c | 10 | ||||
-rw-r--r-- | accel-pppd/logs/log_tcp.c | 8 |
3 files changed, 56 insertions, 56 deletions
diff --git a/accel-pppd/logs/log_file.c b/accel-pppd/logs/log_file.c index 48f43510..1da3ee3f 100644 --- a/accel-pppd/logs/log_file.c +++ b/accel-pppd/logs/log_file.c @@ -42,14 +42,14 @@ struct log_file_t struct log_file_pd_t { - struct ppp_pd_t pd; + struct ap_private pd; struct log_file_t lf; unsigned long tmp; }; struct fail_log_pd_t { - struct ppp_pd_t pd; + struct ap_private pd; struct list_head msgs; }; @@ -285,7 +285,7 @@ static void queue_log_list(struct log_file_t *lf, struct list_head *l) } -static void set_hdr(struct log_msg_t *msg, struct ppp_t *ppp) +static void set_hdr(struct log_msg_t *msg, struct ap_session *ses) { struct tm tm; char timestamp[32]; @@ -295,28 +295,28 @@ static void set_hdr(struct log_msg_t *msg, struct ppp_t *ppp) strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", &tm); sprintf(msg->hdr->msg, "%s[%s]: %s: %s%s%s", conf_color ? level_color[msg->level] : "", timestamp, level_name[msg->level], - ppp ? ppp->ifname : "", - ppp ? ": " : "", + ses ? ses->ifname : "", + ses ? ": " : "", conf_color ? NORMAL_COLOR : ""); msg->hdr->len = strlen(msg->hdr->msg); } -static void general_log(struct log_target_t *t, struct log_msg_t *msg, struct ppp_t *ppp) +static void general_log(struct log_target_t *t, struct log_msg_t *msg, struct ap_session *ses) { - if (ppp && !conf_copy) { + if (ses && !conf_copy) { log_free_msg(msg); return; } - set_hdr(msg, ppp); + set_hdr(msg, ses); queue_log(log_file, msg); } -static struct ppp_pd_t *find_pd(struct ppp_t *ppp, void *pd_key) +static struct ap_private *find_pd(struct ap_session *ses, void *pd_key) { - 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 pd; } @@ -325,9 +325,9 @@ static struct ppp_pd_t *find_pd(struct ppp_t *ppp, void *pd_key) return NULL; } -static struct log_file_pd_t *find_lpd(struct ppp_t *ppp, void *pd_key) +static struct log_file_pd_t *find_lpd(struct ap_session *ses, void *pd_key) { - struct ppp_pd_t *pd = find_pd(ppp, pd_key); + struct ap_private *pd = find_pd(ses, pd_key); if (!pd) return NULL; @@ -335,9 +335,9 @@ static struct log_file_pd_t *find_lpd(struct ppp_t *ppp, void *pd_key) return container_of(pd, struct log_file_pd_t, pd); } -static struct fail_log_pd_t *find_fpd(struct ppp_t *ppp, void *pd_key) +static struct fail_log_pd_t *find_fpd(struct ap_session *ses, void *pd_key) { - struct ppp_pd_t *pd = find_pd(ppp, pd_key); + struct ap_private *pd = find_pd(ses, pd_key); if (!pd) return NULL; @@ -346,63 +346,63 @@ static struct fail_log_pd_t *find_fpd(struct ppp_t *ppp, void *pd_key) } -static void per_user_log(struct log_target_t *t, struct log_msg_t *msg, struct ppp_t *ppp) +static void per_user_log(struct log_target_t *t, struct log_msg_t *msg, struct ap_session *ses) { struct log_file_pd_t *lpd; - if (!ppp) { + if (!ses) { log_free_msg(msg); return; } - lpd = find_lpd(ppp, &pd_key1); + lpd = find_lpd(ses, &pd_key1); if (!lpd) { log_free_msg(msg); return; } - set_hdr(msg, ppp); + set_hdr(msg, ses); queue_log(&lpd->lf, msg); } -static void per_session_log(struct log_target_t *t, struct log_msg_t *msg, struct ppp_t *ppp) +static void per_session_log(struct log_target_t *t, struct log_msg_t *msg, struct ap_session *ses) { struct log_file_pd_t *lpd; - if (!ppp) { + if (!ses) { log_free_msg(msg); return; } - lpd = find_lpd(ppp, &pd_key2); + lpd = find_lpd(ses, &pd_key2); if (!lpd) { log_free_msg(msg); return; } - set_hdr(msg, ppp); + set_hdr(msg, ses); queue_log(&lpd->lf, msg); } -static void fail_log(struct log_target_t *t, struct log_msg_t *msg, struct ppp_t *ppp) +static void fail_log(struct log_target_t *t, struct log_msg_t *msg, struct ap_session *ses) { struct fail_log_pd_t *fpd; - if (!ppp || !conf_fail_log) { + if (!ses || !conf_fail_log) { log_free_msg(msg); return; } - fpd = find_fpd(ppp, &pd_key3); + fpd = find_fpd(ses, &pd_key3); if (!fpd) { log_free_msg(msg); return; } - set_hdr(msg, ppp); + set_hdr(msg, ses); list_add_tail(&msg->entry, &fpd->msgs); } @@ -453,12 +453,12 @@ static void free_lpd(struct log_file_pd_t *lpd) } } -static void ev_ppp_authorized2(struct ppp_t *ppp) +static void ev_ses_authorized2(struct ap_session *ses) { struct fail_log_pd_t *fpd; struct log_msg_t *msg; - fpd = find_fpd(ppp, &pd_key3); + fpd = find_fpd(ses, &pd_key3); if (!fpd) return; @@ -472,12 +472,12 @@ static void ev_ppp_authorized2(struct ppp_t *ppp) mempool_free(fpd); } -static void ev_ppp_authorized1(struct ppp_t *ppp) +static void ev_ses_authorized1(struct ap_session *ses) { struct log_file_pd_t *lpd; char *fname; - lpd = find_lpd(ppp, &pd_key1); + lpd = find_lpd(ses, &pd_key1); if (!lpd) return; @@ -489,14 +489,14 @@ static void ev_ppp_authorized1(struct ppp_t *ppp) strcpy(fname, conf_per_user_dir); strcat(fname, "/"); - strcat(fname, ppp->username); + strcat(fname, ses->username); if (conf_per_session) { if (mkdir(fname, S_IRWXU) && errno != EEXIST) { log_emerg("log_file: mkdir '%s': %s'\n", fname, strerror(errno)); goto out_err; } strcat(fname, "/"); - strcat(fname, ppp->sessionid); + strcat(fname, ses->sessionid); } strcat(fname, ".log"); @@ -518,7 +518,7 @@ out_err: free_lpd(lpd); } -static void ev_ctrl_started(struct ppp_t *ppp) +static void ev_ctrl_started(struct ap_session *ses) { struct log_file_pd_t *lpd; struct fail_log_pd_t *fpd; @@ -534,7 +534,7 @@ static void ev_ctrl_started(struct ppp_t *ppp) lpd->pd.key = &pd_key1; log_file_init(&lpd->lf); lpd->lf.lpd = lpd; - list_add_tail(&lpd->pd.entry, &ppp->pd_list); + list_add_tail(&lpd->pd.entry, &ses->pd_list); } if (conf_per_session_dir) { @@ -568,7 +568,7 @@ static void ev_ctrl_started(struct ppp_t *ppp) _free(fname); - list_add_tail(&lpd->pd.entry, &ppp->pd_list); + list_add_tail(&lpd->pd.entry, &ses->pd_list); } if (conf_fail_log) { @@ -579,29 +579,29 @@ static void ev_ctrl_started(struct ppp_t *ppp) } memset(fpd, 0, sizeof(*fpd)); fpd->pd.key = &pd_key3; - list_add_tail(&fpd->pd.entry, &ppp->pd_list); + list_add_tail(&fpd->pd.entry, &ses->pd_list); INIT_LIST_HEAD(&fpd->msgs); } } -static void ev_ctrl_finished(struct ppp_t *ppp) +static void ev_ctrl_finished(struct ap_session *ses) { struct log_file_pd_t *lpd; struct fail_log_pd_t *fpd; char *fname; - fpd = find_fpd(ppp, &pd_key3); + fpd = find_fpd(ses, &pd_key3); if (fpd) { queue_log_list(fail_log_file, &fpd->msgs); list_del(&fpd->pd.entry); mempool_free(fpd); } - lpd = find_lpd(ppp, &pd_key1); + lpd = find_lpd(ses, &pd_key1); if (lpd) free_lpd(lpd); - lpd = find_lpd(ppp, &pd_key2); + lpd = find_lpd(ses, &pd_key2); if (lpd) { if (lpd->tmp) { fname = _malloc(PATH_MAX); @@ -619,12 +619,12 @@ static void ev_ctrl_finished(struct ppp_t *ppp) } } -static void ev_ppp_starting(struct ppp_t *ppp) +static void ev_ses_starting(struct ap_session *ses) { struct log_file_pd_t *lpd; char *fname1, *fname2; - lpd = find_lpd(ppp, &pd_key2); + lpd = find_lpd(ses, &pd_key2); if (!lpd) return; @@ -647,7 +647,7 @@ static void ev_ppp_starting(struct ppp_t *ppp) strcpy(fname2, conf_per_session_dir); strcat(fname2, "/"); - strcat(fname2, ppp->sessionid); + strcat(fname2, ses->sessionid); strcat(fname2, ".log"); if (rename(fname1, fname2)) @@ -753,17 +753,17 @@ static void init(void) if (conf_per_user_dir) { log_register_target(&per_user_target); - triton_event_register_handler(EV_PPP_AUTHORIZED, (triton_event_func)ev_ppp_authorized1); + triton_event_register_handler(EV_SES_AUTHORIZED, (triton_event_func)ev_ses_authorized1); } if (conf_per_session_dir) { log_register_target(&per_session_target); - triton_event_register_handler(EV_PPP_STARTING, (triton_event_func)ev_ppp_starting); + triton_event_register_handler(EV_SES_STARTING, (triton_event_func)ev_ses_starting); } if (conf_fail_log) { log_register_target(&fail_log_target); - triton_event_register_handler(EV_PPP_AUTHORIZED, (triton_event_func)ev_ppp_authorized2); + triton_event_register_handler(EV_SES_AUTHORIZED, (triton_event_func)ev_ses_authorized2); } triton_event_register_handler(EV_CTRL_STARTED, (triton_event_func)ev_ctrl_started); diff --git a/accel-pppd/logs/log_syslog.c b/accel-pppd/logs/log_syslog.c index 5a922f57..cbab5252 100644 --- a/accel-pppd/logs/log_syslog.c +++ b/accel-pppd/logs/log_syslog.c @@ -50,10 +50,10 @@ static void unpack_msg(struct log_msg_t *msg) log_buf[0] = 0; } -static void set_hdr(struct log_msg_t *msg, struct ppp_t *ppp) +static void set_hdr(struct log_msg_t *msg, struct ap_session *ses) { - if (ppp) { - if (snprintf(msg->hdr->msg, LOG_CHUNK_SIZE, "%s:%s: ", ppp->ifname, ppp->username ? ppp->username : "")) + if (ses) { + if (snprintf(msg->hdr->msg, LOG_CHUNK_SIZE, "%s:%s: ", ses->ifname, ses->username ? ses->username : "")) strcpy(msg->hdr->msg + LOG_CHUNK_SIZE - 3, ": "); } else msg->hdr->msg[0] = 0; @@ -104,9 +104,9 @@ static void queue_log(struct log_msg_t *msg) } -static void general_log(struct log_target_t *t, struct log_msg_t *msg, struct ppp_t *ppp) +static void general_log(struct log_target_t *t, struct log_msg_t *msg, struct ap_session *ses) { - set_hdr(msg, ppp); + set_hdr(msg, ses); if (syslog_ctx.tpd) queue_log(msg); diff --git a/accel-pppd/logs/log_tcp.c b/accel-pppd/logs/log_tcp.c index 3f76ff8a..b89b7d65 100644 --- a/accel-pppd/logs/log_tcp.c +++ b/accel-pppd/logs/log_tcp.c @@ -130,7 +130,7 @@ static void queue_log(struct tcp_target_t *t, struct log_msg_t *msg) } } -static void set_hdr(struct log_msg_t *msg, struct ppp_t *ppp) +static void set_hdr(struct log_msg_t *msg, struct ap_session *ses) { struct tm tm; char timestamp[32]; @@ -138,15 +138,15 @@ static void set_hdr(struct log_msg_t *msg, struct ppp_t *ppp) localtime_r(&msg->timestamp.tv_sec, &tm); strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", &tm); - sprintf(msg->hdr->msg, "[%s]: %s: %s: ", timestamp, level_name[msg->level], ppp ? ppp->ifname : ""); + sprintf(msg->hdr->msg, "[%s]: %s: %s: ", timestamp, level_name[msg->level], ses ? ses->ifname : ""); msg->hdr->len = strlen(msg->hdr->msg); } -static void general_log(struct log_target_t *lt, struct log_msg_t *msg, struct ppp_t *ppp) +static void general_log(struct log_target_t *lt, struct log_msg_t *msg, struct ap_session *ses) { struct tcp_target_t *t = container_of(lt, typeof(*t), target); - set_hdr(msg, ppp); + set_hdr(msg, ses); queue_log(t, msg); } |