static void accounting_start(void) { int tac_fd; char *phone; char *msg; struct tac_attrib *attr; struct in_addr peer_addr; char buf[40]; if (prev_ip_up_hook) { prev_ip_up_hook(); } if (use_tacacs && use_account && authorized) { authorized = 0; logged_in = 1; if (tac_server == -1) return; tac_fd = tac_connect(&tac_server, 1); if (tac_fd < 0) return; /* start accounting */ attr = NULL; sprintf(buf, "%lu", time(0)); tac_add_attrib(&attr, "start_time", buf); sprintf(buf, "%hu", task_id); tac_add_attrib(&attr, "task_id", buf); phone = getenv("CALLER_ID"); if (!phone) phone = "Unknow"; tac_add_attrib(&attr, "phone_#", phone); tac_add_attrib(&attr, "service", "ppp"); tac_add_attrib(&attr, "protocol", "ip"); peer_addr.s_addr = ipcp_hisoptions[0].hisaddr; sprintf(buf, "%s", inet_ntoa(peer_addr)); tac_account_send(tac_fd, TAC_PLUS_ACCT_FLAG_START, peer_authname, tty, buf, attr); msg = tac_account_read(tac_fd); if (msg != NULL) syslog(LOG_ERR,"TACACS+ start accounting failed: %s", msg); close(tac_fd); tac_free_attrib(&attr); } }
static void radius_ip_up(void) { struct radius_attrib *attriblist, *recvattriblist; int ret; if (prev_ip_up_hook) { prev_ip_up_hook(); } if (use_account) { if (radius_server == -1) return; attriblist = NULL; recvattriblist = NULL; if (!radius_add_attrib( &attriblist, PW_VENDOR_NONE, PW_ACCT_STATUS_TYPE, PW_STATUS_START, NULL, 0)) { radius_free_attrib(attriblist); return; } sprintf(sessionid, "%x", radius_sessionid()); if (!radius_add_attrib( &attriblist, PW_VENDOR_NONE, PW_ACCT_SESSION_ID, 0, sessionid, strlen(sessionid))) { radius_free_attrib(attriblist); return; } if (!radius_common_account_attrib(&attriblist)) { radius_free_attrib(attriblist); return; } ret = radius_send_account_request( radius_server, radius_auth_port+1, radius_secret, attriblist, &recvattriblist); radius_free_attrib(attriblist); radius_free_attrib(recvattriblist); if (ret >= 0) { accountstart = 1; } } }