summaryrefslogtreecommitdiff
path: root/accel-pptpd/ctrl
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-11-29 11:40:13 +0300
committerKozlov Dmitry <dima@server>2010-11-29 11:40:13 +0300
commit43803998812ee949cbe02a121030888c51a9aad2 (patch)
tree618929f3badd9cab2284a4069a7df619e1b419e8 /accel-pptpd/ctrl
parent83283bf5a1704714cd849626845b75abc0378217 (diff)
downloadaccel-ppp-43803998812ee949cbe02a121030888c51a9aad2.tar.gz
accel-ppp-43803998812ee949cbe02a121030888c51a9aad2.zip
l2tp: move hello messages to debug log level
Diffstat (limited to 'accel-pptpd/ctrl')
-rw-r--r--accel-pptpd/ctrl/l2tp/l2tp.c48
-rw-r--r--accel-pptpd/ctrl/l2tp/l2tp.h2
-rw-r--r--accel-pptpd/ctrl/l2tp/packet.c29
3 files changed, 45 insertions, 34 deletions
diff --git a/accel-pptpd/ctrl/l2tp/l2tp.c b/accel-pptpd/ctrl/l2tp/l2tp.c
index 4b7e1a6f..b4b7b742 100644
--- a/accel-pptpd/ctrl/l2tp/l2tp.c
+++ b/accel-pptpd/ctrl/l2tp/l2tp.c
@@ -99,7 +99,7 @@ static void l2tp_timeout(struct triton_timer_t *t);
static void l2tp_rtimeout(struct triton_timer_t *t);
static void l2tp_send_HELLO(struct triton_timer_t *t);
static void l2tp_send_SCCRP(struct l2tp_conn_t *conn);
-static int l2tp_send(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack);
+static int l2tp_send(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack, int log_debug);
static int l2tp_conn_read(struct triton_md_handler_t *);
static void l2tp_disconnect(struct l2tp_conn_t *conn)
@@ -173,7 +173,7 @@ static int l2tp_terminate(struct l2tp_conn_t *conn, int res, int err)
if (l2tp_packet_add_octets(pack, Result_Code, (uint8_t *)&rc, sizeof(rc), 0))
goto out_err;
- l2tp_send(conn, pack);
+ l2tp_send(conn, pack, 0);
conn->state = STATE_FIN;
@@ -352,7 +352,7 @@ static int l2tp_tunnel_alloc(struct l2tp_serv_t *serv, struct l2tp_packet_t *pac
if (conf_verbose) {
log_switch(&conn->ctx, &conn->ppp);
log_ppp_info("recv ");
- l2tp_packet_print(pack);
+ l2tp_packet_print(pack, log_ppp_info);
}
triton_context_call(&conn->ctx, (triton_event_func)l2tp_send_SCCRP, conn);
@@ -438,8 +438,8 @@ static void l2tp_rtimeout(struct triton_timer_t *t)
pack = list_entry(conn->send_queue.next, typeof(*pack), entry);
pack->hdr.Nr = htons(conn->Nr + 1);
if (conf_verbose) {
- log_ppp_info("send ");
- l2tp_packet_print(pack);
+ log_ppp_debug("send ");
+ l2tp_packet_print(pack, log_ppp_debug);
}
if (l2tp_packet_send(conn->hnd.fd, pack) == 0)
return;
@@ -455,7 +455,7 @@ static void l2tp_timeout(struct triton_timer_t *t)
l2tp_disconnect(conn);
}
-static int l2tp_send(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack)
+static int l2tp_send(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack, int log_debug)
{
conn->retransmit = 0;
@@ -468,8 +468,13 @@ static int l2tp_send(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack)
conn->Ns++;
if (conf_verbose) {
- log_ppp_info("send ");
- l2tp_packet_print(pack);
+ if (log_debug) {
+ log_ppp_debug("send ");
+ l2tp_packet_print(pack, log_ppp_debug);
+ } else {
+ log_ppp_info("send ");
+ l2tp_packet_print(pack, log_ppp_info);
+ }
}
if (l2tp_packet_send(conn->hnd.fd, pack))
@@ -497,7 +502,7 @@ static int l2tp_send_ZLB(struct l2tp_conn_t *conn)
if (!pack)
return -1;
- if (l2tp_send(conn, pack))
+ if (l2tp_send(conn, pack, 1))
return -1;
return 0;
@@ -514,7 +519,7 @@ static void l2tp_send_HELLO(struct triton_timer_t *t)
return;
}
- if (l2tp_send(conn, pack))
+ if (l2tp_send(conn, pack, 1))
l2tp_disconnect(conn);
}
@@ -535,7 +540,7 @@ static void l2tp_send_SCCRP(struct l2tp_conn_t *conn)
if (l2tp_packet_add_int16(pack, Assigned_Tunnel_ID, conn->tid, 1))
goto out_err;
- if (l2tp_send(conn, pack))
+ if (l2tp_send(conn, pack, 0))
goto out;
if (!conn->timeout_timer.tpd)
@@ -566,7 +571,7 @@ static int l2tp_send_ICRP(struct l2tp_conn_t *conn)
if (l2tp_packet_add_int16(pack, Assigned_Session_ID, conn->sid, 1))
goto out_err;
- l2tp_send(conn, pack);
+ l2tp_send(conn, pack, 0);
if (!conn->timeout_timer.tpd)
triton_timer_add(&conn->ctx, &conn->timeout_timer, 0);
@@ -607,7 +612,7 @@ static int l2tp_send_OCRQ(struct l2tp_conn_t *conn)
if (l2tp_packet_add_string(pack, Called_Number, "", 1))
goto out_err;
- if (l2tp_send(conn, pack))
+ if (l2tp_send(conn, pack, 0))
return -1;
if (!conn->timeout_timer.tpd)
@@ -866,11 +871,6 @@ static int l2tp_conn_read(struct triton_md_handler_t *h)
continue;
}
- if (conf_verbose) {
- log_ppp_info("recv ");
- l2tp_packet_print(pack);
- }
-
if (ntohs(pack->hdr.Ns) == conn->Nr + 1) {
if (!list_empty(&pack->attrs))
conn->Nr++;
@@ -912,6 +912,16 @@ static int l2tp_conn_read(struct triton_md_handler_t *h)
goto drop;
}
+ if (conf_verbose) {
+ if (msg_type->val.uint16 == Message_Type_Hello) {
+ log_ppp_debug("recv ");
+ l2tp_packet_print(pack, log_ppp_debug);
+ } else {
+ log_ppp_info("recv ");
+ l2tp_packet_print(pack, log_ppp_info);
+ }
+ }
+
switch (msg_type->val.uint16) {
case Message_Type_Start_Ctrl_Conn_Connected:
if (l2tp_recv_SCCCN(conn, pack))
@@ -1014,7 +1024,7 @@ static int l2tp_udp_read(struct triton_md_handler_t *h)
else {
if (conf_verbose) {
log_warn("recv (unexpected) ");
- l2tp_packet_print(pack);
+ l2tp_packet_print(pack, log_ppp_warn);
}
}
skip:
diff --git a/accel-pptpd/ctrl/l2tp/l2tp.h b/accel-pptpd/ctrl/l2tp/l2tp.h
index d6ef5f8c..1a317dc3 100644
--- a/accel-pptpd/ctrl/l2tp/l2tp.h
+++ b/accel-pptpd/ctrl/l2tp/l2tp.h
@@ -73,7 +73,7 @@ struct l2tp_dict_value_t *l2tp_dict_find_value(struct l2tp_dict_attr_t *attr, l2
int l2tp_recv(int fd, struct l2tp_packet_t **);
void l2tp_packet_free(struct l2tp_packet_t *);
-void l2tp_packet_print(struct l2tp_packet_t *);
+void l2tp_packet_print(struct l2tp_packet_t *, void (*print)(const char *fmt, ...));
struct l2tp_packet_t *l2tp_packet_alloc(int ver, int msg_type, struct sockaddr_in *addr);
int l2tp_packet_send(int sock, struct l2tp_packet_t *);
int l2tp_packet_add_int16(struct l2tp_packet_t *pack, int id, int16_t val, int M);
diff --git a/accel-pptpd/ctrl/l2tp/packet.c b/accel-pptpd/ctrl/l2tp/packet.c
index 86461337..354b826b 100644
--- a/accel-pptpd/ctrl/l2tp/packet.c
+++ b/accel-pptpd/ctrl/l2tp/packet.c
@@ -19,40 +19,41 @@ static mempool_t attr_pool;
static mempool_t pack_pool;
static mempool_t buf_pool;
-void l2tp_packet_print(struct l2tp_packet_t *pack)
+void l2tp_packet_print(struct l2tp_packet_t *pack, void (*print)(const char *fmt, ...))
{
struct l2tp_attr_t *attr;
struct l2tp_dict_value_t *val;
- if (pack->hdr.ver == 2)
- log_ppp_info("[L2TP tid=%i sid=%i Ns=%i Nr=%i",
- ntohs(pack->hdr.tid), ntohs(pack->hdr.sid), ntohs(pack->hdr.Ns), ntohs(pack->hdr.Nr));
- else
- log_ppp_info("[L2TP cid=%u Ns=%i Nr=%i",
- pack->hdr.cid, pack->hdr.Ns, pack->hdr.Nr);
+ if (pack->hdr.ver == 2) {
+ print("[L2TP tid=%i sid=%i", ntohs(pack->hdr.tid), ntohs(pack->hdr.sid));
+ log_ppp_debug(" Ns=%i Nr=%i", ntohs(pack->hdr.Ns), ntohs(pack->hdr.Nr));
+ } else {
+ print("[L2TP cid=%u", pack->hdr.cid);
+ log_ppp_debug(" Ns=%i Nr=%i", ntohs(pack->hdr.Ns), ntohs(pack->hdr.Nr));
+ }
list_for_each_entry(attr, &pack->attrs, entry) {
- log_ppp_info(" <%s", attr->attr->name);
+ print(" <%s", attr->attr->name);
val = l2tp_dict_find_value(attr->attr, attr->val);
if (val)
- log_ppp_info(" %s", val->name);
+ print(" %s", val->name);
else {
switch (attr->attr->type) {
case ATTR_TYPE_INT16:
- log_ppp_info(" %i", attr->val.int16);
+ print(" %i", attr->val.int16);
break;
case ATTR_TYPE_INT32:
- log_ppp_info(" %i", attr->val.int32);
+ print(" %i", attr->val.int32);
break;
case ATTR_TYPE_STRING:
- log_ppp_info(" %s", attr->val.string);
+ print(" %s", attr->val.string);
break;
}
}
- log_ppp_info(">");
+ print(">");
}
- log_ppp_info("]\n");
+ print("]\n");
}
struct l2tp_packet_t *l2tp_packet_alloc(int ver, int msg_type, struct sockaddr_in *addr)