提交 81ca3923 编写于 作者: D Dmitry Kozlov

remove trailing whitespaces

上级 830c399c
......@@ -147,7 +147,7 @@ static int chap_finish(struct ppp_t *ppp, struct auth_data_t *auth)
if (d->interval.tpd)
triton_timer_del(&d->interval);
if (d->name)
_free(d->name);
......@@ -175,7 +175,7 @@ static void chap_timeout_timer(struct triton_timer_t *t)
static void chap_restart_timer(struct triton_timer_t *t)
{
struct chap_auth_data *d = container_of(t, typeof(*d), interval);
chap_send_challenge(d, 1);
}
......@@ -201,7 +201,7 @@ static void chap_send_failure(struct chap_auth_data *ad)
.hdr.len = htons(sizeof(msg) - 1 - 2),
.message = MSG_FAILURE,
};
if (conf_ppp_verbose)
log_ppp_info2("send [CHAP Failure id=%x \"%s\"]\n", msg.hdr.id, MSG_FAILURE);
......@@ -217,7 +217,7 @@ static void chap_send_success(struct chap_auth_data *ad, int id)
.hdr.len = htons(sizeof(msg)-1-2),
.message = MSG_SUCCESS,
};
if (conf_ppp_verbose)
log_ppp_info2("send [CHAP Success id=%x \"%s\"]\n", msg.hdr.id, MSG_SUCCESS);
......@@ -301,7 +301,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
print_str(msg->name, ntohs(msg->hdr.len) - sizeof(*msg) + 2);
log_ppp_info2("\"]\n");
}
if (ad->started && msg->hdr.id == ad->id - 1) {
chap_send_success(ad, msg->hdr.id);
return;
......@@ -364,7 +364,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
MD5_Update(&md5_ctx,passwd,strlen(passwd));
MD5_Update(&md5_ctx,ad->val,VALUE_SIZE);
MD5_Final(md5,&md5_ctx);
if (memcmp(md5,msg->val,sizeof(md5)))
{
if (conf_ppp_verbose)
......@@ -389,7 +389,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
}
} else
_free(name);
ad->id++;
}
_free(passwd);
......@@ -429,7 +429,7 @@ static int chap_check(uint8_t *ptr)
static int chap_restart(struct ppp_t *ppp, struct auth_data_t *auth)
{
struct chap_auth_data *d = container_of(auth, typeof(*d), auth);
chap_send_challenge(d, 1);
return 0;
......@@ -491,7 +491,7 @@ static void auth_chap_md5_init()
if (ppp_auth_register_handler(&chap))
log_emerg("chap-md5: failed to register handler\n");
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
......
......@@ -176,7 +176,7 @@ static void chap_timeout_timer(struct triton_timer_t *t)
static void chap_restart_timer(struct triton_timer_t *t)
{
struct chap_auth_data *d = container_of(t, typeof(*d), interval);
chap_send_challenge(d, 1);
}
......@@ -218,7 +218,7 @@ static void chap_send_success(struct chap_auth_data *ad, int id)
hdr->id = id;
hdr->len = htons(HDR_LEN + strlen(conf_msg_success));
strcpy((char *)(hdr + 1), conf_msg_success);
if (conf_ppp_verbose)
log_ppp_info2("send [MSCHAP-v1 Success id=%x \"%s\"]\n", hdr->id, conf_msg_success);
......@@ -278,14 +278,14 @@ static void auth_result(struct chap_auth_data *ad, int res)
name = NULL;
}
}
ad->id++;
if (ad->mschap_error != conf_msg_failure) {
_free(ad->mschap_error);
ad->mschap_error = conf_msg_failure;
}
if (name)
_free(name);
}
......@@ -358,7 +358,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
ad->mschap_error = conf_msg_failure;
r = pwdb_check(&ad->ppp->ses, (pwdb_callback)auth_result, ad, name, PPP_CHAP, MSCHAP_V1, ad->id, ad->val, VALUE_SIZE, msg->lm_hash, msg->nt_hash, msg->flags, &ad->mschap_error);
if (r == PWDB_WAIT) {
ad->name = name;
return;
......@@ -367,7 +367,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
if (r == PWDB_NO_IMPL)
if (chap_check_response(ad, msg, name))
r = PWDB_DENIED;
if (r == PWDB_DENIED) {
chap_send_failure(ad, ad->mschap_error);
if (ad->started)
......@@ -426,7 +426,7 @@ static void des_encrypt(const uint8_t *input, const uint8_t *key, uint8_t *outpu
DES_set_key_checked(&cb, &ks);
memcpy(cb, input, 8);
DES_ecb_encrypt(&cb, &res, &ks, DES_ENCRYPT);
memcpy(output, res, 8);
memcpy(output, res, 8);
}
static int chap_check_response(struct chap_auth_data *ad, struct chap_response *msg, const char *name)
......@@ -437,7 +437,7 @@ static int chap_check_response(struct chap_auth_data *ad, struct chap_response *
char *passwd;
char *u_passwd;
int i;
passwd = pwdb_get_passwd(&ad->ppp->ses, name);
if (!passwd) {
if (conf_ppp_verbose)
......@@ -497,7 +497,7 @@ static void set_mppe_keys(struct chap_auth_data *ad, uint8_t *z_hash)
SHA1_Update(&sha_ctx, digest, 16);
SHA1_Update(&sha_ctx, digest, 16);
SHA1_Update(&sha_ctx, ad->val, VALUE_SIZE);
SHA1_Final(digest, &sha_ctx);
SHA1_Final(digest, &sha_ctx);
triton_event_fire(EV_MPPE_KEYS, &ev_mppe);
}
......@@ -505,7 +505,7 @@ static void set_mppe_keys(struct chap_auth_data *ad, uint8_t *z_hash)
static int chap_restart(struct ppp_t *ppp, struct auth_data_t *auth)
{
struct chap_auth_data *d = container_of(auth, typeof(*d), auth);
chap_send_challenge(d, 1);
return 0;
......
......@@ -19,7 +19,7 @@
#include "memdebug.h"
#define MSCHAP_V2 0x81
#define MSCHAP_V2 0x81
#define CHAP_CHALLENGE 1
#define CHAP_RESPONSE 2
......@@ -119,7 +119,7 @@ static void auth_data_free(struct ppp_t *ppp, struct auth_data_t *auth)
if (d->interval.tpd)
triton_timer_del(&d->interval);
_free(d);
}
......@@ -177,7 +177,7 @@ static void chap_timeout_timer(struct triton_timer_t *t)
static void chap_restart_timer(struct triton_timer_t *t)
{
struct chap_auth_data *d = container_of(t, typeof(*d), interval);
chap_send_challenge(d, 1);
}
......@@ -203,7 +203,7 @@ static void chap_send_failure(struct chap_auth_data *ad, char *mschap_error, cha
hdr->len = htons(HDR_LEN + strlen(mschap_error) + strlen(reply_msg) + 3);
sprintf((char *)(hdr + 1), "%s M=%s", mschap_error, reply_msg);
if (conf_ppp_verbose)
log_ppp_info2("send [MSCHAP-v2 Failure id=%x \"%s\"]\n", hdr->id, (char *)(hdr + 1));
......@@ -240,7 +240,7 @@ static int generate_response(struct chap_auth_data *ad, struct chap_response *ms
uint8_t c_hash[SHA_DIGEST_LENGTH];
uint8_t response[SHA_DIGEST_LENGTH];
int i;
uint8_t magic1[39] =
{0x4D, 0x61, 0x67, 0x69, 0x63, 0x20, 0x73, 0x65, 0x72, 0x76,
0x65, 0x72, 0x20, 0x74, 0x6F, 0x20, 0x63, 0x6C, 0x69, 0x65,
......@@ -290,10 +290,10 @@ static int generate_response(struct chap_auth_data *ad, struct chap_response *ms
SHA1_Update(&sha_ctx,c_hash,8);
SHA1_Update(&sha_ctx,magic2,41);
SHA1_Final(response,&sha_ctx);
for(i=0; i<20; i++)
sprintf(authenticator+i*2,"%02X",response[i]);
_free(passwd);
_free(u_passwd);
......@@ -351,19 +351,19 @@ static void auth_result(struct chap_auth_data *ad, int res)
name = NULL;
}
}
ad->id++;
if (ad->mschap_error != conf_msg_failure) {
_free(ad->mschap_error);
ad->mschap_error = conf_msg_failure;
}
if (ad->reply_msg != conf_msg_failure2) {
_free(ad->reply_msg);
ad->reply_msg = conf_msg_failure2;
}
if (name)
_free(name);
}
......@@ -398,7 +398,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
if (ad->name)
return;
ad->mschap_error = conf_msg_failure;
ad->reply_msg = conf_msg_failure2;
......@@ -427,7 +427,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
ppp_auth_failed(ad->ppp, NULL);
return;
}
r = pwdb_check(&ad->ppp->ses, (pwdb_callback)auth_result, ad, name, PPP_CHAP, MSCHAP_V2, ad->id, ad->val, msg->peer_challenge, msg->reserved, msg->nt_hash, msg->flags, authenticator, &ad->mschap_error, &ad->reply_msg);
if (r == PWDB_WAIT) {
......@@ -449,7 +449,7 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr)
ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0);
else
ppp_auth_failed(ad->ppp, name);
_free(name);
if (ad->mschap_error != conf_msg_failure) {
......@@ -508,7 +508,7 @@ static void des_encrypt(const uint8_t *input, const uint8_t *key, uint8_t *outpu
DES_set_key_checked(&cb, &ks);
memcpy(cb,input,8);
DES_ecb_encrypt(&cb,&res,&ks,DES_ENCRYPT);
memcpy(output,res,8);
memcpy(output,res,8);
}
static int chap_check_response(struct chap_auth_data *ad, struct chap_response *msg, const char *name)
......@@ -521,7 +521,7 @@ static int chap_check_response(struct chap_auth_data *ad, struct chap_response *
char *passwd;
char *u_passwd;
int i;
passwd = pwdb_get_passwd(&ad->ppp->ses, name);
if (!passwd) {
if (conf_ppp_verbose)
......@@ -566,7 +566,7 @@ static void set_mppe_keys(struct chap_auth_data *ad, uint8_t *z_hash, uint8_t *n
uint8_t digest[20];
uint8_t send_key[20];
uint8_t recv_key[20];
uint8_t pad1[40] =
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
......@@ -612,7 +612,7 @@ static void set_mppe_keys(struct chap_auth_data *ad, uint8_t *z_hash, uint8_t *n
.recv_key = recv_key,
.send_key = send_key,
};
//NtPasswordHashHash
MD4_Init(&md4_ctx);
MD4_Update(&md4_ctx, z_hash, 16);
......@@ -652,7 +652,7 @@ static int chap_check(uint8_t *ptr)
static int chap_restart(struct ppp_t *ppp, struct auth_data_t *auth)
{
struct chap_auth_data *d = container_of(auth, typeof(*d), auth);
chap_send_challenge(d, 1);
return 0;
......
......@@ -105,10 +105,10 @@ static int pap_start(struct ppp_t *ppp, struct auth_data_t *auth)
static int pap_finish(struct ppp_t *ppp, struct auth_data_t *auth)
{
struct pap_auth_data *d = container_of(auth, typeof(*d), auth);
if (d->timeout.tpd)
triton_timer_del(&d->timeout);
if (d->peer_id)
_free(d->peer_id);
......@@ -147,10 +147,10 @@ static void pap_send_ack(struct pap_auth_data *p, int id)
msg->hdr.len = htons(HDR_LEN + 1 + sizeof(MSG_SUCCESSED) - 1);
msg->msg_len = sizeof(MSG_SUCCESSED) - 1;
memcpy(msg->msg, MSG_SUCCESSED, sizeof(MSG_SUCCESSED));
if (conf_ppp_verbose)
log_ppp_info2("send [PAP AuthAck id=%x \"%s\"]\n", id, MSG_SUCCESSED);
ppp_chan_send(p->ppp, msg, ntohs(msg->hdr.len) + 2);
}
......@@ -164,10 +164,10 @@ static void pap_send_nak(struct pap_auth_data *p, int id)
msg->hdr.len = htons(HDR_LEN + 1 + sizeof(MSG_FAILED) - 1);
msg->msg_len = sizeof(MSG_FAILED) - 1;
memcpy(msg->msg, MSG_FAILED, sizeof(MSG_FAILED));
if (conf_ppp_verbose)
log_ppp_info2("send [PAP AuthNak id=%x \"%s\"]\n", id, MSG_FAILED);
ppp_chan_send(p->ppp, msg, ntohs(msg->hdr.len) + 2);
}
......@@ -236,7 +236,7 @@ static int pap_recv_req(struct pap_auth_data *p, struct pap_hdr *hdr)
}
peer_id = _strndup((const char*)peer_id, peer_id_len);
if (conf_any_login) {
if (ppp_auth_succeeded(p->ppp, peer_id)) {
pap_send_nak(p, hdr->id);
......@@ -293,17 +293,17 @@ static int pap_recv_req(struct pap_auth_data *p, struct pap_hdr *hdr)
_free(passwd);
return ret;
failed:
pap_send_nak(p, hdr->id);
if (p->started)
ap_session_terminate(&p->ppp->ses, TERM_AUTH_ERROR, 0);
else
ppp_auth_failed(p->ppp, peer_id);
_free(passwd);
_free(peer_id);
return -1;
}
......
......@@ -15,7 +15,7 @@ static LIST_HEAD(module_list);
struct backup_tag __export *backup_add_tag(struct backup_mod *m, uint8_t id, int internal, const void *data, size_t size)
{
struct backup_tag *t;
t = m->data->storage->alloc_tag(m->data, size);
if (!t)
return NULL;
......@@ -39,7 +39,7 @@ void backup_add_fd(struct backup_mod *m, int fd)
struct backup_mod __export *backup_find_mod(struct backup_data *d, uint8_t mod_id)
{
struct backup_mod *m;
list_for_each_entry(m, &d->mod_list, entry) {
if (m->id == mod_id)
return m;
......@@ -232,19 +232,19 @@ void __export backup_register_storage(struct backup_storage *s)
void backup_restore_fd()
{
}
void backup_restore(int internal)
{
struct backup_storage *storage;
struct backup_module *module;
list_for_each_entry(storage, &storage_list, entry) {
if (storage->restore)
storage->restore(internal);
}
list_for_each_entry(module, &module_list, entry) {
if (module->restore_complete)
module->restore_complete();
......
......@@ -41,7 +41,7 @@ struct backup_data
struct list_head mod_list;
int internal:1;
};
struct backup_module
{
struct list_head entry;
......@@ -49,7 +49,7 @@ struct backup_module
int (*save)(struct ap_session *, struct backup_mod *);
int (*restore)(struct ap_session *, struct backup_mod *);
struct ap_session *(*ctrl_restore)(struct backup_mod *);
void (*ctrl_start)(struct ap_session *ses);
void (*restore_complete)(void);
......@@ -61,18 +61,18 @@ struct backup_storage
/*int (*check_integrity)(void);
int (*restore)(int internal);*/
void (*restore)(int internal);
struct backup_data *(*create)(struct ap_session *);
int (*commit)(struct backup_data *);
void (*free)(struct backup_data *);
struct backup_mod *(*alloc_mod)(struct backup_data *);
void (*free_mod)(struct backup_mod *);
void (*add_fd)(struct backup_data *, int fd);
struct backup_tag *(*alloc_tag)(struct backup_data *, int size);
void (*free_tag)(struct backup_data *, struct backup_tag *);
};
......
......@@ -78,7 +78,7 @@ static int fs_commit(struct backup_data *d)
MD5_Init(&md5);
MD5_Update(&md5, &version, 1);
iov[0].iov_base = &version;
iov[0].iov_len = 1;
i = 1;
......@@ -145,7 +145,7 @@ static int fs_commit(struct backup_data *d)
}
return 0;
out_err:
close(fd);
unlink(fname);
......@@ -159,10 +159,10 @@ static void fs_free(struct backup_data *d)
if (fsd->map_addr)
munmap(fsd->map_addr, fsd->map_len);
if (fsd->fd != -1)
close(fsd->fd);
sprintf(fname, "%s/%s", conf_path, d->ses->sessionid);
unlink(fname);
......@@ -190,10 +190,10 @@ static void fs_free_mod(struct backup_mod *mod)
static struct backup_tag *fs_alloc_tag(struct backup_data *d, int size)
{
struct backup_tag *t = _malloc(sizeof(struct backup_tag) + 4 + size);
if (!t)
return NULL;
memset(t, 0, sizeof(*t));
t->data = (uint8_t *)(t + 1) + 4;
......@@ -240,7 +240,7 @@ static void restore_session(const char *fn, int internal)
close(fd);
return;
}
if (*ptr != VERSION)
goto out;
......@@ -250,11 +250,11 @@ static void restore_session(const char *fn, int internal)
if (memcmp(md5_buf, ptr + st.st_size - 16, 16))
goto out;
d = fs_create(NULL);
if (!d)
goto out;
d->internal = internal;
fsd = container_of(d, typeof(*fsd), data);
......@@ -304,10 +304,10 @@ static void fs_restore(int internal)
{
DIR *dirp;
struct dirent ent, *res;
if (!conf_path)
return;
dirp = opendir(conf_path);
if (!dirp) {
log_emerg("backup_file: opendir: %s\n", strerror(errno));
......
......@@ -49,7 +49,7 @@ void __export cli_register_simple_cmd2(
c = malloc(sizeof(*c));
memset(c, 0, sizeof(*c));
c->exec = exec;
c->help = help;
c->hdr_len = hdr_len;
......@@ -57,7 +57,7 @@ void __export cli_register_simple_cmd2(
for (i = 0; i < hdr_len; i++)
c->hdr[i] = va_arg(ap, char *);
list_add_tail(&c->entry, &simple_cmd_list);
va_end(ap);
......@@ -319,7 +319,7 @@ out_found:
static void load_config(void)
{
const char *opt;
if (conf_cli_passwd)
_free(conf_cli_passwd);
opt = conf_get_opt("cli", "password");
......@@ -327,7 +327,7 @@ static void load_config(void)
conf_cli_passwd = _strdup(opt);
else
conf_cli_passwd = NULL;
if (conf_cli_prompt && conf_cli_prompt != def_cli_prompt)
_free(conf_cli_prompt);
opt = conf_get_opt("cli", "prompt");
......
......@@ -103,7 +103,7 @@ static void free_row(struct row_t *row)
static void insert_row(struct list_head *list, struct row_t *row)
{
struct row_t *row2, *row3;
row3 = NULL;
list_for_each_entry(row2, list, entry) {
if (strcmp(row->order_key, row2->order_key) <= 0) {
......@@ -213,7 +213,7 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
col->hidden = 1;
list_add_tail(&col->entry, &c_list);
}
if (order_key && !order_key_f) {
col = _malloc(sizeof(*col));
col->column = order_key;
......
......@@ -113,7 +113,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
pcre *re;
const char *pcre_err;
int pcre_offset;
if (f_cnt == 5) {
if (!strcmp(f[4], "hard"))
hard = 1;
......@@ -121,7 +121,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
return CLI_CMD_SYNTAX;
} else if (f_cnt != 4)
return CLI_CMD_SYNTAX;
re = pcre_compile2(f[3], 0, NULL, &pcre_err, &pcre_offset, NULL);
if (!re) {
cli_sendv(cli, "match: %s at %i\r\n", pcre_err, pcre_offset);
......@@ -140,9 +140,9 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate_soft, ses);
}
pthread_rwlock_unlock(&ses_lock);
pcre_free(re);
return CLI_CMD_OK;
}
......@@ -151,7 +151,7 @@ static int terminate_exec2(int key, char * const *f, int f_cnt, void *cli)
struct ap_session *ses;
int hard = 0;
in_addr_t ipaddr = 0;
if (f_cnt == 4) {
if (!strcmp(f[3], "hard"))
hard = 1;
......@@ -159,10 +159,10 @@ static int terminate_exec2(int key, char * const *f, int f_cnt, void *cli)
return CLI_CMD_SYNTAX;
} else if (f_cnt != 3)
return CLI_CMD_SYNTAX;
if (key == 1)
ipaddr = inet_addr(f[2]);
pthread_rwlock_rdlock(&ses_lock);
list_for_each_entry(ses, &ses_list, entry) {
switch (key) {
......@@ -205,7 +205,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt,
if (fields_cnt == 1)
return CLI_CMD_SYNTAX;
if (!strcmp(fields[1], "match") && fields_cnt > 3 && !strcmp(fields[2], "username"))
return terminate_exec1(fields, fields_cnt, client);
else if (!strcmp(fields[1], "username"))
......@@ -220,7 +220,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt,
return terminate_exec2(4, fields, fields_cnt, client);
else if (strcmp(fields[1], "all"))
return CLI_CMD_SYNTAX;
if (fields_cnt == 3) {
if (!strcmp(fields[2], "hard"))
hard = 1;
......@@ -228,7 +228,7 @@ static int terminate_exec(const char *cmd, char * const *fields, int fields_cnt,
return CLI_CMD_SYNTAX;
} else if (fields_cnt != 2)
return CLI_CMD_SYNTAX;
pthread_rwlock_rdlock(&ses_lock);
list_for_each_entry(ses, &ses_list, entry) {
if (hard)
......
......@@ -94,7 +94,7 @@ static int cli_client_send(struct cli_client_t *tcln, const void *_buf, int size
if (cln->disconnect)
return -1;
if (!list_empty(&cln->xmit_queue)) {
b = _malloc(sizeof(*b) + size);
b->size = size;
......@@ -197,10 +197,10 @@ static int cln_write(struct triton_md_handler_t *h)
{
struct tcp_client_t *cln = container_of(h, typeof(*cln), hnd);
int k;
if (!cln->xmit_buf)
return 0;
while (1) {
for (; cln->xmit_pos < cln->xmit_buf->size; cln->xmit_pos += k) {
k = write(cln->hnd.fd, cln->xmit_buf->buf + cln->xmit_pos, cln->xmit_buf->size - cln->xmit_pos);
......@@ -312,7 +312,7 @@ static void start_server(const char *host, int port)
log_emerg("cli: tcp: failed to create server socket: %s\n", strerror(errno));
return;
}
fcntl(serv_hnd.fd, F_SETFD, fcntl(serv_hnd.fd, F_GETFD) | FD_CLOEXEC);
memset(&addr, 0, sizeof(addr));
......@@ -323,7 +323,7 @@ static void start_server(const char *host, int port)
else
addr.sin_addr.s_addr = htonl(INADDR_ANY);
setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
if (bind (serv_hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
log_emerg("cli: tcp: failed to bind socket: %s\n", strerror(errno));
close(serv_hnd.fd);
......@@ -341,7 +341,7 @@ static void start_server(const char *host, int port)
close(serv_hnd.fd);
return;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(host);
......@@ -383,15 +383,15 @@ static void init(void)
port = atoi(d + 1);
if (port <= 0)
goto err_fmt;
load_config();
temp_buf = malloc(RECV_BUF_SIZE);
start_server(host, port);
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
return;
err_fmt:
log_emerg("cli: tcp: invalid format\n");
......
......@@ -142,7 +142,7 @@ static int telnet_send(struct telnet_client_t *cln, const void *_buf, int size)
if (cln->disconnect)
return -1;
if (!list_empty(&cln->xmit_queue)) {
b = _malloc(sizeof(*b) + size);
b->size = size;
......@@ -212,10 +212,10 @@ static int send_password_request(struct telnet_client_t *cln)
if (telnet_send(cln, buf0, sizeof(buf0)))
return -1;
if (telnet_send(cln, buf1, sizeof(buf1)))
return -1;
return 0;
}
......@@ -240,10 +240,10 @@ static int send_cmdline_tail(struct telnet_client_t *cln, int corr)
return -1;
memset(temp_buf, '\b', cln->cmdline_len - cln->cmdline_pos - corr);
if (telnet_send(cln, temp_buf, cln->cmdline_len - cln->cmdline_pos - corr))
return -1;
return 0;
}
......@@ -276,7 +276,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (c == '\n')
return 0;
if (c == '\r') {
cln->cmdline[cln->cmdline_len] = 0;
......@@ -304,14 +304,14 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
b->size = cln->cmdline_len;
list_add(&b->entry, cln->history.next);
cln->history_pos = cln->history.next;
if (conf_verbose == 2)
log_info2("cli: %s: %s\n", inet_ntoa(cln->addr.sin_addr), cln->cmdline);
if (cli_process_cmd(&cln->cli_client))
return -1;
}
cln->cmdline_pos = 0;
cln->cmdline_len = 0;
......@@ -346,7 +346,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (c != SE)
return 0;
}
cln->telcmd = 0;
} else if (cln->esc) {
if (cln->cmdline_pos2 == RECV_BUF_SIZE - 1) {
......@@ -360,7 +360,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (cln->cmdline_pos2 - cln->cmdline_len != 2)
return 0;
cln->esc = 0;
if (cln->auth) {
......@@ -413,14 +413,14 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
if (cln->cmdline_pos) {
if (cln->cmdline_pos < cln->cmdline_len) {
memmove(cln->cmdline + cln->cmdline_pos - 1, cln->cmdline + cln->cmdline_pos, cln->cmdline_len - cln->cmdline_pos);
cln->cmdline[cln->cmdline_len - 1] = ' ';
if (telnet_send(cln, "\b", 1))
return -1;
cln->cmdline_pos--;
if (send_cmdline_tail(cln, 0))
return -1;
} else {
......@@ -459,7 +459,7 @@ static int telnet_input_char(struct telnet_client_t *cln, uint8_t c)
return -1;
}
}
if (cln->cmdline_pos < cln->cmdline_len) {
if (send_cmdline_tail(cln, 0))
return -1;
......@@ -585,9 +585,9 @@ static int serv_read(struct triton_md_handler_t *h)
list_add(&b2->entry, conn->history.next);
}
pthread_mutex_unlock(&history_lock);
conn->history_pos = conn->history.next;
conn->cli_client.cmdline = conn->cmdline;
conn->cli_client.send = cli_client_send;
conn->cli_client.sendv = cli_client_sendv;
......@@ -649,7 +649,7 @@ static void start_server(const char *host, int port)
log_emerg("cli: telnet: failed to create server socket: %s\n", strerror(errno));
return;
}
fcntl(serv_hnd.fd, F_SETFD, fcntl(serv_hnd.fd, F_GETFD) | FD_CLOEXEC);
memset(&addr, 0, sizeof(addr));
......@@ -660,7 +660,7 @@ static void start_server(const char *host, int port)
else
addr.sin_addr.s_addr = htonl(INADDR_ANY);
setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
setsockopt(serv_hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv_hnd.fd, 4);
if (bind (serv_hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
log_emerg("cli: telnet: failed to bind socket: %s\n", strerror(errno));
close(serv_hnd.fd);
......@@ -678,7 +678,7 @@ static void start_server(const char *host, int port)
close(serv_hnd.fd);
return;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr(host);
......@@ -715,7 +715,7 @@ static void load_history_file(void)
f = fopen(conf_history_file, "r");
if (!f)
return;
while (fgets((char *)temp_buf, RECV_BUF_SIZE, f)) {
b = _malloc(sizeof(*b) + strlen((char *)temp_buf) + 1);
b->p_buf = NULL;
......@@ -747,12 +747,12 @@ static void init(void)
opt = conf_get_opt("cli", "telnet");
if (!opt)
return;
host = strdup(opt);
d = strstr(host, ":");
if (!d)
goto err_fmt;
*d = 0;
port = atoi(d + 1);
if (port <= 0)
......@@ -770,11 +770,11 @@ static void init(void)
load_history_file();
start_server(host, port);
atexit(save_history_file);
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
return;
err_fmt:
log_emerg("cli: telnet: invalid format\n");
......
......@@ -50,7 +50,7 @@ static int arp_read(struct triton_md_handler_t *h)
dst.sll_family = AF_PACKET;
dst.sll_ifindex = s->ipoe->ifindex;
dst.sll_protocol = htons(ETH_P_ARP);
ah2.ar_hrd = htons(ARPHRD_ETHER);
ah2.ar_pro = htons(ETH_P_IP);
ah2.ar_hln = ETH_ALEN;
......
......@@ -51,16 +51,16 @@ static int session_save(struct ap_session *ses, struct backup_mod *m)
if (conn->ifcfg)
flags |= IPOE_FLAG_IFCFG;
if (conn->dhcp_addr)
flags |= IPOE_FLAG_DHCP_ADDR;
if (conn->relay_addr)
flags |= IPOE_FLAG_RELAY_ADDR;
if (conn->l4_redirect)
flags |= IPOE_FLAG_L4_REDIR;
if (conn->l4_redirect_set)
flags |= IPOE_FLAG_L4_REDIR_SET;
......@@ -82,7 +82,7 @@ static int session_save(struct ap_session *ses, struct backup_mod *m)
if (conn->relay_agent)
add_tag(IPOE_TAG_RELAY_AGENT, conn->relay_agent->data, conn->relay_agent->len);
add_tag_i(IPOE_TAG_IFINDEX, &conn->ifindex, 4);
return 0;
......@@ -98,7 +98,7 @@ static int session_restore(struct ap_session *ses, struct backup_mod *m)
static void set_dhcpv4_opt(struct dhcpv4_option **opt, struct backup_tag *t, uint8_t **ptr)
{
*opt = (struct dhcpv4_option *)(*ptr);
*opt = (struct dhcpv4_option *)(*ptr);
(*opt)->len = t->size;
memcpy((*opt)->data, t->data, t->size);
(*ptr) += sizeof(**opt) + t->size;
......@@ -200,23 +200,23 @@ static struct ap_session *ctrl_restore(struct backup_mod *m)
if (flags & IPOE_FLAG_IFCFG)
ses->ifcfg = 1;
if (flags & IPOE_FLAG_DHCP_ADDR) {
dhcpv4_reserve_ip(ses->serv->dhcpv4, ses->yiaddr);
ses->dhcp_addr = 1;
}
if (flags & IPOE_FLAG_RELAY_ADDR)
ses->relay_addr = 1;
if (flags & IPOE_FLAG_L4_REDIR)
ses->l4_redirect = 1;
if (flags & IPOE_FLAG_L4_REDIR_SET && m->data->internal)
ses->l4_redirect = 1;
ses->serv = serv;
triton_context_register(&ses->ctx, &ses->ses);
triton_context_wakeup(&ses->ctx);
......
......@@ -57,10 +57,10 @@ static int open_raw_sock(void)
log_error("dhcpv4: socket(AF_PACKET, SOCK_RAW): %s\n", strerror(errno));
return -1;
}
fcntl(raw_sock, F_SETFL, O_NONBLOCK);
fcntl(raw_sock, F_SETFD, fcntl(raw_sock, F_GETFD) | FD_CLOEXEC);
pthread_setspecific(raw_sock_key, (void *)(long)raw_sock);
}
......@@ -78,7 +78,7 @@ static struct dhcpv4_iprange *parse_range(const char *str)
struct dhcpv4_iprange *r;
n = sscanf(str, "%u.%u.%u.%u/%u", &f1, &f2, &f3, &f4, &m);
if (n != 5)
goto parse_err;
if (f1 > 255)
......@@ -91,7 +91,7 @@ static struct dhcpv4_iprange *parse_range(const char *str)
goto parse_err;
if (m == 0 || m > 30)
goto parse_err;
start = (f1 << 24) | (f2 << 16) | (f3 << 8) | f4;
mask = ~((1 << (32 - m)) - 1);
start = start & mask;
......@@ -145,10 +145,10 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
addr.sin_addr.s_addr = htonl(INADDR_ANY);
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &f, sizeof(f)))
log_error("setsockopt(SO_REUSEADDR): %s\n", strerror(errno));
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &f, sizeof(f))) {
log_error("setsockopt(SO_BROADCAST): %s\n", strerror(errno));
......@@ -164,15 +164,15 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
log_error("setsockopt(SO_BINDTODEVICE): %s\n", strerror(errno));
goto out_err;
}
if (ioctl(sock, SIOCGIFHWADDR, &ifr)) {
log_error("dhcpv4(%s): ioctl(SIOCGIFHWADDR): %s\n", ifname, strerror(errno));
goto out_err;
}
fcntl(sock, F_SETFL, O_NONBLOCK);
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
serv = _malloc(sizeof(*serv));
memset(serv, 0, sizeof(*serv));
......@@ -186,13 +186,13 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
if (opt && *opt) {
str0 = _strdup(opt);
str = str0;
while (1) {
for (ptr1 = str + 1; *ptr1 && *ptr1 != '='; ptr1++);
if (!*ptr1)
break;
*ptr1 = 0;
for (ptr2 = ++ptr1; *ptr2 && *ptr2 != ','; ptr2++);
......@@ -213,7 +213,7 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
str = ptr2 + 1;
}
_free(str0);
}
......@@ -301,10 +301,10 @@ static int dhcpv4_parse_packet(struct dhcpv4_packet *pack, int len)
log_warn("dhcpv4: short packet received\n");
return -1;
}
if (pack->hdr->htype != 1)
return -1;
if (pack->hdr->hlen != 6)
return -1;
......@@ -318,7 +318,7 @@ static int dhcpv4_parse_packet(struct dhcpv4_packet *pack, int len)
ptr++;
continue;
}
if (*ptr == 0xff) {
ptr++;
break;
......@@ -357,9 +357,9 @@ static int dhcpv4_parse_packet(struct dhcpv4_packet *pack, int len)
if (dhcpv4_check_options(pack))
return -1;
pack->ptr = ptr;
/*if (conf_verbose) {
log_info2("recv ");
print_packet(pack, log_info2);
......@@ -465,7 +465,7 @@ int dhcpv4_packet_insert_opt82(struct dhcpv4_packet *pack, const char *agent_cir
r = dhcpv4_packet_add_opt(pack, 82, data, 4 + len1 + len2);
_free(data);
*pack->ptr++ = 255;
return r;
......@@ -500,7 +500,7 @@ static int dhcpv4_read(struct triton_md_handler_t *h)
dhcpv4_packet_free(pack);
continue;
}
if (pack->hdr->op != DHCP_OP_REQUEST) {
dhcpv4_packet_free(pack);
continue;
......@@ -510,7 +510,7 @@ static int dhcpv4_read(struct triton_md_handler_t *h)
if (serv->recv)
serv->recv(serv, pack);
dhcpv4_packet_free(pack);
}
}
......@@ -542,7 +542,7 @@ static int dhcpv4_relay_read(struct triton_md_handler_t *h)
dhcpv4_packet_free(pack);
continue;
}
if (pack->hdr->op != DHCP_OP_REPLY) {
dhcpv4_packet_free(pack);
continue;
......@@ -564,17 +564,17 @@ uint16_t ip_csum(uint16_t *buf, int len)
{
uint32_t sum=0;
int i;
for (i=0; i < len; i += 2)
sum += *buf++;
// take only 16 bits out of the 32 bit sum and add up the carries
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
// one's complement the result
sum = ~sum;
return sum & 0xffff;
}
......@@ -591,7 +591,7 @@ static int dhcpv4_send_raw(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
struct sockaddr_ll ll_addr;
struct msghdr msg;
int sock = open_raw_sock();
memset(&ll_addr, 0, sizeof(ll_addr));
ll_addr.sll_family = AF_PACKET;
ll_addr.sll_ifindex = serv->ifindex;
......@@ -638,7 +638,7 @@ static int dhcpv4_send_raw(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
printf("%i %i\n", errno, serv->ifindex);
return -1;
}
return 0;
}
......@@ -656,7 +656,7 @@ static int dhcpv4_send_udp(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
n = sendto(serv->hnd.fd, pack->data, len, 0, (struct sockaddr *)&addr, sizeof(addr));
if (n != len)
return -1;
return 0;
}
......@@ -674,7 +674,7 @@ int dhcpv4_packet_add_opt(struct dhcpv4_packet *pack, int type, const void *data
opt->type = type;
opt->len = len;
opt->data = pack->ptr;
opt->data = pack->ptr;
pack->ptr += len;
memcpy(opt->data, data, len);
......@@ -697,7 +697,7 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
} dns;
int dns_avail = 0;
struct dhcpv4_option *opt;
pack = dhcpv4_packet_alloc();
if (!pack) {
log_emerg("out of memory\n");
......@@ -717,17 +717,17 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
if (dhcpv4_packet_add_opt(pack, 53, &msg_type, 1))
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))
goto out_err;
if (router && dhcpv4_packet_add_opt(pack, 3, &router, 4))
goto out_err;
val = htonl(~((1 << (32 - mask)) - 1));
if (dhcpv4_packet_add_opt(pack, 1, &val, 4))
goto out_err;
......@@ -742,7 +742,7 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
goto out_err;
}
}
if (!dns_avail) {
if (conf_dns1 && conf_dns2) {
dns.dns1 = conf_dns1;
......@@ -783,7 +783,7 @@ int dhcpv4_send_nak(struct dhcpv4_serv *serv, struct dhcpv4_packet *req)
{
struct dhcpv4_packet *pack;
int val, r;
pack = dhcpv4_packet_alloc();
if (!pack) {
log_emerg("out of memory\n");
......@@ -801,7 +801,7 @@ int dhcpv4_send_nak(struct dhcpv4_serv *serv, struct dhcpv4_packet *req)
val = DHCPNAK;
if (dhcpv4_packet_add_opt(pack, 53, &val, 1))
goto out_err;
*pack->ptr++ = 255;
if (conf_verbose) {
......@@ -837,7 +837,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
int sock = -1;
int f = 1;
struct dhcpv4_relay_ctx *c;
ptr = strchr(_addr, ':');
if (ptr) {
memcpy(str, _addr, ptr - _addr);
......@@ -846,7 +846,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
port = atoi(ptr + 1);
} else
addr = inet_addr(_addr);
memset(&raddr, 0, sizeof(raddr));
raddr.sin_family = AF_INET;
raddr.sin_addr.s_addr = addr;
......@@ -862,7 +862,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
if (r->addr == addr && r->giaddr == giaddr)
goto found;
}
r = _malloc(sizeof(*r));
memset(r, 0, sizeof(*r));
INIT_LIST_HEAD(&r->ctx_list);
......@@ -877,7 +877,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &f, sizeof(f)))
log_error("dhcpv4: setsockopt(SO_REUSEADDR): %s\n", strerror(errno));
if (bind(sock, &laddr, sizeof(laddr))) {
log_error("dhcpv4: relay: %s: bind: %s\n", _addr, strerror(errno));
goto out_err_unlock;
......@@ -887,7 +887,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
log_error("dhcpv4: relay: %s: connect: %s\n", _addr, strerror(errno));
goto out_err_unlock;
}
fcntl(sock, F_SETFL, O_NONBLOCK);
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
......@@ -908,7 +908,7 @@ found:
c->ctx = ctx;
c->recv = recv;
list_add_tail(&c->entry, &r->ctx_list);
pthread_mutex_unlock(&relay_lock);
return r;
......@@ -965,11 +965,11 @@ int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request,
if (server_id) {
opt = dhcpv4_packet_find_opt(request, 54);
if (opt) {
_server_id = *(uint32_t *)opt->data;
_server_id = *(uint32_t *)opt->data;
*(uint32_t *)opt->data = server_id;
}
}
if (conf_verbose) {
log_ppp_info2("send ");
dhcpv4_print_packet(request, 1, log_ppp_info2);
......@@ -982,10 +982,10 @@ int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request,
if (opt)
*(uint32_t *)opt->data = _server_id;
if (n != len)
return -1;
return 0;
}
......@@ -1019,7 +1019,7 @@ int dhcpv4_relay_send_release(struct dhcpv4_relay *relay, uint8_t *chaddr, uint3
if (client_id && dhcpv4_packet_add_opt(pack, 61, client_id->data, client_id->len))
goto out_err;
if (relay_agent && dhcpv4_packet_add_opt(pack, 82, relay_agent->data, relay_agent->len))
goto out_err;
else if (!relay_agent) {
......@@ -1028,18 +1028,18 @@ int dhcpv4_relay_send_release(struct dhcpv4_relay *relay, uint8_t *chaddr, uint3
goto out_err;
pack->ptr--;
}
*pack->ptr++ = 255;
len = pack->ptr - pack->data;
if (conf_verbose) {
log_ppp_info2("send ");
dhcpv4_print_packet(pack, 1, log_ppp_info2);
}
n = write(relay->hnd.fd, pack->data, len);
dhcpv4_packet_free(pack);
return n == len ? 0 : -1;
......@@ -1055,7 +1055,7 @@ int dhcpv4_get_ip(struct dhcpv4_serv *serv, uint32_t *yiaddr, uint32_t *siaddr,
if (!serv->range)
return 0;
pthread_mutex_lock(&serv->range->lock);
while (1) {
......@@ -1074,7 +1074,7 @@ int dhcpv4_get_ip(struct dhcpv4_serv *serv, uint32_t *yiaddr, uint32_t *siaddr,
if (serv->range->pos == 0)
break;
serv->range->pos = 0;
}
......@@ -1097,7 +1097,7 @@ void dhcpv4_put_ip(struct dhcpv4_serv *serv, uint32_t ip)
void dhcpv4_reserve_ip(struct dhcpv4_serv *serv, uint32_t ip)
{
int n = ntohl(ip) - serv->range->startip;
if (n <= 0 || n / (8 * sizeof(long)) >= serv->range->len)
return;
......@@ -1108,7 +1108,7 @@ void dhcpv4_reserve_ip(struct dhcpv4_serv *serv, uint32_t ip)
static void load_config()
{
const char *opt;
const char *opt;
opt = conf_get_opt("ipoe", "verbose");
if (opt)
......@@ -1117,7 +1117,7 @@ static void load_config()
opt = conf_get_opt("dns", "dns1");
if (opt)
conf_dns1 = inet_addr(opt);
opt = conf_get_opt("dns", "dns2");
if (opt)
conf_dns2 = inet_addr(opt);
......@@ -1127,7 +1127,7 @@ static void init()
{
pack_pool = mempool_create(BUF_SIZE + sizeof(struct dhcpv4_packet));
opt_pool = mempool_create(sizeof(struct dhcpv4_option));
pthread_key_create(&raw_sock_key, close_raw_sock);
load_config();
......
......@@ -80,7 +80,7 @@ struct dhcpv4_iprange {
int len;
pthread_mutex_t lock;
unsigned long free[0];
};
};
struct dhcpv4_serv {
struct triton_context_t *ctx;
......
......@@ -131,7 +131,7 @@ static void print_ip(const struct dhcpv4_option *opt, int elem_size, void (*prin
{
int i, n = opt->len / elem_size;
uint32_t ip;
for (i = 0; i < n; i++) {
ip = ntohl(*(uint32_t *)(opt->data + i*elem_size));
......@@ -172,10 +172,10 @@ static void print_route(const struct dhcpv4_option *opt, int elem_size, void (*p
for (i = 0; i < n; i++) {
ip = ntohl(*(uint32_t *)(opt->data + i*8));
gw = ntohl(*(uint32_t *)(opt->data + i*8 + 4));
if (i)
print(",");
print("%i.%i.%i.%i via %i.%i.%i.%i",
(ip >> 24) & 0xff,
(ip >> 16) & 0xff,
......@@ -275,7 +275,7 @@ static void print_classless_route(const struct dhcpv4_option *opt, int elem_size
ptr += 4;
gw = ntohl(*(uint32_t *)ptr);
ptr += 4;
print("%i.%i.%i.%i/%i via %i.%i.%i.%i",
(ip >> 24) & 0xff,
(ip >> 16) & 0xff,
......
此差异已折叠。
......@@ -63,7 +63,7 @@ void ipoe_nl_add_net(uint32_t addr, int mask)
struct nlmsghdr n;
char buf[1024];
} req;
if (rth.fd == -1)
return;
......@@ -74,7 +74,7 @@ void ipoe_nl_add_net(uint32_t addr, int mask)
ghdr = NLMSG_DATA(&req.n);
ghdr->cmd = IPOE_CMD_ADD_NET;
mask = ((1 << mask) - 1) << (32 - mask);
addattr32(nlh, 1024, IPOE_ATTR_ADDR, addr);
......@@ -94,12 +94,12 @@ int ipoe_nl_add_exclude(uint32_t addr, int mask)
char buf[1024];
} req;
int ret = 0;
if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) {
log_ppp_error("ipoe: cannot open generic netlink socket\n");
return -1;
}
nlh = &req.n;
nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
......@@ -115,9 +115,9 @@ int ipoe_nl_add_exclude(uint32_t addr, int mask)
log_ppp_error("ipoe: nl_add_net: error talking to kernel\n");
ret = -1;
}
rtnl_close(&rth);
return ret;
}
......@@ -130,7 +130,7 @@ void ipoe_nl_del_exclude(uint32_t addr)
struct nlmsghdr n;
char buf[1024];
} req;
if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) {
log_ppp_error("ipoe: cannot open generic netlink socket\n");
return;
......@@ -148,7 +148,7 @@ void ipoe_nl_del_exclude(uint32_t addr)
if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL, 0) < 0 )
log_ppp_error("ipoe: nl_add_net: error talking to kernel\n");
rtnl_close(&rth);
}
......@@ -186,7 +186,7 @@ void ipoe_nl_add_interface(int ifindex)
struct nlmsghdr n;
char buf[1024];
} req;
if (rth.fd == -1)
return;
......@@ -238,10 +238,10 @@ int ipoe_nl_create(uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_
if (peer_addr)
addattr32(nlh, 1024, IPOE_ATTR_PEER_ADDR, peer_addr);
if (addr)
addattr32(nlh, 1024, IPOE_ATTR_ADDR, addr);
if (hwaddr) {
memcpy(u.hwaddr, hwaddr, 6);
addattr_l(nlh, 1024, IPOE_ATTR_HWADDR, &u.u64, 8);
......@@ -252,7 +252,7 @@ int ipoe_nl_create(uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_
if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL, 0) < 0 )
log_ppp_error("ipoe: nl_create: error talking to kernel\n");
if (nlh->nlmsg_type != ipoe_genl_id) {
log_ppp_error("ipoe: not a IPoE message %d\n", nlh->nlmsg_type);
goto out;
......@@ -281,7 +281,7 @@ int ipoe_nl_create(uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_
}
ret = *(uint32_t *)(RTA_DATA(tb[IPOE_ATTR_IFINDEX]));
out:
rtnl_close(&rth);
......@@ -319,7 +319,7 @@ int ipoe_nl_modify(int ifindex, uint32_t peer_addr, uint32_t addr, const char *i
addattr32(nlh, 1024, IPOE_ATTR_IFINDEX, ifindex);
addattr32(nlh, 1024, IPOE_ATTR_PEER_ADDR, peer_addr);
addattr32(nlh, 1024, IPOE_ATTR_ADDR, addr);
if (hwaddr) {
memcpy(u.hwaddr, hwaddr, 6);
addattr_l(nlh, 1024, IPOE_ATTR_HWADDR, &u.u64, 8);
......@@ -332,7 +332,7 @@ int ipoe_nl_modify(int ifindex, uint32_t peer_addr, uint32_t addr, const char *i
log_ppp_error("ipoe: nl_create: error talking to kernel\n");
ret = -1;
}
rtnl_close(&rth);
return ret;
......@@ -399,7 +399,7 @@ void ipoe_nl_get_sessions(struct list_head *list)
if (rth.fd == -1)
return;
nlh = &req.n;
nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
nlh->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
......@@ -456,7 +456,7 @@ int ipoe_nl_add_vlan_mon(int ifindex, long *mask, int len)
struct nlmsghdr n;
char buf[1024];
} req;
if (rth.fd == -1)
return -1;
......@@ -489,12 +489,12 @@ int ipoe_nl_add_vlan_mon_vid(int ifindex, int vid)
char buf[1024];
} req;
int r = 0;
if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) {
log_error("ipoe: cannot open generic netlink socket\n");
return -1;
}
nlh = &req.n;
nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
......@@ -510,7 +510,7 @@ int ipoe_nl_add_vlan_mon_vid(int ifindex, int vid)
log_error("ipoe: nl_add_vlan_mon_vid: error talking to kernel\n");
r = -1;
}
rtnl_close(&rth);
return r;
......@@ -525,7 +525,7 @@ int ipoe_nl_del_vlan_mon(int ifindex)
struct nlmsghdr n;
char buf[1024];
} req;
if (rth.fd == -1)
return -1;
......@@ -575,7 +575,7 @@ static void ipoe_up_handler(const struct sockaddr_nl *addr, struct nlmsghdr *h)
break;
parse_rtattr_nested(tb2, IPOE_ATTR_MAX, tb[i]);
if (!tb2[IPOE_ATTR_ETH_HDR] || !tb2[IPOE_ATTR_IP_HDR] || !tb2[IPOE_ATTR_IFINDEX])
continue;
......@@ -612,7 +612,7 @@ static void ipoe_vlan_mon_handler(const struct sockaddr_nl *addr, struct nlmsghd
break;
parse_rtattr_nested(tb2, IPOE_ATTR_MAX, tb[i]);
if (!tb2[IPOE_ATTR_IFINDEX] || !tb2[IPOE_ATTR_ADDR])
continue;
......@@ -657,7 +657,7 @@ static int ipoe_mc_read(struct triton_md_handler_t *h)
continue;
return 0;
}
if (status == 0) {
log_error("ipoe: EOF on netlink\n");
return 0;
......@@ -728,13 +728,13 @@ static void init(void)
rth.fd = -1;
return;
}
if (rtnl_open_byproto(&rth, 1 << (mcg_id - 1), NETLINK_GENERIC)) {
log_error("ipoe: cannot open generic netlink socket\n");
rth.fd = -1;
return;
}
fcntl(rth.fd, F_SETFL, O_NONBLOCK);
fcntl(rth.fd, F_SETFD, fcntl(rth.fd, F_GETFD) | FD_CLOEXEC);
......
......@@ -70,7 +70,7 @@ static int packet4_hdr(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
if (!strcmp(name, "xid"))
lua_pushinteger(L, ses->dhcpv4_request->hdr->xid);
else if (!strcmp(name, "ciaddr")) {
......@@ -95,9 +95,9 @@ static int packet4_ifname(lua_State *L)
if (!ses)
return 0;
lua_pushstring(L, ses->serv->ifname);
return 1;
}
......@@ -129,7 +129,7 @@ static int packet4_options(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
lua_newtable(L);
list_for_each_entry(opt, &ses->dhcpv4_request->options, entry) {
......@@ -146,12 +146,12 @@ static int packet4_agent_circuit_id(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
if (ses->agent_circuit_id)
lua_pushlstring(L, (char *)(ses->agent_circuit_id + 1), *ses->agent_circuit_id);
else
lua_pushnil(L);
return 1;
}
......@@ -161,12 +161,12 @@ static int packet4_agent_remote_id(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
if (ses->agent_remote_id)
lua_pushlstring(L, (char *)(ses->agent_remote_id + 1), *ses->agent_remote_id);
else
lua_pushnil(L);
return 1;
}
......@@ -264,7 +264,7 @@ char *ipoe_lua_get_username(struct ipoe_session *ses, const char *func)
lua_settop(L, 0);
return r;
out_err:
file_error = 1;
lua_close(L);
......
......@@ -109,7 +109,7 @@ static int l_unpack(lua_State *L) /** unpack(s,f,[init]) */
{
int c=*f++;
int N=1;
if (isdigit(*f))
if (isdigit(*f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
......@@ -204,7 +204,7 @@ static int l_pack(lua_State *L) /** pack(f,...) */
{
int c=*f++;
int N=1;
if (isdigit(*f))
if (isdigit(*f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
......
......@@ -70,7 +70,7 @@ const struct l2tp_dict_value_t *l2tp_dict_find_value(const struct l2tp_dict_attr
static char *skip_word(char *ptr)
{
for(; *ptr; ptr++)
if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
break;
return ptr;
}
......@@ -91,9 +91,9 @@ static int split(char *buf, char **ptr)
buf = skip_word(buf);
if (!*buf)
return i;
*buf = 0;
buf = skip_space(buf + 1);
if (!*buf)
return i;
......@@ -153,12 +153,12 @@ static int dict_load(const char *fname)
} else if (!strcmp(buf, "ATTRIBUTE")) {
if (r < 3)
goto out_syntax;
attr = malloc(sizeof(*attr));
memset(attr, 0, sizeof(*attr));
list_add_tail(&attr->entry, items);
INIT_LIST_HEAD(&attr->values);
attr->name = strdup(ptr[0]);
attr->id = strtol(ptr[1], &endptr, 10);
if (*endptr != 0)
......@@ -197,7 +197,7 @@ static int dict_load(const char *fname)
} else if (!strcmp(buf, "VALUE")) {
if (r != 3)
goto out_syntax;
attr = l2tp_dict_find_attr_by_name(ptr[0]);
if (!attr) {
log_emerg("l2tp:%s:%i: attribute not found\n", fname, n);
......
......@@ -4552,7 +4552,7 @@ static int start_udp_server(void)
err_hnd:
triton_md_unregister_handler(&udp_serv.hnd, 1);
triton_context_unregister(&udp_serv.ctx);
return -1;
err_fd:
......@@ -4888,7 +4888,7 @@ static void load_config(void)
opt = conf_get_opt("l2tp", "dir300_quirk");
if (opt)
conf_dir300_quirk = atoi(opt);
conf_mppe = MPPE_UNSET;
opt = conf_get_opt("l2tp", "mppe");
if (opt) {
......
......@@ -11,7 +11,7 @@ void l2tp_nl_delete_tunnel(int tid)
{
struct nl_sock *nl_sock;
struct nl_msg *msg;
nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
......@@ -32,10 +32,10 @@ void l2tp_nl_create_tunnel(int fd, int tid, int peer_tid)
{
struct nl_sock *nl_sock;
struct nl_msg *msg;
nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
genl_connect(nl_sock);
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_REQUEST, L2TP_CMD_TUNNEL_CREATE, L2TP_GENL_VERSION);
......@@ -58,10 +58,10 @@ void l2tp_nl_create_session(int tid, int sid, int peer_sid)
{
struct nl_sock *nl_sock;
struct nl_msg *msg;
nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
genl_connect(nl_sock);
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_REQUEST, L2TP_CMD_SESSION_CREATE, L2TP_GENL_VERSION);
......@@ -83,11 +83,11 @@ void l2tp_nl_create_session(int tid, int sid, int peer_sid)
static void init(void)
{
struct nl_sock *nl_sock = nl_socket_alloc();
genl_connect(nl_sock);
family = genl_ctrl_resolve(nl_sock, L2TP_GENL_NAME);
nl_close(nl_sock);
nl_socket_free(nl_sock);
}
......
......@@ -69,7 +69,7 @@ struct l2tp_packet_t *l2tp_packet_alloc(int ver, int msg_type,
struct l2tp_packet_t *pack = mempool_alloc(pack_pool);
if (!pack)
return NULL;
memset(pack, 0, sizeof(*pack));
INIT_LIST_HEAD(&pack->attrs);
pack->hdr.ver = ver;
......@@ -250,16 +250,16 @@ int l2tp_recv(int fd, struct l2tp_packet_t **p, struct in_pktinfo *pkt_info,
memset(&msg, 0, sizeof(msg));
msg.msg_control = msg_control;
msg.msg_controllen = 128;
n = recvmsg(fd, &msg, MSG_PEEK);
if (n < 0) {
if (errno == EAGAIN)
return -1;
log_error("l2tp: recvmsg: %s\n", strerror(errno));
return 0;
}
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
memcpy(pkt_info, CMSG_DATA(cmsg), sizeof(*pkt_info));
......
......@@ -77,7 +77,7 @@ static int intf_exec(const char *cmd, char * const *fields, int fields_cnt, void
pppoe_server_stop(fields[3]);
else
goto help;
return CLI_CMD_OK;
help:
intf_help(fields, fields_cnt, client);
......@@ -149,9 +149,9 @@ static int show_verbose_exec(const char *cmd, char * const *f, int f_cnt, void *
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
cli_sendv(cli, "%i\r\n", conf_verbose);
return CLI_CMD_OK;
}
......@@ -159,9 +159,9 @@ static int show_pado_delay_exec(const char *cmd, char * const *f, int f_cnt, voi
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
cli_sendv(cli, "%s\r\n", conf_pado_delay);
return CLI_CMD_OK;
}
......@@ -169,12 +169,12 @@ static int show_service_name_exec(const char *cmd, char * const *f, int f_cnt, v
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
if (conf_service_name)
cli_sendv(cli, "%s\r\n", conf_service_name);
else
cli_sendv(cli, "*\r\n");
return CLI_CMD_OK;
}
......@@ -182,9 +182,9 @@ static int show_ac_name_exec(const char *cmd, char * const *f, int f_cnt, void *
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
cli_sendv(cli, "%s\r\n", conf_ac_name);
return CLI_CMD_OK;
}
......@@ -192,14 +192,14 @@ static int set_verbose_exec(const char *cmd, char * const *f, int f_cnt, void *c
{
if (f_cnt != 4)
return CLI_CMD_SYNTAX;
if (!strcmp(f[3], "0"))
conf_verbose = 0;
else if (!strcmp(f[3], "1"))
conf_verbose = 1;
else
return CLI_CMD_INVAL;
return CLI_CMD_OK;
}
......@@ -218,7 +218,7 @@ static int set_service_name_exec(const char *cmd, char * const *f, int f_cnt, vo
{
if (f_cnt != 4)
return CLI_CMD_SYNTAX;
if (conf_service_name)
_free(conf_service_name);
......@@ -226,7 +226,7 @@ static int set_service_name_exec(const char *cmd, char * const *f, int f_cnt, vo
conf_service_name = NULL;
else
conf_service_name = _strdup(f[3]);
return CLI_CMD_OK;
}
......@@ -234,10 +234,10 @@ static int set_ac_name_exec(const char *cmd, char * const *f, int f_cnt, void *c
{
if (f_cnt != 4)
return CLI_CMD_SYNTAX;
_free(conf_ac_name);
conf_ac_name = _strdup(f[3]);
return CLI_CMD_OK;
}
//===================================
......
......@@ -37,7 +37,7 @@ void dpado_check_next(int conn_cnt)
dpado_range_next = list_entry(dpado_range_next->entry.next, typeof(*dpado_range_next), entry);
else
dpado_range_next = NULL;
/*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
/*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
dpado_range_prev?dpado_range_prev->pado_delay:0,dpado_range_prev?dpado_range_prev->conn_cnt:0,
dpado_range_next?dpado_range_next->pado_delay:0,dpado_range_next?dpado_range_next->conn_cnt:0,
pado_delay);*/
......@@ -52,7 +52,7 @@ void dpado_check_prev(int conn_cnt)
dpado_range_next = dpado_range_prev;
dpado_range_prev = list_entry(dpado_range_prev->entry.prev, typeof(*dpado_range_prev), entry);
pado_delay = dpado_range_prev->pado_delay;
/*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
/*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
dpado_range_prev?dpado_range_prev->pado_delay:0,dpado_range_prev?dpado_range_prev->conn_cnt:0,
dpado_range_next?dpado_range_next->pado_delay:0,dpado_range_next?dpado_range_next->conn_cnt:0,
pado_delay);*/
......@@ -144,7 +144,7 @@ int dpado_parse(const char *str)
if (conf_pado_delay)
_free(conf_pado_delay);
conf_pado_delay = _strdup(str);
/*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
/*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
dpado_range_prev?dpado_range_prev->pado_delay:0,dpado_range_prev?dpado_range_prev->conn_cnt:0,
dpado_range_next?dpado_range_next->pado_delay:0,dpado_range_next?dpado_range_next->conn_cnt:0,
pado_delay);*/
......
......@@ -73,7 +73,7 @@ static int mac_filter_load(const char *opt)
log_emerg("pppoe: open '%s': %s\n", name, strerror(errno));
goto err;
}
conf_mac_filter = opt;
pthread_rwlock_wrlock(&lock);
......@@ -274,7 +274,7 @@ static void init(void)
const char *opt = conf_get_opt("pppoe", "mac-filter");
if (!opt || mac_filter_load(opt))
type = -1;
cli_register_simple_cmd2(cmd_exec, cmd_help, 2, "pppoe", "mac-filter");
}
......
......@@ -49,7 +49,7 @@ struct pppoe_conn_t {
struct pppoe_tag *service_name;
struct pppoe_tag *tr101;
uint8_t cookie[COOKIE_LENGTH - 4];
struct ap_ctrl ctrl;
struct ppp_t ppp;
#ifdef RADIUS
......@@ -153,7 +153,7 @@ static void disconnect(struct pppoe_conn_t *conn)
pppoe_server_free(conn->serv);
} else
pthread_mutex_unlock(&conn->serv->lock);
pthread_mutex_lock(&sid_lock);
sid_map[conn->sid/(8*sizeof(long))] |= 1 << (conn->sid % (8*sizeof(long)));
pthread_mutex_unlock(&sid_lock);
......@@ -209,7 +209,7 @@ static int pppoe_rad_send_access_request(struct rad_plugin_t *rad, struct rad_pa
if (conn->tr101)
return tr101_send_access_request(conn->tr101, pack);
return 0;
}
......@@ -219,11 +219,11 @@ static int pppoe_rad_send_accounting_request(struct rad_plugin_t *rad, struct ra
if (conn->tr101)
return tr101_send_accounting_request(conn->tr101, pack);
return 0;
}
#endif
static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const uint8_t *addr, const struct pppoe_tag *host_uniq, const struct pppoe_tag *relay_sid, const struct pppoe_tag *service_name, const struct pppoe_tag *tr101, const uint8_t *cookie)
{
struct pppoe_conn_t *conn;
......@@ -241,18 +241,18 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
old_sid_ptr = sid_ptr;
while (1) {
int bit = ffsl(*sid_ptr) - 1;
if (bit != -1) {
conn->sid = sid_idx*8*sizeof(long) + bit;
*sid_ptr &= ~(1lu << bit);
}
if (++sid_idx == SID_MAX/8/sizeof(long)) {
sid_ptr = sid_map;
sid_idx = 0;
} else
sid_ptr++;
if (bit != -1)
break;
......@@ -349,7 +349,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
else
sprintf(conn->ctrl.calling_station_id, "%02x:%02x:%02x:%02x:%02x:%02x",
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
ppp_init(&conn->ppp);
conn->ppp.ses.ctrl = &conn->ctrl;
......@@ -357,16 +357,16 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
if (conf_ip_pool)
conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
conn->disc_sock = dup(serv->hnd.fd);
triton_context_register(&conn->ctx, &conn->ppp.ses);
pthread_mutex_lock(&serv->lock);
list_add_tail(&conn->entry, &serv->conn_list);
serv->conn_cnt++;
pthread_mutex_unlock(&serv->lock);
return conn;
}
......@@ -374,7 +374,7 @@ static void connect_channel(struct pppoe_conn_t *conn)
{
int sock;
struct sockaddr_pppox sp;
triton_event_fire(EV_CTRL_STARTING, &conn->ppp.ses);
triton_event_fire(EV_CTRL_STARTED, &conn->ppp.ses);
......@@ -383,7 +383,7 @@ static void connect_channel(struct pppoe_conn_t *conn)
log_error("pppoe: socket(PPPOX): %s\n", strerror(errno));
goto out_err;
}
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
memset(&sp, 0, sizeof(sp));
......@@ -403,7 +403,7 @@ static void connect_channel(struct pppoe_conn_t *conn)
if (establish_ppp(&conn->ppp))
goto out_err_close;
#ifdef RADIUS
if (conn->tr101 && triton_module_loaded("radius")) {
conn->radius.send_access_request = pppoe_rad_send_access_request;
......@@ -413,9 +413,9 @@ static void connect_channel(struct pppoe_conn_t *conn)
#endif
conn->ppp_started = 1;
dpado_check_next(__sync_add_and_fetch(&stat_active, 1));
return;
out_err_close:
......@@ -478,8 +478,8 @@ static void print_packet(uint8_t *pack)
log_info2("PADT");
break;
}
log_info2(" %02x:%02x:%02x:%02x:%02x:%02x => %02x:%02x:%02x:%02x:%02x:%02x",
log_info2(" %02x:%02x:%02x:%02x:%02x:%02x => %02x:%02x:%02x:%02x:%02x:%02x",
ethhdr->h_source[0], ethhdr->h_source[1], ethhdr->h_source[2], ethhdr->h_source[3], ethhdr->h_source[4], ethhdr->h_source[5],
ethhdr->h_dest[0], ethhdr->h_dest[1], ethhdr->h_dest[2], ethhdr->h_dest[3], ethhdr->h_dest[4], ethhdr->h_dest[5]);
......@@ -577,7 +577,7 @@ static void generate_cookie(struct pppoe_serv_t *serv, const uint8_t *src, uint8
u1.raw[16 + i] = buf[i] ^ buf[i + 4] ^ buf[i + 8] ^ buf[i + 12];
} else
memset(u1.raw + 16, 0, 4);
*(uint32_t *)(u1.raw + 20) = ts.tv_sec + conf_cookie_timeout;
for (i = 0; i < 3; i++)
......@@ -585,7 +585,7 @@ static void generate_cookie(struct pppoe_serv_t *serv, const uint8_t *src, uint8
for (i = 0; i < 3; i++)
DES_ecb_encrypt(&u2.b[i], &u1.b[i], &serv->des_ks, DES_ENCRYPT);
memcpy(cookie, u1.raw, 24);
}
......@@ -593,7 +593,7 @@ static int check_cookie(struct pppoe_serv_t *serv, const uint8_t *src, const uin
{
MD5_CTX ctx;
DES_cblock key;
DES_key_schedule ks;
DES_key_schedule ks;
int i;
union {
DES_cblock b[3];
......@@ -602,7 +602,7 @@ static int check_cookie(struct pppoe_serv_t *serv, const uint8_t *src, const uin
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
memcpy(key, serv->hwaddr, 6);
key[6] = src[4];
key[7] = src[5];
......@@ -612,13 +612,13 @@ static int check_cookie(struct pppoe_serv_t *serv, const uint8_t *src, const uin
for (i = 0; i < 3; i++)
DES_ecb_encrypt(&u1.b[i], &u2.b[i], &serv->des_ks, DES_DECRYPT);
for (i = 0; i < 3; i++)
DES_ecb_encrypt(&u2.b[i], &u1.b[i], &ks, DES_DECRYPT);
if (*(uint32_t *)(u1.raw + 20) < ts.tv_sec)
return 1;
MD5_Init(&ctx);
MD5_Update(&ctx, serv->secret, SECRET_LENGTH);
MD5_Update(&ctx, serv->hwaddr, ETH_ALEN);
......@@ -664,7 +664,7 @@ static void add_tag2(uint8_t *pack, const struct pppoe_tag *t)
struct pppoe_tag *tag = (struct pppoe_tag *)(pack + ETH_HLEN + sizeof(*hdr) + ntohs(hdr->length));
memcpy(tag, t, sizeof(*t) + ntohs(t->tag_len));
hdr->length = htons(ntohs(hdr->length) + sizeof(*tag) + ntohs(t->tag_len));
}
......@@ -695,14 +695,14 @@ static void pppoe_send_PADO(struct pppoe_serv_t *serv, const uint8_t *addr, cons
if (service_name)
add_tag2(pack, service_name);
generate_cookie(serv, addr, cookie, host_uniq, relay_sid);
add_tag(pack, TAG_AC_COOKIE, cookie, COOKIE_LENGTH);
if (host_uniq)
add_tag2(pack, host_uniq);
if (relay_sid)
add_tag2(pack, relay_sid);
......@@ -726,7 +726,7 @@ static void pppoe_send_err(struct pppoe_serv_t *serv, const uint8_t *addr, const
if (host_uniq)
add_tag2(pack, host_uniq);
if (relay_sid)
add_tag2(pack, relay_sid);
......@@ -745,12 +745,12 @@ static void pppoe_send_PADS(struct pppoe_conn_t *conn)
setup_header(pack, conn->serv->hwaddr, conn->addr, CODE_PADS, conn->sid);
add_tag(pack, TAG_AC_NAME, (uint8_t *)conf_ac_name, strlen(conf_ac_name));
add_tag2(pack, conn->service_name);
if (conn->host_uniq)
add_tag2(pack, conn->host_uniq);
if (conn->relay_sid)
add_tag2(pack, conn->relay_sid);
......@@ -831,13 +831,13 @@ static int check_padi_limit(struct pppoe_serv_t *serv, uint8_t *addr)
} else
break;
}
if (serv->padi_cnt == serv->padi_limit)
return -1;
if (conf_padi_limit && total_padi_cnt >= conf_padi_limit)
return -1;
list_for_each_entry(padi, &serv->padi_list, entry) {
if (memcmp(padi->addr, addr, ETH_ALEN) == 0)
return -1;
......@@ -846,7 +846,7 @@ static int check_padi_limit(struct pppoe_serv_t *serv, uint8_t *addr)
padi = mempool_alloc(padi_pool);
if (!padi)
return -1;
padi->ts = ts;
memcpy(padi->addr, addr, ETH_ALEN);
list_add_tail(&padi->entry, &serv->padi_list);
......@@ -990,13 +990,13 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (ap_shutdown)
return;
if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) {
if (conf_verbose)
log_warn("pppoe: discard PADR (destination address is broadcast)\n");
return;
}
if (hdr->sid) {
if (conf_verbose)
log_warn("pppoe: discarding PADR packet (sid is not zero)\n");
......@@ -1007,7 +1007,7 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
log_info2("recv ");
print_packet(pack);
}
for (n = 0; n < ntohs(hdr->length); n += sizeof(*tag) + ntohs(tag->tag_len)) {
tag = (struct pppoe_tag *)(pack + ETH_HLEN + sizeof(*hdr) + n);
......@@ -1110,13 +1110,13 @@ static void pppoe_recv_PADT(struct pppoe_serv_t *serv, uint8_t *pack)
struct pppoe_hdr *hdr = (struct pppoe_hdr *)(pack + ETH_HLEN);
struct pppoe_conn_t *conn;
uint16_t sid = ntohs(hdr->sid);
if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) {
if (conf_verbose)
log_warn("pppoe: discard PADT (destination address is broadcast)\n");
return;
}
if (conf_verbose) {
log_info2("recv ");
print_packet(pack);
......@@ -1191,7 +1191,7 @@ static int pppoe_serv_read(struct triton_md_handler_t *h)
log_warn("pppoe: discarding packet (unsupported version %i)\n", hdr->ver);
continue;
}
if (hdr->type != 1) {
if (conf_verbose)
log_warn("pppoe: discarding packet (unsupported type %i)\n", hdr->type);
......@@ -1266,13 +1266,13 @@ static void pppoe_add_interface_re(const char *opt, void *cli)
struct iplink_arg arg;
for (ptr = opt; *ptr && *ptr != ','; ptr++);
pattern = _malloc(ptr - (opt + 3) + 1);
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
if (!re) {
log_error("pppoe: %s at %i\r\n", pcre_err, pcre_offset);
return;
......@@ -1352,7 +1352,7 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli)
_free(serv);
return;
}
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &f, sizeof(f))) {
......@@ -1398,7 +1398,7 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli)
cli_sendv(cli, "interface %s has MTU of %i, should be %i\r\n", ifname, ifr.ifr_mtu, ETH_DATA_LEN);
log_error("pppoe: interface %s has MTU of %i, should be %i\n", ifname, ifr.ifr_mtu, ETH_DATA_LEN);
}
if (ioctl(sock, SIOCGIFINDEX, &ifr)) {
if (cli)
cli_sendv(cli, "ioctl(SIOCGIFINDEX): %s\r\n", strerror(errno));
......@@ -1464,7 +1464,7 @@ static void _server_stop(struct pppoe_serv_t *serv)
if (serv->stopping)
return;
serv->stopping = 1;
triton_md_disable_handler(&serv->hnd, MD_MODE_READ | MD_MODE_WRITE);
......@@ -1578,11 +1578,11 @@ static void load_config(void)
opt = conf_get_opt("pppoe", "PADO-Delay");
if (opt)
dpado_parse(opt);
opt = conf_get_opt("pppoe", "tr101");
if (opt)
conf_tr101 = atoi(opt);
opt = conf_get_opt("pppoe", "padi-limit");
if (opt)
conf_padi_limit = atoi(opt);
......@@ -1590,7 +1590,7 @@ static void load_config(void)
opt = conf_get_opt("pppoe", "sid-uppercase");
if (opt)
conf_sid_uppercase = atoi(opt);
opt = conf_get_opt("pppoe", "cookie-timeout");
if (opt)
conf_cookie_timeout = atoi(opt);
......@@ -1665,7 +1665,7 @@ static void pppoe_init(void)
log_error("pppoe: no configuration, disabled...\n");
return;
}
load_config();
connlimit_loaded = triton_module_loaded("connlimit");
......
......@@ -78,7 +78,7 @@ static void disconnect(struct pptp_conn_t *conn)
log_ppp_debug("pptp: disconnect\n");
triton_md_unregister_handler(&conn->hnd, 1);
if (conn->timeout_timer.tpd)
triton_timer_del(&conn->timeout_timer);
......@@ -93,14 +93,14 @@ static void disconnect(struct pptp_conn_t *conn)
__sync_sub_and_fetch(&stat_starting, 1);
triton_event_fire(EV_CTRL_FINISHED, &conn->ppp.ses);
log_ppp_info1("disconnected\n");
triton_context_unregister(&conn->ctx);
if (conn->ppp.ses.chan_name)
_free(conn->ppp.ses.chan_name);
_free(conn->in_buf);
_free(conn->out_buf);
_free(conn->ctrl.calling_station_id);
......@@ -178,7 +178,7 @@ static int pptp_stop_ctrl_conn_rqst(struct pptp_conn_t *conn)
}
static int pptp_stop_ctrl_conn_rply(struct pptp_conn_t *conn)
{
{
struct pptp_stop_ctrl_conn *msg = (struct pptp_stop_ctrl_conn*)conn->in_buf;
if (conf_verbose)
log_ppp_info2("recv [PPTP Stop-Ctrl-Conn-Reply <Result %i> <Error %i>]\n", msg->reason_result, msg->error_code);
......@@ -342,7 +342,7 @@ static int pptp_out_call_rqst(struct pptp_conn_t *conn)
conn->state = STATE_PPP;
__sync_sub_and_fetch(&stat_starting, 1);
__sync_add_and_fetch(&stat_active, 1);
if (conn->timeout_timer.tpd)
triton_timer_del(&conn->timeout_timer);
......@@ -366,7 +366,7 @@ static int send_pptp_call_disconnect_notify(struct pptp_conn_t *conn, int result
if (conf_verbose)
log_ppp_info2("send [PPTP Call-Disconnect-Notify <Call-ID %x> <Result %i> <Error %i> <Cause %i>]\n", ntohs(msg.call_id), msg.result_code, msg.error_code, msg.cause_code);
return post_msg(conn, &msg, sizeof(msg));
}
......@@ -409,7 +409,7 @@ static int pptp_echo_rqst(struct pptp_conn_t *conn)
static int pptp_echo_rply(struct pptp_conn_t *conn)
{
struct pptp_echo_rply *msg = (struct pptp_echo_rply *)conn->in_buf;
if (conf_verbose)
log_ppp_debug("recv [PPTP Echo-Reply <Identifier %x>]\n", msg->identifier);
......@@ -678,13 +678,13 @@ static int pptp_connect(struct triton_md_handler_t *h)
conn->ctrl.ppp = 1;
conn->ctrl.name = "pptp";
conn->ctrl.mppe = conf_mppe;
conn->ctrl.calling_station_id = _malloc(17);
conn->ctrl.called_station_id = _malloc(17);
u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.calling_station_id);
getsockname(sock, &addr, &size);
u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.called_station_id);
ppp_init(&conn->ppp);
conn->ppp.ses.ctrl = &conn->ctrl;
......@@ -739,7 +739,7 @@ static void load_config(void)
opt = conf_get_opt("pptp", "timeout");
if (opt && atoi(opt) > 0)
conf_timeout = atoi(opt);
opt = conf_get_opt("pptp", "echo-interval");
if (opt && atoi(opt) >= 0)
conf_echo_interval = atoi(opt);
......@@ -787,7 +787,7 @@ static void pptp_init(void)
}
fcntl(serv.hnd.fd, F_SETFD, fcntl(serv.hnd.fd, F_GETFD) | FD_CLOEXEC);
addr.sin_family = AF_INET;
opt = conf_get_opt("pptp", "bind");
......@@ -801,8 +801,8 @@ static void pptp_init(void)
addr.sin_port = htons(atoi(opt));
else
addr.sin_port = htons(PPTP_PORT);
setsockopt(serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv.hnd.fd, 4);
setsockopt(serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv.hnd.fd, 4);
if (bind (serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
log_emerg("pptp: failed to bind socket: %s\n", strerror(errno));
close(serv.hnd.fd);
......@@ -820,7 +820,7 @@ static void pptp_init(void)
close(serv.hnd.fd);
return;
}
conn_pool = mempool_create(sizeof(struct pptp_conn_t));
load_config();
......@@ -831,7 +831,7 @@ static void pptp_init(void)
triton_context_wakeup(&serv.ctx);
cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat");
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
......
......@@ -71,7 +71,7 @@ static char *skip_word(char *ptr)
*ptr = ' ';
break;
}
} else if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
} else if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
break;
}
......@@ -95,9 +95,9 @@ static int split(char *buf, char **ptr)
buf = skip_word(buf);
if (!*buf)
return i;
*buf = 0;
buf = skip_space(buf + 1);
if (!*buf)
return i;
......@@ -135,7 +135,7 @@ static struct cs_pd_t *create_pd(struct ap_session *ses, const char *username)
if (!conf_chap_secrets)
return NULL;
#ifdef CRYPTO_OPENSSL
if (conf_encrypted && !list_empty(&hash_chain)) {
unsigned int size = 0;
......@@ -153,7 +153,7 @@ static struct cs_pd_t *create_pd(struct ap_session *ses, const char *username)
username = username_hash;
}
#endif
f = fopen(conf_chap_secrets, "r");
if (!f) {
log_error("chap-secrets: open '%s': %s\n", conf_chap_secrets, strerror(errno));
......@@ -166,7 +166,7 @@ static struct cs_pd_t *create_pd(struct ap_session *ses, const char *username)
fclose(f);
return NULL;
}
while (fgets(buf, 4096, f)) {
if (buf[0] == '#')
continue;
......@@ -209,14 +209,14 @@ found:
_free(pd);
goto out;
}
for (i = 0; i < 16; i++) {
c = ptr[1][i*2 + 2];
ptr[1][i*2 + 2] = 0;
pd->passwd[i] = strtol(ptr[1] + i*2, NULL, 16);
ptr[1][i*2 + 2] = c;
}
} else
} else
#endif
{
pd->passwd = _strdup(ptr[1]);
......@@ -290,7 +290,7 @@ static void ev_ses_pre_up(struct ap_session *ses)
static struct ipv4db_item_t *get_ip(struct ap_session *ses)
{
struct cs_pd_t *pd;
if (!conf_gw_ip_address && ses->ctrl->ppp)
return NULL;
......@@ -319,10 +319,10 @@ static char* get_passwd(struct pwdb_t *pwdb, struct ap_session *ses, const char
if (!pd)
pd = create_pd(ses, username);
if (!pd)
return NULL;
return _strdup(pd->passwd);
}
......@@ -353,7 +353,7 @@ static void des_encrypt(const uint8_t *input, const uint8_t *key, uint8_t *outpu
DES_set_key_checked(&cb, &ks);
memcpy(cb, input, 8);
DES_ecb_encrypt(&cb, &res, &ks, DES_ENCRYPT);
memcpy(output, res, 8);
memcpy(output, res, 8);
}
static int auth_pap(struct cs_pd_t *pd, const char *username, va_list args)
......@@ -363,7 +363,7 @@ static int auth_pap(struct cs_pd_t *pd, const char *username, va_list args)
unsigned char z_hash[21];
char *u_passwd;
int i, len = strlen(passwd);
u_passwd = _malloc(len * 2);
for (i = 0; i< len; i++) {
u_passwd[i * 2] = passwd[i];
......@@ -380,10 +380,10 @@ static int auth_pap(struct cs_pd_t *pd, const char *username, va_list args)
/*des_encrypt(ad->val, z_hash, nt_hash);
des_encrypt(ad->val, z_hash + 7, nt_hash + 8);
des_encrypt(ad->val, z_hash + 14, nt_hash + 16);*/
if (memcmp(z_hash, pd->passwd, 16))
return PWDB_DENIED;
return PWDB_SUCCESS;
}
......@@ -421,7 +421,7 @@ static void derive_mppe_keys_mschap_v1(struct ap_session *ses, const uint8_t *z_
SHA1_Update(&sha_ctx, digest, 16);
SHA1_Update(&sha_ctx, digest, 16);
SHA1_Update(&sha_ctx, challenge, challenge_len);
SHA1_Final(digest, &sha_ctx);
SHA1_Final(digest, &sha_ctx);
triton_event_fire(EV_MPPE_KEYS, &ev_mppe);
}
......@@ -439,7 +439,7 @@ int auth_mschap_v1(struct ap_session *ses, struct cs_pd_t *pd, const char *usern
memcpy(z_hash, pd->passwd, 16);
memset(z_hash + 16, 0, sizeof(z_hash) - 16);
des_encrypt(challenge, z_hash, nt_hash);
des_encrypt(challenge, z_hash + 7, nt_hash + 8);
des_encrypt(challenge, z_hash + 14, nt_hash + 16);
......@@ -460,7 +460,7 @@ static void generate_mschap_response(const uint8_t *nt_response, const uint8_t *
uint8_t pw_hash[MD4_DIGEST_LENGTH];
uint8_t response[SHA_DIGEST_LENGTH];
int i;
uint8_t magic1[39] =
{0x4D, 0x61, 0x67, 0x69, 0x63, 0x20, 0x73, 0x65, 0x72, 0x76,
0x65, 0x72, 0x20, 0x74, 0x6F, 0x20, 0x63, 0x6C, 0x69, 0x65,
......@@ -489,7 +489,7 @@ static void generate_mschap_response(const uint8_t *nt_response, const uint8_t *
SHA1_Update(&sha_ctx, c_hash, 8);
SHA1_Update(&sha_ctx, magic2, 41);
SHA1_Final(response, &sha_ctx);
for (i = 0; i < 20; i++)
sprintf(authenticator + i*2, "%02X", response[i]);
}
......@@ -502,7 +502,7 @@ static void derive_mppe_keys_mschap_v2(struct ap_session *ses, const uint8_t *z_
uint8_t digest[20];
uint8_t send_key[20];
uint8_t recv_key[20];
uint8_t pad1[40] =
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
......@@ -548,7 +548,7 @@ static void derive_mppe_keys_mschap_v2(struct ap_session *ses, const uint8_t *z_
.recv_key = recv_key,
.send_key = send_key,
};
//NtPasswordHashHash
MD4_Init(&md4_ctx);
MD4_Update(&md4_ctx, z_hash, 16);
......@@ -602,7 +602,7 @@ int auth_mschap_v2(struct ap_session *ses, struct cs_pd_t *pd, const char *usern
memcpy(z_hash, pd->passwd, 16);
memset(z_hash + 16, 0, sizeof(z_hash) - 16);
des_encrypt(c_hash, z_hash, nt_hash);
des_encrypt(c_hash, z_hash + 7, nt_hash + 8);
des_encrypt(c_hash, z_hash + 14, nt_hash + 16);
......@@ -613,7 +613,7 @@ int auth_mschap_v2(struct ap_session *ses, struct cs_pd_t *pd, const char *usern
if (ses->ctrl->ppp)
derive_mppe_keys_mschap_v2(ses, z_hash, response);
generate_mschap_response(response, c_hash, z_hash, authenticator);
generate_mschap_response(response, c_hash, z_hash, authenticator);
return PWDB_SUCCESS;
}
......@@ -626,7 +626,7 @@ static int check_passwd(struct pwdb_t *pwdb, struct ap_session *ses, pwdb_callba
if (!conf_encrypted)
return PWDB_NO_IMPL;
pd = find_pd(ses);
if (!pd)
......@@ -634,7 +634,7 @@ static int check_passwd(struct pwdb_t *pwdb, struct ap_session *ses, pwdb_callba
if (!pd)
return PWDB_NO_IMPL;
va_copy(args, _args);
switch (type) {
......@@ -656,7 +656,7 @@ static int check_passwd(struct pwdb_t *pwdb, struct ap_session *ses, pwdb_callba
}
break;
}
va_end(args);
return r;
......@@ -692,7 +692,7 @@ static void parse_hash_chain(const char *opt)
char *ptr1 = str, *ptr2;
struct hash_chain *hc;
int f = 0;
while (!f) {
for (ptr2 = ptr1 + 1; *ptr2 && *ptr2 != ','; ptr2++);
f = *ptr2 == 0;
......@@ -748,13 +748,13 @@ static void load_config(void)
else {
conf_gw_ip_address = 0;
}
opt = conf_get_opt("chap-secrets", "encrypted");
if (opt)
conf_encrypted = atoi(opt);
else
conf_encrypted = 0;
#ifdef CRYPTO_OPENSSL
clear_hash_chain();
opt = conf_get_opt("chap-secrets", "username-hash");
......@@ -769,7 +769,7 @@ static void init(void)
pwdb_register(&pwdb);
ipdb_register(&ipdb);
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);
......
......@@ -35,7 +35,7 @@ int __export connlimit_check(uint64_t key)
LIST_HEAD(tmp_list);
int r = 1;
clock_gettime(CLOCK_MONOTONIC, &ts);
pthread_mutex_lock(&lock);
......@@ -87,13 +87,13 @@ int __export connlimit_check(uint64_t key)
r = 0;
}
if (r == 0)
log_debug("connlimit: accept %" PRIu64 "\n", key);
else
log_debug("connlimit: drop %" PRIu64 "\n", key);
while (!list_empty(&tmp_list)) {
it = list_entry(tmp_list.next, typeof(*it), entry);
list_del(&it->entry);
......@@ -113,10 +113,10 @@ static int parse_limit(const char *opt, int *limit, int *time)
*time = 1;
return 0;
}
if (*endptr != '/')
goto out_err;
opt = endptr + 1;
*time = strtol(opt, &endptr, 10);
......@@ -125,18 +125,18 @@ static int parse_limit(const char *opt, int *limit, int *time)
if (*endptr == 's')
return 0;
if (*endptr == 'm') {
*time *= 60;
return 0;
}
if (*endptr == 'h') {
*time *= 3600;
return 0;
}
out_err:
out_err:
log_error("connlimit: failed to parse '%s'\n", opt);
return -1;
}
......@@ -156,7 +156,7 @@ static void load_config()
opt = conf_get_opt("connlimit", "burst");
if (opt)
conf_burst = atoi(opt);
opt = conf_get_opt("connlimit", "timeout");
if (opt)
conf_burst_timeout = atoi(opt) * 1000;
......
......@@ -87,7 +87,7 @@ struct ippool_t *find_pool(const char *name, int create)
if (create)
return create_pool(name);
return NULL;
}
......@@ -95,7 +95,7 @@ static void parse_gw_ip_address(const char *val)
{
if (!val)
return;
conf_gw_ip_address = inet_addr(val);
}
......@@ -103,7 +103,7 @@ static void parse_gw_ip_address(const char *val)
static int parse1(const char *str, uint32_t *begin, uint32_t *end)
{
int n, f1, f2, f3, f4, m, mask = 0;
n = sscanf(str, "%u.%u.%u.%u/%u",&f1, &f2, &f3, &f4, &m);
if (n != 5)
return -1;
......@@ -117,7 +117,7 @@ static int parse1(const char *str, uint32_t *begin, uint32_t *end)
return -1;
if (m == 0 || m > 32)
return -1;
*begin = (f4 << 24) | (f3 << 16) | (f2 << 8) | f1;
mask = htonl(~((1 << (32 - m)) - 1));
......@@ -145,7 +145,7 @@ static int parse2(const char *str, uint32_t *begin, uint32_t *end)
return -1;
if (m < f4 || m > 255)
return -1;
*begin = ntohl((f4 << 24) | (f3 << 16) | (f2 << 8) | f1);
*end = ntohl((m << 24) | (f3 << 16) | (f2 << 8) | f1);
......@@ -184,12 +184,12 @@ static uint8_t get_random()
if (pos == 0)
read(urandom_fd, buf, 128);
r = buf[pos++];
if (pos == 128)
pos = 0;
return r;
}
......@@ -224,17 +224,17 @@ static void generate_pool_p2p(struct ippool_t *p)
pos1 = pos1->next;
pos2 = pos2->prev;
if (r >= 64)
continue;
peer_addr = list_entry(pos, typeof(*peer_addr), entry);
if (pos == pos1)
pos1 = pos1->next;
if (pos == pos2)
pos2 = pos2->prev;
list_del(&peer_addr->entry);
t = 0;
} else {
......@@ -304,13 +304,13 @@ static void generate_pool_net30(struct ippool_t *p)
it->it.peer_addr = addr[2]->addr;
list_add_tail(&it->entry, &p->items);
for (i = 0; i < 4; i++) {
if (addr[i])
free(addr[i]);
}
}
for (i = 0; i < 4; i++) {
if (addr[i])
free(addr[i]);
......@@ -514,7 +514,7 @@ static int parse_vendor_opt(const char *opt)
vendor = rad_dict_find_vendor_name(opt);
if (vendor)
return vendor->id;
return atoi(opt);
}
#endif
......@@ -568,7 +568,7 @@ static void ippool_init2(void)
char *pool_name = NULL;
char *allocator = NULL;
void (*generate)(struct ippool_t *pool);
if (!s)
return;
......@@ -581,7 +581,7 @@ static void ippool_init2(void)
conf_vendor = parse_vendor_opt(opt->val);
continue;
}
if (!strcmp(opt->name, "attr")) {
conf_attr = parse_attr_opt(opt->val);
continue;
......@@ -625,7 +625,7 @@ static void ippool_init2(void)
_free(allocator);
}
}
if (def_pool->generate)
def_pool->generate(def_pool);
......
......@@ -79,7 +79,7 @@ static void generate_ippool(struct in6_addr *addr, int mask, int prefix_len)
*(uint64_t *)(step.s6_addr + 8) = htobe64(1llu << (128 - prefix_len));
else
*(uint64_t *)step.s6_addr = htobe64(1llu << (64 - prefix_len));
while (in6_addr_cmp(&ip, &end) <= 0) {
it = malloc(sizeof(*it));
it->it.owner = &ipdb;
......@@ -115,7 +115,7 @@ static void generate_dppool(struct in6_addr *addr, int mask, int prefix_len)
*(uint64_t *)(step.s6_addr + 8) = htobe64(1llu << (128 - prefix_len));
else
*(uint64_t *)step.s6_addr = htobe64(1llu << (64 - prefix_len));
while (in6_addr_cmp(&ip, &end) <= 0) {
it = malloc(sizeof(*it));
it->it.owner = &ipdb;
......@@ -138,34 +138,34 @@ static void add_prefix(int type, const char *_val)
struct in6_addr addr;
int prefix_len;
int mask;
ptr1 = strchr(val, '/');
if (!ptr1)
goto err;
*ptr1 = 0;
ptr2 = strchr(ptr1 + 1, ',');
if (!ptr2)
goto err;
*ptr2 = 0;
if (inet_pton(AF_INET6, val, &addr) == 0)
goto err;
if (sscanf(ptr1 + 1, "%i", &mask) != 1)
goto err;
if (mask < 7 || mask > 127)
goto err;
if (sscanf(ptr2 + 1, "%i", &prefix_len) != 1)
goto err;
if (prefix_len > 128 || prefix_len < mask)
goto err;
if (type)
generate_dppool(&addr, mask, prefix_len);
else
......@@ -173,7 +173,7 @@ static void add_prefix(int type, const char *_val)
_free(val);
return;
err:
log_error("ipv6_pool: failed to parse '%s'\n", _val);
_free(val);
......@@ -245,7 +245,7 @@ static void ippool_init(void)
if (!s)
return;
list_for_each_entry(opt, &s->items, entry) {
if (!strcmp(opt->name, "delegate"))
add_prefix(1, opt->val);
......
......@@ -45,7 +45,7 @@ static int snmp_term = 0;
static int agent_log(int major, int minor, void *serv_arg, void *cl_arg)
{
struct snmp_log_message *m = serv_arg;
switch (m->priority) {
case LOG_EMERG:
log_emerg("net-snmp: %s", m->msg);
......@@ -96,7 +96,7 @@ static void *snmp_thread(void *a)
snmp_enable_calllog();
//snmp_set_do_debugging(1);
//netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
if (!conf_master)
netsnmp_enable_subagent();
......@@ -117,11 +117,11 @@ static void *snmp_thread(void *a)
if (conf_master)
init_master_agent();
while (!snmp_term) {
agent_check_and_process(1);
}
snmp_shutdown(conf_agent_name);
SOCK_CLEANUP;
......@@ -152,11 +152,11 @@ static void init(void)
opt = conf_get_opt("snmp", "agent-name");
if (opt)
conf_agent_name = opt;
/*opt = conf_get_opt("snmp", "oid-prefix")
if (opt)
conf_oid_prefix = opt;*/
pthread_create(&snmp_thr, NULL, snmp_thread, NULL);
triton_context_register(&ctx, NULL);
triton_context_wakeup(&ctx);
......
......@@ -36,7 +36,7 @@ static void set_action(const char *cmd, size_t len)
memcpy(cc.cmdline, cmd, len);
cc.cmdline[len] = 0;
cli_process_cmd(&cc);
_free(cc.cmdline);
......@@ -69,7 +69,7 @@ handle_cli(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......
/*
* 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.
*/
......
......@@ -124,9 +124,9 @@ typedef struct sessionTable_rowreq_ctx_s {
/** this must be first for container compare to work */
netsnmp_index oid_idx;
oid oid_tmp[MAX_sessionTable_IDX_LEN];
sessionTable_mib_index tbl_idx;
sessionTable_data * data;
/*
......@@ -138,7 +138,7 @@ typedef struct sessionTable_rowreq_ctx_s {
/*
* TODO:131:o: | |-> Add useful data to sessionTable rowreq context.
*/
/*
* storage for future expansion
*/
......
/*
* Note: this file originally auto-generated by mib2c using
* version : 14170 $ of $
* version : 14170 $ of $
*
* $Id:$
*/
......@@ -24,7 +24,7 @@
*
* These routines are used to locate the data used to satisfy
* requests.
*
*
* @{
*/
/**********************************************************************
......@@ -107,7 +107,7 @@ sessionTable_container_init(netsnmp_container **container_ptr_ptr,
netsnmp_cache *cache)
{
DEBUGMSGTL(("verbose:sessionTable:sessionTable_container_init","called\n"));
if (NULL == container_ptr_ptr) {
snmp_log(LOG_ERR,"bad container param to sessionTable_container_init\n");
return;
......@@ -155,7 +155,7 @@ void
sessionTable_container_shutdown(netsnmp_container *container_ptr)
{
DEBUGMSGTL(("verbose:sessionTable:sessionTable_container_shutdown","called\n"));
if (NULL == container_ptr) {
snmp_log(LOG_ERR,"bad params to sessionTable_container_shutdown\n");
return;
......@@ -218,7 +218,7 @@ sessionTable_container_load(netsnmp_container *container)
sessionTable_release_rowreq_ctx(rowreq_ctx);
continue;
}
strcpy(rowreq_ctx->data->ifname, ses->ifname);
if (ses->username)
......
/*
* Note: this file originally auto-generated by mib2c using
* version : 12088 $ of $
* version : 12088 $ of $
*
* $Id:$
*/
......@@ -121,7 +121,7 @@ sessionTable_indexes_set_tbl_idx(sessionTable_mib_index *tbl_idx, char *sesSID_v
}
tbl_idx->sesSID_len = sesSID_val_ptr_len;
memcpy( tbl_idx->sesSID, sesSID_val_ptr, sesSID_val_ptr_len* sizeof(sesSID_val_ptr[0]) );
return MFD_SUCCESS;
} /* sessionTable_indexes_set_tbl_idx */
......@@ -314,7 +314,7 @@ sesUsername_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesUsername_val_ptr
}
(* sesUsername_val_ptr_len_ptr ) = len;
memcpy( (* sesUsername_val_ptr_ptr ), rowreq_ctx->data->username, len);
return MFD_SUCCESS;
} /* sesUsername_get */
......@@ -484,7 +484,7 @@ sesState_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesState_val_ptr )
DEBUGMSGTL(("verbose:sessionTable:sesState_get","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
(* sesState_val_ptr ) = rowreq_ctx->data->state;
return MFD_SUCCESS;
......
......@@ -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.
*
*
* @{
*/
/** @} */
/*
* Note: this file originally auto-generated by mib2c using
* version : 12077 $ of $
* version : 12077 $ of $
*
* $Id:$
*/
......
......@@ -41,20 +41,20 @@ extern "C" {
#ifndef IANATUNNELTYPE_ENUMS
#define IANATUNNELTYPE_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 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
#endif /* IANATUNNELTYPE_ENUMS */
......@@ -69,9 +69,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 */
......
/*
* 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));
......@@ -712,7 +712,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 +734,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 +798,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 +856,7 @@ _container_free(netsnmp_container *container)
* call user code
*/
sessionTable_container_free(container);
/*
* free all items. inefficient, but easy.
*/
......
......@@ -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.
*
*
* @{
*/
/*
......
......@@ -16,27 +16,27 @@ extern "C" {
#define SESSIONTABLE_OID 1,3,6,1,4,1,8072,100,2,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 SESSIONTABLE_MIN_COL COLUMN_SESSID
#define SESSIONTABLE_MAX_COL COLUMN_SESCALLEDSID
#ifdef __cplusplus
......
......@@ -35,7 +35,7 @@ handle_shutdown(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......
......@@ -55,7 +55,7 @@ handle_statCoreUpTime(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......@@ -84,7 +84,7 @@ handle_statCoreCPU(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......@@ -119,7 +119,7 @@ handle_statCoreMemRss(netsnmp_mib_handler *handler,
fscanf(f, "%lu %lu", &vmsize, &vmrss);
fclose(f);
}
vmrss *= page_size;
/* We are never called for a GETNEXT if it's registered as a
......@@ -127,7 +127,7 @@ handle_statCoreMemRss(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......
......@@ -22,8 +22,8 @@ static unsigned int *stat_starting;
static unsigned int *stat_active;
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_statIPOE(void)
......@@ -36,7 +36,7 @@ init_statIPOE(void)
/*
* a debugging statement. Run the agent with -DstatIPOE to see
* the output of this debugging statement.
* the output of this debugging statement.
*/
DEBUGMSGTL(("statIPOE", "Initializing the statIPOE module\n"));
......
......@@ -23,8 +23,8 @@ static unsigned int *stat_starting;
static unsigned int *stat_active;
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_statL2TP(void)
......@@ -37,7 +37,7 @@ init_statL2TP(void)
/*
* a debugging statement. Run the agent with -DstatL2TP to see
* the output of this debugging statement.
* the output of this debugging statement.
*/
DEBUGMSGTL(("statL2TP", "Initializing the statL2TP module\n"));
......
......@@ -11,8 +11,8 @@
#include "ppp.h"
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_statPPP(void)
......@@ -26,7 +26,7 @@ init_statPPP(void)
/*
* a debugging statement. Run the agent with -DstatPPP to see
* the output of this debugging statement.
* the output of this debugging statement.
*/
DEBUGMSGTL(("statPPP", "Initializing the statPPP module\n"));
......
......@@ -22,8 +22,8 @@ static unsigned int *stat_starting;
static unsigned int *stat_active;
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_statPPPOE(void)
......@@ -36,7 +36,7 @@ init_statPPPOE(void)
/*
* a debugging statement. Run the agent with -DstatPPPOE to see
* the output of this debugging statement.
* the output of this debugging statement.
*/
DEBUGMSGTL(("statPPPOE", "Initializing the statPPPOE module\n"));
......
......@@ -22,8 +22,8 @@ static unsigned int *stat_starting;
static unsigned int *stat_active;
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_statPPTP(void)
......@@ -36,7 +36,7 @@ init_statPPTP(void)
/*
* a debugging statement. Run the agent with -DstatPPTP to see
* the output of this debugging statement.
* the output of this debugging statement.
*/
DEBUGMSGTL(("statPPTP", "Initializing the statPPTP module\n"));
......
......@@ -63,7 +63,7 @@ static void terminate_by_ip(const char *val, size_t len)
str[len] = 0;
addr = inet_addr(str);
pthread_rwlock_rdlock(&ses_lock);
list_for_each_entry(ses, &ses_list, entry) {
if (!ses->ipv4 || ses->ipv4->peer_addr != addr)
......@@ -139,7 +139,7 @@ handle_termBySID(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......@@ -200,7 +200,7 @@ handle_termByIfName(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......@@ -262,7 +262,7 @@ handle_termByIP(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......@@ -326,7 +326,7 @@ handle_termByUsername(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
......
此差异已折叠。
......@@ -34,7 +34,7 @@ static void* sigchld_thread(void *arg)
sigaddset(&set, SIGCHLD);
sigaddset(&set, SIGQUIT);
while (1) {
while (1) {
pid = waitpid(-1, &status, 0);
if (pid < 0) {
if (errno == EINTR)
......
此差异已折叠。
......@@ -95,7 +95,7 @@ struct ap_session
int terminate_cause;
struct list_head pd_list;
uint32_t acct_rx_bytes;
uint32_t acct_tx_bytes;
uint32_t acct_input_gigawords;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册