diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-10-29 20:58:35 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-10-29 20:58:35 +0300 |
commit | 0170fc3761114ee94c17c88e000116f0c99ff638 (patch) | |
tree | 5eca928145f61649e3912efca5ca84e9a8542bf4 | |
parent | 4492abfd6b7a410d24fdc488545efd64a22c05b8 (diff) | |
parent | ebdc1835312701b50c402159c48ed5d643619bec (diff) | |
download | accel-ppp-0170fc3761114ee94c17c88e000116f0c99ff638.tar.gz accel-ppp-0170fc3761114ee94c17c88e000116f0c99ff638.zip |
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
-rw-r--r-- | accel-pppd/ppp/ppp.c | 60 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp.h | 14 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ccp.c | 6 | ||||
-rw-r--r-- | accel-pppd/radius/radius.c | 2 |
4 files changed, 33 insertions, 49 deletions
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c index 91c4aa7..9772b84 100644 --- a/accel-pppd/ppp/ppp.c +++ b/accel-pppd/ppp/ppp.c @@ -92,7 +92,7 @@ int __export establish_ppp(struct ppp_t *ppp) log_ppp_error("open(chan) /dev/ppp: %s\n", strerror(errno)); return -1; } - + fcntl(ppp->chan_fd, F_SETFD, fcntl(ppp->chan_fd, F_GETFD) | FD_CLOEXEC); if (ioctl(ppp->chan_fd, PPPIOCATTCHAN, &ppp->chan_idx) < 0) { @@ -120,7 +120,7 @@ int __export establish_ppp(struct ppp_t *ppp) log_ppp_error("open(unit) /dev/ppp: %s\n", strerror(errno)); goto exit_close_chan; } - + fcntl(ppp->unit_fd, F_SETFD, fcntl(ppp->unit_fd, F_GETFD) | FD_CLOEXEC); ppp->ses.unit_idx = -1; @@ -128,14 +128,14 @@ int __export establish_ppp(struct ppp_t *ppp) log_ppp_error("ioctl(PPPIOCNEWUNIT): %s\n", strerror(errno)); goto exit_close_unit; } - + if (fcntl(ppp->unit_fd, F_SETFL, O_NONBLOCK)) { log_ppp_error("ppp: cannot set nonblocking mode: %s\n", strerror(errno)); goto exit_close_unit; } } - if (ioctl(ppp->chan_fd, PPPIOCCONNECT, &ppp->ses.unit_idx) < 0) { + if (ioctl(ppp->chan_fd, PPPIOCCONNECT, &ppp->ses.unit_idx) < 0) { log_ppp_error("ioctl(PPPIOCCONNECT): %s\n", strerror(errno)); goto exit_close_unit; } @@ -144,9 +144,9 @@ int __export establish_ppp(struct ppp_t *ppp) log_ppp_error("ppp: cannot set nonblocking mode: %s\n", strerror(errno)); goto exit_close_unit; } - + sprintf(ppp->ses.ifname, "ppp%i", ppp->ses.unit_idx); - + log_ppp_info1("connect: %s <--> %s(%s)\n", ppp->ses.ifname, ppp->ses.ctrl->name, ppp->ses.chan_name); init_layers(ppp); @@ -166,26 +166,26 @@ int __export establish_ppp(struct ppp_t *ppp) log_ppp_debug("ppp established\n"); if (ap_session_starting(&ppp->ses)) - goto exit_close_unit; - + goto exit_free_buf; + triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->chan_hnd); triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->unit_hnd); - + triton_md_enable_handler(&ppp->chan_hnd, MD_MODE_READ); triton_md_enable_handler(&ppp->unit_hnd, MD_MODE_READ); - + start_first_layer(ppp); return 0; +exit_free_buf: + mempool_free(ppp->buf); + ppp->buf = NULL; exit_close_unit: close(ppp->unit_fd); exit_close_chan: close(ppp->chan_fd); - if (ppp->buf) - mempool_free(ppp->buf); - return -1; } @@ -196,10 +196,10 @@ static void destablish_ppp(struct ppp_t *ppp) triton_event_fire(EV_SES_PRE_FINISHED, &ppp->ses); triton_md_unregister_handler(&ppp->chan_hnd, 1); - + if (conf_unit_cache) { struct ifreq ifr; - + sprintf(ifr.ifr_newname, "ppp%i", ppp->ses.unit_idx); if (strcmp(ifr.ifr_newname, ppp->ses.ifname)) { strncpy(ifr.ifr_name, ppp->ses.ifname, IFNAMSIZ); @@ -218,7 +218,7 @@ static void destablish_ppp(struct ppp_t *ppp) list_add_tail(&uc->entry, &uc_list); if (++uc_size > conf_unit_cache) pthread_cond_signal(&uc_cond); - pthread_mutex_unlock(&uc_lock); + pthread_mutex_unlock(&uc_lock); } else triton_md_unregister_handler(&ppp->unit_hnd, 1); @@ -229,7 +229,7 @@ skip: ppp->unit_fd = -1; _free_layers(ppp); - + log_ppp_debug("ppp destablished\n"); mempool_free(ppp->buf); @@ -242,13 +242,13 @@ static void *uc_thread(void *unused) struct pppunit_cache *uc; int fd; sigset_t set; - + sigfillset(&set); sigdelset(&set, SIGKILL); sigdelset(&set, SIGSTOP); - + pthread_sigmask(SIG_BLOCK, &set, NULL); - + while (1) { pthread_mutex_lock(&uc_lock); if (uc_size > conf_unit_cache) { @@ -285,7 +285,7 @@ int __export ppp_chan_send(struct ppp_t *ppp, void *data, int size) //printf("ppp_chan_send: "); //print_buf((uint8_t*)data,size); - + n = write(ppp->chan_fd,data,size); if (n < size) log_ppp_error("ppp_chan_send: short write %i, excpected %i\n", n, size); @@ -298,7 +298,7 @@ int __export ppp_unit_send(struct ppp_t *ppp, void *data, int size) //printf("ppp_unit_send: "); //print_buf((uint8_t*)data,size); - + n=write(ppp->unit_fd, data, size); if (n < size) log_ppp_error("ppp_unit_send: short write %i, excpected %i\n",n,size); @@ -408,7 +408,7 @@ void ppp_recv_proto_rej(struct ppp_t *ppp, uint16_t proto) return; } } - + list_for_each_entry(ppp_h, &ppp->unit_handlers, entry) { if (ppp_h->proto == proto) { if (ppp_h->recv_proto_rej) @@ -431,12 +431,10 @@ static void __ppp_layer_started(struct ppp_t *ppp, struct ppp_layer_data_t *d) if (!f) return; - if (n->entry.next == &ppp->layers) { - if (ppp->ses.state == AP_STATE_STARTING) { + if (ppp->ses.state == AP_STATE_STARTING) ap_session_activate(&ppp->ses); - } } else { n = list_entry(n->entry.next, typeof(*n), entry); list_for_each_entry(d, &n->items, entry) { @@ -465,7 +463,7 @@ void __export ppp_layer_passive(struct ppp_t *ppp, struct ppp_layer_data_t *d) return; d->passive = 1; - + __ppp_layer_started(ppp, d); } @@ -497,7 +495,7 @@ void __export ppp_terminate(struct ap_session *ses, int hard) destablish_ppp(ppp); return; } - + list_for_each_entry(n,&ppp->layers,entry) { list_for_each_entry(d,&n->items,entry) { if (d->starting) { @@ -599,7 +597,7 @@ static void _free_layers(struct ppp_t *ppp) { struct layer_node_t *n; struct ppp_layer_data_t *d; - + while (!list_empty(&ppp->layers)) { n = list_entry(ppp->layers.next, typeof(*n), entry); while (!list_empty(&n->items)) { @@ -638,7 +636,7 @@ struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *ppp, struct ppp_layer return d; } } - + return NULL; } @@ -664,7 +662,7 @@ static void init(void) load_config(); triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); - + pthread_create(&uc_thr, NULL, uc_thread, NULL); } diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h index e403087..73fe422 100644 --- a/accel-pppd/ppp/ppp.h +++ b/accel-pppd/ppp/ppp.h @@ -39,11 +39,6 @@ #define PPP_CBCP 0xc029 /* Callback Control Protocol */ #define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ -struct ppp_t; - -struct ipv4db_item_t; -struct ipv6db_item_t; - struct ppp_t { struct ap_session ses; @@ -63,8 +58,6 @@ struct ppp_t struct list_head unit_handlers; struct list_head layers; - - struct ppp_lcp_t *lcp; }; struct ppp_layer_t; @@ -98,7 +91,6 @@ struct ppp_handler_t void (*recv_proto_rej)(struct ppp_handler_t *h); }; -struct ppp_t *alloc_ppp(void); void ppp_init(struct ppp_t *ppp); int establish_ppp(struct ppp_t *ppp); int ppp_chan_send(struct ppp_t *ppp, void *data, int size); @@ -106,10 +98,6 @@ int ppp_unit_send(struct ppp_t *ppp, void *data, int size); void lcp_send_proto_rej(struct ppp_t *ppp, uint16_t proto); void ppp_recv_proto_rej(struct ppp_t *ppp, uint16_t proto); -void ppp_ifup(struct ppp_t *ppp); -void ppp_ifdown(struct ppp_t *ppp); - -struct ppp_fsm_t* ppp_lcp_init(struct ppp_t *ppp); void ppp_layer_started(struct ppp_t *ppp,struct ppp_layer_data_t*); void ppp_layer_finished(struct ppp_t *ppp,struct ppp_layer_data_t*); void ppp_layer_passive(struct ppp_t *ppp,struct ppp_layer_data_t*); @@ -124,8 +112,6 @@ int ppp_register_layer(const char *name, struct ppp_layer_t *); void ppp_unregister_layer(struct ppp_layer_t *); struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *, struct ppp_layer_t *); -int ppp_ipv6_nd_start(struct ppp_t *ppp, uint64_t intf_id); - extern int conf_ppp_verbose; #endif diff --git a/accel-pppd/ppp/ppp_ccp.c b/accel-pppd/ppp/ppp_ccp.c index cddc78d..ad6e37e 100644 --- a/accel-pppd/ppp/ppp_ccp.c +++ b/accel-pppd/ppp/ppp_ccp.c @@ -608,7 +608,7 @@ static void send_term_req(struct ppp_fsm_t *fsm) if (conf_ppp_verbose) log_ppp_info2("send [CCP TermReq id=%i]\n", hdr.id); - ppp_chan_send(ccp->ppp, &hdr, 6); + ppp_unit_send(ccp->ppp, &hdr, 6); } static void send_term_ack(struct ppp_fsm_t *fsm) @@ -623,8 +623,8 @@ static void send_term_ack(struct ppp_fsm_t *fsm) if (conf_ppp_verbose) log_ppp_info2("send [CCP TermAck id=%i]\n", hdr.id); - - ppp_chan_send(ccp->ppp, &hdr, 6); + + ppp_unit_send(ccp->ppp, &hdr, 6); } static void ccp_recv(struct ppp_handler_t*h) diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c index 045dee8..ac65959 100644 --- a/accel-pppd/radius/radius.c +++ b/accel-pppd/radius/radius.c @@ -183,7 +183,7 @@ static int rad_pwdb_check(struct pwdb_t *pwdb, struct ap_session *ses, pwdb_call } rpd->auth_ctx = mempool_alloc(auth_ctx_pool); - memset(rpd->auth_ctx, 0, sizeof(rpd->auth_ctx)); + memset(rpd->auth_ctx, 0, sizeof(*rpd->auth_ctx)); rpd->auth_ctx->cb = cb; rpd->auth_ctx->cb_arg = cb_arg; |