summaryrefslogtreecommitdiffstats
path: root/usr.sbin/npppd
diff options
context:
space:
mode:
authoryasuoka <yasuoka@openbsd.org>2010-07-01 03:38:17 +0000
committeryasuoka <yasuoka@openbsd.org>2010-07-01 03:38:17 +0000
commitf0a4e295ec0d8ba054b2deac9d5b70bfe31cda67 (patch)
treefffd65130608b1c4f467c15829e1419fb3b6dd1f /usr.sbin/npppd
parentPartially sync atomic.h with hppa so that we get real atomic ops and some (diff)
downloadwireguard-openbsd-f0a4e295ec0d8ba054b2deac9d5b70bfe31cda67.tar.xz
wireguard-openbsd-f0a4e295ec0d8ba054b2deac9d5b70bfe31cda67.zip
Translate Japanese comments or labels into English. Translation was
done by IIJ people (MATSUI Yoshihiro, SAITOH Masanobu, Tomoyuki Sahara), yuo@ and myself. This diff also includes - delete part of useless comments, correct spelling. - add man page of npppdctl. There is no functional change.
Diffstat (limited to 'usr.sbin/npppd')
-rw-r--r--usr.sbin/npppd/Makefile3
-rw-r--r--usr.sbin/npppd/Makefile.inc3
-rw-r--r--usr.sbin/npppd/common/addr_range.c3
-rw-r--r--usr.sbin/npppd/common/addr_range.h1
-rw-r--r--usr.sbin/npppd/common/bytebuf.c7
-rw-r--r--usr.sbin/npppd/common/bytebuf.h3
-rw-r--r--usr.sbin/npppd/common/config_helper.c123
-rw-r--r--usr.sbin/npppd/common/config_helper.h1
-rw-r--r--usr.sbin/npppd/common/csvreader.c59
-rw-r--r--usr.sbin/npppd/common/csvreader.h18
-rw-r--r--usr.sbin/npppd/common/csvreader_test.c7
-rw-r--r--usr.sbin/npppd/common/ipsec_util.c14
-rw-r--r--usr.sbin/npppd/common/net_utils.c23
-rw-r--r--usr.sbin/npppd/common/properties.c8
-rw-r--r--usr.sbin/npppd/common/properties_test.c10
-rw-r--r--usr.sbin/npppd/common/rt_zebra.c10
-rw-r--r--usr.sbin/npppd/common/rtev_common.c6
-rw-r--r--usr.sbin/npppd/common/rtev_libevent.c12
-rw-r--r--usr.sbin/npppd/common/slist.c126
-rw-r--r--usr.sbin/npppd/common/slist.h2
-rw-r--r--usr.sbin/npppd/common/slist_test.c103
-rw-r--r--usr.sbin/npppd/l2tp/l2tp.h151
-rw-r--r--usr.sbin/npppd/l2tp/l2tp_call.c182
-rw-r--r--usr.sbin/npppd/l2tp/l2tp_ctrl.c311
-rw-r--r--usr.sbin/npppd/l2tp/l2tp_local.h3
-rw-r--r--usr.sbin/npppd/l2tp/l2tp_subr.c15
-rw-r--r--usr.sbin/npppd/l2tp/l2tp_subr.h17
-rw-r--r--usr.sbin/npppd/l2tp/l2tpd.c163
-rw-r--r--usr.sbin/npppd/npppd/Makefile5
-rw-r--r--usr.sbin/npppd/npppd/ccp.c65
-rw-r--r--usr.sbin/npppd/npppd/chap.c135
-rw-r--r--usr.sbin/npppd/npppd/eap.c69
-rw-r--r--usr.sbin/npppd/npppd/fsm.c13
-rw-r--r--usr.sbin/npppd/npppd/fsm.h2
-rw-r--r--usr.sbin/npppd/npppd/ipcp.c55
-rw-r--r--usr.sbin/npppd/npppd/lcp.c195
-rw-r--r--usr.sbin/npppd/npppd/mppe.c86
-rw-r--r--usr.sbin/npppd/npppd/npppd.c377
-rw-r--r--usr.sbin/npppd/npppd/npppd.h10
-rw-r--r--usr.sbin/npppd/npppd/npppd_auth.c96
-rw-r--r--usr.sbin/npppd/npppd/npppd_auth.h8
-rw-r--r--usr.sbin/npppd/npppd/npppd_auth_local.h48
-rw-r--r--usr.sbin/npppd/npppd/npppd_config.c121
-rw-r--r--usr.sbin/npppd/npppd/npppd_ctl.c58
-rw-r--r--usr.sbin/npppd/npppd/npppd_ctl.h34
-rw-r--r--usr.sbin/npppd/npppd/npppd_defs.h29
-rw-r--r--usr.sbin/npppd/npppd/npppd_iface.c92
-rw-r--r--usr.sbin/npppd/npppd/npppd_iface.h25
-rw-r--r--usr.sbin/npppd/npppd/npppd_local.h112
-rw-r--r--usr.sbin/npppd/npppd/npppd_pool.c134
-rw-r--r--usr.sbin/npppd/npppd/npppd_pool.h10
-rw-r--r--usr.sbin/npppd/npppd/npppd_subr.c65
-rw-r--r--usr.sbin/npppd/npppd/npppd_tun.c25
-rw-r--r--usr.sbin/npppd/npppd/pap.c72
-rw-r--r--usr.sbin/npppd/npppd/ppp.c220
-rw-r--r--usr.sbin/npppd/npppd/ppp.h245
-rw-r--r--usr.sbin/npppd/npppd/psm-opt.h37
-rw-r--r--usr.sbin/npppd/npppd/radius+.c8
-rw-r--r--usr.sbin/npppd/npppd/radius_chap_const.h12
-rw-r--r--usr.sbin/npppd/npppd/radius_common.c8
-rw-r--r--usr.sbin/npppd/npppd/radius_req.c78
-rw-r--r--usr.sbin/npppd/npppd/radius_req.h51
-rw-r--r--usr.sbin/npppd/npppd/radiusconst.h1
-rw-r--r--usr.sbin/npppd/npppdctl/Makefile5
-rw-r--r--usr.sbin/npppd/npppdctl/npppdctl.c68
-rw-r--r--usr.sbin/npppd/pppoe/pppoe.h100
-rw-r--r--usr.sbin/npppd/pppoe/pppoe_local.h6
-rw-r--r--usr.sbin/npppd/pppoe/pppoe_session.c80
-rw-r--r--usr.sbin/npppd/pppoe/pppoed.c170
-rw-r--r--usr.sbin/npppd/pptp/pptp.h241
-rw-r--r--usr.sbin/npppd/pptp/pptp_call.c164
-rw-r--r--usr.sbin/npppd/pptp/pptp_ctrl.c230
-rw-r--r--usr.sbin/npppd/pptp/pptp_local.h19
-rw-r--r--usr.sbin/npppd/pptp/pptp_subr.c18
-rw-r--r--usr.sbin/npppd/pptp/pptp_subr.h1
-rw-r--r--usr.sbin/npppd/pptp/pptpd.c188
76 files changed, 2547 insertions, 2728 deletions
diff --git a/usr.sbin/npppd/Makefile b/usr.sbin/npppd/Makefile
index c1a5a6582fd..2d01233669b 100644
--- a/usr.sbin/npppd/Makefile
+++ b/usr.sbin/npppd/Makefile
@@ -1,5 +1,6 @@
+# $OpenBSD: Makefile,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
#
-# $Id: Makefile,v 1.1 2010/01/11 04:20:56 yasuoka Exp $
+# $Id: Makefile,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
#
SUBDIR+= npppd npppdctl
diff --git a/usr.sbin/npppd/Makefile.inc b/usr.sbin/npppd/Makefile.inc
index 26762ad1caa..85102bef166 100644
--- a/usr.sbin/npppd/Makefile.inc
+++ b/usr.sbin/npppd/Makefile.inc
@@ -1,4 +1,5 @@
-# $Id: Makefile.inc,v 1.1 2010/01/11 04:20:56 yasuoka Exp $
+# $OpenBSD: Makefile.inc,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
+# $Id: Makefile.inc,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
.include <bsd.own.mk>
diff --git a/usr.sbin/npppd/common/addr_range.c b/usr.sbin/npppd/common/addr_range.c
index f4df149fe45..fd1637a148b 100644
--- a/usr.sbin/npppd/common/addr_range.c
+++ b/usr.sbin/npppd/common/addr_range.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: addr_range.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -55,7 +56,7 @@
* Author:
* Yasuoka Masahiko <yasuoka@iij.ad.jp>
*
- * $Id: addr_range.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+ * $Id: addr_range.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
#ifdef ADDR_RANGE_DEBUG
#define IIJDEBUG
diff --git a/usr.sbin/npppd/common/addr_range.h b/usr.sbin/npppd/common/addr_range.h
index 7a6745dbd8d..9ebb6bd93ed 100644
--- a/usr.sbin/npppd/common/addr_range.h
+++ b/usr.sbin/npppd/common/addr_range.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: addr_range.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
diff --git a/usr.sbin/npppd/common/bytebuf.c b/usr.sbin/npppd/common/bytebuf.c
index 2f8c91ec96b..66359e49f05 100644
--- a/usr.sbin/npppd/common/bytebuf.c
+++ b/usr.sbin/npppd/common/bytebuf.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: bytebuf.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -40,7 +41,7 @@
* }</pre>
*
* @author Yasuoka Masahiko
- * $Id: bytebuf.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+ * $Id: bytebuf.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
#include <stdlib.h>
#include <string.h>
@@ -102,7 +103,7 @@ bytebuffer_create(size_t capacity)
if (capacity > 0) {
if ((_this->data = malloc(capacity)) == NULL)
- goto reigai;
+ goto fail;
memset(_this->data, 0, capacity);
_this->capacity = capacity;
} else
@@ -111,7 +112,7 @@ bytebuffer_create(size_t capacity)
_this->limit = _this->capacity;
_this->mark = -1;
return _this;
-reigai:
+fail:
if (_this != NULL)
free(_this);
return NULL;
diff --git a/usr.sbin/npppd/common/bytebuf.h b/usr.sbin/npppd/common/bytebuf.h
index c0ced991426..7127ac70c6a 100644
--- a/usr.sbin/npppd/common/bytebuf.h
+++ b/usr.sbin/npppd/common/bytebuf.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: bytebuf.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
#ifndef BYTEBUF_H
#define BYTEBUF_H 1
-/* $Id: bytebuf.h,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: bytebuf.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
typedef struct _bytebuffer bytebuffer;
diff --git a/usr.sbin/npppd/common/config_helper.c b/usr.sbin/npppd/common/config_helper.c
index 5fbf057ea9c..a6148e2885b 100644
--- a/usr.sbin/npppd/common/config_helper.c
+++ b/usr.sbin/npppd/common/config_helper.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: config_helper.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,11 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: config_helper.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
-/**@file コンフィグヘルパ。
- * <p>
- * しています。</p>
- */
+/* $Id: config_helper.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
@@ -40,9 +37,9 @@
#define KEYBUFSZ 512
/**
- * コンフィグキーを作成するための文字列連結
- * (("prefix", "suffix") => "prefix.suffix") を、行います。内部で固定のバッファ
- * 領域を返します。
+ * This function concatenates given prefix and the give suffix for making
+ * configuration key (("prefix", "suffix") => "prefix.suffix"). The string
+ * returned by this function resides in a static memory area.
*/
const char *
config_key_prefix(const char *prefix, const char *suffix)
@@ -57,11 +54,12 @@ config_key_prefix(const char *prefix, const char *suffix)
}
/**
- * 設定を文字列で返します。
- *
- * @param _this {@link ::properties}へのポインタ。
- * @param confKey 設定ファイルの設定項目名
- * @return 設定値。設定が存在しない場合には NULL が返ります。
+ * Retrieve the configuration value as a 'string' that is specified by
+ * given configuration key.
+ * @param _this The pointer to {@link ::properties}
+ * @param confKey configuration key name.
+ * @return pointer to the configuration value. If no configuration value
+ * exists then it returns NULL.
*/
const char *
config_str(struct properties *_this, const char *confKey)
@@ -72,11 +70,12 @@ config_str(struct properties *_this, const char *confKey)
}
/**
- * 設定を int で返します。
- *
- * @param _this {@link ::properties}へのポインタ。
- * @param confKey 設定ファイルの設定項目名
- * @param defValue 設定が省略されている場合のデフォルトの値
+ * Retrieve the configuration value as a 'int' that is specified by
+ * given configuration key.
+ * @param _this The pointer to {@link ::properties}
+ * @param confKey configuration key name.
+ * @param defValue The default value. This function will return this
+ * value in case no configuration exists
*/
int
config_int(struct properties *_this, const char *confKey, int defValue)
@@ -92,19 +91,19 @@ config_int(struct properties *_this, const char *confKey, int defValue)
x = sscanf(val, "%d", &rval);
if (x != 1)
- /* 関数のインタフェースを変更して、エラーは区別すべきかも */
return defValue;
return rval;
}
/**
- * 設定があたえられた文字列と一致するかどうかを返します。
- *
- * @param _this {@link ::properties}へのポインタ。
- * @param confKey 設定ファイルの設定項目名
- * @param defValue 設定が省略されている場合のデフォルトの値
- * @return 一致する場合には 1、一致しない場合には 0 が返ります。
+ * Checks whether the configuration value equals given string.
+ * @param _this The pointer to {@link ::properties}
+ * @param confKey configuration key name.
+ * @param defValue The default value. This function will return this
+ * value in case no configuration exists
+ * @return return 1 if given string matches the configuration value,
+ * otherwise return 0.
*/
int
config_str_equal(struct properties *_this, const char *confKey,
@@ -121,13 +120,14 @@ config_str_equal(struct properties *_this, const char *confKey,
}
/**
- * 設定があたえられた文字列と一致するかどうかを返します。ASCII 文字の
- * 大文字小文字は無視します。
- *
- * @param _this {@link ::properties}へのポインタ。
- * @param confKey 設定ファイルの設定項目名
- * @param defValue 設定が省略されている場合のデフォルトの値
- * @return 一致する場合には 1、一致しない場合には 0 が返ります。
+ * Checks whether the configuration value equals given string ignoring
+ * case.
+ * @param _this The pointer to {@link ::properties}
+ * @param confKey configuration key name.
+ * @param defValue The default value. This function will return this
+ * value in case no configuration exists
+ * @return return 1 if given string equals the configuration value,
+ * otherwise return 0.
*/
int
config_str_equali(struct properties *_this, const char *confKey,
@@ -144,25 +144,29 @@ config_str_equali(struct properties *_this, const char *confKey,
}
/***********************************************************************
- * 設定項目名に指定したプレフィックスをつけて設定を取得し、設定がなければ
- * プレフィックスなしの設定項目で設定を取得するための関数です。
+ * Following functions are to get configuration value by given
+ * configuration key. At first the function will try to get the value
+ * by the key with the prefix, if it fails, then it will try to get the
+ * value by the key without the prefix.
*
- * たとえば
- *
- * pppoe.service_name: default_service
- * PPPoE0.pppoe.service_name: my_service
+ * For example, we have following configuration
*
- * という設定があった場合、
- * config_prefixed_str(prop, "PPPoE0", "service_name")
- * を呼び出すと "my_service" が取得できます。設定に、
+ * pppoe.service_name: default_service
+ * PPPoE0.pppoe.service_name: my_service
*
- * PPPoE0.pppoe.service_name: my_service
+ * calling
*
- * がない場合には、"default_service" が取得できます。
+ * config_prefixed_str(prop, "PPPoE0", "service_name")
*
- * config_helper.h に定義されている PREFIXED_CONFIG_FUNCTIONS マクロを
- * 使って、プレフィックス部分の指定方法を固定して使うこともできます。
- ***********************************************************************/
+ * returns "my_service". If
+ *
+ * PPPoE0.pppoe.service_name: my_service
+ *
+ * does not exist, then it returns "default_service".
+ *
+ * Functions that have fixed prefix can be generated by
+ * PREFIXED_CONFIG_FUNCTIONS macro that is defined in config_helper.h.
+ */
const char *
config_prefixed_str(struct properties *_this, const char *prefix, const char *confKey)
{
@@ -234,24 +238,29 @@ config_prefixed_str_equali(struct properties *_this, const char *prefix,
}
/***********************************************************************
- * 設定項目名に指定したプレフィックスと指定した名前をつけて設定を取得し、
- * 設定がなければプレフィックスに設定項目で設定を取得するための関数です。
+ * Following functions are to get configuration value by given
+ * configuration key. At first the function will try to get the value
+ * by the key with the prefix and given label, if it fail, then it will
+ * try to get the value by the key without the label.
*
- * たとえば
+ * For example, we have following configuration
*
- * ipcp.dns_primary: 192.168.0.1
- * ipcp.ipcp0.dns_primary: 192.168.0.2
+ * ipcp.dns_primary: 192.168.0.1
+ * ipcp.ipcp0.dns_primary: 192.168.0.2
+ *
+ * calling
*
- * という設定があった場合、
* config_named_prefix_str(prop, "ipcp", "ipcp0", "dns_primary");
- * を呼び出すと "192.168.0.2" が取得できます。設定に、
*
- * ipcp.ipcp0.dns_primary: 192.168.0.2
+ * will returns "192.168.0.2". If
+ *
+ * ipcp.ipcp0.dns_primary: 192.168.0.2
*
- * がない場合には、"192.168.0.1" が取得できます。
+ * was not exists, then it returns "default_service".
*
- * config_helper.h に定義されている NAMED_PREFIX_CONFIG_FUNCTIONS マクロ
- * を使って、プレフィックス部分の指定方法を固定して使うこともできます。
+ * Functions that has fixed prefix can be generated by
+ * NAMED_PREFIXED_CONFIG_FUNCTIONS macro that is defined in
+ * config_helper.h.
***********************************************************************/
const char *
config_named_prefix_str(struct properties *_this, const char *prefix,
diff --git a/usr.sbin/npppd/common/config_helper.h b/usr.sbin/npppd/common/config_helper.h
index 8f618727a9b..812e9763b60 100644
--- a/usr.sbin/npppd/common/config_helper.h
+++ b/usr.sbin/npppd/common/config_helper.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: config_helper.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
diff --git a/usr.sbin/npppd/common/csvreader.c b/usr.sbin/npppd/common/csvreader.c
index ce8a852018f..00023e51560 100644
--- a/usr.sbin/npppd/common/csvreader.c
+++ b/usr.sbin/npppd/common/csvreader.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: csvreader.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,9 +24,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* original version は CSVReader.java */
+/* The original version is CSVReader.java */
/* @file
- * CSV(RFC4180) を読み込むための補助的な関数
+ * Subroutines to read CSV(RFC4180)
* <pre>
* csvreader *csv;
* const char **cols;
@@ -53,7 +54,7 @@
* csvreader_destroy(csv);
*</pre>
*/
-/* $Id: csvreader.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: csvreader.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -82,7 +83,7 @@ struct _csvreader {
#define CSV_FLUSH_WAIT 4
#define DQUOTE '"'
-#define COLON ','
+#define COMMA ','
#define CR '\r'
#define LF '\n'
@@ -91,8 +92,7 @@ static int csvreader_flush_column (csvreader *);
static CSVREADER_STATUS csvreader_parse_flush0 (csvreader *, int);
/**
- * cvsreader コンテキストを作成して返却します。メモリ割り当てに失敗すると、
- * NULL が返ります。
+ * Make a cvsreader context and returns it. Return null if malloc() failed.
*/
csvreader *
csvreader_create(void)
@@ -109,7 +109,7 @@ csvreader_create(void)
/**
- * cvsreader コンテキストを解放します。
+ * Free a cvsreader context.
*/
void
csvreader_destroy(csvreader *_this)
@@ -122,7 +122,7 @@ csvreader_destroy(csvreader *_this)
}
/**
- * パース済みのカラム配列の数を取得します。
+ * get the number of parsed columns.
*/
int
csvreader_get_number_of_column(csvreader *_this)
@@ -133,7 +133,7 @@ csvreader_get_number_of_column(csvreader *_this)
}
/**
- * パース済みのカラム配列(=行) を取得します。
+ * get a parsed column.
*/
const char **
csvreader_get_column(csvreader *_this)
@@ -150,7 +150,7 @@ csvreader_get_column(csvreader *_this)
}
/**
- * cvsreader コンテキストをリセットします。
+ * Reset a cvsreader context.
*/
void
csvreader_reset(csvreader *_this)
@@ -165,11 +165,11 @@ csvreader_reset(csvreader *_this)
}
/**
- * パース途中のカラムのパースを完了します。
+ * Finish parsing of a column on the way.
* <p>
- * CSVファイルの末尾など、続く行
- * が存在しない場合や、CSV としての行の区切りであることが確実な場合に呼び
- * だします。フィールドが終了していない場合などにはエラーが返ります。</p>
+ * Call this function when it's sure that there is no next line or the end
+ * of the CSV.
+ * It will return error when the parsing of the field isn't finished. </p>
*/
CSVREADER_STATUS
csvreader_parse_flush(csvreader *_this)
@@ -178,10 +178,10 @@ csvreader_parse_flush(csvreader *_this)
}
/**
- * 行をパースします。
+ * parse a line.
*
- * @param csvreader コンテキスト
- * @param パースする行。
+ * @param a csvreader context
+ * @param a line to parse
*/
CSVREADER_STATUS
csvreader_parse(csvreader *_this, const char *line)
@@ -205,14 +205,14 @@ csvreader_parse(csvreader *_this, const char *line)
_this->column_start_with_quote = 1;
break;
}
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case CSV_IN_DATA:
if (_this->column_start_with_quote != 0) {
if (line[off] == DQUOTE)
_this->state = CSV_HAS_DQUOTE;
break;
}
- if (line[off] == COLON) {
+ if (line[off] == COMMA) {
append = 0;
csvreader_flush_column(_this);
}
@@ -227,12 +227,12 @@ csvreader_parse(csvreader *_this, const char *line)
break;
}
_this->state = CSV_WAIT_DELIM;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case CSV_WAIT_DELIM:
if (line[off] == CR || line[off] == LF)
goto eol;
append = 0;
- if (line[off] != COLON)
+ if (line[off] != COMMA)
return CSVREADER_PARSE_ERROR;
csvreader_flush_column(_this);
break;
@@ -258,11 +258,11 @@ csvreader_parse_flush0(csvreader *_this, int is_final)
/* wait next line */
return CSVREADER_NO_ERROR;
}
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case CSV_INIT:
if (is_final && _this->col_pos == 0)
return CSVREADER_NO_ERROR;
- /* FALL THROUGH */
+ /* FALLTHROUGH */
case CSV_HAS_DQUOTE:
case CSV_WAIT_DELIM:
csvreader_flush_column(_this);
@@ -273,12 +273,13 @@ csvreader_parse_flush0(csvreader *_this, int is_final)
}
/**
- * char ポインタの配列に格納された列を CSV の表現の行文字列に変換します。
-
- * @param cols 変換する列。NULL 要素は、列の終わりとみなします。
- * @param ncols 列の数。
- * @param buffer 変換後の行文字列を書き込むスペース
- * @param lbuffer 変換後の行文字列を書き込むスペースの大きさ。
+ * Convert columns stored in char *[] to a CVS line string.
+ *
+ * @param cols columns to be converted. NULL means the end of the
+ * column.
+ * @param ncols number of columns
+ * @param buffer the output buffer to write a converted line.
+ * @param lbuffer the size of the output buffer.
*/
int
csvreader_toline(const char **cols, int ncols, char *buffer, int lbuffer)
diff --git a/usr.sbin/npppd/common/csvreader.h b/usr.sbin/npppd/common/csvreader.h
index 8dd46f8c481..0d53c6aab90 100644
--- a/usr.sbin/npppd/common/csvreader.h
+++ b/usr.sbin/npppd/common/csvreader.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: csvreader.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -25,22 +26,23 @@
*/
#ifndef CSVREADER_H
#define CSVREADER_H 1
-/* $Id: csvreader.h,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: csvreader.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
-/** cvsreader のステータスを表す */
+/** status of cvsreader */
typedef enum _CSVREADER_STATUS {
- /** 正常に処理が完了した */
+ /** complete without any error */
CSVREADER_NO_ERROR = 0,
/**
- * 処理中の列が存在する
+ * A processing column exists.
* <p>
- * csvreader_get_columns で取り出す前に、次の行をパースすると
- * このエラーが発生します。</p>
+ * This error occurs when parsing next line before getting a
+ * new coloumn by csvreader_get_columns().
+ * </p>
*/
CSVREADER_HAS_PENDING_COLUMN = 10001,
- /** メモリー割り当てに失敗した */
+ /** Failed in memory allocation */
CSVREADER_OUT_OF_MEMORY = 10002,
- /** パースエラー */
+ /** Parse Error */
CSVREADER_PARSE_ERROR = 10003
} CSVREADER_STATUS;
diff --git a/usr.sbin/npppd/common/csvreader_test.c b/usr.sbin/npppd/common/csvreader_test.c
index 865fcd73018..b5b329f3d00 100644
--- a/usr.sbin/npppd/common/csvreader_test.c
+++ b/usr.sbin/npppd/common/csvreader_test.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: csvreader_test.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
/*
* cc -o csvreader_test csvreader.c csvreader_test.c
*/
-/* $Id: csvreader_test.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: csvreader_test.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -149,7 +150,7 @@ test02(void)
column = csvreader_get_column(csv);
ASSERT(column != NULL);
ASSERT(strcmp(column[0], "hogehoge") == 0);
- //printf("**%s**\n", column[1]);
+ /* printf("**%s**\n", column[1]); */
ASSERT(strcmp(column[1], "fuga\nfuga") == 0);
ASSERT(column[2] == NULL);
@@ -158,7 +159,7 @@ test02(void)
column = csvreader_get_column(csv);
ASSERT(column != NULL);
ASSERT(strcmp(column[0], "hogehoge") == 0);
- //printf("**%s**\n", column[1]);
+ /* printf("**%s**\n", column[1]); */
ASSERT(strcmp(column[1], "fuga\rfuga") == 0);
ASSERT(column[2] == NULL);
diff --git a/usr.sbin/npppd/common/ipsec_util.c b/usr.sbin/npppd/common/ipsec_util.c
index 10c634f0250..fb3965b2545 100644
--- a/usr.sbin/npppd/common/ipsec_util.c
+++ b/usr.sbin/npppd/common/ipsec_util.c
@@ -2,8 +2,8 @@
* Copyright 2007, 2009
* Internet Initiative Japan Inc. All rights reserved.
*/
-/* $Id: ipsec_util.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
-/*@file IPsec 関連ユーティリティ */
+/* $Id: ipsec_util.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
+/*@file IPsec related utility functions */
/*
* RFC 2367 PF_KEY Key Management API, Version 2
*/
@@ -59,25 +59,25 @@ ipsec_util_purge_transport_sa(struct sockaddr *sock, struct sockaddr *peer,
tv = KEYSOCK_RCVTIMEO;
if (setsockopt(key_sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) != 0)
- goto reigai;
+ goto fail;
del_in.is_valid = del_out.is_valid = 0;
if (delete_prepare(key_sock, sock, peer, proto, &del_in, &del_out) != 0)
- goto reigai;
+ goto fail;
if (del_in.is_valid && (dir & IPSEC_UTIL_DIRECTION_IN) != 0) {
if (send_sadb_delete(key_sock, &del_in))
- goto reigai;
+ goto fail;
}
if (del_out.is_valid && (dir & IPSEC_UTIL_DIRECTION_OUT) != 0) {
if (send_sadb_delete(key_sock, &del_out))
- goto reigai;
+ goto fail;
}
close(key_sock);
return 0;
-reigai:
+fail:
close(key_sock);
return -1;
diff --git a/usr.sbin/npppd/common/net_utils.c b/usr.sbin/npppd/common/net_utils.c
index 14e4cd22fee..76519143e13 100644
--- a/usr.sbin/npppd/common/net_utils.c
+++ b/usr.sbin/npppd/common/net_utils.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: net_utils.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: net_utils.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -39,7 +39,7 @@
#include "rtev.h"
#endif
-/** struct sockaddr から、インタフェース名を取得します */
+/** Get an interface name from sockaddr */
const char *
get_ifname_by_sockaddr(struct sockaddr *sa, char *ifname)
{
@@ -51,7 +51,7 @@ get_ifname_by_sockaddr(struct sockaddr *sa, char *ifname)
#endif
ifname0 = NULL;
- /* リニアサーチしかないなんて... */
+ /* I want other way than linear search */
getifaddrs(&addr0);
for (addr = addr0; ifname0 == NULL&& addr != NULL;
addr = addr->ifa_next) {
@@ -88,8 +88,8 @@ get_ifname_by_sockaddr(struct sockaddr *sa, char *ifname)
return ifname0;
}
/**
- * "192.168.160.1:1723/tcp" や "[::1]:1723/tcp" という文字列を、getaddrinfo(3)
- * の引数の仕様に併せて実行する。現在は、"/tcp" の部分は無視します。
+ * Cconvert argument like "192.168.160.1:1723/tcp" or "[::1]:1723/tcp" to
+ * match getaddrinfo(3)'s specification and pass them to getaddrinfo(3).
*/
int
addrport_parse(const char *addrport, int proto, struct addrinfo **p_ai)
@@ -114,7 +114,7 @@ addrport_parse(const char *addrport, int proto, struct addrinfo **p_ai)
slash = strrchr(servp, '/');
if (slash != NULL) {
/*
- * "/tcp" などは無視する。
+ * Ignore like "/tcp"
*/
*slash = '\0';
slash++;
@@ -138,10 +138,11 @@ addrport_parse(const char *addrport, int proto, struct addrinfo **p_ai)
}
/**
- * struct sockaddr から、 "192.168.160.1:1723" や "[::1]:1723" という文字列
- * を作成します。
- * @param buf 文字列を格納するバッファ
- * @param lbuf 文字列を格納するバッファの長さ
+ * Make a string like "192.168.160.1:1723" or "[::1]:1723" from a struct
+ * sockaddr
+ *
+ * @param buf the buffer to be stored a string
+ * @param lbuf the length of the buf
*/
const char *
addrport_tostring(struct sockaddr *sa, socklen_t salen, char *buf, int lbuf)
@@ -171,7 +172,7 @@ addrport_tostring(struct sockaddr *sa, socklen_t salen, char *buf, int lbuf)
return buf;
}
-/** IPv4 ネットマスクをプレフィックス長に変換します。ホストバイトオーダーで */
+/** Convert 32bit IPv4 netmask to the prefix length in host byte order */
int
netmask2prefixlen(uint32_t mask)
{
diff --git a/usr.sbin/npppd/common/properties.c b/usr.sbin/npppd/common/properties.c
index 56cdcd474f9..4f60a93b636 100644
--- a/usr.sbin/npppd/common/properties.c
+++ b/usr.sbin/npppd/common/properties.c
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
/*
- * $Id: properties.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+ * $Id: properties.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
/* LINTLIBRARY */
#include <sys/types.h>
@@ -389,7 +389,7 @@ properties_load(struct properties *_this, FILE *fp)
char *line = NULL, *line0, *line1;
if ((line = (char *)malloc(linesz)) == NULL)
- goto reigai;
+ goto fail;
linecont = 0;
while (fgets(buf0, sizeof(buf0), fp) != NULL) {
@@ -407,7 +407,7 @@ properties_load(struct properties *_this, FILE *fp)
while (lineoff + linelen + 128 > linesz) {
if ((line1 = realloc(line, linesz * 2))
== NULL)
- goto reigai;
+ goto fail;
line = line1;
linesz *= 2;
}
@@ -449,7 +449,7 @@ properties_load(struct properties *_this, FILE *fp)
if (line != NULL)
free(line);
return 0;
-reigai:
+fail:
if (line != NULL)
free(line);
diff --git a/usr.sbin/npppd/common/properties_test.c b/usr.sbin/npppd/common/properties_test.c
index 4c31df6f91b..861394f243b 100644
--- a/usr.sbin/npppd/common/properties_test.c
+++ b/usr.sbin/npppd/common/properties_test.c
@@ -86,9 +86,8 @@ test0(void)
}
static void test1()
{
- // [IDGW-DEV 5246] 1024 bytes
+ /* 1024 bytes */
set_and_get("pptpd.listener_in", "PPTP 10.10.10.50 PPTP 100.100.100.100 PPTP 100.100.100.101 PPTP 100.100.100.102 PPTP 100.100.100.103 PPTP 100.100.100.104 PPTP 100.100.100.105 PPTP 100.100.100.106 PPTP 100.100.100.107 PPTP 100.100.100.108 PPTP 100.100.100.109 PPTP 100.100.100.110 PPTP 100.100.100.111 PPTP 100.100.100.112 PPTP 100.100.100.113 PPTP 100.100.100.114 PPTP 100.100.100.115 PPTP 100.100.100.116 PPTP 100.100.100.117 PPTP 100.100.100.118 PPTP 100.100.100.119 PPTP 100.100.100.120 PPTP 100.100.100.121 PPTP 100.100.100.122 PPTP 100.100.100.123 PPTP 100.100.100.124 PPTP 100.100.100.125 PPTP 100.100.100.126 PPTP 100.100.100.127 PPTP 100.100.100.128 PPTP 100.100.100.129 PPTP 100.100.100.130 PPTP 100.100.100.131 PPTP 100.100.100.132 PPTP 100.100.100.133 PPTP 100.100.100.134 PPTP 100.100.100.135 PPTP 100.100.100.136 PPTP 100.100.100.137 PPTP 100.100.100.138 PPTP 100.100.100.139 PPTP 100.100.100.140 PPTP 100.100.100.141 PPTP 100.100.100.142 PPTP 100.100.100.143 PPTP 100.100.100.144 PPTP 100.100.100.145 PPTP 100.100.100.146 PPTP 100.100.100.147 PPTP 100.100.100.148 PPTP 100.100.100.149 PPTP 100.100.100.150 PPTP 100.100.100.151 PPTP 100.100.100.152 PPTP 100.100.100.153 PPTP 100.100.100.154 PPTP 100.100.100.155 PPTP 100.100.100.156 PPTP 100.100.100.157 PPTP 100.100.100.158 PPTP 100.100.100.159 PPTP 100.100.100.160 PPTP 100.100.100.161 PPTP 100.100.100.162 PPTP 100.100.100.163 PPTP 100.100.100.164 PPTP 100.100.100.165 PPTP 100.100.100.166 PPTP 100.100.100.167 PPTP 100.100.100.168 PPTP 100.100.100.169 PPTP 100.100.100.170 PPTP 100.100.100.171 PPTP 100.100.100.172 PPTP 100.100.100.173 PPTP 100.100.100.174 PPTP 100.100.100.175 PPTP 100.100.100.176 PPTP 100.100.100.177 PPTP 100.100.100.178 PPTP 100.100.100.179 PPTP 100.100.100.180 PPTP 100.100.100.181 PPTP 100.100.100.182 PPTP 100.100.100.183 PPTP 100.100.100.184 PPTP 100.100.100.185 PPTP 100.100.100.186 PPTP 100.100.100.187 PPTP 100.100.100.188 PPTP 100.100.100.189 PPTP 100.100.100.190 PPTP 100.100.100.191 PPTP 100.100.100.192 PPTP 100.100.100.193 PPTP 100.100.100.194 PPTP 100.100.100.195 PPTP 100.100.100.196 PPTP 100.100.100.197 PPTP 100.100.100.198 PPTP 100.100.100.200");
- // [IDGW-CVS 9044]
set_and_get("pptpd.ip4_allow", "pptpd.ip4_allow: 192.168.10.1/32 192.168.10.2/32 192.168.10.3/32 192.168.10.4/32 192.168.10.5/32 192.168.10.6/32 192.168.10.7/32 192.168.10.8/32 192.168.10.9/32 192.168.10.10/32 192.168.10.11/32 192.168.10.12/32 192.168.10.13/32 192.168.10.14/32 192.168.10.15/32 192.168.10.16/32 192.168.10.17/32 192.168.10.18/32 192.168.10.19/32 192.168.10.20/32 192.168.10.21/32 192.168.10.22/32 192.168.10.23/32 192.168.10.24/32 192.168.10.25/32 192.168.10.26/32 192.168.10.27/32 192.168.10.28/32 192.168.10.29/32 192.168.10.30/32 192.168.10.31/32 192.168.10.32/32 192.168.10.33/32 192.168.10.34/32 192.168.10.35/32 192.168.10.36/32 192.168.10.37/32 192.168.10.38/32 192.168.10.39/32 192.168.10.40/32 192.168.10.41/32 192.168.10.42/32 192.168.10.43/32 192.168.10.44/32 192.168.10.45/32 192.168.10.46/32 192.168.10.47/32 192.168.10.48/32 192.168.10.49/32 192.168.10.50/32 192.168.10.51/32 192.168.10.52/32 192.168.10.53/32 192.168.10.54/32 192.168.10.55/32 192.168.10.56/32 192.168.1.57/32 192.168.1.58/32 192.168.1.59/32 192.168.10.60/32 192.168.10.61/32 192.168.10.62/32 192.168.10.63/32 192.168.10.64/32 192.168.10.65/32 192.168.10.66/32 192.168.10.67/32 192.168.10.68/32 192.168.10.69/32 192.168.10.70/32 192.168.10.71/32 192.168.10.72/32 192.168.10.73/32 192.168.10.74/32 192.168.10.75/32 192.168.10.76/32 192.168.10.77/32 192.168.10.78/32 192.168.10.79/32 192.168.10.80/32 192.168.10.81/32 192.168.10.82/32 192.168.10.83/32 192.168.10.84/32 192.168.10.85/32 192.168.10.86/32 192.168.10.87/32 192.168.10.88/32 192.168.10.89/32 192.168.10.90/32 192.168.10.91/32 192.168.10.92/32 192.168.10.93/32 192.168.10.94/32 192.168.10.95/32 192.168.10.96/32 192.168.10.97/32 192.168.10.98/32 192.168.10.99/32 192.168.10.100/32 192.168.10.101/32 192.168.10.102/32 192.168.10.103/32 192.168.10.104/32 192.168.10.105/32 192.168.10.106/32 192.168.10.107/32 192.168.10.108/32 192.168.10.109/32 192.168.10.110/32 192.168.10.111/32 192.168.10.112/32 192.168.10.113/32 192.168.10.114/32 192.168.10.115/32 192.168.10.116/32 192.168.10.117/32 192.168.10.118/32 192.168.1.119/32 192.168.1.120/32 192.168.1.121/32");
}
@@ -96,15 +95,10 @@ static void test1()
static void test2()
{
- // [IDGW-DEV 5246] 1024 bytes
set_and_get("hogehoge", "hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge");
- // [IDGW-DEV 5246] 1024 bytes - 1024 bytes
set_and_get("hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge", "hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge");
- // [IDGW-DEV 5246] 1024 bytes - 1024 bytes
set_and_get("hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge", "hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge");
- // [IDGW-DEV 5246] 2048 bytes
set_and_get("hogehoge", "hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge");
- // [IDGW-DEV 5246] 2048 bytes
set_and_get("hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge", "hogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehogehoge");
}
void
@@ -140,7 +134,7 @@ test4_read_fn(void *cookie, char *buf, int len)
rval = MIN(len, sizeof(test4_buf) - test4_off);
if (rval == 0)
- return 0; // EOF
+ return 0; /* EOF */
memcpy(buf, test4_buf + test4_off, rval);
test4_off += rval;
diff --git a/usr.sbin/npppd/common/rt_zebra.c b/usr.sbin/npppd/common/rt_zebra.c
index 726262b6741..7dcdbb36d0f 100644
--- a/usr.sbin/npppd/common/rt_zebra.c
+++ b/usr.sbin/npppd/common/rt_zebra.c
@@ -2,7 +2,7 @@
* Copyright (c) 2007
* Internet Initiative Japan Inc. All rights reserved.
*/
-/* $Id: rt_zebra.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: rt_zebra.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*
* @file This file provides utility functions to help add/delete routing
* information with GNU Zebra. This utility uses event(3) and uses a UNIX
@@ -154,10 +154,10 @@ rt_zebra_start(rt_zebra *_this)
}
if ((ival = fcntl(sock, F_GETFL, 0)) < 0) {
log_printf(LOG_ERR, "fcntl(,F_GETFL) failed: %m");
- goto reigai;
+ goto fail;
} else if (fcntl(sock, F_SETFL, ival | O_NONBLOCK) < 0) {
log_printf(LOG_ERR, "fcntl(,F_SETFL, +O_NONBLOCK) failed: %m");
- goto reigai;
+ goto fail;
}
_this->state = ZEBRA_STATUS_CONNECTING;
@@ -175,7 +175,7 @@ rt_zebra_start(rt_zebra *_this)
default:
log_printf(LOG_ERR,
"Connection to the zserv failed: %m");
- goto reigai;
+ goto fail;
}
}
event_set(&_this->ev_sock, _this->sock, EV_READ|EV_WRITE,
@@ -183,7 +183,7 @@ rt_zebra_start(rt_zebra *_this)
event_add(&_this->ev_sock, NULL);
return 0;
-reigai:
+fail:
if (sock >= 0)
close(sock);
rt_zebra_stop(_this);
diff --git a/usr.sbin/npppd/common/rtev_common.c b/usr.sbin/npppd/common/rtev_common.c
index ea9403067eb..bcb52ca44dd 100644
--- a/usr.sbin/npppd/common/rtev_common.c
+++ b/usr.sbin/npppd/common/rtev_common.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: rtev_common.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: rtev_common.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*
* PF_ROUTE related utility functions.
* <p>
@@ -283,7 +283,7 @@ rtev_base_init(rtev_impl *impl, int flags)
if (rtev_sndbuf == NULL) {
if ((rtev_sndbuf = bytebuffer_wrap(rtev_buffer_space,
sizeof(rtev_buffer_space))) == NULL)
- goto reigai;
+ goto fail;
bytebuffer_clear(rtev_sndbuf);
}
impl->base_on_rtevent = rtev_base_on_rtevent;
@@ -292,7 +292,7 @@ rtev_base_init(rtev_impl *impl, int flags)
singleton_impl = impl;
return 0;
-reigai:
+fail:
rtev_fini();
return 1;
diff --git a/usr.sbin/npppd/common/rtev_libevent.c b/usr.sbin/npppd/common/rtev_libevent.c
index c22fa80970f..bd062300ba6 100644
--- a/usr.sbin/npppd/common/rtev_libevent.c
+++ b/usr.sbin/npppd/common/rtev_libevent.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: rtev_libevent.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: rtev_libevent.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
@@ -252,17 +252,17 @@ rtev_libevent_init0(rtev_libevent *_this, int rt_delay, int send_delay,
_this->impl.impl_on_write = rtev_libevent_on_write;
if (rtev_base_init(&_this->impl, flags) != 0)
- goto reigai;
+ goto fail;
if ((sock = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC)) < 0)
- goto reigai;
+ goto fail;
dummy = 0;
if ((fflags = fcntl(sock, F_GETFL, dummy)) < 0)
- goto reigai;
+ goto fail;
if (fcntl(sock, F_SETFL, fflags | O_NONBLOCK) < 0)
- goto reigai;
+ goto fail;
_this->sock = sock;
@@ -274,7 +274,7 @@ rtev_libevent_init0(rtev_libevent *_this, int rt_delay, int send_delay,
rtev_libevent_reset_event(_this);
return 0;
-reigai:
+fail:
if (sock >= 0)
close(sock);
diff --git a/usr.sbin/npppd/common/slist.c b/usr.sbin/npppd/common/slist.c
index 7f6c67b05ce..5fedb7d141d 100644
--- a/usr.sbin/npppd/common/slist.c
+++ b/usr.sbin/npppd/common/slist.c
@@ -24,21 +24,20 @@
* SUCH DAMAGE.
*/
/**@file
- * 任意のポインタに関するリスト操作を提供します。
+ * provide list accesses against any pointer
*/
/*
* void **list;
- * list_size; // list に割り当てたサイズ。
- * last_idx; // 最初のインデックス
- * first_idx; // 最後のインデックス
+ * list_size; // allocated size for the list
+ * last_idx; // The last index
+ * first_idx; // The first index
*
- * ・first_idx == last_idx は空を示します。
- * ・fist_idx と last_idx は 0 以上 list_size - 1 以下です。
- * ・使っているサイズは、(last_idx - first_idx) % list_size です。
- * list_size まで使ってしまうと、空と区別ができず区別しようとすると複雑
- * になるので、そういう状況を作りません。このため、list に割り当てたサイズ
- * のうち 1個分は使いません。
- * ・XXX itr_curr が削除されると、
+ * - first_idx == last_idx means empty.
+ * - 0 <= (fist_idx and last_idx) <= (list_size - 1)
+ * - Allocated size is (last_idx - first_idx) % list_size.
+ * To make the code for checking empty and full simple, we use only
+ * list_size-1 items instead of using the full size.
+ * - XXX Wnen itr_curr is removed...
*/
#include <sys/types.h>
@@ -64,28 +63,27 @@
#endif
/**
- * 内部のインデックスが範囲内ならば、1 を範囲を越えている場合には 0 を
- * を返すマクロです。
+ * Returns 1 if a index is in the valid range, otherwise returns 0.
*/
#define VALID_IDX(_list, _idx) \
(((_list)->first_idx <= (_list)->last_idx) \
? (((_list)->first_idx <= (_idx) && (_idx) < (_list)->last_idx)? 1 : 0)\
: (((_list)->first_idx <= (_idx) || (_idx) < (_list)->last_idx)? 1 : 0))
-/** インデックスを内部のインデックスに変換します。 */
+/** Convert an index into the internal index */
#define REAL_IDX(_list, _idx) \
(((_list)->first_idx + (_idx)) % (_list)->list_size)
-/** 内部のインデックスをインデックスに変換します。 */
+/** Convert a virtual index into the index */
#define VIRT_IDX(_list, _idx) (((_list)->first_idx <= (_idx)) \
? (_idx) - (_list)->first_idx \
: (_list)->list_size - (_list)->first_idx + (_idx))
-/** インデックスを示すメンバー変数を decrement します */
+/** Decrement an index */
#define DECR_IDX(_list, _memb) \
(_list)->_memb = ((_list)->list_size + --((_list)->_memb)) \
% (_list)->list_size
-/** インデックスを示すメンバー変数を increment します */
+/** Increment an index */
#define INCR_IDX(_list, _memb) \
(_list)->_memb = (++((_list)->_memb)) % (_list)->list_size
@@ -96,7 +94,7 @@ static __inline void slist_swap0 (slist *, int, int);
#define itr_is_valid(list) ((list)->itr_next >= 0)
#define itr_invalidate(list) ((list)->itr_next = -1)
-/** 初期化処理を行います */
+/** Initialize a slist */
void
slist_init(slist *list)
{
@@ -105,8 +103,8 @@ slist_init(slist *list)
}
/**
- * リストのサイズを指定します。1つの要素は内部で利用されるので、必要なサイズ
- * + 1 を指定します。サイズは小さくなりません。
+ * Specify the size of a list. The size must be specified with the size you
+ * want to use +1. Extra 1 entry is for internal use. The size doesn't shrink.
*/
int
slist_set_size(slist *list, int size)
@@ -117,7 +115,7 @@ slist_set_size(slist *list, int size)
return 0;
}
-/** 終了化処理を行います */
+/** Finish using. Free the buffers and reinit. */
void
slist_fini(slist *list)
{
@@ -126,7 +124,7 @@ slist_fini(slist *list)
slist_init(list);
}
-/** このリストの長さ */
+/** The length of the list */
int
slist_length(slist *list)
{
@@ -136,16 +134,16 @@ slist_length(slist *list)
: (list->list_size - list->first_idx + list->last_idx);
}
-/** リストがいっぱいの場合に割り当てサイズを成長させます。 */
+/** Extend the size. Used if the list is full. */
static int
slist_grow0(slist *list, int grow_sz)
{
int size_new;
void **list_new = NULL;
- /* ひとつ追加できるか。できるならそのまま抜ける。*/
+ /* just return if it is possible to add one item */
if (slist_length(list) + 1 < list->list_size)
- /* list_size == slist_length() という状況は作らない */
+ /* "+ 1" to avoid the situation list_size == slist_length() */
return 0;
size_new = list->list_size + grow_sz;
@@ -158,23 +156,27 @@ slist_grow0(slist *list, int grow_sz)
list->list = list_new;
if (list->last_idx < list->first_idx && list->last_idx >= 0) {
+
/*
- * 空きが真ん中にある状況で右側に空きを作ったので、左側
- * を右にもっていく。
+ * space is created at the right side when center has space,
+ * so move left side to right side
*/
if (list->last_idx <= grow_sz) {
/*
- * 左側を右側にもっていく場合に十分なスペースがある
- * のですべて移動
+ * The right side has enough space, so move the left
+ * side to right side.
*/
memmove(&list->list[list->list_size],
&list->list[0], PTR_SIZE * list->last_idx);
list->last_idx = list->list_size + list->last_idx;
} else {
- /* 左側をできるかぎり右端に copy */
+ /*
+ * Copy the left side to right side as long as we
+ * can
+ */
memmove(&list->list[list->list_size],
&list->list[0], PTR_SIZE * grow_sz);
- /* 左側、copy した分を左にずらす */
+ /* Shift the remain to left */
memmove(&list->list[0], &list->list[grow_sz],
PTR_SIZE *(list->last_idx - grow_sz));
@@ -192,7 +194,7 @@ slist_grow(slist *list)
return slist_grow0(list, GROW_SIZE);
}
-/** リストの末尾に要素を追加します。*/
+/** Add an item to a list */
void *
slist_add(slist *list, void *item)
{
@@ -213,7 +215,7 @@ slist_add(slist *list, void *item)
#define slist_get0(list_, idx) ((list_)->list[REAL_IDX((list_), (idx))])
-/** リストの末尾に指定したリストの要素全てを追加します */
+/** Add all items in add_items to a list. */
int
slist_add_all(slist *list, slist *add_items)
{
@@ -228,7 +230,7 @@ slist_add_all(slist *list, slist *add_items)
return 0;
}
-/** idx番目の要素を返します。*/
+/** Return "idx"th item. */
void *
slist_get(slist *list, int idx)
{
@@ -241,7 +243,7 @@ slist_get(slist *list, int idx)
return slist_get0(list, idx);
}
-/** idx番目の要素をセットします。*/
+/** Store a value in "idx"th item */
int
slist_set(slist *list, int idx, void *item)
{
@@ -256,7 +258,7 @@ slist_set(slist *list, int idx, void *item)
return 0;
}
-/** 1番目の要素を削除して取り出します。*/
+/** Remove the 1st entry and return it. */
void *
slist_remove_first(slist *list)
{
@@ -278,10 +280,7 @@ slist_remove_first(slist *list)
return oldVal;
}
-
-
-
-/** 最後の要素を削除して取り出します。*/
+/** Remove the last entry and return it */
void *
slist_remove_last(slist *list)
{
@@ -295,7 +294,7 @@ slist_remove_last(slist *list)
return list->list[list->last_idx];
}
-/** 全て要素を削除します */
+/** Remove all entries */
void
slist_remove_all(slist *list)
{
@@ -306,20 +305,20 @@ slist_remove_all(slist *list)
list->list = list0;
}
-/* this doesn't check boudary. */
+/* Swap items. This doesn't check boudary. */
static __inline void
slist_swap0(slist *list, int m, int n)
{
void *m0;
- itr_invalidate(list); /* イテレータ無効 */
+ itr_invalidate(list); /* Invalidate iterator */
m0 = list->list[REAL_IDX(list, m)];
list->list[REAL_IDX(list, m)] = list->list[REAL_IDX(list, n)];
list->list[REAL_IDX(list, n)] = m0;
}
-/** リストの m 番目の要素と n 番目の要素を入れ換えます。 */
+/** Swap between mth and nth */
void
slist_swap(slist *list, int m, int n)
{
@@ -339,7 +338,7 @@ slist_swap(slist *list, int m, int n)
slist_swap0(list, m, n);
}
-/** idx 番目の要素を削除します */
+/** Remove "idx"th item */
void *
slist_remove(slist *list, int idx)
{
@@ -365,9 +364,9 @@ slist_remove(slist *list, int idx)
list->itr_next = -2; /* on the last item */
}
- /* last 側を縮めるか、first 側を縮めるか。*/
+ /* should we reduce the last side or the first side? */
if (list->first_idx < list->last_idx) {
- /* いちおう短い方を選択 */
+ /* take the smaller side */
if (idx0 - list->first_idx < list->last_idx - idx0) {
first = list->first_idx;
INCR_IDX(list, first_idx);
@@ -377,7 +376,8 @@ slist_remove(slist *list, int idx)
}
} else {
/*
- * 0 < last (未使用) first < idx < size なので first 側を縮める
+ * 0 < last (unused) first < idx < size, so let's reduce the
+ * first.
*/
if (list->first_idx <= idx0) {
first = list->first_idx;
@@ -388,10 +388,10 @@ slist_remove(slist *list, int idx)
}
}
- /* last側 */
+ /* the last side */
if (last != -1 && last != 0 && last != idx0) {
- /* idx0 〜 last を左にひとつずらす */
+ /* move left the items that is from idx0 to the last */
if (itr_is_valid(list) &&
idx0 <= list->itr_next && list->itr_next <= last) {
DECR_IDX(list, itr_next);
@@ -402,10 +402,10 @@ slist_remove(slist *list, int idx)
memmove(&list->list[idx0], &list->list[idx0 + 1],
(PTR_SIZE) * (last - idx0));
}
- /* first側 */
+ /* the first side */
if (first != -1 && first != idx0) {
- /* first 〜 idx0 を右にひとつずらす */
+ /* move right the items that is from first to the idx0 */
if (itr_is_valid(list) &&
first <= list->itr_next && list->itr_next <= idx0) {
INCR_IDX(list, itr_next);
@@ -425,10 +425,8 @@ slist_remove(slist *list, int idx)
}
/**
- * シャッフルします。
- * <p>
- * <b>slist_shuffle は random(3) を使ってます。使用前に srandom(3) してく
- * ださい。</b></p>
+ * Shuffle items.
+ * slist_shuffle() uses random(3). Call srandom(3) before use it.
*/
void
slist_shuffle(slist *list)
@@ -440,9 +438,7 @@ slist_shuffle(slist *list)
slist_swap0(list, i - 1, (int)(random() % i));
}
-/**
- * イテレータを初期化します。ひとつの slist インスタンスでひとつしか使えません。
- */
+/** Init an iterator. Only one iterator exists. */
void
slist_itr_first(slist *list)
{
@@ -452,10 +448,10 @@ slist_itr_first(slist *list)
}
/**
- * イテレータが次の要素に進めるかどうかを返します。
- * @return イテレータが次の要素を返すことができる場合に 1 を返します。
- * 終端に達したか、イテレータが最後まで達したか、リスト構造の変更があって、
- * 続行不能な場合には 0 が返ります。
+ * Return whether a iterator can go to the next item.
+ * @return Return 1 if the iterator can return the next item.
+ * Return 0 it reaches the end of the list or the list is modified
+ * destructively.
*/
int
slist_itr_has_next(slist *list)
@@ -465,7 +461,7 @@ slist_itr_has_next(slist *list)
return VALID_IDX(list, list->itr_next);
}
-/** イテレータの次の要素を取り出しつつ、次の要素に進めます。 */
+/** Return the next item and iterate to the next */
void *
slist_itr_next(slist *list)
{
@@ -488,7 +484,7 @@ slist_itr_next(slist *list)
return rval;
}
-/** イテレータの現在の要素を削除します */
+/** Delete the current iterated item */
void *
slist_itr_remove(slist *list)
{
diff --git a/usr.sbin/npppd/common/slist.h b/usr.sbin/npppd/common/slist.h
index 10fea5c8929..020fd081e88 100644
--- a/usr.sbin/npppd/common/slist.h
+++ b/usr.sbin/npppd/common/slist.h
@@ -53,7 +53,7 @@ void *slist_remove_first (slist *);
void *slist_remove_last (slist *);
void slist_swap (slist *, int, int);
void *slist_remove (slist *, int);
-/* slist_shuffle は random(3) を使ってます。使用前に srandom(3) してください。*/
+/* slist_shuffle() uses random(3), so call srandom(3) before use. */
void slist_shuffle (slist *);
void slist_itr_first (slist *);
int slist_itr_has_next (slist *);
diff --git a/usr.sbin/npppd/common/slist_test.c b/usr.sbin/npppd/common/slist_test.c
index f7ac334be69..0457f08ec0e 100644
--- a/usr.sbin/npppd/common/slist_test.c
+++ b/usr.sbin/npppd/common/slist_test.c
@@ -77,7 +77,7 @@ dump(slist *l)
fprintf(stderr, "\n");
}
-// まんなかに空きの場合に削除系のテスト
+/* Test code for removing of the first, last and middle item. */
static void
test_01a()
{
@@ -99,7 +99,7 @@ test_01a()
} \
}
- // 先頭要素削除
+ /* Remove the first item. */
SETUP();
f = 0;
while (slist_length(l) > 0) {
@@ -110,7 +110,7 @@ test_01a()
}
}
- // 最終要素削除
+ /* Remove the last item. */
SETUP();
while (slist_length(l) > 0) {
slist_remove(l, slist_length(l) - 1);
@@ -118,7 +118,7 @@ test_01a()
ASSERT((int)slist_get(l, i) == i);
}
}
- // 最終要素-1削除
+ /* Remove the second item from the end. */
SETUP();
while (slist_length(l) > 1) {
slist_remove(l, slist_length(l) - 2);
@@ -156,13 +156,13 @@ test_01()
ASSERT((int)slist_get(&sl, 254) == 129 + 253);
ASSERT((int)slist_length(&sl) == 255);
- //dump(&sl);
- //printf("==\n");
+ /* dump(&sl); */
+ /* printf("==\n"); */
slist_add(&sl, (void *)(128 + 255));
ASSERT((int)slist_get(&sl, 127) == 255);
- //ASSERT((int)slist_get(&sl, 255) == 128 + 255);
+ /* ASSERT((int)slist_get(&sl, 255) == 128 + 255); */
ASSERT((int)slist_length(&sl) == 256);
- //dump(&sl);
+ /* dump(&sl); */
}
static void
@@ -175,7 +175,7 @@ test_02()
slist_init(&sl);
- // 内部配置が、左側に 300 個、右側に 211 個になるように配置
+ /* Place 300 items for left side and 211 items for right side. */
for (i = 0; i < 511; i++)
slist_add(&sl, (void *)i);
for (i = 0; i <= 300; i++)
@@ -184,27 +184,27 @@ test_02()
slist_add(&sl, (void *)i);
- // index 番号になるように再度割り当て
+ /* Set values to make index number and value the same. */
for (i = 0; i < slist_length(&sl); i++)
slist_set(&sl, i, (void *)(i + 1));
- ASSERT(slist_length(&sl) == 511); //論理サイズは511
- ASSERT((int)sl.list[511] == 211); //右端が 211番目
- ASSERT((int)sl.list[0] == 212); //左端が 212番目
- ASSERT(sl.list_size == 512); //物理サイズは 512
+ ASSERT(slist_length(&sl) == 511); /* The logical length is 511. */
+ ASSERT((int)sl.list[511] == 211); /* The most right is 211th. */
+ ASSERT((int)sl.list[0] == 212); /* The most left is 212th. */
+ ASSERT(sl.list_size == 512); /* The physical size is 512. */
- slist_add(&sl, (void *)512); // 512番めを追加
+ slist_add(&sl, (void *)512); /* Add 512th item. */
- ASSERT(sl.list_size == 768); //物理サイズが拡大
- ASSERT(slist_length(&sl) == 512); //論理サイズは512
- ASSERT((int)sl.list[511] == 211); //繋め
- ASSERT((int)sl.list[512] == 212); //繋め
- ASSERT((int)sl.list[767] == 467); //右端が 467番目
- ASSERT((int)sl.list[0] == 468); //左端が 468番目
+ ASSERT(sl.list_size == 768); /* The physical size is extended. */
+ ASSERT(slist_length(&sl) == 512); /* The logical length is 512. */
+ ASSERT((int)sl.list[511] == 211); /* boundary */
+ ASSERT((int)sl.list[512] == 212); /* boundary */
+ ASSERT((int)sl.list[767] == 467); /* The most right is 467th. */
+ ASSERT((int)sl.list[0] == 468); /* The most left is 468th. */
- //全部チェック
+ /* Check all items */
for (i = 0; i < slist_length(&sl); i++)
- ASSERT((int)slist_get(&sl, i) == i + 1); // チェック
+ ASSERT((int)slist_get(&sl, i) == i + 1); /* check */
}
static void
@@ -225,8 +225,8 @@ test_03()
}
slist_remove(&sl, 0);
ASSERT(slist_length(&sl) == 0);
- //dump(&sl);
- //TEST(test_02);
+ /* dump(&sl); */
+ /* TEST(test_02); */
}
static void
@@ -238,30 +238,31 @@ test_itr_subr_01(slist *l)
slist_set(l, i, (void *)(i + 1));
slist_itr_first(l);
- ASSERT((int)slist_itr_next(l) == 1); // 普通にイテレート
- ASSERT((int)slist_itr_next(l) == 2); // 普通にイテレート
- slist_remove(l, 2); // next を削除
- // "3" が削除
- ASSERT((int)slist_itr_next(l) == 4); // 削除したものはスキップ
- slist_remove(l, 1); // 通りすぎたところを削除
- // "2" を削除
- ASSERT((int)slist_itr_next(l) == 5); // 影響なし
- ASSERT((int)slist_get(l, 0) == 1); // 削除確認
- ASSERT((int)slist_get(l, 1) == 4); // 削除確認
- ASSERT((int)slist_get(l, 2) == 5); // 削除確認
-
- // 255 アイテム中 2 個削除し、4回イテレートし、1回の削除は通りすぎ
- // たあとなので、残り 250回
+ ASSERT((int)slist_itr_next(l) == 1); /* normal iterate */
+ ASSERT((int)slist_itr_next(l) == 2); /* normal iterate */
+ slist_remove(l, 2); /* remove next. "3" is removed */
+ ASSERT((int)slist_itr_next(l) == 4); /* removed item is skipped */
+ slist_remove(l, 1); /* remove past item. "2" is removed */
+ ASSERT((int)slist_itr_next(l) == 5); /* no influence */
+ ASSERT((int)slist_get(l, 0) == 1); /* checking for removing */
+ ASSERT((int)slist_get(l, 1) == 4); /* checking for removing */
+ ASSERT((int)slist_get(l, 2) == 5); /* checking for removing */
+ /*
+ * Total number was 255. We removed 2 items and iterated 4 times.
+ * 1 removing was past item, so the remaining is 250.
+ */
for (i = 0; i < 249; i++)
ASSERT(slist_itr_next(l) != NULL);
ASSERT(slist_itr_next(l) != NULL);
ASSERT(slist_itr_next(l) == NULL);
- // 上記と同じだが、最後を取り出す前に削除
+ /*
+ * Same as above except removing before getting the last item.
+ */
- // リセット (253アイテム)
+ /* Reset (253 items) */
for (i = 0; i < slist_length(l); i++)
slist_set(l, i, (void *)(i + 1));
slist_itr_first(l);
@@ -272,7 +273,7 @@ test_itr_subr_01(slist *l)
ASSERT(slist_itr_next(l) != NULL);
slist_remove(l, 252);
- ASSERT(slist_itr_next(l) == NULL); // 最後を指してたけど、NULL
+ ASSERT(slist_itr_next(l) == NULL); /* The last item is NULL */
slist_itr_first(l);
while (slist_length(l) > 0)
@@ -295,7 +296,7 @@ test_04()
test_itr_subr_01(&sl);
for (i = 0; i < 256; i++) {
- // ローテーションして、どんな物理配置でも成功すること確認
+ /* Verify any physical placements are OK by rotating. */
sl.first_idx = i;
sl.last_idx = sl.first_idx + 255;
sl.last_idx %= sl.list_size;
@@ -304,7 +305,7 @@ test_04()
}
}
-// 物理配置の一番最後の要素を削除しても、大丈夫か。
+/* Verify removing the last item on the physical location */
static void
test_05()
{
@@ -313,16 +314,16 @@ test_05()
slist *l = &sl;
slist_init(&sl);
- // ぎりぎりまで追加
+ /* Fill */
for (i = 0; i < 255; i++) {
slist_add(&sl, (void *)i);
}
- // 254 個削除
+ /* Remove 254 items */
for (i = 0; i < 254; i++) {
slist_remove_first(&sl);
}
slist_set(l, 0, (void *)0);
- // 7個追加
+ /* Add 7 items */
for (i = 0; i < 8; i++) {
slist_add(&sl, (void *)i + 1);
}
@@ -401,7 +402,6 @@ test_07()
static void
test_08()
{
- //int i, x;
slist sl;
slist *l = &sl;
@@ -431,8 +431,6 @@ test_08()
ASSERT((int)slist_get(l, 1) == 3);
ASSERT((int)slist_get(l, 2) == 4);
ASSERT((int)slist_get(l, 3) == 5);
-
- //dump(l);
}
static void
@@ -456,7 +454,7 @@ test_09()
ASSERT((int)slist_itr_next(l) == 3); /* 3 */
/* reaches the last */
slist_add(l, (void *)4); /* add a new item */
- ASSERT(slist_itr_has_next(l)); /* iterates the new*/
+ ASSERT(slist_itr_has_next(l)); /* iterates the new */
ASSERT((int)slist_itr_next(l) == 4);
slist_fini(l);
@@ -475,11 +473,8 @@ test_09()
ASSERT((int)slist_itr_next(l) == 2); /* 2 */
ASSERT((int)slist_itr_next(l) == 3); /* 3 */
/* reaches the last */
- //dump(l);
slist_itr_remove(l); /* and remove the last*/
- //dump(l);
slist_add(l, (void *)4); /* add 4 (new last)*/
- //dump(l);
ASSERT(slist_itr_has_next(l)); /* */
ASSERT((int)slist_itr_next(l) == 4); /* 4 */
slist_fini(l);
diff --git a/usr.sbin/npppd/l2tp/l2tp.h b/usr.sbin/npppd/l2tp/l2tp.h
index c3910f91010..3dca153a73c 100644
--- a/usr.sbin/npppd/l2tp/l2tp.h
+++ b/usr.sbin/npppd/l2tp/l2tp.h
@@ -26,19 +26,19 @@
#ifndef L2TP_H
#define L2TP_H 1
/*@file
- * L2TPモジュールヘッダファイル
+ * header file for the L2TP module
*/
-/* $Id: l2tp.h,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: l2tp.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/************************************************************************
- * プロトコル上の定数
+ * Protocol Constants
************************************************************************/
#define L2TP_RFC2661_VERSION 1
#define L2TP_RFC2661_REVISION 0
#define L2TP_AVP_MAXSIZ 1024
-/* ヘッダ */
+/* Header */
#define L2TP_HEADER_FLAG_TOM 0x8000
#define L2TP_HEADER_FLAG_LENGTH 0x4000
@@ -168,8 +168,8 @@
#define L2TP_BEARER_CAP_FLAGS_ANALOG 0x00000002
/*
- * RFC2661 の pp.19 〜 pp.22 の定数
- * ラベル名は不適切かも。
+ * Constants on pp.19-22 of RFC2661
+ * macro names may be inappropriate.
*/
#define L2TP_STOP_CCN_RCODE_GENERAL 1
#define L2TP_STOP_CCN_RCODE_GENERAL_ERROR 2
@@ -209,7 +209,7 @@
#define L2TP_AUTH_TYPE_MS_CHAP_V1 5
/************************************************************************
- * この実装の定数
+ * Implementation Specific Constants
************************************************************************/
#define L2TPD_BACKLOG 16
@@ -225,13 +225,13 @@
#endif
#define L2TPD_DEFAULT_UDP_PORT 1701
-/** アドレスは最大何個 bind 可能か。*/
+/** maximum number of addresses we will listen on */
#ifndef L2TP_NLISTENER
#define L2TP_NLISTENER 6
#endif
/*
- * デーモンの状態
+ * state of daemon
*/
#define L2TPD_STATE_INIT 0
#define L2TPD_STATE_RUNNING 1
@@ -239,7 +239,7 @@
#define L2TPD_STATE_STOPPED 3
/*
- * コントロール接続の状態
+ * state of a control connection
*/
#define L2TP_CTRL_STATE_IDLE 0
#define L2TP_CTRL_STATE_WAIT_CTL_CONN 1
@@ -248,7 +248,7 @@
#define L2TP_CTRL_STATE_CLEANUP_WAIT 4
/*
- * コールの状態
+ * state of a call
*/
#define L2TP_CALL_STATE_IDLE 0
#define L2TP_CALL_STATE_WAIT_CONN 1
@@ -256,10 +256,10 @@
#define L2TP_CALL_STATE_CLEANUP_WAIT 3
/*
- * タイムアウト関連
+ * timeout
*/
#define L2TP_CTRL_CTRL_PKT_TIMEOUT 12
-/** 最初の Call を待つ時間 */
+/** wait time for the first call */
#define L2TP_CTRL_WAIT_CALL_TIMEOUT 16
#define L2TP_CTRL_CLEANUP_WAIT_TIME 3
#define L2TP_CTRL_DEFAULT_HELLO_INTERVAL 60
@@ -267,64 +267,64 @@
#define L2TPD_SHUTDOWN_TIMEOUT 5
-/** L2TPデーモンが停止したかどうかを返します。 */
+/** returns whether an L2TP daemon is stopped */
#define l2tpd_is_stopped(l2tpd) \
(((l2tpd)->state != L2TPD_STATE_SHUTTING_DOWN && \
(l2tpd)->state != L2TPD_STATE_RUNNING)? 1 : 0)
-/** L2TPデーモンが停止処理中かどうかを返します。 */
+/** returns whether an L2TP daemon is going to shutdown */
#define l2tpd_is_shutting_down(l2tpd) \
(((l2tpd)->state == L2TPD_STATE_SHUTTING_DOWN)? 1 : 0)
-/** l2tp_ctrl から、リスナーの物理層のラベルを取り出すマクロ */
+/** macro to retrieve a physical layer label from l2tp_ctrl */
#define L2TP_CTRL_LISTENER_LABEL(ctrl) \
((l2tpd_listener *)slist_get(&(ctrl)->l2tpd->listener, \
(ctrl)->listener_index))->phy_label
-/** L2TP のデーモンを示す型。*/
+/** datatype represents L2TP daemon */
struct _l2tpd;
typedef struct _l2tpd_listener {
- /** イベントコンテキスト */
+ /** event context */
struct event ev_sock;
- /** L2TPD 自身 */
+ /** L2TPD itself */
struct _l2tpd *self;
- /** インデックス番号 */
+ /** index number */
uint16_t index;
- /** 有効/無効 */
+ /** enable/disable */
uint16_t enabled;
- /** 待ち受けソケット */
+ /** listening socket */
int sock;
- /** 待ち受けアドレス UDP */
+ /** listening socket address for UDP packets */
struct sockaddr_in bind_sin;
- /** 物理層のラベル */
+ /** physical layer label */
char phy_label[16];
} l2tpd_listener;
-/** L2TP のデーモンを示す型。*/
+/** datatype represents L2TP daemon */
typedef struct _l2tpd {
- /** タイムアウトイベントコンテキスト */
+ /** timeout event context */
struct event ev_timeout;
- /** インスタンスの ID */
+ /** instance ID */
unsigned id;
- /** 待ち受けリスト */
+ /** listener list */
slist listener;
- /** ステータス */
+ /** state */
int state;
- /** トンネル ID と {@link ::_l2tp_ctrl L2TP コントロール} のマップ */
+ /** mappings from tunnel ID to {@link ::_l2tp_ctrl L2TP control} */
hash_table *ctrl_map;
- /** 接続を許可するIPv4ネットワーク */
+ /** IPv4 network addresses allowed to connect */
struct in_addr_range *ip4_allow;
- /** デフォルトのホスト名 */
+ /** default hostname */
char default_hostname[80];
- /** 設定 */
+ /** configuration */
struct properties *config;
- /** フラグ */
+ /** flags */
uint32_t
require_ipsec:1,
purge_ipsec_sa:1,
@@ -335,101 +335,104 @@ typedef struct _l2tpd {
phy_label_with_ifname:1;
} l2tpd;
-/** L2TP コントロール接続を示す型。*/
+/** datatype represents L2TP control connection */
typedef struct _l2tp_ctrl {
struct event ev_timeout;
/** ID */
unsigned id;
- /** 親 L2TPD */
+ /** parent L2TPD */
l2tpd *l2tpd;
- /** リスナー インデックス番号 */
+ /** listener index number */
uint16_t listener_index;
- /** 状態 */
+ /** state */
int state;
- /** トンネルId。 */
+ /** tunnel Id */
int tunnel_id;
- /** Window サイズ */
+ /** window size */
int winsz;
- /** 先方のトンネルId */
+ /** peer's tunnel Id */
int peer_tunnel_id;
- /** 先方の Window サイズ */
+ /** peer's window size */
int peer_winsz;
- /** 次の確認応答 */
+ /** next acknowledgement number */
uint16_t snd_una;
- /** 次の送信シーケンス番号 */
+ /** next send sequence number */
uint16_t snd_nxt;
- /** 受信シーケンス番号 */
+ /** receive sequence number */
uint16_t rcv_nxt;
- /** 先方のアドレス*/
+ /** peer's IP address */
struct sockaddr_storage peer;
- /** こちらのアドレス */
+ /** my IP address */
struct sockaddr_storage sock;
- /** IPSEC NAT-T SA クッキー */
+ /** IPSEC NAT-T SA cookie */
void *sa_cookie;
- /** 物理層のラベル (コピー) */
+ /** physical layer label (copied) */
char phy_label[16];
- /** L2TPコールのリスト */
+ /** list of L2TP calls */
slist call_list;
/*
- * 送信 Window 関連
- * pos == lim は、バッファが一杯であることを示します。
- * pos == -1、lim == 0 はバッファが空であることを示します。
+ * Note about send window:
+ * pos == lim when buffer is full.
+ * pos == -1, lim == 0 when buffer is empty.
*/
- /** 利用可能な送信バッファ。#winsz 分のリストになってます*/
+ /** bytes available in send buffer. it is a list of length #winsz */
bytebuffer **snd_buffers;
- /** Sending buffer for ZLB */
+ /** sending buffer for ZLB */
bytebuffer *zlb_buffer;
- /** 最後にコントロールメッセージを送信した時間 */
+ /** the time when last control message sent */
time_t last_snd_ctrl;
- /** 最後にパケットを受信を送信した時間 */
+ /** the time when last packet received */
time_t last_rcv;
/**
- * アクティブクローズの場合で、StopCCN を未送信の場合は、StopCCN
- * で伝える result code が入ります。
+ * If we are on active close and have not sent a StopCCN message yet,
+ * active_closing has the result code to be in the StopCCN message.
*/
int active_closing;
- /** アイドル状態から HELLO 送信までの秒数。0以下は無効。*/
+ /**
+ * delay between transition to idle state and sending HELLO in seconds.
+ * invalid if less than or equal to zero.
+ */
int hello_interval;
- /** HELLO のタイムアウト */
+ /** HELLO timeout */
int hello_timeout;
- /** HELLO 送出時刻 */
+ /** time when the last HELLO packet was sent */
time_t hello_io_time;
- /** 確立した call 数 */
+ /** number of calls established */
int ncalls;
int
- /* L2TP Data Message でシーケンス番号を使うか */
+ /** use sequence number in L2TP Data Message? */
data_use_seq:1,
- /** HELLO の応答待ちかどうか */
+ /** waiting to acknowledge HELLO? */
hello_wait_ack:1;
} l2tp_ctrl;
/**
- * L2TP コールを示す型。
+ * datatype represents a L2TP call
*/
typedef struct _l2tp_call {
/** ID */
unsigned id;
- /** 状態 */
+ /** state */
int state;
- /** 親コントロールコネクション */
+ /** parent control connection */
l2tp_ctrl *ctrl;
- /** バインドした {@link ::_npppd_ppp ppp} */
+ /** bound {@link ::_npppd_ppp ppp} */
void *ppp;
- /** セッション ID */
+ /** session ID */
int session_id;
- /** 先方のセッション ID */
+ /** peer's session ID */
int peer_session_id;
- /** 次の送信シーケンス番号 */
+ /** next sequence number */
uint16_t snd_nxt;
- /** 受信シーケンス番号 */
+ /** receiving sequence number */
uint16_t rcv_nxt;
- /** Calling number */
+ /** calling number */
char calling_number[32];
uint32_t /** Sequencing required */
diff --git a/usr.sbin/npppd/l2tp/l2tp_call.c b/usr.sbin/npppd/l2tp/l2tp_call.c
index 1654681bc8d..03e7d550cea 100644
--- a/usr.sbin/npppd/l2tp/l2tp_call.c
+++ b/usr.sbin/npppd/l2tp/l2tp_call.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: l2tp_call.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,10 +24,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: l2tp_call.c,v 1.3 2010/01/27 07:27:02 yasuoka Exp $ */
-/**@file
- * L2TP LNS のコールの実装。
- */
+/* $Id: l2tp_call.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $ */
+/**@file L2TP LNS call */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -40,6 +39,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <event.h>
+#include <net/if_dl.h>
#include "debugutil.h"
#include "bytebuf.h"
@@ -48,12 +48,7 @@
#include "l2tp.h"
#include "l2tp_subr.h"
-#ifndef L2TPD_TEST
-#include <net/if_dl.h>
#include "npppd.h"
-#else
-typedef struct _dialin_proxy_info { } dialin_proxy_info;
-#endif
#include "l2tp_local.h"
#ifdef L2TP_CALL_DEBUG
@@ -77,11 +72,13 @@ static int l2tp_call_bind_ppp (l2tp_call *, dialin_proxy_info *);
static void l2tp_call_notify_down (l2tp_call *);
static int l2tp_call_send_data_packet (l2tp_call *, bytebuffer *);
+static int l2tp_call_ppp_output (npppd_ppp *, unsigned char *, int, int);
+static void l2tp_call_closed_by_ppp (npppd_ppp *);
-/** l2tp_call の ID番号のシーケンス番号 */
+/* l2tp_call ID sequence # */
static unsigned l2tp_call_id_seq = 0;
-/** {@link ::_l2tp_call L2TP コール} インスタンスを生成します。*/
+/* create {@link ::_l2tp_call L2TP call} instance */
l2tp_call *
l2tp_call_create(void)
{
@@ -93,7 +90,7 @@ l2tp_call_create(void)
return _this;
}
-/** {@link ::_l2tp_call L2TP コール} インスタンスを初期化します。 */
+/* initialize {@link ::_l2tp_call L2TP call} instance */
void
l2tp_call_init(l2tp_call *_this, l2tp_ctrl *ctrl)
{
@@ -104,7 +101,7 @@ l2tp_call_init(l2tp_call *_this, l2tp_ctrl *ctrl)
_this->use_seq = ctrl->data_use_seq;
}
-/** このインスタンスを解放します。 */
+/* free {@link ::_l2tp_call L2TP call} instance */
void
l2tp_call_destroy(l2tp_call *_this, int from_l2tp_ctrl)
{
@@ -112,13 +109,13 @@ l2tp_call_destroy(l2tp_call *_this, int from_l2tp_ctrl)
}
/*
- * 切断について
- * a) npppdctl (vdipwho) から切断要求があった。
- * ppp_stop() で切断します。→ PPP LCP TermReq
- * b) npppd が終了する、あるいは設定変更により l2tp.enabled = false
- * l2tp_call_disconnect() で切断します。→ L2TP CDN
+ * l2tp disconnect will occur when
+ * 1) disconnect request issued from nppdctl command
+ * 2) npppd is terminated
+ * in case 1) ppp_stop() is used to terminal. (PPP LCP TermReq)
+ * and in case 2) l2tp_call_disconnect() is used (L2TP CDN)
*/
-/** 管理上の理由から切断します。 */
+/* administrative reason disconnection */
void
l2tp_call_admin_disconnect(l2tp_call *_this)
{
@@ -126,10 +123,9 @@ l2tp_call_admin_disconnect(l2tp_call *_this)
NULL, NULL, 0);
}
-/**
- * 切断します。
- * @param result_code CDN を送信せずに切断(解放)する場合には、0 を指定
- * します。
+/*
+ * disconnect l2tp connection
+ * @param result_code disconect without CDN, specify zero
*/
static void
l2tp_call_disconnect(l2tp_call *_this, int result_code, int error_code,
@@ -138,8 +134,8 @@ l2tp_call_disconnect(l2tp_call *_this, int result_code, int error_code,
L2TP_CALL_ASSERT(_this != NULL);
if (_this->state == L2TP_CALL_STATE_CLEANUP_WAIT) {
- // 既に CDN を受信、または送信済み
- l2tp_call_notify_down(_this); // ねんのため
+ /* CDN received, or have been sent */
+ l2tp_call_notify_down(_this); /* just in case */
return;
}
if (result_code > 0) {
@@ -152,10 +148,11 @@ l2tp_call_disconnect(l2tp_call *_this, int result_code, int error_code,
l2tp_call_notify_down(_this);
}
-/************************************************************************
- * 制御パケットの送受信
- ************************************************************************/
-/** 制御パケットが入力された時に呼び出します。 */
+/*
+ * control packet
+ */
+
+/* call it when control packet is recieved */
int
l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
u_char *pkt, int pktlen)
@@ -164,7 +161,7 @@ l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
l2tp_call *call;
dialin_proxy_info dpi;
- // ICRQ の時だけ、_this == NULL
+ /* when ICRQ, this will be NULL */
L2TP_CALL_ASSERT(_this != NULL ||
mestype == L2TP_AVP_MESSAGE_TYPE_ICRQ);
@@ -184,7 +181,7 @@ l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
len = slist_length(&ctrl->call_list);
session_id = _this->id;
again:
- /* セッションIDの割り当て */
+ /* assign a session ID */
session_id &= 0xffff;
if (session_id == 0)
session_id = 1;
@@ -197,7 +194,7 @@ l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
}
_this->session_id = session_id;
- /* この l2tp_call をリストに追加。 */
+ /* add the l2tp_call to call list */
slist_add(&_this->ctrl->call_list, _this);
if (l2tp_call_send_ICRP(_this) != 0)
@@ -206,7 +203,7 @@ l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
return 0;
}
- /* ステートマシン */
+ /* state machine */
send_cdn = 0;
switch (_this->state) {
default:
@@ -225,7 +222,7 @@ l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
case L2TP_AVP_MESSAGE_TYPE_ICRQ:
case L2TP_AVP_MESSAGE_TYPE_ICRP:
send_cdn = 1;
- // FALL THROUGH
+ /* FALLTHROUGH */
default:
l2tp_call_log(_this, LOG_ERR,
"Waiting ICCN. But received %s",
@@ -242,9 +239,7 @@ l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
case L2TP_CALL_STATE_ESTABLISHED:
switch (mestype) {
case L2TP_AVP_MESSAGE_TYPE_CDN:
- /*
- * peer からの切断。ログに残す
- */
+ /* disconnect from peer. log it */
l2tp_recv_CDN(_this, pkt, pktlen);
_this->state = L2TP_CALL_STATE_CLEANUP_WAIT;
l2tp_call_notify_down(_this);
@@ -276,12 +271,12 @@ l2tp_call_recv_packet(l2tp_ctrl *ctrl, l2tp_call *_this, int mestype,
l2tp_call_disconnect(_this, 0, 0, NULL, NULL, 0);
return 1;
}
-/**
- * ICRQ受信
- * @return acceptable な ICRQ の場合には、0 を返します。
- * 失敗した場合には、0 以外を返し、CDN は送信済みで、ステータス
- * も変更済みです。
- */
+/*
+ * receieve ICRQ
+ * @return return 0 if the ICRQ is acceptable.
+ * other values means fail to receive, and
+ * CDN was sent and status was updated.
+ */
static int
l2tp_call_recv_ICRQ(l2tp_call *_this, u_char *pkt, int pktlen)
{
@@ -326,9 +321,10 @@ l2tp_call_recv_ICRQ(l2tp_call *_this, u_char *pkt, int pktlen)
case L2TP_AVP_TYPE_BEARER_TYPE:
case L2TP_AVP_TYPE_PHYSICAL_CHANNEL_ID:
/*
- * Windows 98/Me/NT の MS "L2TP/IPsec VPN Client"
- * では Physical Channel Id は mandatory ビットがたって
- * いる。
+ * Memo:
+ * Microsoft "L2TP/IPsec VPN Client" for
+ * Windows 98/Me/NT asserts mandatory bit in
+ * Physical Channel Id
*/
case L2TP_AVP_TYPE_CALLING_NUMBER:
slen = MIN(sizeof(_this->calling_number) - 1,
@@ -338,7 +334,6 @@ l2tp_call_recv_ICRQ(l2tp_call *_this, u_char *pkt, int pktlen)
break;
case L2TP_AVP_TYPE_CALLED_NUMBER:
case L2TP_AVP_TYPE_SUB_ADDRESS:
- // 使い途あれば。
continue;
default:
if (avp->is_mandatory) {
@@ -384,7 +379,7 @@ size_check_failed:
return 1;
}
-/** ICRP 送信 */
+/* send ICRP */
static int
l2tp_call_send_ICRP(l2tp_call *_this)
{
@@ -423,7 +418,7 @@ l2tp_call_send_ICRP(l2tp_call *_this)
return 0;
}
-/** L2TP data messageを送信します。*/
+/* send L2TP data message */
static int
l2tp_call_send_data_packet(l2tp_call *_this, bytebuffer *buffer)
{
@@ -432,7 +427,7 @@ l2tp_call_send_data_packet(l2tp_call *_this, bytebuffer *buffer)
bytebuffer_flip(buffer);
hdr = (struct l2tp_header *)bytebuffer_pointer(buffer);
- memset(hdr, 0, sizeof(*hdr) - 4); /* Nr, Ns はオプション */
+ memset(hdr, 0, sizeof(*hdr) - 4); /* Nr, NS are option */
hdr->t = 0;
hdr->ver = L2TP_HEADER_VERSION_RFC2661;
@@ -461,10 +456,11 @@ l2tp_call_send_data_packet(l2tp_call *_this, bytebuffer *buffer)
return (rval == bytebuffer_remaining(buffer))? 0 : 1;
}
-/**
- * ICCN 受信
- * @return acceptable な ICCN の場合には、0 を返します。失敗した場合には、0
- * 以外を返し、CDN は送信済みで、ステータスも変更済みです。
+/*
+ * receive ICCN
+ * @return return 0 if the ICCN is acceptable.
+ * other value means fail to receive, and
+ * CDN was sent and status was updated.
*/
static int
l2tp_call_recv_ICCN(l2tp_call *_this, u_char *pkt, int pktlen,
@@ -608,7 +604,7 @@ size_check_failed:
return 1;
}
-/** CDN 受信 */
+/* receive CDN */
static int
l2tp_recv_CDN(l2tp_call *_this, u_char *pkt, int pktlen)
{
@@ -616,7 +612,7 @@ l2tp_recv_CDN(l2tp_call *_this, u_char *pkt, int pktlen)
struct l2tp_avp *avp;
char buf[L2TP_AVP_MAXSIZ], emes[256], pmes[256];
- /* 初期化 */
+ /* initialize */
result = 0;
error = 0;
sessid = 0;
@@ -707,13 +703,13 @@ l2tp_recv_CDN(l2tp_call *_this, u_char *pkt, int pktlen)
return 0;
size_check_failed:
- // CDN のメッセージがおかしくても、続行
+ /* continue to process even if the CDN message was broken */
l2tp_call_log(_this, LOG_ERR, "Received bad CDN: %s", emes);
return 0;
}
-/** CDN 送信 */
+/* send CDN */
static int
l2tp_call_send_CDN(l2tp_call *_this, int result_code, int error_code, const
char *errmes, struct l2tp_avp *addavp[], int naddavp)
@@ -745,8 +741,10 @@ l2tp_call_send_CDN(l2tp_call *_this, int result_code, int error_code, const
avp->attr_type = L2TP_AVP_TYPE_RESULT_CODE;
#if 0
/*
- * エラーコード無しの長さ 8 の AVP を送信すると、Windows 2000 側が StopCCN で
- * "2 - Length is wrong" を返してくる。長さ10にして回避。
+ * Windows 2000 work around:
+ * Windows 2000 will return "2 - Length is wrong" in StopCCN,
+ * when it received "length = 8 and no error code AVP".
+ * Avoid the error, use AVP length = 10.
*/
if (error_code > 0) {
val32 = (result_code << 16) | (error_code & 0xffff);
@@ -802,7 +800,7 @@ l2tp_call_send_CDN(l2tp_call *_this, int result_code, int error_code, const
return 0;
}
-/** ZLB の送信 */
+/* send ZLB */
static int
l2tp_call_send_ZLB(l2tp_call *_this)
{
@@ -818,10 +816,10 @@ l2tp_call_send_ZLB(l2tp_call *_this)
bytebuf, 1);
}
-/************************************************************************
- * その他
- ************************************************************************/
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/*
+ * misc
+ */
+/* logging with the label of the instance */
static void
l2tp_call_log(l2tp_call *_this, int prio, const char *fmt, ...)
{
@@ -840,7 +838,7 @@ l2tp_call_log(l2tp_call *_this, int prio, const char *fmt, ...)
va_end(ap);
}
-/** 現在のステータスの文字列表現を返します。 */
+/* convert current status to strings */
static inline const char *
l2tp_call_state_string(l2tp_call *_this)
{
@@ -853,33 +851,11 @@ l2tp_call_state_string(l2tp_call *_this)
return "unknown";
}
+/*
+ * npppd physical layer
+ */
-#ifdef L2TPD_TEST
-
-void
-l2tp_call_ppp_input(l2tp_call *_this, u_char *pkt, int pktlen)
-{
-}
-static int
-l2tp_call_bind_ppp(l2tp_call *_this, dialin_proxy_info *dpi)
-{
- return 0;
-}
-static void
-l2tp_call_notify_down(l2tp_call *_this)
-{
-}
-
-#else
-/************************************************************************
- * npppd の物理層として
- ************************************************************************/
-#include "npppd.h"
-
-static int l2tp_call_ppp_output (npppd_ppp *, unsigned char *, int, int);
-static void l2tp_call_closed_by_ppp (npppd_ppp *);
-
-/** ppp にパケットを入力します。 */
+/* input packet to ppp */
void
l2tp_call_ppp_input(l2tp_call *_this, u_char *pkt, int pktlen)
{
@@ -900,7 +876,7 @@ l2tp_call_ppp_input(l2tp_call *_this, u_char *pkt, int pktlen)
}
}
-/** ppp からパケットが出力される時に呼び出されます。 */
+/* called ppp output a packet */
static int
l2tp_call_ppp_output(npppd_ppp *ppp, unsigned char *bytes, int nbytes,
int flags)
@@ -926,7 +902,7 @@ l2tp_call_ppp_output(npppd_ppp *ppp, unsigned char *bytes, int nbytes,
return 0;
}
-/** ppp で切断された場合に呼び出されます。 */
+/* it will be called when the connection was closed at ppp */
static void
l2tp_call_closed_by_ppp(npppd_ppp *ppp)
{
@@ -937,7 +913,8 @@ l2tp_call_closed_by_ppp(npppd_ppp *ppp)
_this = ppp->phy_context;
- _this->ppp = NULL; // l2tp_call_disconnect より先に。
+ /* do before l2tp_call_disconnect() */
+ _this->ppp = NULL;
if (_this->state == L2TP_CALL_STATE_CLEANUP_WAIT) {
/* no need to call l2tp_call_disconnect */
@@ -980,7 +957,7 @@ l2tp_call_closed_by_ppp(npppd_ppp *ppp)
l2tp_call_log(_this, LOG_NOTICE, "logtype=PPPUnbind");
}
-/** ppp に切断した旨を通知し ppp の終了/解放を行います。 */
+/* notify disconnection to ppp to terminate or free of ppp */
static void
l2tp_call_notify_down(l2tp_call *_this)
{
@@ -988,7 +965,7 @@ l2tp_call_notify_down(l2tp_call *_this)
ppp_phy_downed(_this->ppp);
}
-/** ppp の bind。 */
+/* bind ppp */
static int
l2tp_call_bind_ppp(l2tp_call *_this, dialin_proxy_info *dpi)
{
@@ -999,7 +976,7 @@ l2tp_call_bind_ppp(l2tp_call *_this, dialin_proxy_info *dpi)
errcode = 0;
ppp = NULL;
if ((ppp = ppp_create()) == NULL)
- goto reigai;
+ goto fail;
ASSERT(_this->ppp == NULL);
@@ -1021,7 +998,7 @@ l2tp_call_bind_ppp(l2tp_call *_this, dialin_proxy_info *dpi)
sizeof(ppp->calling_number));
if (ppp_init(npppd_get_npppd(), ppp) != 0) {
l2tp_call_log(_this, LOG_ERR, "failed binding ppp");
- goto reigai;
+ goto fail;
}
l2tp_call_log(_this, LOG_NOTICE, "logtype=PPPBind ppp=%d", ppp->id);
@@ -1032,18 +1009,18 @@ l2tp_call_bind_ppp(l2tp_call *_this, dialin_proxy_info *dpi)
"'accept_dialin' is 'false' in the setting.");
code = L2TP_CDN_RCODE_ERROR_CODE;
errcode = L2TP_ECODE_INVALID_MESSAGE;
- goto reigai;
+ goto fail;
}
if (ppp_dialin_proxy_prepare(ppp, dpi) != 0) {
code = L2TP_CDN_RCODE_TEMP_NOT_AVALIABLE;
- goto reigai;
+ goto fail;
}
}
ppp_start(ppp);
return 0;
-reigai:
+fail:
if (ppp != NULL)
ppp_destroy(ppp);
_this->ppp = NULL;
@@ -1051,4 +1028,3 @@ reigai:
l2tp_call_disconnect(_this, code, 0, NULL, NULL, 0);
return 1;
}
-#endif
diff --git a/usr.sbin/npppd/l2tp/l2tp_ctrl.c b/usr.sbin/npppd/l2tp/l2tp_ctrl.c
index a7517b9f146..79bd0239981 100644
--- a/usr.sbin/npppd/l2tp/l2tp_ctrl.c
+++ b/usr.sbin/npppd/l2tp/l2tp_ctrl.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: l2tp_ctrl.c,v 1.3 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,10 +24,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/**@file
- * L2TP LNS のコントロールコネクションの処理を提供します。
- */
-// $Id: l2tp_ctrl.c,v 1.2 2010/01/13 07:49:44 yasuoka Exp $
+/**@file Control connection processing functions for L2TP LNS */
+/* $Id: l2tp_ctrl.c,v 1.3 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
@@ -92,14 +91,14 @@ static inline const char *l2tp_ctrl_state_string (l2tp_ctrl *);
#define L2TP_CTRL_DBG(x)
#endif
-/** l2tp_ctrl の ID番号のシーケンス番号 */
+/* Sequence # of l2tp_ctrl ID */
static unsigned l2tp_ctrl_id_seq = 0;
#define SEQ_LT(a,b) ((int16_t)((a) - (b)) < 0)
#define SEQ_GT(a,b) ((int16_t)((a) - (b)) > 0)
/**
- * {@link ::_l2tp_ctrl L2TP LNS コントロールコネクション}のインスタンス生成
+ * Build instance of {@link ::_l2tp_ctrl L2TP LNS control connection}
*/
l2tp_ctrl *
l2tp_ctrl_create(void)
@@ -114,8 +113,8 @@ l2tp_ctrl_create(void)
}
/**
- * {@link ::_l2tp_ctrl L2TP LNS コントロールコネクション}のインスタンスの
- * 初期化と開始を行います。
+ * initialize and startup of {@link ::_l2tp_ctrl L2TP LNS control connection}
+ * instance
*/
static int
l2tp_ctrl_init(l2tp_ctrl *_this, l2tpd *_l2tpd, struct sockaddr *peer,
@@ -133,9 +132,8 @@ l2tp_ctrl_init(l2tp_ctrl *_this, l2tpd *_l2tpd, struct sockaddr *peer,
_this->last_snd_ctrl = curr_time;
slist_init(&_this->call_list);
- /*
- * 空いているトンネルIDを探す
- */
+
+ /* seek a free tunnel ID */
i = 0;
_this->id = ++l2tp_ctrl_id_seq;
for (i = 0, tunid = _this->id; ; i++, tunid++) {
@@ -146,7 +144,7 @@ l2tp_ctrl_init(l2tp_ctrl *_this, l2tpd *_l2tpd, struct sockaddr *peer,
if (l2tpd_get_ctrl(_l2tpd, tunid) == NULL)
break;
if (i > 80000) {
- // バグに違いない
+ /* this must be happen, just log it. */
l2tpd_log(_l2tpd, LOG_ERR, "Too many l2tp controls");
return -1;
}
@@ -159,19 +157,19 @@ l2tp_ctrl_init(l2tp_ctrl *_this, l2tpd *_l2tpd, struct sockaddr *peer,
memcpy(&_this->peer, peer, peer->sa_len);
memcpy(&_this->sock, sock, sock->sa_len);
- /* 送信バッファの準備 */
+ /* prepare send buffer */
_this->winsz = L2TPD_DEFAULT_SEND_WINSZ;
if ((_this->snd_buffers = calloc(_this->winsz, sizeof(bytebuffer *)))
== NULL) {
l2tpd_log(_l2tpd, LOG_ERR,
"calloc() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
for (i = 0; i < _this->winsz; i++) {
if ((bytebuf = bytebuffer_create(L2TPD_SND_BUFSIZ)) == NULL) {
l2tpd_log(_l2tpd, LOG_ERR,
"bytebuffer_create() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
_this->snd_buffers[i] = bytebuf;
}
@@ -179,7 +177,7 @@ l2tp_ctrl_init(l2tp_ctrl *_this, l2tpd *_l2tpd, struct sockaddr *peer,
+ 128)) == NULL) {
l2tpd_log(_l2tpd, LOG_ERR,
"bytebuffer_create() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
#ifdef USE_LIBSOCKUTIL
if (nat_t_ctx != NULL) {
@@ -190,7 +188,7 @@ l2tp_ctrl_init(l2tp_ctrl *_this, l2tpd *_l2tpd, struct sockaddr *peer,
} else {
l2tpd_log(_l2tpd, LOG_ERR,
"creating sa_cookie failed: %m");
- goto reigai;
+ goto fail;
}
}
#endif
@@ -198,20 +196,19 @@ l2tp_ctrl_init(l2tp_ctrl *_this, l2tpd *_l2tpd, struct sockaddr *peer,
_this->hello_timeout = L2TP_CTRL_DEFAULT_HELLO_TIMEOUT;
_this->hello_io_time = curr_time;
- /* タイマーのセット */
+ /* initialize timeout timer */
l2tp_ctrl_reset_timeout(_this);
- /* 登録 */
+ /* register l2tp context */
l2tpd_add_ctrl(_l2tpd, _this);
return 0;
-reigai:
+fail:
l2tp_ctrl_stop(_this, 0);
return -1;
}
-/**
- * {@link ::_l2tp_ctrl L2TP LNS コントロールコネクション} のインスタンスの
- * 設定を行います。
+/*
+ * setup {@link ::_l2tp_ctrl L2TP LNS control connection} instance
*/
static void
l2tp_ctrl_reload(l2tp_ctrl *_this)
@@ -229,9 +226,8 @@ l2tp_ctrl_reload(l2tp_ctrl *_this)
return;
}
-/**
- * {@link ::_l2tp_ctrl L2TP LNS コントロールコネクション}のインスタンスを解放
- * します。
+/*
+ * free {@link ::_l2tp_ctrl L2TP LNS control connection} instance
*/
void
l2tp_ctrl_destroy(l2tp_ctrl *_this)
@@ -244,12 +240,13 @@ l2tp_ctrl_destroy(l2tp_ctrl *_this)
free(_this);
}
-/**
- * 切断を先方に通知します。
+/*
+ * nortify disconnection to peer
*
- * @return CDN、StopCCN を送信済みの場合には 0。CDN を送信できていない
- * コールが存在する場合にはその数、StopCCN の送信に失敗した場合
- * -1 が返ります。
+ * @return 0: all CDN and StopCCN have been sent.
+ * N: if the remaining calls which still not sent CDN exist,
+ * return # of the calls.
+ * -1: when try to send of StopCCN failed.
*/
static int
l2tp_ctrl_send_disconnect_notify(l2tp_ctrl *_this)
@@ -260,19 +257,18 @@ l2tp_ctrl_send_disconnect_notify(l2tp_ctrl *_this)
L2TP_CTRL_ASSERT(_this->state == L2TP_CTRL_STATE_ESTABLISHED ||
_this->state == L2TP_CTRL_STATE_CLEANUP_WAIT);
- // アクティブじゃなかったり、StopCCN を送信済み。
+ /* the contexts is not active or StopCCN have been sent */
if (_this->active_closing == 0)
return 0;
- // すべての Call に CDN
+ /* CDN have been sent for all Calls */
ncalls = 0;
if (slist_length(&_this->call_list) != 0) {
ncalls = l2tp_ctrl_disconnect_all_calls(_this);
if (ncalls > 0) {
- /*
- * 送信 Window が埋まっているかどうかを検査するために
- * 再度呼び出す。ゼロになれば、すべての call に CDN を
- * 送信し終わった。
+ /*
+ * Call l2tp_ctrl_disconnect_all_calls() to check
+ * the send window still filled.
*/
ncalls = l2tp_ctrl_disconnect_all_calls(_this);
}
@@ -287,19 +283,21 @@ l2tp_ctrl_send_disconnect_notify(l2tp_ctrl *_this)
return 0;
}
-/**
- * コントロールコネクションを終了します。
+/*
+ * Terminate the control connection
*
* <p>
- * アクティブクローズの (StopCCN を送信する) 場合には、StopCCN の
- * ResultCode AVP ように result に 1 以上の適切な値を指定してください。</p>
+ * please spcify an appropriate value to result( >0 ) for
+ * StopCCN ResultCode AVP, when to sent Active Close (which
+ * require StopCCN sent).</p>
* <p>
- * 戻り値が 0 の場合、_this は解放されていますので、l2tp_ctrl の処理を
- * 続行することはできません。また、1 の場合(解放されていない場合) は、
- * タイマはリセットされています。</p>
+ * When the return value of this function is zero, the _this
+ * is already released. The lt2p_ctrl process that was bound to it
+ * could not contine.
+ * When the return value of this function is one, the timer
+ * is reset.</p>
*
- * @return 完全に終了した場合には 0 を、まだ完全に終了していない場合
- * には、0 以外を返します。
+ * @return return 0 if terminate process was completed.
*/
int
l2tp_ctrl_stop(l2tp_ctrl *_this, int result)
@@ -321,9 +319,9 @@ l2tp_ctrl_stop(l2tp_ctrl *_this, int result)
default:
l2tp_ctrl_log(_this, LOG_DEBUG, "%s() unexpected state=%s",
__func__, l2tp_ctrl_state_string(_this));
- // FALL THROUGH;
+ /* FALLTHROUGH */
case L2TP_CTRL_STATE_WAIT_CTL_CONN:
- // FALL THROUGH;
+ /* FALLTHROUGH */
case L2TP_CTRL_STATE_CLEANUP_WAIT:
cleanup:
if (slist_length(&_this->call_list) != 0) {
@@ -339,7 +337,7 @@ cleanup:
evtimer_del(&_this->ev_timeout);
- /* 送信バッファの解放 */
+ /* free send buffer */
if (_this->snd_buffers != NULL) {
for (i = 0; i < _this->winsz; i++)
bytebuffer_destroy(_this->snd_buffers[i]);
@@ -350,7 +348,8 @@ cleanup:
bytebuffer_destroy(_this->zlb_buffer);
_this->zlb_buffer = NULL;
}
- /* l2tp_call の解放 */
+
+ /* free l2tp_call */
l2tp_ctrl_destroy_all_calls(_this);
slist_fini(&_this->call_list);
@@ -360,7 +359,7 @@ cleanup:
l2tp_ctrl_destroy(_this);
l2tpd_ctrl_finished_notify(_l2tpd);
- return 0; // stopped
+ return 0; /* stopped */
}
l2tp_ctrl_reset_timeout(_this);
@@ -459,7 +458,7 @@ l2tp_ctrl_purge_ipsec_sa(l2tp_ctrl *_this)
}
#endif
-/** タイマー関連処理 */
+/* timeout processing */
static void
l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
{
@@ -468,10 +467,10 @@ l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
l2tp_ctrl *_this;
l2tp_call *call;
- /*
- * この関数から抜ける場合は、タイマをリセットしなければならない。
- * l2tp_ctrl_stop は、l2tp_ctrl_stop 内でタイマをリセットする。
- * l2tp_ctrl_stop は、_this を解放する可能性がある点にも注意。
+ /*
+ * the timer must be reset, when leave this function.
+ * MEMO: l2tp_ctrl_stop() will reset the timer in it.
+ * and please remember that the l2tp_ctrl_stop() may free _this.
*/
_this = ctx;
L2TP_CTRL_ASSERT(_this != NULL);
@@ -484,7 +483,7 @@ l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
if (l2tp_ctrl_txwin_size(_this) > 0) {
if (_this->state == L2TP_CTRL_STATE_ESTABLISHED) {
if (_this->hello_wait_ack != 0) {
- /* Hello 応答待ち */
+ /* wait Hello reply */
if (curr_time - _this->hello_io_time >=
_this->hello_timeout) {
l2tp_ctrl_log(_this, LOG_NOTICE,
@@ -518,8 +517,8 @@ l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
switch (_this->state) {
case L2TP_CTRL_STATE_IDLE:
/*
- * idle の場合
- * この実装ではあり得ない。
+ * idle:
+ * XXX: never happen in current implementation
*/
l2tp_ctrl_log(_this, LOG_ERR,
"Internal error, timeout on illegal state=idle");
@@ -527,10 +526,11 @@ l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
break;
case L2TP_CTRL_STATE_WAIT_CTL_CONN:
/*
- * wait-ctrl-conn の場合
- * SCCRP に対する確認応答がない場合は、先方は SCCRQ
- * を再送するが、この実装側で「再送」であることを検知
- * できない。こちらからは再送しない。
+ * wait-ctrl-conn:
+ * if there is no ack for SCCRP, the peer will
+ * resend SCCRQ. however this implementation can
+ * not recognize that the SCCRQ was resent or not.
+ * Therefore, never resent from this side.
*/
need_resend = 0;
break;
@@ -539,7 +539,7 @@ l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
curr_time - _this->last_snd_ctrl >=
L2TP_CTRL_WAIT_CALL_TIMEOUT) {
if (_this->ncalls == 0)
- /* 最初の call がこない。 */
+ /* fail to recieve first call */
l2tp_ctrl_log(_this, LOG_WARNING,
"timeout waiting call");
l2tp_ctrl_stop(_this,
@@ -547,13 +547,11 @@ l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
return;
}
if (_this->hello_wait_ack == 0 && _this->hello_interval > 0) {
- /*
- * Hello 送信
- */
+ /* send Hello */
if (curr_time - _this->hello_interval >=
_this->hello_io_time) {
if (l2tp_ctrl_send_HELLO(_this) == 0)
- /* 成功した場合 */
+ /* success */
_this->hello_wait_ack = 1;
_this->hello_io_time = curr_time;
need_resend = 0;
@@ -578,7 +576,7 @@ l2tp_ctrl_timeout(int fd, short evtype, void *ctx)
l2tp_ctrl_stop(_this, L2TP_STOP_CCN_RCODE_GENERAL);
return;
}
- /* 再送の必要があれば、再送 */
+ /* resend if required */
if (need_resend)
l2tp_ctrl_resend_una_packets(_this);
l2tp_ctrl_reset_timeout(_this);
@@ -605,7 +603,7 @@ l2tp_ctrl_send(l2tp_ctrl *_this, const void *msg, int len)
return rval;
}
-/** 確認応答待ちのパケットを再送する。 */
+/* resend una packets */
static int
l2tp_ctrl_resend_una_packets(l2tp_ctrl *_this)
{
@@ -639,9 +637,7 @@ l2tp_ctrl_resend_una_packets(l2tp_ctrl *_this)
return nsend;
}
-/**
- * すべてのコールを解放します。
- */
+/* free all calls */
static void
l2tp_ctrl_destroy_all_calls(l2tp_ctrl *_this)
{
@@ -653,9 +649,9 @@ l2tp_ctrl_destroy_all_calls(l2tp_ctrl *_this)
l2tp_call_destroy(call, 1);
}
-/**
- * このコントロールの全ての call を切断します。
- * @return 解放待ちになっていない call の数を返します。
+
+/* disconnect all calls on the control context
+ * @return return # of calls that is not waiting cleanup.
*/
static int
l2tp_ctrl_disconnect_all_calls(l2tp_ctrl *_this)
@@ -684,9 +680,7 @@ l2tp_ctrl_disconnect_all_calls(l2tp_ctrl *_this)
return ncalls;
}
-/**
- * タイムアウトを再設定します。
- */
+/* reset timeout */
static void
l2tp_ctrl_reset_timeout(l2tp_ctrl *_this)
{
@@ -713,12 +707,10 @@ l2tp_ctrl_reset_timeout(l2tp_ctrl *_this)
evtimer_add(&_this->ev_timeout, &tv0);
}
-/***********************************************************************
- * プロトコル - 送受信
- ***********************************************************************/
-/**
- * パケット受信
+/*
+ * protocols / send and receive
*/
+/* Recieve packet */
void
l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
struct sockaddr *sock, void *nat_t_ctx, u_char *pkt, int pktlen)
@@ -746,7 +738,7 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
l2tpd_log(_this, LOG_ERR,
"Received a packet peer unknown address "
"family=%d", peer->sa_family);
- return; // ここまでは reigai に飛ばさない
+ return;
}
peersin = (struct sockaddr_in *)peer;
socksin = (struct sockaddr_in *)sock;
@@ -763,7 +755,7 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
memcpy(&hdr, pkt, 2);
pkt += 2;
if (hdr.ver != L2TP_HEADER_VERSION_RFC2661) {
- /* 現在 RFC2661 のみサポートします */
+ /* XXX: only RFC2661 is supported */
snprintf(errmsg, sizeof(errmsg),
"Unsupported version at header = %d", hdr.ver);
goto bad_packet;
@@ -824,7 +816,7 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
ctrl = l2tpd_get_ctrl(_this, hdr.tunnel_id);
if (ctrl == NULL) {
- /* 新しいコントロール */
+ /* new control */
if (!is_ctrl) {
snprintf(errmsg, sizeof(errmsg),
"bad data message: tunnelId=%d is not "
@@ -847,7 +839,7 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
l2tpd_log_access_deny(_this,
"could not get interface informations",
peer);
- goto reigai;
+ goto fail;
}
if (l2tpd_config_str_equal(_this,
config_key_prefix("l2tpd.interface", ifname),
@@ -858,23 +850,23 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
config_key_prefix("l2tpd.interface", "any"),
"accept", 0)){
} else {
- /* このインタフェースは許可されていない。*/
+ /* the interface is not permited */
snprintf(errmsg, sizeof(errmsg),
"'%s' is not allowed by config.", ifname);
l2tpd_log_access_deny(_this, errmsg, peer);
- goto reigai;
+ goto fail;
}
}
if ((ctrl = l2tp_ctrl_create()) == NULL) {
l2tp_ctrl_log(ctrl, LOG_ERR,
"l2tp_ctrl_create() failed: %m");
- goto reigai;
+ goto fail;
}
if (l2tp_ctrl_init(ctrl, _this, peer, sock, nat_t_ctx) != 0) {
l2tp_ctrl_log(ctrl, LOG_ERR,
"l2tp_ctrl_start() failed: %m");
- goto reigai;
+ goto fail;
}
ctrl->listener_index = listener_index;
@@ -882,8 +874,8 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
l2tp_ctrl_reload(ctrl);
} else {
/*
- * 始点アドレス/ポートが異なる場合には、エラーとする。(DoS
- * の可能性があるので)
+ * treat as an error if src address and port is not
+ * match. (because it is potentially DoS attach)
*/
L2TP_CTRL_ASSERT(ctrl->peer.ss_family == peer->sa_family);
@@ -909,7 +901,8 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
ctrl->last_rcv = curr_time;
call = NULL;
if (hdr.session_id != 0) {
- /* Session Id から l2tp_call を探す。リニアサーチ */
+ /* search l2tp_call by Session ID */
+ /* linear search is enough for this purpose */
len = slist_length(&ctrl->call_list);
for (i = 0; i < len; i++) {
call = slist_get(&ctrl->call_list, i);
@@ -919,20 +912,18 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
}
}
if (!is_ctrl) {
- /*
- * L2TP データ
- */
+ /* L2TP data */
if (ctrl->state != L2TP_CTRL_STATE_ESTABLISHED) {
l2tp_ctrl_log(ctrl, LOG_WARNING,
"Received Data packet in '%s'",
l2tp_ctrl_state_string(ctrl));
- goto reigai;
+ goto fail;
}
if (call == NULL) {
l2tp_ctrl_log(ctrl, LOG_WARNING,
"Received a data packet but it has no call. "
"session_id=%u", hdr.session_id);
- goto reigai;
+ goto fail;
}
L2TP_CTRL_DBG((ctrl, DEBUG_LEVEL_2,
"call=%u RECV ns=%u nr=%u snd_nxt=%u rcv_nxt=%u len=%d",
@@ -942,13 +933,13 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
l2tp_ctrl_log(ctrl, LOG_WARNING,
"Received a data packet but call is not "
"established");
- goto reigai;
+ goto fail;
}
if (hdr.s != 0) {
if (SEQ_LT(hdr.ns, call->rcv_nxt)) {
- /* シーケンスが戻った。*/
- /* 統計情報に残すべきかもしれない */
+ /* sequence number seems to rewind */
+ /* XXX: need to log? */
L2TP_CTRL_DBG((ctrl, LOG_DEBUG,
"receive a out of sequence data packet: "
"%u < %u. ", hdr.ns, call->rcv_nxt));
@@ -978,15 +969,15 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
"Received message has bad Nr field: "
"%u < %u.", hdr.ns, ctrl->snd_nxt);
/* XXX Drop with ZLB? */
- goto reigai;
+ goto fail;
}
}
if (l2tp_ctrl_txwin_size(ctrl) <= 0) {
- /* 確認応答待ちなし */
+ /* no waiting ack */
if (ctrl->hello_wait_ack != 0) {
/*
- * Hello に対する Ack が返ったので、Hello
- * の状態をリセット
+ * Reset Hello state, as an ack for the Hello
+ * is recived.
*/
ctrl->hello_wait_ack = 0;
ctrl->hello_io_time = curr_time;
@@ -998,13 +989,13 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
}
}
if (hdr.ns != ctrl->rcv_nxt) {
- // 受信してないパケットがある
+ /* there are remaining packet */
if (l2tp_ctrl_resend_una_packets(ctrl) <= 0) {
- // 再送または ZLB 送信
+ /* resend or sent ZLB */
l2tp_ctrl_send_ZLB(ctrl);
}
#ifdef L2TP_CTRL_DEBUG
- if (pktlen != 0) { // ZLB ではない。
+ if (pktlen != 0) { /* not ZLB */
L2TP_CTRL_DBG((ctrl, LOG_DEBUG,
"receive out of sequence %u must be %u. "
"mestype=%s", hdr.ns, ctrl->rcv_nxt,
@@ -1028,12 +1019,12 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
if (avp == NULL) {
l2tpd_log(_this, LOG_WARNING,
"bad control message: no message-type AVP.");
- goto reigai;
+ goto fail;
}
}
/*
- * ステートマシン (RFC2661 pp. 56-57)
+ * state machine (RFC2661 pp. 56-57)
*/
switch (ctrl->state) {
case L2TP_CTRL_STATE_IDLE:
@@ -1041,28 +1032,28 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
case L2TP_AVP_MESSAGE_TYPE_SCCRQ:
if (l2tp_ctrl_recv_SCCRQ(ctrl, pkt, pktlen, _this,
peer) == 0) {
- // acceptable
+ /* acceptable */
l2tp_ctrl_send_SCCRP(ctrl);
ctrl->state = L2TP_CTRL_STATE_WAIT_CTL_CONN;
return;
}
/*
- * un-accectable な場合は、l2tp_ctrl_recv_SCCRQ 側で
- * 処理済みです。
+ * in case un-acceptable, it was already processed
+ * at l2tcp_ctrl_recv_SCCRQ
*/
return;
case L2TP_AVP_MESSAGE_TYPE_SCCRP:
/*
- * RFC上は StopCCN を送信するが、この LNS の実装では、
- * Passive Open だけなので、 このパケットは受け取らな
- * いはず。
+ * RFC specifies that sent of StopCCN in the state,
+ * However as this implementation only support Passive
+ * open, this packet will not recieved.
*/
- // FALL THROUGH
+ /* FALLTHROUGH */
case L2TP_AVP_MESSAGE_TYPE_SCCCN:
default:
break;
}
- goto fsm_reigai;
+ goto fsm_fail;
case L2TP_CTRL_STATE_WAIT_CTL_CONN:
/* Wait-Ctl-Conn */
@@ -1080,7 +1071,7 @@ l2tp_ctrl_input(l2tpd *_this, int listener_index, struct sockaddr *peer,
default:
break;
}
- break; /* fsm_reigai */
+ break; /* fsm_fail */
case L2TP_CTRL_STATE_ESTABLISHED:
/* Established */
switch (mestype) {
@@ -1112,9 +1103,9 @@ receive_stop_ccn:
l2tp_ctrl_log(ctrl, LOG_INFO,
"Unknown call message: %s",
avp_mes_type_string(mestype));
- goto reigai;
+ goto fail;
}
- // FALL THROUGH
+ /* FALLTHROUGH */
case L2TP_AVP_MESSAGE_TYPE_ICRQ:
l2tp_call_recv_packet(ctrl, call, mestype, pkt,
pktlen);
@@ -1122,26 +1113,25 @@ receive_stop_ccn:
default:
break;
}
- break; /* fsm_reigai */
+ break; /* fsm_fail */
case L2TP_CTRL_STATE_CLEANUP_WAIT:
if (mestype == L2TP_AVP_MESSAGE_TYPE_StopCCN) {
/*
- * StopCCN が交錯したか、Window が埋まっていて
- * StopCCN が送信できない間に、StopCCN を受信
+ * We left ESTABLISHED state, but the peer sent StopCCN.
*/
goto receive_stop_ccn;
}
- break; /* fsm_reigai */
+ break; /* fsm_fail */
}
-fsm_reigai:
- /* ステートマシンのエラー */
+fsm_fail:
+ /* state machine error */
l2tp_ctrl_log(ctrl, LOG_WARNING, "Received %s in '%s' state",
avp_mes_type_string(mestype), l2tp_ctrl_state_string(ctrl));
l2tp_ctrl_stop(ctrl, L2TP_STOP_CCN_RCODE_FSM_ERROR);
return;
-reigai:
+fail:
if (ctrl != NULL && mestype != 0) {
l2tp_ctrl_log(ctrl, LOG_WARNING, "Received %s in '%s' state",
avp_mes_type_string(mestype), l2tp_ctrl_state_string(ctrl));
@@ -1173,7 +1163,7 @@ l2tp_ctrl_txwin_is_full(l2tp_ctrl *_this)
return (l2tp_ctrl_txwin_size(_this) >= _this->winsz)? 1 : 0;
}
-/** パケットの送信 */
+/* send control packet */
int
l2tp_ctrl_send_packet(l2tp_ctrl *_this, int call_id, bytebuffer *bytebuf,
int is_ctrl)
@@ -1232,8 +1222,8 @@ l2tp_ctrl_send_packet(l2tp_ctrl *_this, int call_id, bytebuffer *bytebuf,
return (rval == bytebuffer_remaining(bytebuf))? 0 : 1;
}
-/**
- * SCCRQ の受信
+/*
+ * receiver SCCRQ
*/
static int
l2tp_ctrl_recv_SCCRQ(l2tp_ctrl *_this, u_char *pkt, int pktlen, l2tpd *_l2tpd,
@@ -1293,8 +1283,8 @@ l2tp_ctrl_recv_SCCRQ(l2tp_ctrl *_this, u_char *pkt, int pktlen, l2tpd *_l2tpd,
case L2TP_AVP_TYPE_TIE_BREAKER:
AVP_SIZE_CHECK(avp, ==, 14);
/*
- * この実装からは SCCRQ は送らないので常に peer が
- * winner。
+ * As the implementation never send SCCRQ,
+ * the peer is always winner
*/
continue;
case L2TP_AVP_TYPE_FIRMWARE_REVISION:
@@ -1359,8 +1349,8 @@ size_check_failed:
return 1;
}
-/**
- * StopCCN を送信します。
+/*
+ * send StopCCN
*/
static int
l2tp_ctrl_send_StopCCN(l2tp_ctrl *_this, int result)
@@ -1406,8 +1396,8 @@ l2tp_ctrl_send_StopCCN(l2tp_ctrl *_this, int result)
return 0;
}
-/**
- * StopCCN の受信
+/*
+ * Receiver StopCCN
*/
static int
l2tp_ctrl_recv_StopCCN(l2tp_ctrl *_this, u_char *pkt, int pktlen)
@@ -1487,15 +1477,12 @@ l2tp_ctrl_recv_StopCCN(l2tp_ctrl *_this, u_char *pkt, int pktlen)
if (rcode == L2TP_CDN_RCODE_ERROR_CODE &&
ecode == L2TP_ECODE_NO_RESOURCE) {
/*
- * 現在観測された状況
- *
- * (1) IDGWとWindows が同一 LAN セグメント上にあり、
- * Windows の(そのLAN IP アドレスが、ナチュラルマスク
- * で評価した場合のブロードキャストアドレスだった場合
- * (192.168.0.255/23など)
- * (2) Windows 2000 を起動しっぱなしで、L2TPの接続切断を繰り
- * 返すと、あるタイミングからこの状況に陥り、接続できない。
- * Windows が再起動するまで、問題は継続。
+ * Memo:
+ * This state may be happen in following state.
+ * - lots of connect/disconect by long-running
+ * windows2000, sometimes it fall to this state.
+ * Once it fall to here, connection will fail till
+ * the windows rebooted
*/
l2tp_ctrl_log(_this, LOG_WARNING,
"Peer indicates \"No Resource\" error.");
@@ -1514,8 +1501,8 @@ size_check_failed:
return -1;
}
-/**
- * SCCRP の送信
+/*
+ * send SCCRP
*/
static void
l2tp_ctrl_send_SCCRP(l2tp_ctrl *_this)
@@ -1563,7 +1550,7 @@ l2tp_ctrl_send_SCCRP(l2tp_ctrl *_this)
if ((val = l2tp_ctrl_config_str(_this, "l2tp.host_name")) == NULL)
val = _this->l2tpd->default_hostname;
if (val[0] == '\0')
- val = "G"; /* おまじない。ask yasuoka */
+ val = "G"; /* XXX magic word, why? ask yasuoka */
len = strlen(val);
memcpy(avp->attr_value, val, len);
bytebuf_add_avp(bytebuf, avp, len);
@@ -1576,8 +1563,7 @@ l2tp_ctrl_send_SCCRP(l2tp_ctrl *_this)
bytebuf_add_avp(bytebuf, avp, 2);
/* Bearer Capability
- *
- * この実装は LAC になり得ない LNS なので。
+ * This implementation never act as LAC.
*
memset(avp, 0, sizeof(*avp));
avp->is_mandatory = 1;
@@ -1652,7 +1638,7 @@ l2tp_ctrl_send_HELLO(l2tp_ctrl *_this)
return 0;
}
-/** ZLB の送信 */
+/* Send ZLB */
static int
l2tp_ctrl_send_ZLB(l2tp_ctrl *_this)
{
@@ -1668,12 +1654,13 @@ l2tp_ctrl_send_ZLB(l2tp_ctrl *_this)
return l2tp_ctrl_send_packet(_this, 0, _this->zlb_buffer, 1);
}
-/***********************************************************************
- * ユーティリティ関数
- ***********************************************************************/
+/*
+ * Utitlity
+ */
+
/**
- * 送信バッファの準備
- * @return 送信バッファが Window を越えている場合には NULL が返ります。
+ * Prepare send buffer
+ * @return return Null when the send buffer exceed Window.
*/
bytebuffer *
l2tp_ctrl_prepare_snd_buffer(l2tp_ctrl *_this, int with_seq)
@@ -1699,7 +1686,7 @@ l2tp_ctrl_prepare_snd_buffer(l2tp_ctrl *_this, int with_seq)
}
/**
- * 現在のステータスの文字列表現を返します。
+ * return current state as strings
*/
static inline const char *
l2tp_ctrl_state_string(l2tp_ctrl *_this)
@@ -1714,9 +1701,7 @@ l2tp_ctrl_state_string(l2tp_ctrl *_this)
return "unknown";
}
-/**
- * このインスタンスに基づいたラベルから始まるログを記録します。
- */
+/* logging with the label of the l2tp instance. */
void
l2tp_ctrl_log(l2tp_ctrl *_this, int prio, const char *fmt, ...)
{
diff --git a/usr.sbin/npppd/l2tp/l2tp_local.h b/usr.sbin/npppd/l2tp/l2tp_local.h
index 517072db216..424b58f2cae 100644
--- a/usr.sbin/npppd/l2tp/l2tp_local.h
+++ b/usr.sbin/npppd/l2tp/l2tp_local.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: l2tp_local.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#ifndef L2TP_LOCAL_H
#define L2TP_LOCAL_H 1
-/* $Id: l2tp_local.h,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: l2tp_local.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#ifndef GETSHORT
#define GETSHORT(s, cp) { \
diff --git a/usr.sbin/npppd/l2tp/l2tp_subr.c b/usr.sbin/npppd/l2tp/l2tp_subr.c
index 62a6326a687..fecfe603ab4 100644
--- a/usr.sbin/npppd/l2tp/l2tp_subr.c
+++ b/usr.sbin/npppd/l2tp/l2tp_subr.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: l2tp_subr.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,10 +24,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: l2tp_subr.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
-/**@file
- * L2TP 関連の補助的な関数を提供します。
- */
+/* $Id: l2tp_subr.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
+/**@file L2TP related sub-routines */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
@@ -55,9 +54,9 @@
#define L2TP_SUBR_ASSERT(x)
#endif
-/***********************************************************************
- * AVP関連
- ***********************************************************************/
+/*
+ * AVP
+ */
int
avp_enum(struct l2tp_avp *avp, const u_char *pkt, int pktlen, int filldata)
{
@@ -309,7 +308,7 @@ avp_find_message_type_avp(struct l2tp_avp *avp, const u_char *pkt, int pktlen)
}
/**
- * bytebuffer に AVP を追加します。
+ * add an AVP to bytebuffer
*/
int
bytebuf_add_avp(bytebuffer *bytebuf, struct l2tp_avp *avp, int value_len)
diff --git a/usr.sbin/npppd/l2tp/l2tp_subr.h b/usr.sbin/npppd/l2tp/l2tp_subr.h
index 4aed34c29ff..8cb11cedbf3 100644
--- a/usr.sbin/npppd/l2tp/l2tp_subr.h
+++ b/usr.sbin/npppd/l2tp/l2tp_subr.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: l2tp_subr.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -25,10 +26,10 @@
*/
#ifndef L2TP_SUBR_H
#define L2TP_SUBR_H 1
-/* $Id: l2tp_subr.h,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: l2tp_subr.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/**
- * L2TP の Attribute Value Pair (AVP) のパケットヘッダを示す構造体です。
+ * structure of L2TP Attribute Value Pair (AVP) packet header
*/
struct l2tp_avp
{
@@ -90,14 +91,10 @@ short_hash(const void *v, int sz)
return (int)v % sz;
}
-/**
- * AVPのサイズをチェックするマクロ。
- * <p>
- * 準備<br>
- * <ul>
- * <li>エラーメッセージ用の char emes[256] を準備する。
- * <li>reigai ラベルを準備する。
- * </ul></p>
+/*
+ * macro to check AVP size.
+ * Prepare 1) char emes[256] for error message, 2) size_check_failed label
+ * before use this macro.
*/
#define AVP_SIZE_CHECK(avp, op, exp) \
if (!((avp)->length op (exp))) { \
diff --git a/usr.sbin/npppd/l2tp/l2tpd.c b/usr.sbin/npppd/l2tp/l2tpd.c
index baa8604c135..6df6d75bdf1 100644
--- a/usr.sbin/npppd/l2tp/l2tpd.c
+++ b/usr.sbin/npppd/l2tp/l2tpd.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: l2tpd.c,v 1.3 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,13 +24,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/**@file
- * L2TP(Layer Two Tunneling Protocol "L2TP") の実装
- */
-/*
- * RFC 2661
- */
-// $Id: l2tpd.c,v 1.2 2010/01/13 07:49:44 yasuoka Exp $
+/**@file L2TP(Layer Two Tunneling Protocol "L2TP") / RFC2661 */
+/* $Id: l2tpd.c,v 1.3 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -81,11 +77,8 @@
static void l2tpd_io_event (int, short, void *);
static inline int short_cmp (const void *, const void *);
static inline uint32_t short_hash (const void *, int);
-/*
- * static 変数
- */
-/** l2tpd の ID番号のシーケンス番号 */
+/* sequence # of l2tpd ID */
static unsigned l2tpd_id_seq = 0;
#ifndef USE_LIBSOCKUTIL
@@ -93,15 +86,14 @@ struct in_ipsec_sa_cookie { };
#endif
-/***********************************************************************
- * L2TP デーモンインスタンス操作
- ***********************************************************************/
+/* L2TP daemon instance */
/**
- * L2TPデーモンインスタンスを初期化します。
+ * initialize L2TP daemon instance
* <p>
- * {@link _l2tpd#bind_sin} は、.sin_family = AF_INET、.sin_port = 1701、
- * .sin_len が設定された状態で返ります。 </p>
+ * {@link _l2tpd#bind_sin} will return with .sin_family = AF_INET,
+ * .sin_port = 1701 and .sin_len = "appropriate value"
+ * </p>
*/
int
l2tpd_init(l2tpd *_this)
@@ -137,12 +129,12 @@ l2tpd_init(l2tpd *_this)
return 0;
}
-/**
- * {@link ::l2tpd L2TPデーモン}に{@link ::l2tpd_listener リスナ}を追加します。
- * @param _this {@link ::l2tpd L2TPデーモン}
- * @param idx リスナのインデックス
- * @param label 物理層としてのラベル。"L2TP" など
- * @param bindaddr 待ち受けるアドレス
+/*
+ * Add a {@link :l2tpd_listener} to the {@link ::l2tpd L2TP daemon}
+ * @param _this {@link ::l2tpd L2TP daemon}
+ * @param idx index of the lisnter
+ * @param label physical layer label (ex. "L2TP")
+ * @param bindaddr bind address
*/
int
l2tpd_add_listener(l2tpd *_this, int idx, const char *label,
@@ -166,18 +158,17 @@ l2tpd_add_listener(l2tpd *_this, int idx, const char *label,
l2tpd_log(_this, LOG_ERR,
"Invalid argument error on %s(): idx must be %d but %d",
__func__, slist_length(&_this->listener), idx);
- goto reigai;
+ goto fail;
}
if ((plistener = malloc(sizeof(l2tpd_listener))) == NULL) {
l2tpd_log(_this, LOG_ERR, "malloc() failed in %s: %m",
__func__);
- goto reigai;
+ goto fail;
}
memset(plistener, 0, sizeof(l2tpd_listener));
L2TPD_ASSERT(sizeof(plistener->bind_sin) >= bindaddr->sa_len);
memcpy(&plistener->bind_sin, bindaddr, bindaddr->sa_len);
- /* ポート番号が省略された場合は、デフォルト (1701/udp)を使う */
if (plistener->bind_sin.sin_port == 0)
plistener->bind_sin.sin_port = htons(L2TPD_DEFAULT_UDP_PORT);
@@ -189,16 +180,16 @@ l2tpd_add_listener(l2tpd *_this, int idx, const char *label,
if (slist_add(&_this->listener, plistener) == NULL) {
l2tpd_log(_this, LOG_ERR, "slist_add() failed in %s: %m",
__func__);
- goto reigai;
+ goto fail;
}
return 0;
-reigai:
+fail:
if (plistener != NULL)
free(plistener);
return 1;
}
-/** L2TPデーモンインスタンスの終了処理を行います。*/
+/* finalize L2TP daemon instance */
void
l2tpd_uninit(l2tpd *_this)
{
@@ -223,12 +214,12 @@ l2tpd_uninit(l2tpd *_this)
}
slist_fini(&_this->listener);
- event_del(&_this->ev_timeout); // ねんのため
+ event_del(&_this->ev_timeout); /* just in case */
_this->state = L2TPD_STATE_STOPPED;
_this->config = NULL;
}
-/** 待ち受けを開始します。*/
+/* start l2tpd listner */
static int
l2tpd_listener_start(l2tpd_listener *_this, char *ipsec_policy_in,
char *ipsec_policy_out)
@@ -251,7 +242,7 @@ l2tpd_listener_start(l2tpd_listener *_this, char *ipsec_policy_in,
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
l2tpd_log(_l2tpd, LOG_ERR,
"socket() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
#ifdef NPPPD_FAKEBIND
if (!wildcardbinding)
@@ -267,25 +258,25 @@ l2tpd_listener_start(l2tpd_listener *_this, char *ipsec_policy_in,
if ((ival = fcntl(sock, F_GETFL, 0)) < 0) {
l2tpd_log(_l2tpd, LOG_ERR,
"fcntl(,F_GETFL) failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
} else if (fcntl(sock, F_SETFL, ival | O_NONBLOCK) < 0) {
l2tpd_log(_l2tpd, LOG_ERR, "fcntl(,F_SETFL,O_NONBLOCK) failed "
"in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
ival = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &ival, sizeof(ival))
!= 0) {
l2tpd_log(_l2tpd, LOG_ERR,
"setsockopt(,,SO_REUSEPORT) failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
if (bind(sock, (struct sockaddr *)&_this->bind_sin,
_this->bind_sin.sin_len) != 0) {
l2tpd_log(_l2tpd, LOG_ERR, "Binding %s:%u/udp: %m",
inet_ntoa(_this->bind_sin.sin_addr),
ntohs(_this->bind_sin.sin_port));
- goto reigai;
+ goto fail;
}
#ifdef NPPPD_FAKEBIND
if (!wildcardbinding)
@@ -298,24 +289,23 @@ l2tpd_listener_start(l2tpd_listener *_this, char *ipsec_policy_in,
l2tpd_log(_l2tpd, LOG_ERR,
"setsockopt(,,UDP_NO_CKSUM) failed in %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
#endif
#ifdef USE_LIBSOCKUTIL
if (setsockoptfromto(sock) != 0) {
l2tpd_log(_l2tpd, LOG_ERR,
"setsockoptfromto() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
#else
- // recvfromto のために
- ival = 1;
+ ival = 1; /* for recvfromto */
if (setsockopt(sock, IPPROTO_IP, IP_RECVDSTADDR, &ival, sizeof(ival))
!= 0) {
l2tpd_log(_l2tpd, LOG_ERR,
"setsockopt(,,IP_RECVDSTADDR) failed in %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
#endif
#ifdef IP_IPSEC_POLICY
@@ -346,14 +336,14 @@ l2tpd_listener_start(l2tpd_listener *_this, char *ipsec_policy_in,
ntohs(_this->bind_sin.sin_port), _this->phy_label);
return 0;
-reigai:
+fail:
if (sock >= 0)
close(sock);
return 1;
}
-/** L2TPデーモンを開始します。*/
+/* start L2TP daemon */
int
l2tpd_start(l2tpd *_this)
{
@@ -374,23 +364,23 @@ l2tpd_start(l2tpd *_this)
if (_this->require_ipsec != 0) {
#if 0
/*
- * NOTE ipsec_set_policy() 内で利用する yacc のスタック用の
- * バッファは動的に割り当てられますが、解放されません。
- * yasuoka の調査時は 2000 バイトリークします。
+ * Note: ipsec_set_policy() will assign the buffer for
+ * yacc parser stack, however it never free.
+ * it cause memory leak (-2000byte).
*/
if ((ipsec_policy_in = ipsec_set_policy(L2TPD_IPSEC_POLICY_IN,
strlen(L2TPD_IPSEC_POLICY_IN))) == NULL) {
l2tpd_log(_this, LOG_ERR,
"ipsec_set_policy(L2TPD_IPSEC_POLICY_IN) failed "
"at %s(): %s: %m", __func__, ipsec_strerror());
- goto reigai;
+ goto fail;
}
if ((ipsec_policy_out = ipsec_set_policy(L2TPD_IPSEC_POLICY_OUT,
strlen(L2TPD_IPSEC_POLICY_OUT))) == NULL) {
l2tpd_log(_this, LOG_ERR,
"ipsec_set_policy(L2TPD_IPSEC_POLICY_OUT) failed "
"at %s(): %s: %m", __func__, ipsec_strerror());
- goto reigai;
+ goto fail;
}
#endif
}
@@ -412,7 +402,7 @@ l2tpd_start(l2tpd *_this)
return rval;
#if 0
-reigai:
+fail:
#endif
if (ipsec_policy_in != NULL)
free(ipsec_policy_in);
@@ -422,7 +412,7 @@ reigai:
return 1;
}
-/** 待ち受けを終了します */
+/* stop l2tp lisnter */
static void
l2tpd_listener_stop(l2tpd_listener *_this)
{
@@ -436,9 +426,8 @@ l2tpd_listener_stop(l2tpd_listener *_this)
_this->sock = -1;
}
}
-/**
- * 切断を猶予せずにすぐに停止します。
- */
+
+/* stop immediattly without disconnect operation */
void
l2tpd_stop_immediatly(l2tpd *_this)
{
@@ -449,12 +438,13 @@ l2tpd_stop_immediatly(l2tpd *_this)
plsnr = slist_itr_next(&_this->listener);
l2tpd_listener_stop(plsnr);
}
- event_del(&_this->ev_timeout); // ねんのため
+ event_del(&_this->ev_timeout); /* XXX */
_this->state = L2TPD_STATE_STOPPED;
}
-/**
- * {@link ::_l2tp_ctrl コントロール} が終了した際にコールされます。
+/*
+ * this function will be called when {@link ::_l2tp_ctrl control}
+ * is terminated.
*/
void
l2tpd_ctrl_finished_notify(l2tpd *_this)
@@ -485,9 +475,7 @@ l2tpd_stop_timeout(int fd, short evtype, void *ctx)
l2tpd_stop_immediatly(_this);
}
-/**
- * L2TPデーモンを停止します。
- */
+/* stop L2TP daemon */
void
l2tpd_stop(l2tpd *_this)
{
@@ -500,9 +488,7 @@ l2tpd_stop(l2tpd *_this)
if (l2tpd_is_stopped(_this))
return;
if (l2tpd_is_shutting_down(_this)) {
- /*
- * 2度目はすぐに終了
- */
+ /* terminate immidiatly, when 2nd call */
l2tpd_stop_immediatly(_this);
return;
}
@@ -527,9 +513,9 @@ l2tpd_stop(l2tpd *_this)
l2tpd_stop_immediatly(_this);
}
-/***********************************************************************
- * 設定関連
- ***********************************************************************/
+/*
+ * Configuration
+ */
#define CFG_KEY(p, s) config_key_prefix((p), (s))
#define VAL_SEP " \t\r\n"
@@ -550,7 +536,7 @@ l2tpd_reload(l2tpd *_this, struct properties *config, const char *name,
do_start = 0;
if (l2tpd_config_str_equal(_this, CFG_KEY(name, "enabled"), "true",
default_enabled)) {
- // false にした直後に true にされるかもしれない。
+ /* care the case false-true flapping */
if (l2tpd_is_shutting_down(_this))
l2tpd_stop_immediatly(_this);
if (l2tpd_is_stopped(_this))
@@ -564,7 +550,7 @@ l2tpd_reload(l2tpd *_this, struct properties *config, const char *name,
return 1;
_this->config = config;
- /* 設定がなかったら使われる */
+ /* default value */
gethostname(_this->default_hostname, sizeof(_this->default_hostname));
_this->ctrl_in_pktdump = l2tpd_config_str_equal(_this,
@@ -578,7 +564,7 @@ l2tpd_reload(l2tpd *_this, struct properties *config, const char *name,
_this->phy_label_with_ifname = l2tpd_config_str_equal(_this,
CFG_KEY(name, "label_with_ifname"), "true", 0);
- // ip4_allow をパース
+ /* parse ip4_allow */
in_addr_range_list_remove_all(&_this->ip4_allow);
val = l2tpd_config_str(_this, CFG_KEY(name, "ip4_allow"));
if (val != NULL) {
@@ -602,12 +588,12 @@ l2tpd_reload(l2tpd *_this, struct properties *config, const char *name,
}
if (do_start) {
- /*
- * 起動直後と、l2tpd.enable が false -> true に変更された
- * 場合に、do_start。すべてのリスナーが、初期化された状態を
- * 仮定できる
- */
- // l2tpd.listener_in の読み込む
+ /*
+ * in the case of 1) cold-booted and 2) pptpd.enable
+ * toggled "false" to "true" do this, because we can
+ * assume that all pptpd listner are initialized.
+ */
+ /* read l2tpd.lisnter_in */
val = l2tpd_config_str(_this, CFG_KEY(name, "listener_in"));
if (val != NULL) {
if (strlen(val) >= sizeof(buf)) {
@@ -619,7 +605,8 @@ l2tpd_reload(l2tpd *_this, struct properties *config, const char *name,
strlcpy(buf, val, sizeof(buf));
label = NULL;
- // タブ、スペース区切りで、複数指定可能
+ /* it can accept multiple values with tab/space
+ * separation */
for (i = 0, cp = buf;
(tok = strsep(&cp, VAL_SEP)) != NULL;) {
if (*tok == '\0')
@@ -667,10 +654,10 @@ l2tpd_reload(l2tpd *_this, struct properties *config, const char *name,
return 0;
}
-/***********************************************************************
- * I/O 関連
- ***********************************************************************/
-/** アクセスを拒否したことをログに残す */
+/*
+ * I/O functions
+ */
+/* logging when deny an access */
void
l2tpd_log_access_deny(l2tpd *_this, const char *reason, struct sockaddr *peer)
{
@@ -686,7 +673,7 @@ l2tpd_log_access_deny(l2tpd *_this, const char *reason, struct sockaddr *peer)
"%s", hostbuf, servbuf, reason);
}
-/** I/Oイベントハンドラ */
+/* I/O event handler */
static void
l2tpd_io_event(int fd, short evtype, void *ctx)
{
@@ -728,7 +715,7 @@ l2tpd_io_event(int fd, short evtype, void *ctx)
l2tpd_stop(_l2tpd);
return;
}
- //送信元チェック(allows.in)
+ /* source address check (allows.in) */
switch (peer.ss_family) {
case AF_INET:
#ifdef USE_LIBSOCKUTIL
@@ -740,7 +727,7 @@ l2tpd_io_event(int fd, short evtype, void *ctx)
nat_t = NULL;
#endif
/*
- * XXX NAT-T の場合の送信元チェック
+ * XXX check source address when NAT-T
*/
if (in_addr_range_list_includes(
&_l2tpd->ip4_allow,
@@ -764,9 +751,9 @@ l2tpd_io_event(int fd, short evtype, void *ctx)
}
}
-/***********************************************************************
- * L2TPコントロール関連
- ***********************************************************************/
+/*
+ * L2TP control
+ */
l2tp_ctrl *
l2tpd_get_ctrl(l2tpd *_this, int tunid)
{
@@ -792,9 +779,9 @@ l2tpd_remove_ctrl(l2tpd *_this, int tunid)
}
-/***********************************************************************
- * 雑多
- ***********************************************************************/
+/*
+ * misc
+ */
void
l2tpd_log(l2tpd *_this, int prio, const char *fmt, ...)
diff --git a/usr.sbin/npppd/npppd/Makefile b/usr.sbin/npppd/npppd/Makefile
index e74ad9af30e..0c25eafffdd 100644
--- a/usr.sbin/npppd/npppd/Makefile
+++ b/usr.sbin/npppd/npppd/Makefile
@@ -1,10 +1,13 @@
+# $OpenBSD: Makefile,v 1.5 2010/07/01 03:38:17 yasuoka Exp $
+# $OpenBSD: Makefile,v 1.5 2010/07/01 03:38:17 yasuoka Exp $
#
# $Id
#
NPPPD_COMMON_DIR= ${.CURDIR}/../common
-NOMAN= #
PROG= npppd
+NOMAN= noman
+#MAN= npppd.8 npppd.conf.5 npppd-users.csv.5
CPPFLAGS+= -I${NPPPD_COMMON_DIR} -I${.CURDIR}
SRCS= ccp.c chap.c chap_ms.c fsm.c ipcp.c lcp.c
SRCS+= mppe.c pap.c ppp.c radius_req.c
diff --git a/usr.sbin/npppd/npppd/ccp.c b/usr.sbin/npppd/npppd/ccp.c
index a8716f2550c..2767a50cda3 100644
--- a/usr.sbin/npppd/npppd/ccp.c
+++ b/usr.sbin/npppd/npppd/ccp.c
@@ -24,12 +24,9 @@
* SUCH DAMAGE.
*/
/**@file
- * CCP - Compression Control Protocol
- * <p>
- * 対応するオプション
- * <pre>
- * - MPPE</pre></p>
- * $Id: ccp.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+ * This file provides functions for CCP (Compression Control Protocol).
+ * MPPE is supported as a CCP option.
+ * $Id: ccp.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
#include <sys/types.h>
#include <sys/socket.h>
@@ -84,9 +81,7 @@ static struct fsm_callbacks ccp_callbacks = {
.proto_name = "ccp",
};
-/**
- * ccp コンテキストを初期化します。
- */
+/** Initialize the context for ccp */
void
ccp_init(ccp *_this, npppd_ppp *ppp)
{
@@ -98,7 +93,6 @@ ccp_init(ccp *_this, npppd_ppp *ppp)
_this->fsm.ppp = ppp;
fsm_init(&_this->fsm);
- //_this->fsm.flags |= OPT_SILENT;
PPP_FSM_CONFIG(&_this->fsm, timeouttime, "ccp.timeout");
PPP_FSM_CONFIG(&_this->fsm, maxconfreqtransmits,"ccp.max_configure");
@@ -106,9 +100,7 @@ ccp_init(ccp *_this, npppd_ppp *ppp)
PPP_FSM_CONFIG(&_this->fsm, maxnakloops, "ccp.max_nak_loop");
}
-/**
- * Request Command Interpreter。
- */
+/** Request Command Interpreter */
static int
ccp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
{
@@ -141,13 +133,13 @@ ccp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
GETCHAR(type, pktp);
GETCHAR(len, pktp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
#ifdef USE_NPPPD_MPPE
case CCP_MPPE:
if (len < 6)
- goto reigai;
+ goto fail;
if (ppp->mppe.enabled == 0)
goto reject;
@@ -159,7 +151,7 @@ ccp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
goto reject;
}
if (lrej > 0) {
- /* reject があれば、Rej するので Nak しない */
+ /* don't nak because we are doing rej */
} else {
PUTCHAR(type, nakbuf);
PUTCHAR(6, nakbuf);
@@ -180,7 +172,7 @@ reject:
}
continue;
}
-reigai:
+fail:
switch (rcode) {
case CONFREJ:
memcpy(pktp0, rejbuf, lrej);
@@ -234,7 +226,7 @@ ccp_resetci(fsm *f)
if (f->ppp->mppe_started == 0)
f->ppp->ccp.mppe_o_bits =
mppe_create_our_bits(&f->ppp->mppe, 0);
- /* 開始していたらリセットはしない */
+ /* don't reset if the ccp is started. */
#endif
}
@@ -244,9 +236,7 @@ ccp_cilen(fsm *f)
return f->ppp->mru;
}
-/**
- * ConfReq を作ります。
- */
+/** Create a Confugre-Request */
static void
ccp_addci(fsm *f, u_char *pktp, int *lpktp)
{
@@ -302,32 +292,33 @@ ccp_nackackci(fsm *f, u_char *pktp, int lpkt, int is_nak, int is_rej)
GETCHAR(type, pktp);
GETCHAR(len, pktp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
#ifdef USE_NPPPD_MPPE
case CCP_MPPE:
if (len < 6)
- goto reigai;
+ goto fail;
if (is_rej) {
f->ppp->ccp.mppe_rej = 1;
return 1;
}
if (ppp->mppe_started != 0) {
- // 静かに再送する。
+ /* resend silently */
return 1;
}
GETLONG(peer_bits, pktp);
/*
- * RTX-1000 で ppp ccp mppe-any すると、
+ * With Yamaha RTX-1000 that is configured as
+ * "ppp ccp mppe-any",
+ *
+ * npppd ConfReq (40,56,128) => RTX 1000
+ * npppd <= (40,128) ConfNAK RTX 1000
+ * npppd ConfReq (40,56,128) => RTX 1000
+ * npppd <= (40,128) ConfNAK RTX 1000
*
- * IDGW ConfReq (40,56,128) => RTX
- * IDGW <= (40,128) ConfNAK RTX
- * IDGW ConfReq (40,56,128) => RTX
- * IDGW <= (40,128) ConfNAK RTX
- * :
- * とお互い譲りすぎ。ConfNak されたら、こちらが提案
- * する。
+ * both peers never decide the final bits. We insist
+ * the longest bit if our request is nacked.
*/
our_bits = mppe_create_our_bits(&ppp->mppe, peer_bits);
if (peer_bits == our_bits || is_nak)
@@ -336,11 +327,11 @@ ccp_nackackci(fsm *f, u_char *pktp, int lpkt, int is_nak, int is_rej)
break;
#endif
default:
- goto reigai;
+ goto fail;
}
}
return 1;
-reigai:
+fail:
return 0;
}
@@ -357,8 +348,10 @@ ccp_ext(fsm *f, int code, int id, u_char *pktp, int lpktp)
mppe_recv_ccp_reset(&f->ppp->mppe);
#endif
/*
- * RFC 3078 では、Reset Ack 不要とは書いていないが、送信する
- * と Windows が Code Reject を返すので、送信しない。
+ * RFC 3078 says MPPE can be synchronized without Reset-Ack,
+ * but it doesn't tell about necessity of Reset-Ack. But
+ * in fact, windows peer will complain Reset-Ack with
+ * Code-Reject. So we don't send Reset-Ack.
*/
return 1;
case RESET_ACK:
diff --git a/usr.sbin/npppd/npppd/chap.c b/usr.sbin/npppd/npppd/chap.c
index 8aa4801bb96..b7c1cc63485 100644
--- a/usr.sbin/npppd/npppd/chap.c
+++ b/usr.sbin/npppd/npppd/chap.c
@@ -24,19 +24,17 @@
* SUCH DAMAGE.
*/
/**@file
- * CHAP の実装
- * <p>
- * RFC 1994 PPP Challenge Handshake Authentication Protocol(CHAP) の実装です。
- * 現在認証する側の実装のみです。</p>
- * <p>
- * 対応しているプロトコルは、
- * <ul>
+ * This file provides CHAP (PPP Challenge Handshake Authentication Protocol,
+ * RFC 1994) handlers. Currently this contains authenticator side
+ * implementation only.
+ *<p>
+ * Supported authentication types:
* <li>MD5-CHAP</li>
- * <li>MS-CHAP v2</li>
- * </ul> です。
+ * <li>MS-CHAP Version 2 (RFC 2759)</li>
+ * </ul></p>
*/
/* RFC 1994, 2433 */
-// $Id: chap.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+/* $Id: chap.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -74,15 +72,16 @@
#define CHAP_STATE_STOPPED 5
#define CHAP_STATE_PROXY_AUTHENTICATION 6
-#define CHAP_TIMEOUT 3 /* リトライ間隔 */
-#define CHAP_RETRY 10 /* リトライ間隔 */
+/* retry intervals */
+#define CHAP_TIMEOUT 3
+#define CHAP_RETRY 10
#define CHAP_CHALLENGE 1
#define CHAP_RESPONSE 2
#define CHAP_SUCCESS 3
#define CHAP_FAILURE 4
-// RFC 2433
+/* from RFC 2433 */
#define ERROR_RESTRICTED_LOGIN_HOURS 646
#define ERROR_ACCT_DISABLED 647
#define ERROR_PASSWD_EXPIRED 648
@@ -90,7 +89,7 @@
#define ERROR_AUTHENTICATION_FAILURE 691
#define ERROR_CHANGING_PASSWORD 709
-// MprError.h
+/* MprError.h */
#define ERROR_AUTH_SERVER_TIMEOUT 930
#ifdef CHAP_DEBUG
@@ -122,7 +121,7 @@ static void chap_radius_response (void *, RADIUS_PACKET *, int);
static char *strip_nt_domain (char *);
static void chap_log (chap *, uint32_t, const char *, ...) __printflike(3,4);
-/** {@link ::_chap CHAPインスタンス}を初期化します。*/
+/** Initialize the CHAP */
void
chap_init(chap *_this, npppd_ppp *ppp)
{
@@ -145,7 +144,7 @@ chap_init(chap *_this, npppd_ppp *ppp)
_this->ntry = CHAP_RETRY;
}
-/** 認証者として、CHAPを開始します。チャレンジを投げます。*/
+/** Start CHAP as a authenticator. Send a challenge */
void
chap_start(chap *_this)
{
@@ -169,7 +168,7 @@ chap_start(chap *_this)
_this->ntry--;
_this->type = _this->ppp->peer_auth;
- /* サポートされている認証タイプかどうか。 */
+ /* The type is supported? */
if (_this->type != PPP_AUTH_CHAP_MS_V2 &&
_this->type != PPP_AUTH_CHAP_MD5) {
chap_log(_this, LOG_ALERT,
@@ -182,8 +181,9 @@ chap_start(chap *_this)
return;
}
- /* MS-CHAPv2 を強制 */
+
#ifdef USE_NPPPD_MPPE
+ /* The peer must use MS-CHAP-V2 as the type */
if (MPPE_REQUIRED(_this->ppp) &&
_this->type != PPP_AUTH_CHAP_MS_V2) {
chap_log(_this, LOG_ALERT,
@@ -196,8 +196,7 @@ chap_start(chap *_this)
return;
}
#endif
-
- /* チャレンジのパケットを作成、送信。 */
+ /* Generate a challenge packet and send it */
challp = ppp_packetbuf(_this->ppp, PPP_AUTH_CHAP);
challp += HEADERLEN;
challp0 = challp;
@@ -232,7 +231,7 @@ chap_start(chap *_this)
}
}
-/** CHAP を停止します。*/
+/** Stop the CHAP */
void
chap_stop(chap *_this)
{
@@ -246,7 +245,7 @@ chap_stop(chap *_this)
#endif
}
-/** CHAP パケットの入力があった場合に呼び出します。*/
+/** Called when a CHAP packet is received. */
void
chap_input(chap *_this, u_char *pktp, int len)
{
@@ -283,7 +282,8 @@ chap_input(chap *_this, u_char *pktp, int len)
chap_log(_this, LOG_ERR, "Received unknown code=%d", code);
return;
}
- // Chap Response
+
+ /* Create a chap response */
if (id != _this->challid) {
chap_log(_this, LOG_ERR,
@@ -296,7 +296,7 @@ chap_input(chap *_this, u_char *pktp, int len)
authok = 0;
UNTIMEOUT(chap_start, _this);
- /* ユーザ名を取得する */
+ /* pick the username */
GETCHAR(lval, pktp1);
val = pktp1;
pktp1 += lval;
@@ -320,7 +320,10 @@ chap_input(chap *_this, u_char *pktp, int len)
name = namebuf;
if (_this->state == CHAP_STATE_SENT_RESPONSE) {
if (strcmp(_this->name, name) != 0) {
- /* 再送を要求されているが、ユーザ名が変更された */
+ /*
+ * The peer requests us to resend, but the username
+ * has been changed.
+ */
chap_log(_this, LOG_ERR,
"Received AuthReq is not same as before. "
"%s != %s", name, _this->name);
@@ -357,7 +360,7 @@ chap_authenticate(chap *_this, u_char *response, int lresponse)
switch(_this->type) {
case PPP_AUTH_CHAP_MD5:
- /* 長さチェック */
+ /* check the length */
if (lresponse != 16) {
chap_log(_this, LOG_ERR,
"Invalid response length %d != 16", lresponse);
@@ -367,7 +370,7 @@ chap_authenticate(chap *_this, u_char *response, int lresponse)
}
break;
case PPP_AUTH_CHAP_MS_V2:
- /* 長さチェック */
+ /* check the length */
if (lresponse < 49) {
chap_log(_this, LOG_ERR, "Packet too short.");
chap_failure(_this, "FAILED",
@@ -434,7 +437,7 @@ chap_response(chap *_this, int authok, u_char *pktp, int lpktp)
"logtype=Failure username=\"%s\" realm=%s", _this->name,
realm_name);
chap_stop(_this);
- /* 失敗したら ppp 終了 */
+ /* Stop the PPP if the authentication is failed. */
ppp_stop_ex(_this->ppp, "Authentication Required",
PPP_DISCON_AUTH_FAILED, PPP_PROTO_CHAP, 1 /* peer */, NULL);
} else {
@@ -444,13 +447,13 @@ chap_response(chap *_this, int authok, u_char *pktp, int lpktp)
"logtype=Success username=\"%s\" "
"realm=%s", _this->name, realm_name);
chap_stop(_this);
- // 再送要求に答えるために chap_stop でのセットを上書きします。
+ /* We change our state to prepare to resend requests. */
_this->state = CHAP_STATE_SENT_RESPONSE;
ppp_auth_ok(_this->ppp);
}
}
-/** チャレンジを生成する。*/
+/** Generate a challenge */
static void
chap_create_challenge(chap *_this)
{
@@ -543,7 +546,7 @@ chap_proxy_authen_prepare(chap *_this, dialin_proxy_info *dpi)
}
/************************************************************************
- * MD5 CHAP の実装 (See RFC 1994)
+ * Functions for MD5-CHAP(RFC1994)
************************************************************************/
static void
md5chap_authenticate(chap *_this, int id, char *username, u_char *challenge,
@@ -584,9 +587,9 @@ md5chap_authenticate(chap *_this, int id, char *username, u_char *challenge,
chap_response(_this, 1, "OK", 2);
return;
}
- // パスワード一致せず FALL THROUGH
+ /* FALLTHROUGH. The password are not matched */
auth_failed:
- //ユーザの有無の情報などは与えない
+ /* No extra information, just "FAILED" */
chap_send_error(_this, "FAILED");
return;
@@ -610,7 +613,7 @@ chap_send_error(chap *_this, const char *msg)
}
/************************************************************************
- * MS CHAP V2 の実装 (See RFC 2759)
+ * Functions for MS-CHAP-V2(RFC 2759)
************************************************************************/
static void
mschapv2_send_error(chap *_this, int error, int can_retry)
@@ -641,7 +644,6 @@ mschapv2_send_error(chap *_this, int error, int can_retry)
chap_response(_this, 0, pkt, lpkt);
}
-// idradiusd/auth_mschap2.c からコピペ
static void
mschapv2_authenticate(chap *_this, int id, char *username, u_char *challenge,
int lchallenge, u_char *response)
@@ -674,13 +676,12 @@ mschapv2_authenticate(chap *_this, int id, char *username, u_char *challenge,
}
goto auth_failed;
}
- /*
- * Unicode 化
- */
+
+ /* Convert the string charset from ASCII to UTF16-LE */
passlen = strlen(password);
for (i = passlen - 1; i >= 0; i--) {
password[i*2] = password[i];
- password[i*2+1] = 0; // LE
+ password[i*2+1] = 0;
}
GenerateNTResponse(challenge, response, username, strlen(username),
@@ -691,8 +692,9 @@ mschapv2_authenticate(chap *_this, int id, char *username, u_char *challenge,
"username=\"%s\" password mismatch.", username);
goto auth_failed;
}
+
/*
- * 認証成功
+ * Authentication succeed
*/
CHAP_DBG((_this, LOG_DEBUG, "%s() OK", __func__));
@@ -717,7 +719,7 @@ mschapv2_authenticate(chap *_this, int id, char *username, u_char *challenge,
return;
auth_failed:
- //ユーザの有無の情報などは与えない
+ /* No extra information */
mschapv2_send_error(_this, ERROR_AUTHENTICATION_FAILURE, 0);
return;
@@ -725,12 +727,10 @@ auth_failed:
#ifdef USE_NPPPD_RADIUS
/************************************************************************
- * RADIUS
+ * Functions for RADIUS
+ * RFC 2058: RADIUS
+ * RFC 2548: Microsoft Vendor-specific RADIUS Attributes
************************************************************************/
-/*
- RFC 2058: RADIUS
- RFC 2548: Microsoft Vendor-specific RADIUS Attributes
- */
static void
chap_radius_authenticate(chap *_this, int id, char *username,
u_char *challenge, int lchallenge, u_char *response)
@@ -747,28 +747,28 @@ chap_radius_authenticate(chap *_this, int id, char *username,
if ((rad_setting = npppd_get_radius_req_setting(_this->ppp->pppd,
_this->ppp)) == NULL) {
- goto reigai; // NO radius
+ goto fail; /* no radius server */
}
pkt = ppp_packetbuf(_this->ppp, PPP_PROTO_CHAP) + HEADERLEN;
lpkt = _this->ppp->mru - HEADERLEN;
if ((radpkt = radius_new_request_packet(RADIUS_CODE_ACCESS_REQUEST))
== NULL)
- goto reigai;
+ goto fail;
if (radius_prepare(rad_setting, _this, &radctx, chap_radius_response,
_this->ppp->auth_timeout) != 0) {
radius_delete_packet(radpkt);
- goto reigai;
+ goto fail;
}
if (ppp_set_radius_attrs_for_authreq(_this->ppp, rad_setting, radpkt)
!= 0)
- goto reigai;
+ goto fail;
if (radius_put_string_attr(radpkt, RADIUS_TYPE_USER_NAME,
npppd_ppp_get_username_for_auth(_this->ppp->pppd, _this->ppp,
username, buf0)) != 0)
- goto reigai;
+ goto fail;
switch (_this->type) {
case PPP_AUTH_CHAP_MD5:
@@ -779,17 +779,17 @@ chap_radius_authenticate(chap *_this, int id, char *username,
memcpy(&md5response[1], response, 16);
if (radius_put_raw_attr(radpkt,
RADIUS_TYPE_CHAP_PASSWORD, md5response, 17) != 0)
- goto reigai;
+ goto fail;
if (radius_put_raw_attr(radpkt,
RADIUS_TYPE_CHAP_CHALLENGE, challenge, 16) != 0)
- goto reigai;
+ goto fail;
break;
}
case PPP_AUTH_CHAP_MS_V2:
{
struct RADIUS_MS_CHAP2_RESPONSE msresponse;
- /* RADIUS_MS_CHAP2_RESPONSE の準備 */
+ /* Preparing RADIUS_MS_CHAP2_RESPONSE */
memset(&msresponse, 0, sizeof(msresponse));
msresponse.ident = id;
msresponse.flags = response[48];
@@ -798,33 +798,34 @@ chap_radius_authenticate(chap *_this, int id, char *username,
if (radius_put_vs_raw_attr(radpkt, RADIUS_VENDOR_MICROSOFT,
RADIUS_VTYPE_MS_CHAP_CHALLENGE, challenge, 16) != 0)
- goto reigai;
+ goto fail;
if (radius_put_vs_raw_attr(radpkt, RADIUS_VENDOR_MICROSOFT,
RADIUS_VTYPE_MS_CHAP2_RESPONSE, &msresponse,
sizeof(msresponse)) != 0)
- goto reigai;
+ goto fail;
break;
}
}
radius_get_authenticator(radpkt, _this->authenticator);
- /* 古い要求はキャンセル。*/
+ /* Cancel previous request */
if (_this->radctx != NULL)
radius_cancel_request(_this->radctx);
- /* 要求を投げる */
+ /* Send a request */
_this->radctx = radctx;
radius_request(radctx, radpkt);
return;
-reigai:
- //ユーザの有無の情報などは与えない
+fail:
switch (_this->type) {
case PPP_AUTH_CHAP_MD5:
+ /* No extra information, just "FAILED" */
chap_send_error(_this, "FAILED");
break;
case PPP_AUTH_CHAP_MS_V2:
+ /* No extra information */
mschapv2_send_error(_this, ERROR_AUTHENTICATION_FAILURE, 0);
break;
}
@@ -849,7 +850,7 @@ chap_radius_response(void *context, RADIUS_PACKET *pkt, int flags)
_this = context;
secret = radius_get_server_secret(_this->radctx);
radctx = _this->radctx;
- _this->radctx = NULL; /* 大事 */
+ _this->radctx = NULL; /* IMPORTANT */
respkt = respkt0 = ppp_packetbuf(_this->ppp, PPP_PROTO_CHAP)
+ HEADERLEN;
@@ -871,7 +872,7 @@ chap_radius_response(void *context, RADIUS_PACKET *pkt, int flags)
if (code == RADIUS_CODE_ACCESS_REJECT) {
reason="reject";
errorCode = ERROR_AUTHENTICATION_FAILURE;
- /* Windows 側のパスワードはリセットされる */
+ /* Windows peer will reset the passowrd by this error code */
goto auth_failed;
} else if (code != RADIUS_CODE_ACCESS_ACCEPT) {
reason="error";
@@ -885,7 +886,7 @@ chap_radius_response(void *context, RADIUS_PACKET *pkt, int flags)
goto auth_failed;
}
/*
- * 認証 OK
+ * Authetication OK
*/
switch (_this->type) {
case PPP_AUTH_CHAP_MD5:
@@ -908,12 +909,14 @@ chap_radius_response(void *context, RADIUS_PACKET *pkt, int flags)
#ifdef USE_NPPPD_MPPE
if (_this->ppp->mppe.enabled != 0) {
len = sizeof(sendkey);
+ /* XXX: radius_get_vs_raw_attr doesn't read 'len' */
if (radius_get_vs_raw_attr(pkt, RADIUS_VENDOR_MICROSOFT,
RADIUS_VTYPE_MPPE_SEND_KEY, &sendkey, &len) != 0) {
chap_log(_this, LOG_ERR, "no mppe_send_key");
goto auth_failed;
}
len = sizeof(recvkey);
+ /* XXX: radius_get_vs_raw_attr doesn't read 'len' */
if (radius_get_vs_raw_attr(pkt, RADIUS_VENDOR_MICROSOFT,
RADIUS_VTYPE_MPPE_RECV_KEY, &recvkey, &len) != 0) {
chap_log(_this, LOG_ERR, "no mppe_recv_key");
@@ -931,20 +934,20 @@ chap_radius_response(void *context, RADIUS_PACKET *pkt, int flags)
break;
}
}
- ppp_proccess_radius_framed_ip(_this->ppp, pkt);
+ ppp_process_radius_framed_ip(_this->ppp, pkt);
return;
auth_failed:
chap_log(_this, LOG_WARNING, "Radius authentication request failed: %s",
reason);
- //ユーザの有無の情報などは与えない
+ /* No extra information */
chap_failure(_this, "FAILED", errorCode);
}
#endif
/************************************************************************
- * ユーティリティ関数
+ * Miscellaneous functions
************************************************************************/
static char *
strip_nt_domain(char *username)
diff --git a/usr.sbin/npppd/npppd/eap.c b/usr.sbin/npppd/npppd/eap.c
index 26fce035a7d..c0ddc3a766b 100644
--- a/usr.sbin/npppd/npppd/eap.c
+++ b/usr.sbin/npppd/npppd/eap.c
@@ -24,18 +24,17 @@
* SUCH DAMAGE.
*/
/**@file
- *
- * EAP Pass-through Authenticator の実装。
- *
+ * This file provides EAP(Extensible Authentication Protocols, RFC 3748)
+ * handlers. This currently provides only EAP Pass-through Authenticator.
* @see RFC3748
* Extensible Authentication Protocols(EAP)
* @see RFC3579
* RADIUS (Remote Authentication Dial In User Service) Support For
* Extensible Authentication Protocol (EAP). B. Aboba, P. Calhoun.
*/
-// $Id: eap.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+/* $Id: eap.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
-/* FIXME: コメント/ログの意味がわからない */
+/* FIXME: This must be rewritten. */
#include <sys/types.h>
#include <sys/param.h>
@@ -71,9 +70,9 @@
#define EAP_HEADERLEN 4
-#define EAP_TIMEOUT_INIT 3 /* 初期リトライ間隔 */
-#define EAP_TIMEOUT_MAX 20 /* 最大リトライ間隔 */
-#define EAP_RETRY 4 /* リトライ回数 */
+#define EAP_TIMEOUT_INIT 3 /* Initial retry internval */
+#define EAP_TIMEOUT_MAX 20 /* Maximum retry internval */
+#define EAP_RETRY 4 /* Number of retry */
#define EAP_REQUEST 1
#define EAP_RESPONSE 2
@@ -113,9 +112,7 @@ static void eap_log(eap *_this, uint32_t prio, const char *fmt, ...) __printflik
static int get_mppe_keys(eap *_this, RADIUS_PACKET *pkt, const char *secret);
#endif
-/**
- * {@link ::_eap EAPインスタンス}を初期化します。
- */
+/** Initialize the EAP */
void
eap_init(eap *_this, npppd_ppp *ppp)
{
@@ -128,9 +125,7 @@ eap_init(eap *_this, npppd_ppp *ppp)
_this->state = EAP_STATE_INITIAL;
}
-/**
- * 認証者として、EAPを開始します。Identity Requestを投げます。
- */
+/** Start the EAP as a authenticator. Send a identity request */
void
eap_start(eap *_this)
{
@@ -316,7 +311,10 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
unsigned int timeout;
char buf0[MAX_USERNAME_LENGTH];
- /* FIXME: 毎度やる必要なし */
+ /*
+ * FIXME: Whenever a radius packet is forwarded, is
+ * FIXME: npppd_ppp_bind_realm() called?
+ */
if (npppd_ppp_bind_realm(_this->ppp->pppd, _this->ppp, _this->name, 1)
!= 0) {
/*
@@ -325,7 +323,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
*/
eap_log(_this, LOG_ERR, "Not found realm");
retry = 1;
- goto reigai;
+ goto fail;
}
if (npppd_ppp_is_realm_radius(
@@ -336,7 +334,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
*/
eap_log(_this, LOG_ERR, "Not found realm");
retry = 1;
- goto reigai;
+ goto fail;
}
if ((rad_setting = npppd_get_radius_req_setting(
@@ -347,7 +345,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
*/
eap_log(_this, LOG_ERR, "Not found radius server setting");
retry = 1;
- goto reigai;
+ goto fail;
}
/*
@@ -361,7 +359,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
*/
eap_log(_this, LOG_ERR, "Can't make new request packet");
retry = 1;
- goto reigai;
+ goto fail;
}
if (ppp_set_radius_attrs_for_authreq(_this->ppp, rad_setting, radpkt)
@@ -371,7 +369,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
* retry
*/
retry = 1;
- goto reigai;
+ goto fail;
}
/* avoid EAP fragmentation */
@@ -382,7 +380,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
* retry
*/
retry = 1;
- goto reigai;
+ goto fail;
}
/*
@@ -400,7 +398,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
"Can't put attribute to radius packet. type = %d",
RADIUS_TYPE_USER_NAME);
retry = 1;
- goto reigai;
+ goto fail;
}
} else {
/*
@@ -408,7 +406,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
* discard
*/
eap_log(_this, LOG_NOTICE, "Identity name is not seted");
- goto reigai;
+ goto fail;
}
/*
@@ -426,7 +424,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
eap_log(_this, LOG_ERR,
"Can't put attribute to radius packet. type = %d",
RADIUS_TYPE_STATE);
- goto reigai;
+ goto fail;
}
}
@@ -447,7 +445,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
"Can't put attribute to radius packet. "
"type = %d", RADIUS_TYPE_EAP_MESSAGE);
retry = 1;
- goto reigai;
+ goto fail;
}
rlength -= 253;
} else {
@@ -463,7 +461,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
"Can't put attribute to radius packet. "
"type = %d", RADIUS_TYPE_EAP_MESSAGE);
retry = 1;
- goto reigai;
+ goto fail;
}
rlength -= rlength;
}
@@ -479,7 +477,10 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
* prepare request
*/
if (_this->session_timeout != 0)
-/* FIXME: 認証タイムアウトと独立したタイマーが必要なのか? */
+/*
+ * FIXME: Is the timer other than authentication timeout timer really
+ * FIXME: necessary?
+ */
timeout = _this->session_timeout/2;
else
timeout = _this->ppp->auth_timeout;
@@ -496,7 +497,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
"radius server setting is not ready");
}
retry = 1;
- goto reigai;
+ goto fail;
}
_this->radctx = radctx;
@@ -514,7 +515,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
eap_log(_this, LOG_ERR, "couldn't put message authentication "
"attribute to radius packet");
retry = 1;
- goto reigai;
+ goto fail;
}
radius_get_authenticator(radpkt, _this->authenticator);
@@ -524,7 +525,7 @@ eap_forward_to_radius(eap *_this, u_int8_t *data, int datalen)
*/
radius_request(_this->radctx, radpkt);
return;
-reigai:
+fail:
/*
* don't give peer user infomation
*/
@@ -547,7 +548,7 @@ eap_recv_from_radius(void *context, RADIUS_PACKET *pkt, int flags)
int retry = 0;
char *notify_reason = NULL;
RADIUS_REQUEST_CTX radctx;
- u_char msgbuf[4096], *cp; /* FIXME: たぶん十分 */
+ u_char msgbuf[4096], *cp; /* FIXME: May be enough? */
int len;
u_int8_t attrlen = 0;
@@ -776,7 +777,7 @@ eap_recv_from_radius(void *context, RADIUS_PACKET *pkt, int flags)
goto auth_failed;
break;
case EAP_SUCCESS:
- ppp_proccess_radius_framed_ip(_this->ppp, pkt);
+ ppp_process_radius_framed_ip(_this->ppp, pkt);
#ifdef USE_NPPPD_MPPE
if (get_mppe_keys(_this, pkt, secret)) {
if (MPPE_REQUIRED(_this->ppp)) {
@@ -878,12 +879,14 @@ get_mppe_keys(eap *_this, RADIUS_PACKET *pkt, const char *secret) {
return 1;
}
len = sizeof(sendkey);
+ /* XXX: radius_get_vs_raw_attr doesn't read 'len' */
if (radius_get_vs_raw_attr(pkt, RADIUS_VENDOR_MICROSOFT,
RADIUS_VTYPE_MPPE_SEND_KEY, &sendkey, &len) != 0) {
eap_log(_this, LOG_ERR, "no mppe_send_key");
return 1;
}
len = sizeof(recvkey);
+ /* XXX: radius_get_vs_raw_attr doesn't read 'len' */
if (radius_get_vs_raw_attr(pkt, RADIUS_VENDOR_MICROSOFT,
RADIUS_VTYPE_MPPE_RECV_KEY, &recvkey, &len) != 0) {
eap_log(_this, LOG_ERR, "no mppe_recv_key");
@@ -947,7 +950,7 @@ eap_forward_to_peer(eap *_this, u_int8_t *data, int datalen, int type, u_int8_t
}
/************************************************************************
- * ユーティリティ関数
+ * Miscellaneous functions
************************************************************************/
void
eap_log(eap *_this, uint32_t prio, const char *fmt, ...)
diff --git a/usr.sbin/npppd/npppd/fsm.c b/usr.sbin/npppd/npppd/fsm.c
index 2ec34810dfc..f21b1d93424 100644
--- a/usr.sbin/npppd/npppd/fsm.c
+++ b/usr.sbin/npppd/npppd/fsm.c
@@ -1,11 +1,12 @@
/**@file
* This file was adapted from NetBSD:/usr/src/usr.sbin/pppd/pppd/fsm.c
- * <p>
- * 無駄な実装もなく、ほとんど修正せずに使えるので、なるべくオリジナルの
- * 状態に近いように実装しています。(2005/04 yasuoka)</p>
*/
/*
-XXX 再送の ConfReq で Initial ConfReq を再送するのはどうかと思う。
+ * fsm.c is simple and it can be use without modifications. So keep the
+ * original as much as possible. (2005/04 yasuoka)
+ *
+ * XXX: I think the same message for initial configure-request is a bad idea
+ * XXX: on resending configure-request.(yasuoka)
*/
/* $NetBSD: fsm.c,v 1.13 2000/09/23 22:39:35 christos Exp $ */
@@ -54,9 +55,7 @@ __RCSID("$NetBSD: fsm.c,v 1.13 2000/09/23 22:39:35 christos Exp $");
#include <syslog.h>
#include <stdlib.h>
-/*
- * npppd 関連
- */
+/* npppd related headers below */
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/usr.sbin/npppd/npppd/fsm.h b/usr.sbin/npppd/npppd/fsm.h
index 053d64deae9..be46df47177 100644
--- a/usr.sbin/npppd/npppd/fsm.h
+++ b/usr.sbin/npppd/npppd/fsm.h
@@ -134,7 +134,7 @@ typedef struct fsm_callbacks {
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
-/** NetBSD(ANU, CMU) の pppd で使われているマクロを npppd 用に定義 */
+/** define TIMEOUT to use event(3)'s timer. */
#define TIMEOUT(fn, f, t) \
{ \
struct timeval tv0; \
diff --git a/usr.sbin/npppd/npppd/ipcp.c b/usr.sbin/npppd/npppd/ipcp.c
index a5cc34cb58c..ed992c5ff12 100644
--- a/usr.sbin/npppd/npppd/ipcp.c
+++ b/usr.sbin/npppd/npppd/ipcp.c
@@ -24,13 +24,13 @@
* SUCH DAMAGE.
*/
/**@file
- * IPCP の実装です。現在ネットワーク提供者としての実装で、こちらの提案を
- * 押しつけます。
+ * This is an implementation of IPCP. This code is currently implemented
+ * as network service provider, and the peer is forced to obey our proposal.
*/
/*
* RFC 1332, 1877
*/
-/* $Id: ipcp.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: ipcp.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -98,7 +98,7 @@ static struct fsm_callbacks ipcp_callbacks = {
};
/**
- * {@link ::_ipcp IPCP インスタンス} を初期化します。
+ * Initialize {@link ::_ipcp IPCP instance }.
*/
void
ipcp_init(ipcp *_this, npppd_ppp *ppp)
@@ -209,7 +209,7 @@ ipcp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
rcode = CONFREJ;
rejbuf = pktp;
lrej = *lpktp;
- goto reigai;
+ goto fail;
}
#define remlen() (*lpktp - (pktp - pktp0))
@@ -219,7 +219,7 @@ ipcp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
GETCHAR(type, pktp);
GETCHAR(len, pktp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
case IPCP_IP_ADDRESS:
@@ -228,7 +228,7 @@ ipcp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
case IPCP_SEC_DNS:
case IPCP_SEC_NBNS:
if (remlen() < 4)
- goto reigai;
+ goto fail;
GETLONG(ip_addr.s_addr, pktp);
ip_addr.s_addr = htonl(ip_addr.s_addr);
@@ -240,12 +240,9 @@ ipcp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
npppd_assign_ip_addr(ppp->pppd, ppp,
INADDR_ANY) != 0) {
/*
- * INADDR_ANY で call しなおす
- * のは、user-select が許可さ
- * れている場合に動的割り当て
- * へのフォールバックを期待す
- * るクライアントへの対応のた
- * め。[IDGW-DEV 6847]
+ * The reason why it call with INADDR_ANY again here
+ * is to adapt the client expecting to fall back into
+ * dynamic allocation when user-select is allowed.
*/
pktp -= 4;
goto do_reject;
@@ -262,10 +259,9 @@ ipcp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
.s_addr, ip_addr.s_addr,
ppp->ppp_framed_ip_address.s_addr)) {
/*
- * ネットワーク型払出し時は、対抗の
- * IP-Address Option が、払い出すネッ
- * トワークに含まれる場合には、対抗
- * の提案に従う。
+ * In case of assigning network address, it obey
+ * peer's proposal if peer's IP-Address Option is
+ * included in network address to assign.
*/
ip_addrp = &ip_addr;
} else {
@@ -297,7 +293,7 @@ ipcp_reqci(fsm *f, u_char *pktp, int *lpktp, int reject_if_disagree)
goto do_reject;
}
if (lrej > 0) {
- /* reject があれば、Rej するので Nak しない */
+ /* if there is a reject, will send Rej, not send Nak. */
} else {
PUTCHAR(type, nakbuf);
PUTCHAR(6, nakbuf);
@@ -325,7 +321,7 @@ do_reject:
if (rcode == -1)
rcode = CONFACK;
-reigai:
+fail:
switch (rcode) {
case CONFREJ:
IPCP_DBG((f, LOG_DEBUG, "SendConfRej"));
@@ -334,23 +330,23 @@ reigai:
break;
case CONFNAK:
/*
- * Yamaha で、"pp ppp ipcp ip-address off" すると、IP-Adddress
- * Option なしで ConfReq が届く。RFC 1332 より
- *
- * If negotiation about the remote IP-address is required, and
+ * In case of Yamaha router is set "pp ppp ipcp ip-address off",
+ * it sends ConfReq without IP-Address Option.
+ * To quote RFC 1332:
+ * If negotiation about the remote IP-address is required, and
* the peer did not provide the option in its Configure-Request,
* the option SHOULD be appended to a Configure-Nak.
*
- * 6バイト lpkt をはみだしても大丈夫か?
- * - ppp.c では mru + 64 分確保している。lpkt は mru 以下
- * なので、+6 は大丈夫。
+ * Is any problem of overrunning 6 bytes of lpkt?
+ * - In ppp.c, lpkt is allocated mru + 64 bytes. lpkt is less
+ * than mru, so +6 is enough.
*/
if (!ip_address_acked) {
- /* IPアドレスの割り当ては必須。*/
+ /* It is mandatory to assign IP address. */
if (!ppp_ip_assigned(ppp)) {
if (npppd_assign_ip_addr(ppp->pppd, ppp,
INADDR_ANY) != 0) {
- /* ログは npppd_assign_ip_addr で出力済み */
+ /* The log already put in npppd_assign_ip_addr(). */
}
}
PUTCHAR(IPCP_IP_ADDRESS, nakbuf);
@@ -379,8 +375,7 @@ ipcp_open(fsm *f)
fsm_log(f, LOG_INFO, "the ip-address option from the peer was "
"not agreed.");
/*
- * IP-Address Option 無しで合意。固定IPアドレス割当てを
- * 試みる
+ * agreed without IP-Address Option. try to assign static address.
*/
if (f->ppp->realm_framed_ip_address.s_addr
!= INADDR_USER_SELECT &&
diff --git a/usr.sbin/npppd/npppd/lcp.c b/usr.sbin/npppd/npppd/lcp.c
index f3f0d63841f..726d05b5b0f 100644
--- a/usr.sbin/npppd/npppd/lcp.c
+++ b/usr.sbin/npppd/npppd/lcp.c
@@ -23,9 +23,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: lcp.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: lcp.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/**@file
- * LCP に関する処理を提供します。
+ * This file provides LCP related functions.
*<pre>
* RFC1661: The Point-to-Point Protocol (PPP)
* RFC1570: PPP LCP Extensions
@@ -109,7 +109,7 @@ static struct fsm_callbacks lcp_callbacks = {
(!psm_opt_is_enabled(lcp, eap) || psm_opt_is_rejected(lcp, eap))
-/** LCPのためのコンテキストを初期化します。 */
+/** initializing context for LCP. */
void
lcp_init(lcp *_this, npppd_ppp *ppp)
{
@@ -131,8 +131,8 @@ lcp_init(lcp *_this, npppd_ppp *ppp)
PPP_FSM_CONFIG(&_this->fsm, maxnakloops, "lcp.max_nak_loop");
/*
- * デフォルトは LCP ECHO しない。PPTP, L2TP は、lost carrier を検知で
- * きるので。
+ * PPTP and L2TP are able to detect lost carrier, so LCP ECHO is off
+ * by default.
*/
_this->echo_interval = 0;
_this->echo_failures = 0;
@@ -143,7 +143,7 @@ lcp_init(lcp *_this, npppd_ppp *ppp)
/**
- * LCPの下のレイヤ (HDLC) が up したときに呼び出します。
+ * This function is called when HDLC as LCP's lower layer is up.
*/
void
lcp_lowerup(lcp *_this)
@@ -153,7 +153,7 @@ lcp_lowerup(lcp *_this)
}
/**
- * Protocol-Reject を送信します。
+ * sending Protocol-Reject.
*/
void
lcp_send_protrej(lcp *_this, u_char *pktp, int lpktp)
@@ -213,7 +213,7 @@ lcp_open(fsm *f)
if (f->ppp->peer_mru <= 0)
f->ppp->peer_mru = f->ppp->mru;
- // ppp->peer_mru のサイズチェック
+ /* checking the size of ppp->peer_mru. */
LCP_ASSERT(f->ppp->peer_mru > 500);
fsm_log(f, LOG_INFO, "logtype=Opened mru=%d/%d auth=%s magic=%08x/%08x"
@@ -241,7 +241,7 @@ lcp_finished(fsm *f)
}
/**
- * ConfReq リセット
+ * reseting ConfReq.
*/
static void
lcp_resetci(fsm *f)
@@ -254,7 +254,7 @@ lcp_resetci(fsm *f)
}
/**
- * ConfReq の長さ
+ * The length of ConfReq.
*/
static int
lcp_cilen(fsm *f)
@@ -264,8 +264,9 @@ lcp_cilen(fsm *f)
}
/**
- * auth_order 順に、まだ reject されていない認証プロトコルを選択して、LCP
- * ConfReq パケット領域に Authentication-Protocol オプションを追加する。
+ * selecting authentication protocols which is not rejected yet in order
+ * of auth_order, and adding Authentication-Protocol options in ConfReq
+ * packet area.
*/
static int
lcp_add_auth(fsm *f, u_char **ucpp)
@@ -339,7 +340,7 @@ end_loop:
}
/**
- * ConfReq 作り
+ * making ConfReq.
*/
static void
lcp_addci(fsm *f, u_char *ucp, int *lenp)
@@ -354,7 +355,7 @@ lcp_addci(fsm *f, u_char *ucp, int *lenp)
PUTCHAR(PPP_LCP_MRU, ucp);
PUTCHAR(4, ucp);
- if (_this->xxxmru > 0) { /* Nak でもらった値 */
+ if (_this->xxxmru > 0) { /* this value is got by Nak. */
PUTSHORT(_this->xxxmru, ucp);
} else {
PUTSHORT(f->ppp->mru, ucp);
@@ -420,12 +421,12 @@ lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree)
GETCHAR(type, inp);
GETCHAR(len, inp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
case PPP_LCP_MRU:
if (len != 4)
- goto reigai;
+ goto fail;
GETSHORT(mru, inp);
f->ppp->peer_mru = mru;
if (mru < NPPPD_MIN_MRU) {
@@ -434,7 +435,7 @@ lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree)
goto reject;
}
if (lrej > 0) {
- /* reject があれば、Rej するので Nak しない */
+ /* if there is a reject, will send Rej, not send Nak. */
} else {
inp -= 2;
memcpy(nakbuf, inp, len);
@@ -449,7 +450,7 @@ lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree)
break;
case PPP_LCP_MAGICNUMBER:
if (len != 6)
- goto reigai;
+ goto fail;
GETLONG(magic, inp);
if (magic == _this->magic_number) {
inp -= 4;
@@ -459,17 +460,17 @@ lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree)
break;
case PPP_LCP_PFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_PEER_ACCEPTED(pfc);
break;
case PPP_LCP_ACFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_PEER_ACCEPTED(acfc);
break;
case PPP_LCP_AUTH_PROTOCOL:
- // 認証されることは現在のところない。
- case PPP_LCP_QUALITY_PROTOCOL: // 使用せず
+ /* currently never authenticate. */
+ case PPP_LCP_QUALITY_PROTOCOL: /* not used */
default:
reject:
inp -= 2;
@@ -482,7 +483,7 @@ reject:
}
if (rcode == -1)
rcode = CONFACK;
-reigai:
+fail:
switch (rcode) {
case CONFREJ:
memcpy(inp0, rejbuf, lrej);
@@ -508,7 +509,7 @@ reigai:
#undef LCP_OPT_PEER_ACCEPTED
}
-/** ConfAck を受け取った */
+/** receiving ConfAck. */
static int
lcp_ackci(fsm *f, u_char *inp, int inlen)
{
@@ -518,7 +519,7 @@ lcp_ackci(fsm *f, u_char *inp, int inlen)
#define remlen() (inlen - (inp - inp0))
#define LCP_OPT_ACCEPTED(opt) \
if (!psm_opt_is_requested(&f->ppp->lcp, opt)) \
- goto reigai; \
+ goto fail; \
psm_opt_set_accepted(&f->ppp->lcp, opt, 1);
f->ppp->lcp.recv_ress++;
@@ -528,35 +529,35 @@ lcp_ackci(fsm *f, u_char *inp, int inlen)
GETCHAR(len, inp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
case PPP_LCP_MAGICNUMBER:
if (len != 6)
- goto reigai;
+ goto fail;
GETLONG(magic, inp);
if (f->ppp->lcp.magic_number != magic)
- goto reigai;
+ goto fail;
break;
case PPP_LCP_MRU:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(mru);
GETSHORT(mru, inp);
break;
case PPP_LCP_AUTH_PROTOCOL:
if (len < 4)
- goto reigai;
+ goto fail;
GETSHORT(authproto, inp);
switch (authproto) {
case PPP_AUTH_PAP:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(pap);
break;
case PPP_AUTH_CHAP:
if (len != 5)
- goto reigai;
+ goto fail;
GETCHAR(chapalg, inp);
switch (chapalg) {
case PPP_AUTH_CHAP_MD5:
@@ -572,7 +573,7 @@ lcp_ackci(fsm *f, u_char *inp, int inlen)
break;
case PPP_AUTH_EAP:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(eap);
break;
}
@@ -584,21 +585,21 @@ lcp_ackci(fsm *f, u_char *inp, int inlen)
*/
case PPP_LCP_PFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(pfc);
break;
case PPP_LCP_ACFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(acfc);
break;
default:
- goto reigai;
+ goto fail;
}
}
return 1;
-reigai:
+fail:
fsm_log(f, LOG_ERR, "Received unexpected ConfAck.");
if (debug_get_debugfp() != NULL)
show_hd(debug_get_debugfp(), inp, remlen());
@@ -606,7 +607,7 @@ reigai:
#undef LCP_OPT_ACCEPTED
}
-/** ConfNak を受け取った */
+/** receiving ConfNak. */
static int
lcp_nakci(fsm *f, u_char *inp, int inlen)
{
@@ -618,7 +619,7 @@ lcp_nakci(fsm *f, u_char *inp, int inlen)
#define remlen() (inlen - (inp - inp0))
#define LCP_OPT_REJECTED(opt) \
if (!psm_opt_is_requested(&f->ppp->lcp, opt)) \
- goto reigai; \
+ goto fail; \
psm_opt_set_rejected(&f->ppp->lcp, opt, 1);
f->ppp->lcp.recv_ress++;
@@ -629,12 +630,12 @@ lcp_nakci(fsm *f, u_char *inp, int inlen)
GETCHAR(len, inp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
case PPP_LCP_MRU:
if (len < 4)
- goto reigai;
+ goto fail;
GETSHORT(mru, inp);
fsm_log(f, LOG_NOTICE,
"ignored ConfNak from the peer: mru=%d", mru);
@@ -642,7 +643,7 @@ lcp_nakci(fsm *f, u_char *inp, int inlen)
break;
case PPP_LCP_AUTH_PROTOCOL:
if (len < 4)
- goto reigai;
+ goto fail;
switch (_this->lastauth) {
case PPP_AUTH_PAP:
psm_opt_set_rejected(_this, pap, 1);
@@ -694,7 +695,7 @@ lcp_nakci(fsm *f, u_char *inp, int inlen)
break;
case PPP_AUTH_EAP:
if (len != 4)
- goto reigai;
+ goto fail;
peer_auth = "eap";
psm_opt_set_accepted(_this, eap, 1);
break;
@@ -710,20 +711,20 @@ lcp_nakci(fsm *f, u_char *inp, int inlen)
break;
case PPP_LCP_PFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_REJECTED(pfc);
break;
case PPP_LCP_ACFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_REJECTED(acfc);
break;
default:
- goto reigai;
+ goto fail;
}
}
return 1;
-reigai:
+fail:
log_printf(LOG_ERR, "Received unexpected ConfNak.");
if (debug_get_debugfp() != NULL)
show_hd(debug_get_debugfp(), inp, inlen);
@@ -733,7 +734,7 @@ reigai:
}
/**
- * ConfRej を受け取った
+ * receiving ConfRej.
*/
static int
lcp_rejci(fsm *f, u_char *inp, int inlen)
@@ -745,7 +746,7 @@ lcp_rejci(fsm *f, u_char *inp, int inlen)
#define remlen() (inlen - (inp - inp0))
#define LCP_OPT_REJECTED(opt) \
if (!psm_opt_is_requested(&f->ppp->lcp, opt)) \
- goto reigai; \
+ goto fail; \
psm_opt_set_rejected(&f->ppp->lcp, opt, 1);
f->ppp->lcp.recv_ress++;
@@ -756,12 +757,12 @@ lcp_rejci(fsm *f, u_char *inp, int inlen)
GETCHAR(len, inp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
case PPP_LCP_MAGICNUMBER:
if (f->ppp->lcp.echo_interval > 0)
- goto reigai;
+ goto fail;
inp += 4;
break;
case PPP_LCP_MRU:
@@ -770,12 +771,12 @@ lcp_rejci(fsm *f, u_char *inp, int inlen)
break;
case PPP_LCP_AUTH_PROTOCOL:
if (len < 4)
- goto reigai;
+ goto fail;
GETSHORT(authproto, inp);
switch (authproto) {
case PPP_AUTH_PAP:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_REJECTED(pap);
break;
case PPP_AUTH_CHAP:
@@ -801,7 +802,7 @@ lcp_rejci(fsm *f, u_char *inp, int inlen)
break;
case PPP_AUTH_EAP:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_REJECTED(eap);
break;
}
@@ -814,20 +815,20 @@ lcp_rejci(fsm *f, u_char *inp, int inlen)
break;
case PPP_LCP_PFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_REJECTED(pfc);
break;
case PPP_LCP_ACFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_REJECTED(acfc);
break;
default:
- goto reigai;
+ goto fail;
}
}
return 1;
-reigai:
+fail:
log_printf(LOG_ERR, "Received unexpected ConfRej.");
if (debug_get_debugfp() != NULL)
show_hd(debug_get_debugfp(), inp, inlen);
@@ -842,7 +843,7 @@ lcp_rcoderej(fsm *f, u_char *inp, int inlen)
fsm *rejfsm;
if (inlen < 2) {
- fsm_log(f, LOG_WARNING, "Recevied short ProtRej packet.");
+ fsm_log(f, LOG_WARNING, "Received short ProtRej packet.");
return;
}
GETSHORT(proto, inp);
@@ -872,7 +873,7 @@ lcp_rcoderej(fsm *f, u_char *inp, int inlen)
}
if (rejfsm == NULL) {
fsm_log(f, LOG_WARNING,
- "Recevied ProtRej packet for unknown protocol=(%d/%04x)",
+ "Received ProtRej packet for unknown protocol=(%d/%04x)",
proto, proto);
return;
}
@@ -992,7 +993,10 @@ lcp_ext(fsm *f, int code, int id, u_char *inp, int inlen)
}
-/** 認証の設定を読み込んで、記述順に ppp_order に格納していく。*/
+/*
+ * reading some authentication settings and storing ppp_order in
+ * order of settings.
+ */
static void
lcp_load_authconfig(fsm *f)
{
@@ -1022,7 +1026,7 @@ lcp_load_authconfig(fsm *f)
psm_opt_set_enabled(_this, chap, 1);
} else if (strcasecmp("CHAPMS", authp) == 0 ||
strcasecmp("MSCHAP", authp) == 0) {
-#if 0 /* MS-CHAP は、サポートせず。 */
+#if 0 /* MS-CHAP is not supported. */
_this->auth_order[i++] =
PPP_AUTH_CHAP_MS;
psm_opt_set_enabled(_this, chapms, 1);
@@ -1052,11 +1056,12 @@ lcp_load_authconfig(fsm *f)
}
/***********************************************************************
- * Dialin Proxy 関連
+ * related functions of Dialin Proxy
**********************************************************************/
/**
- * Dialin proxy 情報にしたがって LCP の状態をセットします。LCPの状態が、
- * 受け入れられない場合は、0 以外が返ります。
+ * This function set LCP status following dialin proxy information.
+ * This returns non-zero value when LCP status is unacceptable.
+ *
*/
int
lcp_dialin_proxy(lcp *_this, dialin_proxy_info *dpi, int renegotiation,
@@ -1067,7 +1072,7 @@ lcp_dialin_proxy(lcp *_this, dialin_proxy_info *dpi, int renegotiation,
_this->dialin_proxy = 1;
lcp_load_authconfig(&_this->fsm);
- /* 認証方式が設定で許可されているかどうか */
+ /* whether authentication type is permitted by configuration or not. */
authok = 0;
if (dpi->auth_type != 0) {
for (i = 0; _this->auth_order[i] > 0; i++) {
@@ -1093,8 +1098,8 @@ lcp_dialin_proxy(lcp *_this, dialin_proxy_info *dpi, int renegotiation,
if (_this->dialin_proxy_lcp_renegotiation == 0) {
_this->fsm.ppp->peer_auth = dpi->auth_type;
/*
- * 全て拒否された状態にして、lcp_proxy_sent_ci で合意したも
- * のを解釈する。
+ * It changes status which all options are rejected, and
+ * accepts agreed options in lcp_proxy_send_ci.
*/
psm_opt_set_rejected(_this, mru, 1);
psm_opt_set_rejected(_this, pfc, 1);
@@ -1144,9 +1149,9 @@ lcp_dialin_proxy(lcp *_this, dialin_proxy_info *dpi, int renegotiation,
}
/*
- * lcp_reqci からコピー。以下の点だけが異なる。
- * - LCP_OPT_ACCEPTED を変更
- * - Magic Number や MRU は代入
+ * This function copies from lcp_reqci. It only differs as follows:
+ * - changes LCP_OPT_ACCEPTED.
+ * - Magic Number and MRU.
*/
static int
lcp_proxy_recv_ci(fsm *f, u_char *inp, int inlen)
@@ -1169,46 +1174,46 @@ lcp_proxy_recv_ci(fsm *f, u_char *inp, int inlen)
GETCHAR(type, inp);
GETCHAR(len, inp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
case PPP_LCP_MRU:
if (len != 4)
- goto reigai;
+ goto fail;
GETSHORT(mru, inp);
f->ppp->peer_mru = mru;
if (mru < NPPPD_MIN_MRU)
- goto reigai;
+ goto fail;
else
LCP_OPT_PEER_ACCEPTED(mru);
break;
case PPP_LCP_MAGICNUMBER:
if (len != 6)
- goto reigai;
+ goto fail;
GETLONG(magic, inp);
if (magic == _this->magic_number)
- goto reigai;
+ goto fail;
_this->peer_magic_number = magic;
break;
case PPP_LCP_PFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_PEER_ACCEPTED(pfc);
break;
case PPP_LCP_ACFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_PEER_ACCEPTED(acfc);
break;
default:
- goto reigai;
+ goto fail;
}
}
#undef remlen
#undef LCP_OPT_PEER_ACCEPTED
return 0;
-reigai:
+fail:
return 1;
}
@@ -1223,10 +1228,10 @@ lcp_dialin_proxy_open(void *ctx)
}
/*
- * lcp_ackci からコピー。以下の点だけが異なる。
- * - recv_reass++ はしない
- * - LCP_OPT_ACCEPTED を変更
- * - Magic Number や MRU は代入
+ * This function copies from lcp_ackci. It only differs as follows:
+ * - Do not recv_reass++.
+ * - changes LCP_OPT_ACCEPTED.
+ * - Magic Number and MRU.
*/
static int
lcp_proxy_sent_ci(fsm *f, u_char *inp, int inlen)
@@ -1248,35 +1253,35 @@ lcp_proxy_sent_ci(fsm *f, u_char *inp, int inlen)
GETCHAR(len, inp);
if (len <= 0 || remlen() + 2 < len)
- goto reigai;
+ goto fail;
switch (type) {
case PPP_LCP_MAGICNUMBER:
if (len != 6)
- goto reigai;
+ goto fail;
GETLONG(magic, inp);
f->ppp->lcp.magic_number = magic;
break;
case PPP_LCP_MRU:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(mru);
GETSHORT(mru, inp);
f->ppp->lcp.xxxmru = mru;
break;
case PPP_LCP_AUTH_PROTOCOL:
if (len < 4)
- goto reigai;
+ goto fail;
GETSHORT(authproto, inp);
switch (authproto) {
case PPP_AUTH_PAP:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(pap);
break;
case PPP_AUTH_CHAP:
if (len != 5)
- goto reigai;
+ goto fail;
GETCHAR(chapalg, inp);
switch (chapalg) {
case PPP_AUTH_CHAP_MD5:
@@ -1292,27 +1297,27 @@ lcp_proxy_sent_ci(fsm *f, u_char *inp, int inlen)
break;
case PPP_AUTH_EAP:
if (len != 4)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(eap);
break;
}
break;
case PPP_LCP_PFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(pfc);
break;
case PPP_LCP_ACFC:
if (len != 2)
- goto reigai;
+ goto fail;
LCP_OPT_ACCEPTED(acfc);
break;
default:
- goto reigai;
+ goto fail;
}
}
return 0;
-reigai:
+fail:
return 1;
#undef LCP_OPT_ACCEPTED
}
diff --git a/usr.sbin/npppd/npppd/mppe.c b/usr.sbin/npppd/npppd/mppe.c
index dadb94feb16..f68e5fbf5dd 100644
--- a/usr.sbin/npppd/npppd/mppe.c
+++ b/usr.sbin/npppd/npppd/mppe.c
@@ -23,14 +23,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: mppe.c,v 1.2 2010/01/13 07:49:44 yasuoka Exp $ */
+/* $Id: mppe.c,v 1.3 2010/07/01 03:38:17 yasuoka Exp $ */
/**@file
*
- * MPPE(Microsoft Point-To-Point Encryption Protocol) の実装。
+ * The implementation of MPPE(Microsoft Point-To-Point Encryption Protocol)
*/
/*
- * PPPパケット入れ替わり問題の回避。
- * L2TP/IPsec で、フレーム順を復元できなければ、回避した方がベター。
+ * To avoid the PPP packet out of sequence problem.
+ * It may avoid if it reconstruct the frame order in L2TP/IPsec.
*/
#define WORKAROUND_OUT_OF_SEQUENCE_PPP_FRAMING 1
@@ -79,8 +79,8 @@ static void rc4 __P((mppe *, mppe_rc4_t *, int, u_char *, u_char *));
static void GetNewKeyFromSHA __P((u_char *, u_char *, int, u_char *));
/**
- * mppe コンテキストを初期化します。
- * - 設定を読み込みます。
+ * initializing mppe context.
+ * - reading configuration.
*/
void
mppe_init(mppe *_this, npppd_ppp *ppp)
@@ -122,7 +122,7 @@ mppe_init(mppe *_this, npppd_ppp *ppp)
_this->mode_stateless = 0;
} else if (strcmp(sval, "auto") == 0 ||
strcmp(sval, "*") == 0) {
- /* デフォルトのまま */
+ /* no changes from default. */
} else {
mppe_log(_this, LOG_WARNING,
"configuration \"mppe.mode\" has bad value");
@@ -132,7 +132,7 @@ mppe_init(mppe *_this, npppd_ppp *ppp)
}
if (ppp_config_str_equal(_this->ppp, "mppe.keylen", "auto", 0) ||
ppp_config_str_equal(_this->ppp, "mppe.keylen", "*", 0)) {
- /* デフォルトのまま */
+ /* no changes from default. */
} else {
ival = ppp_config_int(_this->ppp, "mppe.keylen", -1);
if (ival != -1) {
@@ -188,7 +188,7 @@ mppe_key_change(mppe *_mppe, mppe_rc4_t *_this)
}
/**
- * MPPE プロトコルを開始します。
+ * starting mppe protocol.
*/
void
mppe_start(mppe *_this)
@@ -246,14 +246,15 @@ mppe_start(mppe *_this)
/**
- * mppe bits を作成します。最初の提案を行う場合には、peer_bits に 0 を指定し
- * ます。peer_bits が指定されていれば、peer の提案にそった値を返します。
+ * creating the mppe bits. In case of first proposal, it specifies the
+ * peer_bits as 0 value. If it specifies the peer_bits, it returns the
+ * value as peer's proposal.
*/
uint32_t
mppe_create_our_bits(mppe *_this, uint32_t peer_bits)
{
uint32_t our_bits;
- // デフォルトの提案
+ /* default proposal */
our_bits = CCP_MPPE_NT_128bit;
if (_this->keylen_auto == 0) {
@@ -266,7 +267,7 @@ mppe_create_our_bits(mppe *_this, uint32_t peer_bits)
our_bits = CCP_MPPE_NT_128bit; break;
}
} else {
- // 自動
+ /* auto */
our_bits = CCP_MPPE_NT_128bit | CCP_MPPE_NT_56bit
| CCP_MPPE_NT_40bit;
if (peer_bits != 0) {
@@ -280,35 +281,35 @@ mppe_create_our_bits(mppe *_this, uint32_t peer_bits)
}
if (_this->mode_auto != 0) {
- /* 自動の場合 */
+ /* in case of auto_mode */
if (peer_bits == 0) {
/*
- * 最初の提案は stateless で行う。Windows 9x の場合、
- * 送受信で stateful/stateless が逆になるバグがある。
- * Windows 9x は、stateless を優先してネゴシエーション
- * しようとするため、こちらも stateless を優先すること
- * で、この Windows のバグを回避する。
- * (idgw-develop 4224)
+ * It proposes stateless mode in first time. Windows 9x has
+ * a bug that it is reverse to stateful and stateless in
+ * sending and receiving packets.
+ * Windows 9x is prior to negotiate in stateless mode, so
+ * it will avoid the Windows bug to be prior to negotiate
+ * in stateless mode.
*
- * このバグがなかったにせよ、パケットロスが一定割合
- * 以上発生するような場合に、stateful はユーザからみ
- * たコストが高いので、インターネットや無線LAN経由し
- * た利用では、よい選択ではない。
+ * Even if this bug doesn't exists, the stateful mode is high
+ * cost from user's viewpoint when packets may loss more than a
+ * certain rate, so it is not good choice to use via Internet or
+ * wireless LAN.
*/
our_bits |= CCP_MPPE_STATELESS;
} else {
- /* 譲歩する */
+ /* giving up */
our_bits |= peer_bits & CCP_MPPE_STATELESS;
}
} else {
- /* auto 以外が設定されている場合は、譲歩しない */
+ /* it doesn't give up in case of setting non-auto value. */
if (_this->mode_stateless != 0)
our_bits |= CCP_MPPE_STATELESS;
}
if (peer_bits != 0 && our_bits != peer_bits) {
char obuf[128], pbuf[128];
- /* 失敗した場合にログに残らないので。*/
+ /* in case of failure, it puts a log. */
strlcpy(obuf, mppe_bits_to_string(our_bits), sizeof(obuf));
strlcpy(pbuf, mppe_bits_to_string(peer_bits), sizeof(pbuf));
mppe_log(_this, LOG_INFO,
@@ -323,7 +324,7 @@ mppe_create_our_bits(mppe *_this, uint32_t peer_bits)
#define COHRENCY_CNT_MASK 0x0fff;
/**
- * MPPE 経由でのパケット受信
+ * receiving packets via MPPE.
*/
void
mppe_input(mppe *_this, u_char *pktp, int len)
@@ -356,11 +357,13 @@ mppe_input(mppe *_this, u_char *pktp, int len)
}
#ifdef WORKAROUND_OUT_OF_SEQUENCE_PPP_FRAMING
/*
- * L2TP/IPsec の実装で、PPPフレーム順を復元できず、順番が入れ替わった
- * 場合に、大量のパケットロスと区別が付かず、そう判断すると MPPE の
- * 鍵がズレる。この問題を回避するため、4096-256 パケット以上落ちてい
- * るように見える場合には、パケットが落ちたわけではなく順番が入れ替
- * わったモノとみなす。
+ * In L2TP/IPsec implementation, in case that the ppp frame sequence
+ * is not able to reconstruct and the ppp frame is out of sequence, it
+ * is unable to identify with many packets losing. If it does so, MPPE
+ * key is out of place.
+ * To avoid this problem, when it seems that more than 4096-256 packets
+ * drops, it assumes that the packet doesn't lose but the packet is out
+ * of sequence.
*/
{
int coher_cnt0;
@@ -388,7 +391,7 @@ mppe_input(mppe *_this, u_char *pktp, int len)
} else {
if (flushed) {
if (coher_cnt < _this->recv.coher_cnt) {
- // 繰り上がった場合
+ /* in case of carrying up. */
coher_cnt += 0x1000;
}
pktloss += coher_cnt - _this->recv.coher_cnt;
@@ -421,8 +424,10 @@ mppe_input(mppe *_this, u_char *pktp, int len)
#ifndef WORKAROUND_OUT_OF_SEQUENCE_PPP_FRAMING
if (pktloss > 1000) {
/*
- * パケット落ち過ぎ、あるいはパケット順が入れ替わった。
- * 後者の場合、この後鍵がズレているため通信ができなくなる。
+ * In case of many packets losing or out of sequence.
+ * The latter is not able to communicate because the key is
+ * out of place soon.
+ *
*/
mppe_log(_this, LOG_WARNING, "%d packets loss", pktloss);
}
@@ -442,7 +447,8 @@ mppe_input(mppe *_this, u_char *pktp, int len)
}
/**
- * CCP Reset (MPPE の場合鍵リセット) を受信した時に呼び出される関数。
+ * The call out function in case of receiving CCP Reset (key reset in case
+ * of MPPE).
*/
void
mppe_recv_ccp_reset(mppe *_this)
@@ -452,7 +458,7 @@ mppe_recv_ccp_reset(mppe *_this)
}
/**
- * MPPE 経由でのパケット送信
+ * sending packet via MPPE.
*/
void
mppe_pkt_output(mppe *_this, uint16_t proto, u_char *pktp, int len)
@@ -540,7 +546,7 @@ mppe_bits_to_string(uint32_t bits)
}
/************************************************************************
- * 以下、認証/暗号化アルゴリズムの実装
+ * implementations of authentication/cipher algorism.
************************************************************************/
static u_char SHAPad1[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -567,7 +573,7 @@ static u_char SHAPad1[] = {
#define SHAFinal(ctx,digest) SHA1_Final(digest, ctx)
/************************************************************************
- * OpenSSL 版実装
+ * implementations of OpenSSL version
************************************************************************/
static int
diff --git a/usr.sbin/npppd/npppd/npppd.c b/usr.sbin/npppd/npppd/npppd.c
index edfe3e8007e..fab51150d5d 100644
--- a/usr.sbin/npppd/npppd/npppd.c
+++ b/usr.sbin/npppd/npppd/npppd.c
@@ -24,10 +24,10 @@
* SUCH DAMAGE.
*/
/**@file
- * Next pppd。npppd プロセスと npppdインスタンスの実装。
- *
+ * Next pppd(nppd). This file provides a npppd daemon process and operations
+ * for npppd instance.
* @author Yasuoka Masahiko
- * $Id: npppd.c,v 1.3 2010/01/31 05:49:51 yasuoka Exp $
+ * $Id: npppd.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $
*/
#include <sys/cdefs.h>
#include "version.h"
@@ -105,7 +105,6 @@ __COPYRIGHT(
#include <net/pipex.h>
#endif /* USE_NPPPD_PIPEX */
-/* static変数はこちら。 */
static npppd s_npppd; /* singleton */
static void npppd_reload0(npppd *);
@@ -143,7 +142,7 @@ static void pipex_periodic(npppd *);
#endif
/***********************************************************************
- * エントリポイント
+ * Daemon process
***********************************************************************/
int main (int, char *[]);
@@ -197,7 +196,7 @@ main(int argc, char *argv[])
if (npppd_init(&s_npppd, npppd_conf0) != 0) {
retval = 1;
- goto reigai;
+ goto fail;
}
if ((pw = getpwnam(NPPPD_USER)) == NULL)
@@ -215,7 +214,7 @@ main(int argc, char *argv[])
npppd_start(&s_npppd);
npppd_fini(&s_npppd);
/* FALLTHROUGH */
-reigai:
+fail:
privsep_fini();
log_printf(LOG_NOTICE, "Terminate npppd.");
@@ -236,7 +235,7 @@ usage()
);
}
-/** 唯一の npppd インスタンスを返します。 */
+/** Returns the singleton npppd instance */
npppd *
npppd_get_npppd()
{
@@ -244,9 +243,9 @@ npppd_get_npppd()
}
/***********************************************************************
- * npppd 自身の操作 (init/fini/stop/start)
+ * Operations to npppd itself (initialize/finalize/start/stop)
***********************************************************************/
-/** 初期化します */
+ /** Initialize the npppd */
int
npppd_init(npppd *_this, const char *config_file)
{
@@ -282,24 +281,14 @@ npppd_init(npppd *_this, const char *config_file)
config_file, __func__);
return 1;
}
- /*
- * NetBSD 2.0 の realpath(3) より
- *
- * This implementation of realpath() differs slightly from the Solaris
- * implementation. The 4.4BSD version always returns absolute
- * pathnames, whereas the Solaris implementation will, under certain
- * circumstances, return a relative resolvedname when given a relative
- * pathname.
- *
- * FIXME: 4.4BSD互換ではない場合には、確認が必要。
- */
+ /* we assume 4.4 compatible realpath(). See realpath(3) on BSD. */
NPPPD_ASSERT(_this->config_file[0] == '/');
/* initialize random seeds */
seed_random(&seed);
srandom(seed);
- /* 設定読み込み */
+ /* load configuration */
if ((status = npppd_reload_config(_this)) != 0)
return status;
@@ -315,18 +304,17 @@ npppd_init(npppd *_this, const char *config_file)
return -1;
}
- /* PIDファイルの場所 */
if ((pidpath0 = npppd_config_str(_this, "pidfile")) == NULL)
pidpath0 = DEFAULT_NPPPD_PIDFILE;
- /* 実行時のディレクトリ */
+ /* Runtime directory */
if ((coredir = npppd_config_str(_this, "coredir")) == NULL) {
- /* PIDファイルのディレクトリ */
+ /* diretory for pid file */
strlcpy(pidpath, pidpath0, sizeof(pidpath));
strlcpy(cwd, dirname(pidpath), sizeof(cwd));
}
else {
- /* core を書くディレクトリ */
+ /* directory for dumping core */
strlcpy(cwd, coredir, sizeof(cwd));
}
if (chdir(cwd) != 0) {
@@ -335,10 +323,10 @@ npppd_init(npppd *_this, const char *config_file)
return -1;
}
- /* イベント関連 */
+ /* initialize event(3) */
event_init();
- /* Routingソケット関連 */
+ /* initialize rtev */
rtev_libevent_init(
npppd_config_int(_this, "rtsock.event_delay",
DEFAULT_RTSOCK_EVENT_DELAY),
@@ -346,6 +334,7 @@ npppd_init(npppd *_this, const char *config_file)
DEFAULT_RTSOCK_SEND_WAIT_MILLISEC),
npppd_config_int(_this, "rtsock.send_npkts",
DEFAULT_RTSOCK_SEND_NPKTS), 0);
+
#ifdef NPPPD_USE_RT_ZEBRA
if (rt_zebra_get_instance() == NULL)
return -1;
@@ -354,27 +343,21 @@ npppd_init(npppd *_this, const char *config_file)
#endif
_this->rtev_event_serial = -1;
- /* 無視するシグナル */
+ /* ignore signals */
signal(SIGPIPE, SIG_IGN);
signal(SIGURG, SIG_IGN);
- /*
- * シグナルハンドラ
- * EV_PERSIST でセットされる(event(3)参照)ので、1度でよい。
- */
+
+ /* set signal handlers */
signal_set(&_this->ev_sigterm, SIGTERM, npppd_on_sigterm, _this);
signal_set(&_this->ev_sigint, SIGINT, npppd_on_sigint, _this);
signal_set(&_this->ev_sighup, SIGHUP, npppd_on_sighup, _this);
signal_add(&_this->ev_sigterm, NULL);
signal_add(&_this->ev_sigint, NULL);
signal_add(&_this->ev_sighup, NULL);
- //_npppd
- signal_add(&_this->ev_sighup, NULL);
evtimer_set(&_this->ev_timer, npppd_timer, _this);
- /*
- * トンネルデバイス関連
- */
+ /* start tun(4) or pppac(4) */
status = 0;
for (i = 0; i < countof(_this->iface); i++) {
if (_this->iface[i].initialized != 0)
@@ -384,10 +367,10 @@ npppd_init(npppd *_this, const char *config_file)
return -1;
/*
- * インタフェースの start (open) できたなら、唯一の nppp プロセス
- * と見なし、PIDファイルは上書きする。
+ * If the npppd can start(open) interfaces successfully, it can
+ * act as only one npppd process on the system and overwrite the pid
+ * file.
*/
- /* pid ファイル */
if ((pidfp = fopen(pidpath0, "w+")) == NULL) {
log_printf(LOG_ERR, "fopen(%s,w+) failed in %s(): %m",
pidpath0, __func__);
@@ -408,7 +391,7 @@ npppd_init(npppd *_this, const char *config_file)
return npppd_modules_reload(_this);
}
-/** npppd を開始します。 */
+/** start the npppd */
void
npppd_start(npppd *_this)
{
@@ -416,7 +399,6 @@ npppd_start(npppd *_this)
npppd_reset_timer(_this);
while ((event_loop(EVLOOP_ONCE)) == 0) {
- // 終了要求の検査
if (_this->finalized != 0)
break;
}
@@ -424,7 +406,7 @@ npppd_start(npppd *_this)
log_printf(LOG_CRIT, "event_loop() failed: %m");
}
-/** npppd を停止します。 */
+/** stop the npppd */
void
npppd_stop(npppd *_this)
{
@@ -457,7 +439,6 @@ npppd_stop(npppd *_this)
npppd_reset_timer(_this);
}
-
static void
npppd_stop_really(npppd *_this)
{
@@ -490,7 +471,7 @@ npppd_stop_really(npppd *_this)
_this->finalized = 1;
}
-/** npppd デーモンの終了化を行います。 */
+/** finalize the npppd */
void
npppd_fini(npppd *_this)
{
@@ -542,7 +523,7 @@ npppd_fini(npppd *_this)
}
/***********************************************************************
- * タイマ関連
+ * Timer related functions
***********************************************************************/
static void
npppd_reset_timer(npppd *_this)
@@ -550,7 +531,7 @@ npppd_reset_timer(npppd *_this)
struct timeval tv;
if (_this->finalizing != 0) {
- /* 終了化処理の専用 */
+ /* we can use the timer exclusively on finalizing */
tv.tv_usec = 500000;
tv.tv_sec = 0;
evtimer_add(&_this->ev_timer, &tv);
@@ -568,9 +549,8 @@ npppd_timer(int fd, short evtype, void *ctx)
_this = ctx;
if (_this->finalizing != 0) {
- npppd_stop_really(_this);
- /* タイマはリセットされている。*/
- return; /* 終了化処理中は専用 */
+ npppd_stop_really(_this); /* The timer has been reset */
+ return; /* we can use the timer exclusively on finalizing */
}
_this->secs += NPPPD_TIMER_TICK_IVAL;
if (_this->reloading_count > 0) {
@@ -667,18 +647,24 @@ npppd_reset_routing_table(npppd *_this, int pool_only)
}
/***********************************************************************
- * npppd その他 API (export)
+ * Other npppd related functions.
***********************************************************************/
/**
- * ユーザのパスワードを取得します。成功すると 0 が返ります。
+ * Get the user's password. Return 0 on success.
*
- * @param username パスワードを取得するユーザの名前
- * @param password パスワードを格納する領域。
- * パスワードの長さだけを知りたい場合には NULL
- * を指定します。
- * @param lppassword パスワードを格納する領域の長さのポインタ
- * @return User unknown の場合は 1、パスワードバッファの長さが足りない場合
- * は 2、その他のエラーは負の数が返ります。
+ * @param username Username who acquires password
+ * @param password A pointer to a buffer space to store the password.
+ * Use NULL when you need to know only the length of
+ * the password.
+ * @param plpassword A pointer to the length of the password parameter.
+ * This function uses this parameter value and stores
+ * the required length value pointed to by this
+ * parameter. Use NULL when use don't need to know
+ * the password and its length.
+ * @return If the function succeeds, 0 is returned. The function returns
+ * 1 if the username is unknown, returns 2 if the password buffer
+ * length is not enough. It returns negative value for other
+ * errors.
*/
int
npppd_get_user_password(npppd *_this, npppd_ppp *ppp,
@@ -692,7 +678,7 @@ npppd_get_user_password(npppd *_this, npppd_ppp *ppp,
plpassword);
}
-/** ユーザの Framed-IP-Address を取得します。*/
+/** Get the Framed-IP-Address attribute of the user */
struct in_addr *
npppd_get_user_framed_ip_address(npppd *_this, npppd_ppp *ppp,
const char *username)
@@ -707,9 +693,9 @@ npppd_get_user_framed_ip_address(npppd *_this, npppd_ppp *ppp,
if (ppp->realm_framed_ip_address.s_addr != 0) {
#if 1
/*
- * FIXME: radius での固定 IPアドレス割り当てが禁止されている場合に、ここで上
- * FIXME: 書きするアドホック修正。radius と acctlist 以外を足すとバグるので、
- * FIXME: それまでに要修正。
+ * FIXME: This fix is ad hok, it overwrites the ip address here if assigning
+ * FIXME: IP address by RADIUS is prohibited. This will make a bug when a
+ * FIXME: new authentication type is add. Fix this until then.
*/
if ((ppp_ipcp(ppp)->ip_assign_flags & NPPPD_IP_ASSIGN_RADIUS)
== 0) {
@@ -721,7 +707,7 @@ npppd_get_user_framed_ip_address(npppd *_this, npppd_ppp *ppp,
ppp->realm_framed_ip_netmask.s_addr = 0xffffffffL;
if ((ppp_ipcp(ppp)->ip_assign_flags & NPPPD_IP_ASSIGN_FIXED) != 0) {
- /* 認証レルムから指定 */
+ /* assign by the authentication realm */
if (npppd_auth_get_framed_ip(ppp->realm, username,
&ppp->realm_framed_ip_address,
&ppp->realm_framed_ip_netmask) != 0)
@@ -729,11 +715,11 @@ npppd_get_user_framed_ip_address(npppd *_this, npppd_ppp *ppp,
}
do_default:
- /* 認証レルムで指定が無ければ USER_SELECT */
+ /* Use USER_SELECT if the realm doesn't specify the ip address */
if (ppp->realm_framed_ip_address.s_addr == 0)
ppp->realm_framed_ip_address.s_addr = INADDR_USER_SELECT;
if (ppp->realm_framed_ip_address.s_addr == INADDR_USER_SELECT) {
- /* USER_SELECT は、設定で不許可の場合は NAS_SELECT に */
+ /* Use NAS_SELECT if USER_SELECT is not allowed by the config */
if ((ppp_ipcp(ppp)->ip_assign_flags &
NPPPD_IP_ASSIGN_USER_SELECT) == 0)
ppp->realm_framed_ip_address.s_addr = INADDR_NAS_SELECT;
@@ -768,26 +754,23 @@ npppd_check_calling_number(npppd *_this, npppd_ppp *ppp)
return 1;
}
-/* 使いまわし用 */
-static struct sockaddr_in npppd_get_ppp_by_ip_sin4 = {
- .sin_family = AF_INET,
- .sin_len = sizeof(struct sockaddr_in)
-};
-
/**
- * 指定した IPアドレスが割り当てられた {@link npppd_ppp} インスタンスを
- * 検索して返します。
- * @param ipaddr IPアドレス。ネットワークバイトオーダーで指定します。
+ * This function finds a {@link npppd_ppp} instance that is assigned the
+ * specified ip address and returns it
+ * @param ipaddr IP Address(Specify in network byte order)
*/
npppd_ppp *
npppd_get_ppp_by_ip(npppd *_this, struct in_addr ipaddr)
{
struct sockaddr_npppd *snp;
struct radish *rdp;
+ struct sockaddr_in npppd_get_ppp_by_ip_sin4;
+ npppd_get_ppp_by_ip_sin4.sin_family = AF_INET;
+ npppd_get_ppp_by_ip_sin4.sin_len = sizeof(struct sockaddr_in);
npppd_get_ppp_by_ip_sin4.sin_addr = ipaddr;
if (_this->rd == NULL)
- return NULL; /* スタートアップ時 */
+ return NULL; /* no radix tree on startup */
if (rd_match((struct sockaddr *)&npppd_get_ppp_by_ip_sin4, _this->rd,
&rdp)) {
snp = rdp->rd_rtent;
@@ -798,11 +781,11 @@ npppd_get_ppp_by_ip(npppd *_this, struct in_addr ipaddr)
}
/**
- * 指定した PPPユーザの {@link npppd_ppp} インスタンスを検索して返します。
- * @param username PPPユーザ名。
- * @param rlist 検索結果を格納する {@link slist}。
- * @retnr 成功したら 0。失敗したら -1。失敗した場合は、rlistのアイテム
- * には、中途半端なデータが入っている可能性があります。
+ * This function finds {@link npppd_ppp} instances that are authenticated
+ * as the specified username and returns them as a {@link slist} list.
+ * @param username PPP Username.
+ * @return {@link slist} that contans the {@link npppd_ppp} instances.
+ * NULL may be returned if no instance has been found.
*/
slist *
npppd_get_ppp_by_user(npppd *_this, const char *username)
@@ -816,10 +799,11 @@ npppd_get_ppp_by_user(npppd *_this, const char *username)
}
/**
- * 指定した PPP の ID から {@link npppd_ppp} インスタンスを検索して返します。
- * @param id 検索する {@link npppd_ppp#id ppp の id}
- * @return id が一致する {@link npppd_ppp} インスタンスが見つかればその
- * ポインタを、見つからなければ NULL ポインタを返却します。
+ * This function finds a {@link npppd_ppp} instance that matches the specified
+ * ppp id and returns it.
+ * @param id {@link npppd_ppp#id ppp's id}
+ * @return This function returns the pointer if the instance which has
+ * specified ID is found, otherwise it returns NULL.
*/
npppd_ppp *
npppd_get_ppp_by_id(npppd *_this, int ppp_id)
@@ -835,7 +819,7 @@ npppd_get_ppp_by_id(npppd *_this, int ppp_id)
log_printf(LOG_WARNING,
"npppd_get_all_users() failed in %s()", __func__);
} else {
- /* FIXME: Id での検索がリニアサーチ */
+ /* FIXME: This linear search eats CPU. */
for (slist_itr_first(&users); slist_itr_has_next(&users); ) {
ppp0 = slist_itr_next(&users);
if (ppp0->id == ppp_id) {
@@ -850,9 +834,10 @@ npppd_get_ppp_by_id(npppd *_this, int ppp_id)
}
/**
- * 指定したユーザが最大接続数の制限 (user_max_session) を越えているかどうかを
- * 検査します。
- * @return 検査に問題無ければ 1 が、あれば 0 を返します。
+ * Checks whether the user reaches the maximum session limit
+ * (user_max_serssion).
+ * @return This function returns 1(true) if the user does not reach the
+ * limit, otherwise it returns 0(false).
*/
int
npppd_check_user_max_session(npppd *_this, npppd_ppp *ppp)
@@ -861,10 +846,9 @@ npppd_check_user_max_session(npppd *_this, npppd_ppp *ppp)
npppd_ppp *ppp1;
slist *uppp;
- /* user_max_sessionが0のときは無制限とみなす */
- if (ppp_iface(ppp)->user_max_session == 0) {
+ /* user_max_session == 0 means unlimit */
+ if (ppp_iface(ppp)->user_max_session == 0)
return 1;
- }
count = 0;
if ((uppp = npppd_get_ppp_by_user(_this, ppp->username)) != NULL) {
@@ -880,11 +864,11 @@ npppd_check_user_max_session(npppd *_this, npppd_ppp *ppp)
}
/***********************************************************************
- * ネットワーク I/O 関連
+ * Network I/O ralated functions.
***********************************************************************/
/**
- * ネットワーク(tun)側に出力する際に呼び出します。
- * 現在は IPv4 のパケットを出力することを仮定しています。
+ * Call this function to output packets to the network(tun). This function
+ * currently assumes the packet is a IPv4 datagram.
*/
void
npppd_network_output(npppd *_this, npppd_ppp *ppp, int proto, u_char *pktp,
@@ -892,7 +876,7 @@ npppd_network_output(npppd *_this, npppd_ppp *ppp, int proto, u_char *pktp,
{
struct ip *pip;
int lbuf;
- u_char buf[256]; /* TCP/IP ヘッダとして十分なサイズ */
+ u_char buf[256]; /* enough size for TCP/IP header */
NPPPD_ASSERT(ppp != NULL);
@@ -931,8 +915,8 @@ npppd_network_output(npppd *_this, npppd_ppp *ppp, int proto, u_char *pktp,
if (ppp->adjust_mss) {
if (lpktp == lbuf) {
/*
- * TCP ヘッダまでが sizeof(buf) オクテットに収まって
- * いるという仮定。
+ * We can assume the packet length is less than
+ * sizeof(buf).
*/
if (!ALIGNED_POINTER(pktp, struct ip))
pktp = buf;
@@ -943,11 +927,10 @@ npppd_network_output(npppd *_this, npppd_ppp *ppp, int proto, u_char *pktp,
npppd_iface_write(ppp_iface(ppp), proto, pktp, lpktp);
}
+#ifdef USE_NPPPD_PIPEX
/***********************************************************************
- * IPv4 パケットのカーネル折り返し処理
+ * PIPEX related functions
***********************************************************************/
-#ifdef USE_NPPPD_PIPEX
-
static void
pipex_setup_common(npppd_ppp *ppp, struct pipex_session_req *req)
{
@@ -996,7 +979,7 @@ pipex_setup_common(npppd_ppp *ppp, struct pipex_session_req *req)
#endif /* USE_NPPPD_MPPE */
}
-/** PPPAC インタフェースの IPv4パケットカーネル折り返しを有効化します */
+/** Enable PIPEX of the {@link npppd_ppp ppp} */
int
npppd_ppp_pipex_enable(npppd *_this, npppd_ppp *ppp)
{
@@ -1020,7 +1003,7 @@ npppd_ppp_pipex_enable(npppd *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPPOE:
pppoe = (pppoe_session *)ppp->phy_context;
- /* PPPOE 固有の情報 */
+ /* PPPoE specific informations */
req.pr_protocol = PIPEX_PROTO_PPPOE;
req.pr_session_id = pppoe->session_id;
req.pr_peer_session_id = 0;
@@ -1036,7 +1019,7 @@ npppd_ppp_pipex_enable(npppd *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPTP:
call = (pptp_call *)ppp->phy_context;
- /* PPTP 固有の情報 */
+ /* PPTP specific informations */
req.pr_session_id = call->id;
req.pr_protocol = PIPEX_PROTO_PPTP;
@@ -1071,7 +1054,7 @@ npppd_ppp_pipex_enable(npppd *_this, npppd_ppp *ppp)
ppp->pipex_enabled = 1;
if (ppp->timeout_sec > 0) {
- /* NPPPD 側の idle timer は停止 */
+ /* Stop the npppd's idle-timer. We use pipex's idle-timer */
ppp->timeout_sec = 0;
ppp_reset_idle_timeout(ppp);
}
@@ -1079,7 +1062,7 @@ npppd_ppp_pipex_enable(npppd *_this, npppd_ppp *ppp)
return error;
}
-/** PPPAC インタフェースの IPv4パケットカーネル折り返しを無効化します */
+/** Disable PIPEX of the {@link npppd_ppp ppp} */
int
npppd_ppp_pipex_disable(npppd *_this, npppd_ppp *ppp)
{
@@ -1101,7 +1084,7 @@ npppd_ppp_pipex_disable(npppd *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPPOE:
pppoe = (pppoe_session *)ppp->phy_context;
- /* PPPOE 固有の情報 */
+ /* PPPoE specific informations */
req.pcr_protocol = PIPEX_PROTO_PPPOE;
req.pcr_session_id = pppoe->session_id;
break;
@@ -1110,7 +1093,7 @@ npppd_ppp_pipex_disable(npppd *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPTP:
call = (pptp_call *)ppp->phy_context;
- /* PPTP 固有の情報 */
+ /* PPTP specific informations */
req.pcr_session_id = call->id;
req.pcr_protocol = PIPEX_PROTO_PPTP;
break;
@@ -1133,7 +1116,9 @@ npppd_ppp_pipex_disable(npppd *_this, npppd_ppp *ppp)
return error;
}
-/** PPPAC インタフェースの IPv4パケットカーネル折り返しを無効化します */
+/* XXX: s/npppd_ppp_pipex_ip_disable/npppd_ppp_pipex_stop/ ?? */
+
+/** Stop PIPEX of the {@link npppd_ppp ppp} */
static int
npppd_ppp_pipex_ip_disable(npppd *_this, npppd_ppp *ppp)
{
@@ -1153,7 +1138,7 @@ npppd_ppp_pipex_ip_disable(npppd *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPPOE:
pppoe = (pppoe_session *)ppp->phy_context;
- /* PPPOE 固有の情報 */
+ /* PPPoE specific informations */
req.pcr_protocol = PIPEX_PROTO_PPPOE;
req.pcr_session_id = pppoe->session_id;
break;
@@ -1162,7 +1147,7 @@ npppd_ppp_pipex_ip_disable(npppd *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPTP:
call = (pptp_call *)ppp->phy_context;
- /* PPTP 固有の情報 */
+ /* PPTP specific informations */
req.pcr_session_id = call->id;
req.pcr_protocol = PIPEX_PROTO_PPTP;
break;
@@ -1208,10 +1193,10 @@ pipex_periodic(npppd *_this)
goto pipex_done;
}
- /* 切断要求処理 */
+ /* Disconnect request */
slist_itr_first(&dlist);
while (slist_itr_has_next(&dlist)) {
- /* FIXME: PPP id での検索がリニアサーチの繰り返し */
+ /* FIXME: Linear search by PPP Id eats CPU */
ppp_id = (int)slist_itr_next(&dlist);
slist_itr_first(&users);
ppp = NULL;
@@ -1240,9 +1225,9 @@ pipex_done:
#endif /* USE_NPPPD_PIPEX */
/***********************************************************************
- * IP割り当て関連
+ * IP address assignment related functions
***********************************************************************/
-/** npppd に IP の利用を要求します。*/
+/** Prepare to use IP */
int
npppd_prepare_ip(npppd *_this, npppd_ppp *ppp)
{
@@ -1270,7 +1255,7 @@ npppd_prepare_ip(npppd *_this, npppd_ppp *ppp)
return 0;
}
-/** npppd に IP の利用が終了したことを通知して、リソースを解放します。*/
+/** Notify stop using IP to npppd and release the resources. */
void
npppd_release_ip(npppd *_this, npppd_ppp *ppp)
{
@@ -1288,7 +1273,10 @@ npppd_release_ip(npppd *_this, npppd_ppp *ppp)
ppp->ppp_framed_ip_address.s_addr = 0;
}
-/** IPアドレスの有効無効を切替えます。enabled が変更されると経路を操作します。*/
+/**
+ * Change IP enableness. When the enableness is change, npppd will operate
+ * the route entry.
+ */
void
npppd_set_ip_enabled(npppd *_this, npppd_ppp *ppp, int enabled)
{
@@ -1302,14 +1290,17 @@ npppd_set_ip_enabled(npppd *_this, npppd_ppp *ppp, int enabled)
"npppd_set_ip_enabled(%s/%s, %s)", ppp->username,
inet_ntoa(ppp->ppp_framed_ip_address),
(enabled)?"true" : "false"));
+
/*
- * enabled に変更がなければ、なにもしない。経路変更すると、いろんなプ
- * ログラムが wakeup して重くなるので、余計な経路情報の更新は控える。
+ * Don't do anything if the enableness is not change. Changing route
+ * makes many programs will wake up and do heavy operations, it causes
+ * system overload, so we refrain useless changing route.
*/
enabled = (enabled)? 1 : 0;
was_enabled = (ppp->assigned_ip4_enabled != 0)? 1 : 0;
if (enabled == was_enabled)
return;
+
ppp->assigned_ip4_enabled = enabled;
if (enabled) {
if (ppp->username[0] != '\0') {
@@ -1329,13 +1320,16 @@ npppd_set_ip_enabled(npppd *_this, npppd_ppp *ppp, int enabled)
ppp->username));
}
}
- if (u != NULL) /* malloc 失敗がある */
+ if (u != NULL) /* above malloc() may failed */
slist_add(u, ppp);
}
#ifndef NO_ROUTE_FOR_POOLED_ADDRESS
if (ppp->snp.snp_next != NULL)
- /* 同じアドレス/マスクでブラックホールあり */
+ /*
+ * There is a blackhole route that has same
+ * address/mask.
+ */
in_route_delete(&ppp->ppp_framed_ip_address,
&ppp->ppp_framed_ip_netmask, &loop, RTF_BLACKHOLE);
/* See the comment for MRU_IPMTU() on ppp.h */
@@ -1361,7 +1355,10 @@ npppd_set_ip_enabled(npppd *_this, npppd_ppp *ppp, int enabled)
&ppp_iface(ppp)->ip4addr, 0);
}
if (ppp->snp.snp_next != NULL)
- /* 同じアドレス/マスクでブラックホールあり */
+ /*
+ * There is a blackhole route that has same
+ * address/mask.
+ */
in_route_add(&ppp->snp.snp_addr, &ppp->snp.snp_mask,
&loop, LOOPBACK_IFNAME, RTF_BLACKHOLE, 0);
#endif
@@ -1391,7 +1388,7 @@ npppd_set_ip_enabled(npppd *_this, npppd_ppp *ppp, int enabled)
}
NPPPD_ASSERT(found != 0);
if (slist_length(u) <= 0) {
- /* 最後の PPP */
+ /* The last PPP */
NPPPD_DBG((LOG_DEBUG,
"hash_delete(user->ppp, %s)",
ppp->username));
@@ -1405,7 +1402,7 @@ npppd_set_ip_enabled(npppd *_this, npppd_ppp *ppp, int enabled)
slist_fini(u);
free(u);
} else {
- /* 参照の差し替え */
+ /* Replace the reference. */
ppp1 = slist_get(u, 0);
hl->key = ppp1->username;
}
@@ -1419,10 +1416,10 @@ npppd_set_ip_enabled(npppd *_this, npppd_ppp *ppp, int enabled)
}
/**
- * IPアドレスを割り当てます。返される struct in_addr はネットバイトオーダー
- * で格納されています。
- * @param req_ip4 新たに割り当てを要求する IPアドレス。既に同一のア
- * ドレスが割り当て済の場合に呼び出すと失敗します。
+ * Assign the IP address. Returning "struct in_addr" is stored IP address
+ * in network byte order.
+ * @param req_ip4 IP address request to assign. If the address is used
+ * already, this function will return fail.
*/
int
npppd_assign_ip_addr(npppd *_this, npppd_ppp *ppp, uint32_t req_ip4)
@@ -1454,7 +1451,7 @@ npppd_assign_ip_addr(npppd *_this, npppd_ppp *ppp, uint32_t req_ip4)
dyna = 1;
} else {
NPPPD_ASSERT(realm != NULL);
- /* レルムなしで、固定 IPアドレス割り当てはできない */
+ /* We cannot assign a fixed ip address without realm */
if ((npppd_auth_get_type(realm) == NPPPD_AUTH_TYPE_RADIUS &&
(flag & NPPPD_IP_ASSIGN_RADIUS) == 0 &&
@@ -1470,9 +1467,9 @@ npppd_assign_ip_addr(npppd *_this, npppd_ppp *ppp, uint32_t req_ip4)
}
if (!dyna) {
/*
- * fallback_dyna ...
- * Realm で固定割り当てが設定されているがアドレスがプール
- * されていない場合には、動的割り当てに fallback する。
+ * Realm requires the fixed IP address, but the address
+ * doesn't belong any address pool. Fallback to dynamic
+ * assignment.
*/
for (slist_itr_first(ppp_pools(ppp));
slist_itr_has_next(ppp_pools(ppp));){
@@ -1483,8 +1480,9 @@ npppd_assign_ip_addr(npppd *_this, npppd_ppp *ppp, uint32_t req_ip4)
case ADDRESS_OK:
if (snp->snp_type == SNP_POOL) {
/*
- * 固定アドレスプールを使えるのは、
- * Realm で指定した場合に限る
+ * Fixed address pool can be used
+ * only if the realm specified to use
+ * it.
*/
if (ppp->realm_framed_ip_address
.s_addr != INADDR_USER_SELECT)
@@ -1499,7 +1497,7 @@ npppd_assign_ip_addr(npppd *_this, npppd_ppp *ppp, uint32_t req_ip4)
continue;
case ADDRESS_OUT_OF_POOL:
reason = "out of the pool";
- continue; /* 続行 */
+ continue; /* try next */
case ADDRESS_BUSY:
fallback_dyna = 0;
reason = "busy";
@@ -1568,7 +1566,7 @@ rtlist_remove(slist *prtlist, struct radish *radish)
return NULL;
}
-/** {@link ::npppd#rd npppd に唯一の radish} をセットします。*/
+/** Set {@link ::npppd#rd the only radish of npppd} */
int
npppd_set_radish(npppd *_this, void *radish_head)
{
@@ -1586,13 +1584,13 @@ npppd_set_radish(npppd *_this, void *radish_head)
if (radish_head != NULL) {
if (rd2slist(radish_head, &rtlist1) != 0) {
log_printf(LOG_WARNING, "rd2slist failed: %m");
- goto reigai;
+ goto fail;
}
}
if (_this->rd != NULL) {
if (rd2slist(_this->rd, &rtlist0) != 0) {
log_printf(LOG_WARNING, "rd2slist failed: %m");
- goto reigai;
+ goto fail;
}
}
if (_this->rd != NULL && radish_head != NULL) {
@@ -1600,37 +1598,37 @@ npppd_set_radish(npppd *_this, void *radish_head)
radish = slist_itr_next(&rtlist0);
snp = radish->rd_rtent;
/*
- * プールアドレスの差し替え
+ * replace the pool address
*/
if (snp->snp_type == SNP_POOL ||
snp->snp_type == SNP_DYN_POOL) {
if (rd_lookup(radish->rd_route, radish->rd_mask,
radish_head) == NULL)
continue;
- /* 追加しない */
+ /* don't add */
rtlist_remove(&rtlist1, radish);
- /* 削除しない */
+ /* don't delete */
slist_itr_remove(&rtlist0);
continue;
}
/*
- * アクティブ PPP セッションの処理
+ * handle the active PPP sessions.
*/
NPPPD_ASSERT(snp->snp_type == SNP_PPP);
ppp = snp->snp_data_ptr;
- /* アクティブ PPP の経路は削除しない。*/
+ /* Don't delete the route of active PPP session */
slist_itr_remove(&rtlist0);
- /* 古いプール設定に関する情報はクリア */
+ /* clear informations about old pool configuration */
ppp->assigned_pool = NULL;
snp->snp_next = NULL;
delppp0 = 0;
if (!rd_match((struct sockaddr *)snp, radish_head, &r)){
/*
- * 新プールに含まれない場合、PPPセッションは
- * 切断リスト入り。
+ * If the address doesn't belong the new pools,
+ * add the PPP session to the deletion list.
*/
slist_add(&delppp, snp->snp_data_ptr);
delppp0 = 1;
@@ -1641,26 +1639,29 @@ npppd_set_radish(npppd *_this, void *radish_head)
((struct sockaddr_npppd *)r->rd_rtent)
->snp_type == SNP_DYN_POOL);
/*
- * アドレス/マスクが等しいプールが存在する場合
- * は、RADISH エントリをリスト化する。リストは
- * SNP_PPP が先にするので、現在のエントリは
- * snp->snp_next にセットし、現在のエントリを
- * 削除。
+ * If there is a pool entry that has same
+ * address/mask, then make the RADISH entry a
+ * list. Set SNP_PPP as the first in the list,
+ * set current entry in snp->snp_next and
+ * delete it.
*/
if (sockaddr_npppd_match(
radish->rd_route, r->rd_route) &&
sockaddr_npppd_match(
radish->rd_mask, r->rd_mask)) {
- /* 解放するので、新経路リストから削除 */
+ /*
+ * Releasing it, so remove it from the
+ * new routing list.
+ */
rtlist_remove(&rtlist1, radish);
- /* snp_next をセット */
+ /* set as snp_snp_next */
snp->snp_next = r->rd_rtent;
rval = rd_delete(r->rd_route,
r->rd_mask, radish_head, &dummy);
NPPPD_ASSERT(rval == 0);
}
}
- /* 新 Radish に登録。*/
+ /* Register to the new radish */
rval = rd_insert(radish->rd_route, radish->rd_mask,
radish_head, snp);
if (rval != 0) {
@@ -1715,7 +1716,7 @@ npppd_set_radish(npppd *_this, void *radish_head)
slist_fini(&delppp);
return 0;
-reigai:
+fail:
slist_fini(&rtlist0);
slist_fini(&rtlist1);
slist_fini(&delppp);
@@ -1724,8 +1725,8 @@ reigai:
}
/**
- * すべてのユーザを {@link slist} に格納して返却します。users には、
- * {@link ::npppd_ppp} への参照が格納されます。
+ * This function stores all users to {@link slist} and returns them.
+ * References to {@link ::npppd_ppp} will be stored in users.
*/
int
npppd_get_all_users(npppd *_this, slist *users)
@@ -1749,14 +1750,14 @@ npppd_get_all_users(npppd *_this, slist *users)
if (slist_add(users, snp->snp_data_ptr) == NULL) {
log_printf(LOG_ERR,
"slist_add() failed in %s: %m", __func__);
- goto reigai;
+ goto fail;
}
}
}
slist_fini(&list);
return 0;
-reigai:
+fail:
slist_fini(&list);
return 1;
@@ -1805,7 +1806,7 @@ npppd_reload0(npppd *_this)
}
/***********************************************************************
- * シグナルハンドラ
+ * Signal handlers
***********************************************************************/
static void
npppd_on_sighup(int fd, short ev_type, void *ctx)
@@ -1840,7 +1841,7 @@ npppd_on_sigint(int fd, short ev_type, void *ctx)
}
/***********************************************************************
- * 雑多な関数
+ * Miscellaneous functions
***********************************************************************/
static uint32_t
str_hash(const void *ptr, int sz)
@@ -1859,8 +1860,8 @@ str_hash(const void *ptr, int sz)
}
/**
- * 指定した {@link ::npppd_ppp PPP} 用の認証レルムを選択します。
- * 選択に成功した場合には、0 が返ります。
+ * Select a authentication realm that is for given {@link ::npppd_ppp PPP}.
+ * Return 0 on success.
*/
int
npppd_ppp_bind_realm(npppd *_this, npppd_ppp *ppp, const char *username, int
@@ -1876,8 +1877,8 @@ npppd_ppp_bind_realm(npppd *_this, npppd_ppp *ppp, const char *username, int
NPPPD_ASSERT(username != NULL);
/*
- * PPPサフィックスが最長で、サフィックスの長さが同じものであれば、
- * 最初に一致したものを返却します。
+ * If the PPP suffix is the longest, and the length of the suffix is
+ * same, select the first one.
*/
lusername = strlen(username);
lmax = -1;
@@ -1886,8 +1887,8 @@ npppd_ppp_bind_realm(npppd *_this, npppd_ppp *ppp, const char *username, int
if ((val = ppp_config_str(ppp, "realm_list")) == NULL) {
#ifndef NO_DEFAULT_REALM
/*
- * 従来版との互換性のため、レルムがリストになっていなければ
- * ローカル=>RADIUS とフォールバックする。
+ * If the realm is not a list, because of compatibility for
+ * past versions, we try fallback from LOCAL to RADIUS.
*/
realm0 = NULL;
slist_itr_first(&_this->realms);
@@ -1976,7 +1977,7 @@ found:
return 0;
}
-/** 割当っている認証レルムがローカル認証かどうか。*/
+/** Is assigned realm a LOCAL authentication? */
int
npppd_ppp_is_realm_local(npppd *_this, npppd_ppp *ppp)
{
@@ -1990,7 +1991,7 @@ npppd_ppp_is_realm_local(npppd *_this, npppd_ppp *ppp)
? 1 : 0;
}
-/** 割当っている認証レルムがRADIUS認証かどうか。*/
+/** Is assigned realm a RADIUS authentication? */
int
npppd_ppp_is_realm_radius(npppd *_this, npppd_ppp *ppp)
{
@@ -2004,7 +2005,7 @@ npppd_ppp_is_realm_radius(npppd *_this, npppd_ppp *ppp)
? 1 : 0;
}
-/** 割当っている認証レルムが使用可能かどうか。*/
+/** Is assigned realm usable? */
int
npppd_ppp_is_realm_ready(npppd *_this, npppd_ppp *ppp)
{
@@ -2014,7 +2015,7 @@ npppd_ppp_is_realm_ready(npppd *_this, npppd_ppp *ppp)
return npppd_auth_is_ready(ppp->realm);
}
-/** 割当っている認証レルムの名前を返却します。*/
+/** Return the name of assigned realm */
const char *
npppd_ppp_get_realm_name(npppd *_this, npppd_ppp *ppp)
{
@@ -2023,7 +2024,7 @@ npppd_ppp_get_realm_name(npppd *_this, npppd_ppp *ppp)
return npppd_auth_get_name(ppp->realm);
}
-/** ppp に割当ったインタフェース名をセットします。*/
+/** Return the interface name that bound given {@link ::npppd_ppp PPP} */
const char *
npppd_ppp_get_iface_name(npppd *_this, npppd_ppp *ppp)
{
@@ -2032,7 +2033,7 @@ npppd_ppp_get_iface_name(npppd *_this, npppd_ppp *ppp)
return ppp_iface(ppp)->ifname;
}
-/** インタフェースが利用可能かどうか。*/
+/** Is the interface usable? */
int
npppd_ppp_iface_is_ready(npppd *_this, npppd_ppp *ppp)
{
@@ -2040,7 +2041,7 @@ npppd_ppp_iface_is_ready(npppd *_this, npppd_ppp *ppp)
ppp_ipcp(ppp) != NULL)? 1 : 0;
}
-/** ppp に適切なインタフェースを紐付けます。*/
+/** Select a suitable interface for {@link :npppd_ppp PPP} and bind them */
int
npppd_ppp_bind_iface(npppd *_this, npppd_ppp *ppp)
{
@@ -2072,7 +2073,7 @@ npppd_ppp_bind_iface(npppd *_this, npppd_ppp *ppp)
if (ifname == NULL)
return 1;
- /* インタフェース検索 */
+ /* Search a interface */
ifidx = -1;
ntotal_session = 0;
for (i = 0; i < countof(_this->iface); i++) {
@@ -2104,7 +2105,7 @@ npppd_ppp_bind_iface(npppd *_this, npppd_ppp *ppp)
return 0;
}
-/** ppp に割当ったインタフェースを解除します */
+/** Unbind the interface from the {@link ::npppd_ppp PPP} */
void
npppd_ppp_unbind_iface(npppd *_this, npppd_ppp *ppp)
{
@@ -2136,7 +2137,10 @@ npppd_rd_walktree_delete(struct radish_head *rh)
}
#ifdef USE_NPPPD_RADIUS
-/** @return 使用可能な radius の設定が無い場合は NULL が返ります。 */
+/**
+ * Return radius_req_setting for the given {@link ::npppd_ppp PPP}.
+ * @return return NULL if no usable RADIUS setting.
+ */
void *
npppd_get_radius_req_setting(npppd *_this, npppd_ppp *ppp)
{
@@ -2152,7 +2156,7 @@ npppd_get_radius_req_setting(npppd *_this, npppd_ppp *ppp)
(npppd_auth_radius *)ppp->realm);
}
-/** Radius サーバが問い合わせに失敗したことを通知します。*/
+/** Notice a failure on RAIDUS request/response */
void
npppd_radius_server_failure_notify(npppd *_this, npppd_ppp *ppp, void *rad_ctx,
const char *reason)
@@ -2166,7 +2170,7 @@ npppd_radius_server_failure_notify(npppd *_this, npppd_ppp *ppp, void *rad_ctx,
}
#endif
-/** 認証レルムの終了化処理 */
+/** Finalize authentication realm */
static void
npppd_auth_finalizer_periodic(npppd *_this)
{
@@ -2176,8 +2180,8 @@ npppd_auth_finalizer_periodic(npppd *_this)
npppd_ppp *ppp;
/*
- * disposing フラグがセットされた realm について、割当った PPP が
- * あれば切断する。全て切断済みなら realm を解放する。
+ * For the realms with disposing flag, if the realm has assigned PPPs,
+ * disconnect them. If all PPPs are disconnected then free the realm.
*/
NPPPD_DBG((DEBUG_LEVEL_2, "%s() called", __func__));
slist_itr_first(&_this->realms);
@@ -2215,7 +2219,7 @@ npppd_auth_finalizer_periodic(npppd *_this)
slist_fini(&users);
}
-/** sockaddr_npppd の比較関数。一致すると 0 が返ります */
+/** compare sockaddr_npppd. return 0 if matches */
int
sockaddr_npppd_match(void *a0, void *b0)
{
@@ -2228,10 +2232,9 @@ sockaddr_npppd_match(void *a0, void *b0)
}
/**
- * 認証に使用するユーザ名を username_buffer で指定した領域に作成して、
- * 返却します。
- * @param username_buffer 認証に使用するユーザ名を格納するバッファ領域
- * を指定します。MAX_USERNAME_LENGTH 以上の領域である必要があります。
+ * This function stores the username for authentication to the space specified
+ * by username_buffer and returns it. username_buffer must have space more
+ * than MAX_USERNAME_LENGTH.
*/
const char *
npppd_ppp_get_username_for_auth(npppd *_this, npppd_ppp *ppp,
diff --git a/usr.sbin/npppd/npppd/npppd.h b/usr.sbin/npppd/npppd/npppd.h
index 11616deb786..6c86bfa7595 100644
--- a/usr.sbin/npppd/npppd/npppd.h
+++ b/usr.sbin/npppd/npppd/npppd.h
@@ -39,13 +39,13 @@
#define DEFAULT_AUTH_TIMEOUT 30
-/** 固定割り当て */
+/** assign fixed IP address */
#define NPPPD_IP_ASSIGN_FIXED 0x0001
-/** 先方が提案したアドレスを受け入れる */
+/** accept IP address which is proposed by peer and assign it */
#define NPPPD_IP_ASSIGN_USER_SELECT 0x0002
-/** RADIUS の Framed-IP-Address を使う */
+/** use RADIUS Framed-IP-Address */
#define NPPPD_IP_ASSIGN_RADIUS 0x0004
/** sockaddr_npppd */
@@ -57,9 +57,9 @@ struct sockaddr_npppd {
#define snp_addr sin4.sin_addr
int snp_type; /* SNP_POOL or SNP_PPP */
#define snp_mask sin4mask.sin_addr
- /** 次のエントリ */
+ /** next entry */
struct sockaddr_npppd *snp_next;
- /** エントリの中身 */
+ /** contents of entry */
void *snp_data_ptr;
};
#define SNP_POOL 1
diff --git a/usr.sbin/npppd/npppd/npppd_auth.c b/usr.sbin/npppd/npppd/npppd_auth.c
index fa5ec6ef498..89ceab43c9d 100644
--- a/usr.sbin/npppd/npppd/npppd_auth.c
+++ b/usr.sbin/npppd/npppd/npppd_auth.c
@@ -23,9 +23,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/**@file 認証レルム */
-/* $Id: npppd_auth.c,v 1.4 2010/01/31 05:49:51 yasuoka Exp $ */
-/* なるべく npppd に非依存で書いていきたいところ。*/
+/**@file authentication realm */
+/* $Id: npppd_auth.c,v 1.5 2010/07/01 03:38:17 yasuoka Exp $ */
+/* I hope to write the source code in npppd-independent as possible. */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -64,7 +64,7 @@
* @see ::NPPPD_AUTH_TYPE_LOCAL
* @see ::NPPPD_AUTH_TYPE_RADIUS
* @return The pointer to the {@link ::npppd_auth_base} object will be returned
- * in case success otherwise NULL wiil be returned.
+ * in case success otherwise NULL will be returned.
*/
npppd_auth_base *
npppd_auth_create(int auth_type, const char *label, void *_npppd)
@@ -167,7 +167,7 @@ npppd_auth_reload(npppd_auth_base *base)
val = npppd_auth_config_str(base, "name");
if (val == NULL)
- /* .name の定義がなければ、ラベルを使う */
+ /* use the label if .name is not defined. */
strlcpy(base->name, npppd_auth_default_label(base),
sizeof(base->name));
else
@@ -201,19 +201,19 @@ npppd_auth_reload(npppd_auth_base *base)
str_hash, 1021)) == NULL) {
npppd_auth_base_log(base,
LOG_WARNING, "hash_create() failed: %m.");
- goto reigai;
+ goto fail;
}
}
base->reloadable = NPPPD_DEFAULT_AUTH_LOCAL_RELOADABLE;
base->has_acctlist = 1;
if (npppd_auth_reload_acctlist(base) != 0)
- goto reigai;
+ goto fail;
} else {
if (base->type == NPPPD_AUTH_TYPE_LOCAL) {
npppd_auth_base_log(base,
LOG_WARNING, "missing acctlist property.");
- goto reigai;
+ goto fail;
}
}
@@ -221,7 +221,7 @@ npppd_auth_reload(npppd_auth_base *base)
#ifdef USE_NPPPD_RADIUS
case NPPPD_AUTH_TYPE_RADIUS:
if (npppd_auth_radius_reload(base) != 0)
- goto reigai;
+ goto fail;
break;
#endif
}
@@ -229,7 +229,7 @@ npppd_auth_reload(npppd_auth_base *base)
return 0;
-reigai:
+fail:
base->initialized = 0;
base->has_acctlist = 0;
base->acctlist_ready = 0;
@@ -239,15 +239,18 @@ reigai:
}
/**
- * ユーザのパスワードを取得します。成功すると 0 が返ります。
+ * This function gets specified user's password. The value 0 is returned
+ * if the call succeeds.
*
- * @param username パスワードを取得するユーザの名前
- * @param password パスワードを格納する領域。
- * パスワードの長さだけを知りたい場合には NULL
- * を指定します。
- * @param lppassword パスワードを格納する領域の長さのポインタ
- * @return User unknown の場合は 1、パスワードバッファの長さが足りない場合
- * は 2、その他のエラーは負の数が返ります。
+ * @param username username which gets the password
+ * @param password buffers which stores the password
+ * Specify NULL if you want to known the length of
+ * the password only.
+ * @param lppassword pointer which indicates the length of
+ * the buffer which stores the password.
+ * @return A value 1 is returned if user is unknown. A value 2 is returned
+ * if password buffer is sufficient. A negative value is
+ * returned if other error occurred.
*/
int
npppd_auth_get_user_password(npppd_auth_base *base,
@@ -285,15 +288,18 @@ npppd_auth_get_user_password(npppd_auth_base *base,
}
/**
- * ユーザの Framed-IP-{Address,Netmask} を取得します。成功すると 0 が返ります。
+ * This function gets specified users' Framed-IP-{Address,Netmask}.
+ * The value 0 is returned if the call succeeds.
* <p>
- * 認証データベースは随時更新されるため、認証直後にこの関数を呼び出さないと、
- * パスワードと世代がズレる可能性があります。したがって認証直後にこの関数
- * を呼び出します。</p>
- * @param username パスワードを取得するユーザの名前
- * @param ip4address Framed-IP-Address を格納する struct in_addr
- * @param ip4netmask Framed-IP-Netmask を格納する struct in_addr
- * のポインタ
+ * Because authentication database is updated at any time, the password is
+ * possible to be inconsistent if this function is not called immediately
+ * after authentication. So this function is called immediately after
+ * authentication. </p>
+ * @param username username which gets the password
+ * @param ip4address pointer which indicates struct in_addr which
+ * stores the Framed-IP-Address
+ * @param ip4netmask pointer which indicates struct in_addr which
+ * stores Framed-IP-Netmask
*/
int
npppd_auth_get_framed_ip(npppd_auth_base *base, const char *username,
@@ -476,7 +482,7 @@ npppd_auth_reload_acctlist(npppd_auth_base *base)
slist_init(&users);
csv = NULL;
if ((file = priv_fopen(base->acctlist_path)) == NULL) {
- /* ファイルが存在しない場合は、空とする */
+ /* hash is empty if file is not found. */
if (errno == ENOENT)
hash_delete_all(base->users_hash, 1);
npppd_auth_base_log(base,
@@ -487,7 +493,7 @@ npppd_auth_reload_acctlist(npppd_auth_base *base)
if ((csv = csvreader_create()) == NULL) {
npppd_auth_base_log(base, LOG_ERR,
"Loading a account list failed: csvreader_create(): %m");
- goto reigai;
+ goto fail;
}
for (linno = 0, eof = 0; !eof;) {
@@ -501,13 +507,13 @@ npppd_auth_reload_acctlist(npppd_auth_base *base)
npppd_auth_base_log(base, LOG_ERR,
"Loading a account list failed: lineno=%d "
"line too short", linno + 1);
- goto reigai;
+ goto fail;
}
if (line[linelen - 1] != '\n' && !feof(file)) {
npppd_auth_base_log(base, LOG_ERR,
"Loading a account list failed: lineno=%d "
"line too long", linno + 1);
- goto reigai;
+ goto fail;
}
status = csvreader_parse(csv, line);
@@ -515,7 +521,7 @@ npppd_auth_reload_acctlist(npppd_auth_base *base)
if (!feof(file)) {
npppd_auth_base_log(base, LOG_ERR,
"Loading a account list failed: %m");
- goto reigai;
+ goto fail;
}
status = csvreader_parse_flush(csv);
eof = 1;
@@ -528,12 +534,12 @@ npppd_auth_reload_acctlist(npppd_auth_base *base)
npppd_auth_base_log(base, LOG_ERR,
"Loading a account list "
"failed: lineno=%d parse error", linno);
- goto reigai;
+ goto fail;
}
ncols = csvreader_get_number_of_column(csv);
if ((cols = csvreader_get_column(csv)) == NULL)
continue;
- linno++; /* CSV としての行番号としたいのでココでカウント */
+ linno++; /* count up here because line number is treated as CSV. */
if (linno == 1) {
/* skip a title line */
continue;
@@ -581,7 +587,7 @@ npppd_auth_reload_acctlist(npppd_auth_base *base)
if ((user = malloc(usersz)) == NULL) {
npppd_auth_base_log(base, LOG_ERR,
"Loading a account list failed: %m");
- goto reigai;
+ goto fail;
}
memset(user, 0, usersz);
@@ -618,7 +624,7 @@ npppd_auth_reload_acctlist(npppd_auth_base *base)
if (hash_insert(base->users_hash, user->username, user) != 0) {
npppd_auth_base_log(base, LOG_ERR,
"Loading a account list failed: hash_insert(): %m");
- goto reigai;
+ goto fail;
}
nuser++;
next_user:
@@ -634,7 +640,7 @@ next_user:
base->acctlist_ready = 1;
return 0;
-reigai:
+fail:
fclose(file);
if (csv != NULL)
csvreader_destroy(csv);
@@ -713,7 +719,7 @@ radius_server_address_load(radius_req_setting *radius, int idx,
return 0;
}
-/** RADIUS認証レルムの設定を読み込みます */
+/** reload the configuration of RADIUS authentication realm */
static int
npppd_auth_radius_reload(npppd_auth_base *base)
{
@@ -737,12 +743,12 @@ npppd_auth_radius_reload(npppd_auth_base *base)
continue;
snprintf(label, sizeof(label), "server.%s.address",tok);
if ((val = npppd_auth_config_str(base, label)) == NULL)
- goto reigai;
+ goto fail;
if (radius_server_address_load(&_this->rad_setting, n,
val) != 0) {
npppd_auth_base_log(base, LOG_INFO,
"parse error at %s", label);
- goto reigai;
+ goto fail;
}
snprintf(label, sizeof(label), "server.%s.secret",
tok);
@@ -762,7 +768,7 @@ npppd_auth_radius_reload(npppd_auth_base *base)
!= 0) {
npppd_auth_base_log(base, LOG_INFO,
"parse error at %s", label);
- goto reigai;
+ goto fail;
}
if ((val = npppd_auth_config_str(base, "server.secret"))!= NULL)
strlcpy(_this->rad_setting.server[n].secret, val,
@@ -785,7 +791,7 @@ npppd_auth_radius_reload(npppd_auth_base *base)
_this->rad_setting.timeout, n);
return 0;
-reigai:
+fail:
npppd_auth_destroy(base);
return 1;
@@ -801,7 +807,7 @@ npppd_auth_radius_get_radius_req_setting(npppd_auth_radius *_this)
return &_this->rad_setting;
}
-/** RADIUS サーバが問い合わせに失敗したことを通知します。*/
+/** This function notifies that RADIUS server failed the request. */
void
npppd_auth_radius_server_failure_notify(npppd_auth_radius *_this,
struct sockaddr *server, const char *reason)
@@ -820,8 +826,8 @@ npppd_auth_radius_server_failure_notify(npppd_auth_radius *_this,
if (memcmp(&rad_setting->server[rad_setting->curr_server].peer,
server, server->sa_len) == 0) {
/*
- * 失敗した Radius は現在カレントなので、次の Radius
- * に切替える。
+ * The RADIUS server which request was failed is currently selected,
+ * so next RADIUS server will be selected.
*/
for (i = 1; i < countof(rad_setting->server); i++) {
n = (rad_setting->curr_server + i) %
@@ -843,7 +849,7 @@ npppd_auth_radius_server_failure_notify(npppd_auth_radius *_this,
/***********************************************************************
* Helper functions
***********************************************************************/
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/** Log it which starts the label based on this instance. */
static int
npppd_auth_base_log(npppd_auth_base *_this, int prio, const char *fmt, ...)
{
diff --git a/usr.sbin/npppd/npppd/npppd_auth.h b/usr.sbin/npppd/npppd/npppd_auth.h
index 1a1db6935b0..a520740fb3a 100644
--- a/usr.sbin/npppd/npppd/npppd_auth.h
+++ b/usr.sbin/npppd/npppd/npppd_auth.h
@@ -26,19 +26,19 @@
#ifndef NPPPD_AUTH_H
#define NPPPD_AUTH_H 1
-/** ローカル認証レルム */
+/** local authentication realm */
#define NPPPD_AUTH_TYPE_LOCAL 1
-/** RADIUS認証レルム */
+/** RADIUS authentication realm */
#define NPPPD_AUTH_TYPE_RADIUS 2
struct _npppd_auth_base;
struct _npppd_auth_radius;
struct _npppd_auth_local;
-/** ローカル認証レルムの既定の型 */
+/** default type of local authentication realm */
typedef struct _npppd_auth_base npppd_auth_base;
-/** RADIUS認証レルムの型 */
+/** type of RADIUS authentication realm */
typedef struct _npppd_auth_radius npppd_auth_radius;
typedef struct _npppd_auth_local npppd_auth_local;
diff --git a/usr.sbin/npppd/npppd/npppd_auth_local.h b/usr.sbin/npppd/npppd/npppd_auth_local.h
index 5fad21ea7c3..53e8da0e379 100644
--- a/usr.sbin/npppd/npppd/npppd_auth_local.h
+++ b/usr.sbin/npppd/npppd/npppd_auth_local.h
@@ -25,72 +25,72 @@
*/
struct _npppd_auth_base {
- /** ラベル名 */
+ /** name of label */
char label[NPPPD_GENERIC_NAME_LEN];
- /** レルム名 */
+ /** name of realm */
char name[NPPPD_GENERIC_NAME_LEN];
- /** 親 npppd の参照 */
+ /** reference indicated to parent npppd */
void *npppd;
- /** 認証レルムのタイプ */
+ /** type of authentication realm */
int type;
- /** PPP サフィックス */
+ /** PPP suffix */
char pppsuffix[64];
- /** PPP プレフィックス */
+ /** PPP prefix */
char pppprefix[64];
uint32_t
- /** 初期化済み */
+ /** whether initialized or not */
initialized:1,
- /** 再読み込み可能 */
+ /** whether reloadable or not */
reloadable:1,
- /** 廃棄中 */
+ /** in disposing */
disposing:1,
/** Is the account list ready */
acctlist_ready:1,
/** Is the radius configuration ready */
radius_ready:1,
- /** EAP が利用できるかどうか */
+ /** whether EAP capable or not */
eap_capable:1,
- /** Windows-NT ドメインを強制的に strip するかどうか */
+ /** whether force to strip Windows-NT domain or not */
strip_nt_domain:1,
- /** PPPユーザ名の @ 以降を強制的に strip するかどうか。*/
+ /** whether force to strip after the '@' of PPP username or not */
strip_atmark_realm:1,
/** has account-list */
has_acctlist:1,
reserved:24;
- /** ユーザ名 => npppd_auth_user hash */
+ /** username => npppd_auth_user hash */
hash_table *users_hash;
- /** アカウントリストのパス名 */
+ /** path name of account list */
char acctlist_path[64];
- /** 最終ロード時間 */
+ /** last load time */
time_t last_load;
};
#ifdef USE_NPPPD_RADIUS
struct _npppd_auth_radius {
- /** 親 npppd_auth_base */
+ /** parent of npppd_auth_base */
npppd_auth_base nar_base;
- /** 現在の利用中のサーバ */
+ /** server currently in use */
int curr_server;
- /** RADIUSサーバ */
+ /** RADIUS server */
radius_req_setting rad_setting;
};
#endif
-/** ローカル認証レルムの型 */
+/** type of local authentication realm */
struct _npppd_auth_local {
- /* 親 npppd_auth_base */
+ /* parent npppd_auth_base */
npppd_auth_base nal_base;
};
-/** ユーザのアカウント情報を示す型 */
+/** the type of user account */
typedef struct _npppd_auth_user {
- /** ユーザ名 */
+ /** username */
char *username;
- /** パスワード */
+ /** password */
char *password;
/** Framed-IP-Address */
struct in_addr framed_ip_address;
@@ -98,7 +98,7 @@ typedef struct _npppd_auth_user {
struct in_addr framed_ip_netmask;
/** Calling-Number */
char *calling_number;
- /** スペース確保用フィールド */
+ /** field for space assignment */
char space[0];
} npppd_auth_user;
diff --git a/usr.sbin/npppd/npppd/npppd_config.c b/usr.sbin/npppd/npppd/npppd_config.c
index 9c01ec2f347..2d07ecef13b 100644
--- a/usr.sbin/npppd/npppd/npppd_config.c
+++ b/usr.sbin/npppd/npppd/npppd_config.c
@@ -23,9 +23,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: npppd_config.c,v 1.3 2010/01/31 05:49:51 yasuoka Exp $ */
+/* $Id: npppd_config.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $ */
/*@file
- * npppd 設定関連を操作する関数を格納するファイル。
+ * This file provides functions which operates configuration and so on.
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -90,13 +90,14 @@ NAMED_PREFIX_CONFIG_FUNCTIONS(npppd_ipcp_config, npppd_ipcp_config,
npppd->properties, "ipcp", label);
/***********************************************************************
- * 設定読み込み。各部の読み込みをまとめた export 関数
+ * Reading the configuration. This is the export function which
+ * aggregates functions to read from each part.
***********************************************************************/
/**
- * 設定ファイルを再読み込みします。
- * @param _this npppd へのポインタ。
- * @returns 成功時は 0 を返します。設定にエラーがあった場合などには、
- * 0 以外を返します。
+ * reload the configuration file.
+ * @param _this pointer indicated to npppd
+ * @returns A 0 is returned if succeeds, otherwise non 0 is returned
+ * in case of configuration error.
*/
int
npppd_reload_config(npppd *_this)
@@ -109,23 +110,23 @@ npppd_reload_config(npppd *_this)
log_printf(LOG_ERR, "Load configuration from='%s' failed: %m",
_this->config_file);
retval = -1;
- goto reigai;
+ goto fail;
}
if ((proptmp = properties_create(1061)) == NULL) {
log_printf(LOG_ERR, "Load configuration from='%s' failed: %m",
_this->config_file);
retval = -1;
- goto reigai;
+ goto fail;
}
if (properties_load(proptmp, conffp) != 0) {
log_printf(LOG_ERR, "Load configuration from='%s' failed: %m",
_this->config_file);
retval = -1;
- goto reigai;
+ goto fail;
}
if (_this->properties != NULL) {
- /* 入れ換え */
+ /* swap */
properties_remove_all(_this->properties);
properties_put_all(_this->properties, proptmp);
properties_destroy(proptmp);
@@ -133,7 +134,7 @@ npppd_reload_config(npppd *_this)
_this->properties = proptmp;
proptmp = NULL;
- /* ログなので処理順としてここ。 */
+ /* It is suitable for here as process sequence because of logging. */
npppd_debug_log_reload(_this);
#ifndef NO_DELAYED_RELOAD
@@ -151,8 +152,8 @@ npppd_reload_config(npppd *_this)
log_printf(LOG_NOTICE, "Load configuration from='%s' successfully.",
_this->config_file);
- // FALL THROUGH
-reigai:
+ /* FALLTHROUGH */
+fail:
if (conffp != NULL)
fclose(conffp);
if (proptmp != NULL)
@@ -161,14 +162,14 @@ reigai:
return retval;
}
-/** モジュール毎の設定の再読み込み。 */
+/** reload the configuration for each module */
int
npppd_modules_reload(npppd *_this)
{
int i, rval;
rval = 0;
- /* アドレスプール */
+ /* address pool */
if (npppd_ip_addr_pool_load(_this) != 0)
return -1;
@@ -196,10 +197,10 @@ npppd_modules_reload(npppd *_this)
}
/***********************************************************************
- * 設定読み込み。各部
+ * reload the configuration on each part
***********************************************************************/
#ifdef USE_NPPPD_NPPPD_CTL
-/** npppd制御機能の設定を読み込んで、必要なら起動します。*/
+/** reload the configuration for npppd management, start it if necessary. */
static int
npppd_ctl_reload(npppd *_npppd, npppd_ctl *_this)
{
@@ -242,7 +243,7 @@ npppd_ipcp_config_load(npppd *_this)
continue;
if (n >= countof(_this->ipcp_config)) {
log_printf(LOG_WARNING,
- "number of the ipcp configration reached "
+ "number of the ipcp configuration reached "
"limit=%d",
(int)countof(_this->ipcp_config));
break;
@@ -257,7 +258,7 @@ npppd_ipcp_config_load(npppd *_this)
}
}
-/** IPCP設定を読み込みます。 */
+/** load IPCP configuration */
static void
npppd_ipcp_config_load0(npppd_ipcp_config *_this, const char *label)
{
@@ -280,7 +281,7 @@ npppd_ipcp_config_load0(npppd_ipcp_config *_this, const char *label)
}
strlcpy(_this->name, val, sizeof(_this->name));
- /* IPアドレス割り当てポリシー */
+ /* IP address assignment policy */
ip_assign_flags = 0;
if (npppd_ipcp_config_str_equal(_this, "assign_userselect", "true", 1))
ip_assign_flags |= NPPPD_IP_ASSIGN_USER_SELECT;
@@ -325,7 +326,7 @@ npppd_ipcp_config_load0(npppd_ipcp_config *_this, const char *label)
#undef LOAD_IPADDR_SETTING
}
-/** デバッグとログファイルについての設定を再読込 */
+/** reload the configuration for debug and the log file */
static void
npppd_debug_log_reload(npppd *_this)
{
@@ -337,7 +338,7 @@ npppd_debug_log_reload(npppd *_this)
debuglevel)
return;
- // デバッグレベル変更
+ /* change debug level */
oval = debuglevel;
debuglevel = ival;
log_printf(LOG_NOTICE, "Debug level is changed %d => %d", oval, ival);
@@ -345,7 +346,7 @@ npppd_debug_log_reload(npppd *_this)
debugfp = debug_get_debugfp();
if (debugfp != stderr) {
sval = npppd_config_str(_this, "debug.logpath");
- // フォアグランドモードではない
+ /* It is not foreground mode. */
if (debugfp != NULL)
fclose(debugfp);
if (sval != NULL) {
@@ -361,7 +362,7 @@ npppd_debug_log_reload(npppd *_this)
}
}
-/** IPアドレスプールの設定を読み込みます。 */
+/** load the configuration for IP address pool */
static int
npppd_ip_addr_pool_load(npppd *_this)
{
@@ -379,11 +380,11 @@ npppd_ip_addr_pool_load(npppd *_this)
sizeof(struct sockaddr_npppd),
offsetof(struct sockaddr_npppd, snp_addr),
sizeof(struct in_addr), sockaddr_npppd_match)) {
- goto reigai;
+ goto fail;
}
_this->rd = rd_new;
- /* 設定ファイル読み込み */
+ /* load the configuration */
if ((val = npppd_config_str(_this, "pool_list")) != NULL) {
strlcpy(buf, val, sizeof(buf));
buf0 = buf;
@@ -397,29 +398,29 @@ npppd_ip_addr_pool_load(npppd *_this)
break;
}
if (npppd_pool_init(&pool0[n], _this, tok) != 0) {
- log_printf(LOG_WARNING, "Failed to initilize "
+ log_printf(LOG_WARNING, "Failed to initialize "
"npppd_pool '%s': %m", tok);
- goto reigai;
+ goto fail;
}
if (npppd_pool_reload(&pool0[n]) != 0)
- goto reigai;
+ goto fail;
n++;
}
} else {
if (npppd_pool_init(&pool0[n], _this, "default") != 0) {
- log_printf(LOG_WARNING, "Failed to initilize "
+ log_printf(LOG_WARNING, "Failed to initialize "
"npppd_pool 'default': %m");
- goto reigai;
+ goto fail;
}
if (npppd_pool_reload(&pool0[n++]) != 0)
- goto reigai;
+ goto fail;
}
for (; n < countof(pool0); n++)
pool0[n].initialized = 0;
- _this->rd = rd_curr; // backup
+ _this->rd = rd_curr; /* backup */
if (npppd_set_radish(_this, rd_new) != 0)
- goto reigai;
+ goto fail;
for (i = 0; i < countof(_this->pool); i++) {
if (_this->pool[i].initialized != 0)
@@ -427,17 +428,17 @@ npppd_ip_addr_pool_load(npppd *_this)
if (pool0[i].initialized == 0)
continue;
_this->pool[i] = pool0[i];
- /* 参照の差し替え */
+ /* swap references */
for (j = 0; j < _this->pool[i].addrs_size; j++) {
if (_this->pool[i].initialized == 0)
continue;
_this->pool[i].addrs[j].snp_data_ptr = &_this->pool[i];
}
}
- log_printf(LOG_INFO, "Loading pool config successfuly.");
+ log_printf(LOG_INFO, "Loading pool config successfully.");
return 0;
-reigai:
+fail:
/* rollback */
for (i = 0; i < n; i++) {
if (pool0[i].initialized != 0)
@@ -458,7 +459,7 @@ reigai:
return 1;
}
-/* 認証レルム */
+/* authentication realm */
static int
npppd_auth_realm_reload(npppd *_this)
{
@@ -475,11 +476,11 @@ npppd_auth_realm_reload(npppd *_this)
if (slist_add_all(&realms0, &_this->realms) != 0) {
log_printf(LOG_WARNING, "slist_add_all() failed in %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
ndef = 0;
- /* ローカルレルムのラベルを取得 */
+ /* get the label of the local realm */
if ((val = npppd_config_str(_this, "auth.local.realm_list")) != NULL) {
ndef++;
strlcpy(buf, val, sizeof(buf));
@@ -491,32 +492,35 @@ npppd_auth_realm_reload(npppd *_this)
log_printf(LOG_WARNING,
"label '%s' for auth.*.realm_list is not "
"unique", tok);
- goto reigai;
+ goto fail;
}
auth_base = realm_list_remove(&realms0, tok);
if (auth_base != NULL &&
npppd_auth_get_type(auth_base)
!= NPPPD_AUTH_TYPE_LOCAL) {
- /* 同じラベル名で認証レルムの型が変わった */
+ /*
+ * The type of authentication realm was changed in the
+ * same label name.
+ */
slist_add(&realms0, auth_base);
auth_base = NULL;
}
if (auth_base == NULL) {
- /* 新規作成 */
+ /* create newly */
if ((auth_base = npppd_auth_create(
NPPPD_AUTH_TYPE_LOCAL, tok, _this))
== NULL) {
log_printf(LOG_WARNING,
"npppd_auth_create() failed in "
"%s(): %m", __func__);
- goto reigai;
+ goto fail;
}
}
slist_add(&nrealms, auth_base);
}
}
#ifdef USE_NPPPD_RADIUS
- /* RADIUSレルムのラベルを取得 */
+ /* get the label of the RADIUS realm */
if ((val = npppd_config_str(_this, "auth.radius.realm_list")) != NULL) {
ndef++;
strlcpy(buf, val, sizeof(buf));
@@ -528,25 +532,28 @@ npppd_auth_realm_reload(npppd *_this)
log_printf(LOG_WARNING,
"label '%s' for auth.*.realm_list is not "
"unique", tok);
- goto reigai;
+ goto fail;
}
auth_base = realm_list_remove(&realms0, tok);
if (auth_base != NULL &&
npppd_auth_get_type(auth_base)
!= NPPPD_AUTH_TYPE_RADIUS) {
- /* 同じラベル名で認証レルムの型が変わった */
+ /*
+ * The type of authentication realm was changed in the
+ * same label name.
+ */
slist_add(&realms0, auth_base);
auth_base = NULL;
}
if (auth_base == NULL) {
- /* 新規作成 */
+ /* create newly */
if ((auth_base = npppd_auth_create(
NPPPD_AUTH_TYPE_RADIUS, tok, _this))
== NULL) {
log_printf(LOG_WARNING,
"npppd_auth_create() failed in "
"%s(): %m", __func__);
- goto reigai;
+ goto fail;
}
}
slist_add(&nrealms, auth_base);
@@ -556,7 +563,7 @@ npppd_auth_realm_reload(npppd *_this)
#ifndef NO_DEFAULT_REALM
if (ndef == 0) {
/*
- * 従来版との互換性。デフォルトのレルムを使う。
+ * Compatibility for current implementation. Use default realm.
*/
if (slist_length(&realms0) > 0) {
slist_add_all(&nrealms, &realms0);
@@ -566,7 +573,7 @@ npppd_auth_realm_reload(npppd *_this)
NPPPD_AUTH_TYPE_LOCAL, "", _this)) == NULL) {
log_printf(LOG_WARNING,
"malloc() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
slist_add(&nrealms, auth_base);
#ifdef USE_NPPPD_RADIUS
@@ -574,7 +581,7 @@ npppd_auth_realm_reload(npppd *_this)
NPPPD_AUTH_TYPE_RADIUS, "", _this)) == NULL) {
log_printf(LOG_WARNING,
"malloc() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
slist_add(&nrealms, auth_base);
#endif
@@ -584,7 +591,7 @@ npppd_auth_realm_reload(npppd *_this)
if (slist_set_size(&_this->realms, slist_length(&nrealms)) != 0) {
log_printf(LOG_WARNING, "slist_set_size() failed in %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
slist_itr_first(&realms0);
@@ -608,7 +615,7 @@ npppd_auth_realm_reload(npppd *_this)
slist_fini(&nrealms);
return rval;
-reigai:
+fail:
slist_itr_first(&nrealms);
while (slist_itr_has_next(&nrealms)) {
@@ -653,7 +660,7 @@ realm_list_remove(slist *list0, const char *label)
return NULL;
}
-/** インタフェースの設定を読み込みます。*/
+/** load the interface configuration */
int
npppd_ifaces_load_config(npppd *_this)
{
@@ -754,7 +761,7 @@ npppd_iface_binding_reload(npppd *_this, npppd_iface *iface,
} else if (_this->ipcp_config[0].initialized != 0 &&
_this->ipcp_config[0].label[0] == '\0') {
#ifndef NO_DEFAULT_IPCP
- /* デフォルト IPCP がある。*/
+ /* There is default IPCP configuration. */
binding->ipcp = &_this->ipcp_config[0];
using_default = 1;
#else
diff --git a/usr.sbin/npppd/npppd/npppd_ctl.c b/usr.sbin/npppd/npppd/npppd_ctl.c
index b72a1804a25..204f69c2ebc 100644
--- a/usr.sbin/npppd/npppd/npppd_ctl.c
+++ b/usr.sbin/npppd/npppd/npppd_ctl.c
@@ -24,10 +24,11 @@
* SUCH DAMAGE.
*/
/**@file
- * npppd 制御。UNIXドメインソケット /var/run/npppd_ctl を open して、
- * npppdctlコマンドからのコマンドを受け付ける。
+ * npppd management.
+ * This file provides to open UNIX domain socket which located in
+ * /var/run/npppd_ctl and accept commmands from the npppdctl command.
*/
-/* $Id: npppd_ctl.c,v 1.3 2010/01/31 05:49:51 yasuoka Exp $ */
+/* $Id: npppd_ctl.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -103,7 +104,7 @@ static void npppd_who_init(struct npppd_who *, npppd_ctl *, npppd_ppp *);
static int npppd_ppp_get_pipex_stat(struct npppd_who *, npppd_ppp *);
#endif
-/** npppd制御機能を初期化します。*/
+/** initialize npppd management */
void
npppd_ctl_init(npppd_ctl *_this, npppd *_npppd, const char *pathname)
{
@@ -115,7 +116,7 @@ npppd_ctl_init(npppd_ctl *_this, npppd *_npppd, const char *pathname)
_this->max_msgsz = DEFAULT_NPPPD_CTL_MAX_MSGSZ;
}
-/** npppd制御機能を起動します。*/
+/** start npppd management */
int
npppd_ctl_start(npppd_ctl *_this)
{
@@ -124,7 +125,7 @@ npppd_ctl_start(npppd_ctl *_this)
if ((_this->sock = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
log_printf(LOG_ERR, "socket() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
val = _this->max_msgsz;
@@ -135,13 +136,16 @@ npppd_ctl_start(npppd_ctl *_this)
"ctl.max_msgbuf may beyonds kernel limit. "
"setsockopt(,SOL_SOCKET, SO_SNDBUF,%d) "
"failed in %s(): %m", val, __func__);
- /* NetBSD の場合は kern.sbmax 以下にする必要あり */
+ /*
+ * on NetBSD, need to set value which is less than or equal
+ * to kern.sbmax.
+ */
else
log_printf(LOG_ERR,
"setsockopt(,SOL_SOCKET, SO_SNDBUF,%d) "
"failed in %s(): %m", val, __func__);
- goto reigai;
+ goto fail;
}
priv_unlink(_this->pathname);
memset(&sun, 0, sizeof(sun));
@@ -152,18 +156,18 @@ npppd_ctl_start(npppd_ctl *_this)
if (priv_bind(_this->sock, (struct sockaddr *)&sun, sizeof(sun))
!= 0) {
log_printf(LOG_ERR, "bind() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
dummy = 0;
if ((flags = fcntl(_this->sock, F_GETFL, &dummy)) < 0) {
log_printf(LOG_ERR, "fcntl(,F_GETFL) failed in %s(): %m",
__func__);
- goto reigai;
+ goto fail;
} else if (fcntl(_this->sock, F_SETFL, flags | O_NONBLOCK) < 0) {
log_printf(LOG_ERR, "fcntl(,F_SETFL,O_NONBLOCK) failed in %s()"
": %m", __func__);
- goto reigai;
+ goto fail;
}
chown(_this->pathname, -1, NPPPD_GID);
chmod(_this->pathname, NPPPD_CTL_SOCK_FILE_MODE);
@@ -175,7 +179,7 @@ npppd_ctl_start(npppd_ctl *_this)
log_printf(LOG_INFO, "Listening %s (npppd_ctl)", _this->pathname);
return 0;
-reigai:
+fail:
if (_this->sock >= 0)
close(_this->sock);
_this->sock = -1;
@@ -183,7 +187,7 @@ reigai:
return -1;
}
-/** npppd制御機能を停止します。*/
+/** stop npppd management */
void
npppd_ctl_stop(npppd_ctl *_this)
{
@@ -196,7 +200,7 @@ npppd_ctl_stop(npppd_ctl *_this)
}
}
-/** コマンド毎に制御手続きを実行します */
+/** execute management procedure on each command */
static void
npppd_ctl_command(npppd_ctl *_this, u_char *pkt, int pktlen,
struct sockaddr *peer)
@@ -272,7 +276,7 @@ cmd_who_out:
break;
cmd_who_send_error:
/*
- * FIXME: we should wait until the buffer is avaliable.
+ * FIXME: we should wait until the buffer is available.
*/
NPPPD_CTL_DBG((_this, LOG_DEBUG, "sendto() failed in %s: %m",
__func__));
@@ -352,14 +356,14 @@ user_end:
break;
}
/*
- * 端末認証関連
+ * related to client authentication
*/
case NPPPD_CTL_CMD_TERMID_SET_AUTH: {
#ifndef NPPPD_USE_CLIENT_AUTH
npppd_ctl_log(_this, LOG_ERR,
"NPPPD_CTL_CMD_TERMID_SET_AUTH is requested, but "
"the terminal authentication is disabled.");
- goto reigai;
+ goto fail;
#else
struct npppd_ctl_termid_set_auth_request *req;
npppd_ppp *ppp;
@@ -369,7 +373,7 @@ user_end:
npppd_ctl_log(_this, LOG_ERR,
"NPPPD_CTL_CMD_TERMID_SET_AUTH is requested, but "
"the request is invalid.");
- goto reigai;
+ goto fail;
}
ppp = NULL;
@@ -382,7 +386,7 @@ user_end:
"NPPPD_CTL_CMD_TERMID_SET_AUTH is "
"requested, but the requested ppp(id=%d) "
"is not found.", req->ppp_key.id);
- goto reigai;
+ goto fail;
}
break;
@@ -394,14 +398,14 @@ user_end:
"requested, but the requested ppp(ip=%s) "
"is not found.",
inet_ntoa(req->ppp_key.framed_ip_address));
- goto reigai;
+ goto fail;
}
break;
default:
npppd_ctl_log(_this, LOG_ERR,
"NPPPD_CTL_CMD_TERMID_SET_AUTH is requested, but "
"the ppp_key_type is invalid.");
- goto reigai;
+ goto fail;
}
NPPPD_CTL_ASSERT(ppp != NULL);
@@ -441,7 +445,7 @@ user_end:
npppd_ctl_log(_this, LOG_ERR,
"Received unknown command %04x", command);
}
-reigai:
+fail:
return;
}
@@ -509,7 +513,7 @@ npppd_ppp_get_pipex_stat(struct npppd_who *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPPOE:
pppoe = (pppoe_session *)ppp->phy_context;
- /* PPPOE 固有の情報 */
+ /* PPPOE specific information */
req.psr_protocol = PIPEX_PROTO_PPPOE;
req.psr_session_id = pppoe->session_id;
break;
@@ -518,7 +522,7 @@ npppd_ppp_get_pipex_stat(struct npppd_who *_this, npppd_ppp *ppp)
case PPP_TUNNEL_PPTP:
call = (pptp_call *)ppp->phy_context;
- /* PPTP 固有の情報 */
+ /* PPTP specific information */
req.psr_session_id = call->id;
req.psr_protocol = PIPEX_PROTO_PPTP;
break;
@@ -529,7 +533,7 @@ npppd_ppp_get_pipex_stat(struct npppd_who *_this, npppd_ppp *ppp)
return 1;
}
- /* カーネル側の統計情報を反映 */
+ /* update statistics in kernel */
if (ioctl(iface->devf, PIPEXGSTAT, &req) != 0)
return 1;
@@ -544,7 +548,7 @@ npppd_ppp_get_pipex_stat(struct npppd_who *_this, npppd_ppp *ppp)
}
#endif
-/** IOイベントハンドラー */
+/** IO event handler */
static void
npppd_ctl_io_event(int fd, short evmask, void *ctx)
{
@@ -570,7 +574,7 @@ npppd_ctl_io_event(int fd, short evmask, void *ctx)
return;
}
-/** このインスタンスに基づいたラベルから始まるログを記録します。*/
+/** Record log that begins the label based this instance. */
static int
npppd_ctl_log(npppd_ctl *_this, int prio, const char *fmt, ...)
{
diff --git a/usr.sbin/npppd/npppd/npppd_ctl.h b/usr.sbin/npppd/npppd/npppd_ctl.h
index d8cb3e2ed04..bc67c5af911 100644
--- a/usr.sbin/npppd/npppd/npppd_ctl.h
+++ b/usr.sbin/npppd/npppd/npppd_ctl.h
@@ -32,7 +32,7 @@
#define DEFAULT_NPPPD_CTL_SOCK_PATH "/var/run/npppd_ctl"
#endif
-/** 利用ユーザの統計情報 */
+/** connected user statistics */
#define NPPPD_CTL_CMD_WHO 1
#ifndef DEFAULT_NPPPD_CTL_MAX_MSGSZ
@@ -42,37 +42,37 @@
struct npppd_who {
/** ppp Id */
int id;
- /** ユーザ名 */
+ /** username */
char name[MAX_USERNAME_LENGTH];
- /** 開始時刻 */
+ /** start time */
time_t time;
- /** 経過時間 */
+ /** elapsed time */
uint32_t duration_sec;
- /** 物理層ラベル */
+ /** label of physical layer */
char phy_label[16];
- /** 集約インターフェイス **/
+ /** concentration interface **/
char ifname[IF_NAMESIZE];
char rlmname[NPPPD_GENERIC_NAME_LEN];
union {
struct sockaddr_in peer_in;
struct sockaddr_dl peer_dl;
- } /** 物理層のアドレス情報 */
+ } /** address information of physical interface */
phy_info;
- /** 割り当てた IP アドレス */
+ /** assigned IP address */
struct in_addr assign_ip4;
- /** 入力パケット数 */
+ /** numbers of input packets */
uint32_t ipackets;
- /** 出力パケット数 */
+ /** numbers of output packets */
uint32_t opackets;
- /** 入力エラーパケット数 */
+ /** numbers of input error packets */
uint32_t ierrors;
- /** 出力エラーパケット数 */
+ /** numbers of output error packets */
uint32_t oerrors;
- /** 入力パケットバイト*/
+ /** bytes of input packets */
uint64_t ibytes;
- /** 出力パケットバイト*/
+ /** bytes of output packets */
uint64_t obytes;
};
struct npppd_who_list {
@@ -80,7 +80,7 @@ struct npppd_who_list {
struct npppd_who entry[0];
};
-/** 指定したユーザの接続を切断 */
+/** disconnect specified user's connection */
#define NPPPD_CTL_CMD_DISCONNECT_USER 2
struct npppd_disconnect_user_req {
@@ -88,10 +88,10 @@ struct npppd_disconnect_user_req {
char username[MAX_USERNAME_LENGTH];
};
-/** 端末認証の認証情報をセットします */
+/** set client authentication information */
#define NPPPD_CTL_CMD_TERMID_SET_AUTH 3
-/** npppd の持つ経路情報をシステムにリセットします */
+/** reset npppd's routing information to system's */
#define NPPPD_CTL_CMD_RESET_ROUTING_TABLE 4
typedef enum _npppd_ctl_ppp_key {
diff --git a/usr.sbin/npppd/npppd/npppd_defs.h b/usr.sbin/npppd/npppd/npppd_defs.h
index 644e6f75d45..cabc5efda21 100644
--- a/usr.sbin/npppd/npppd/npppd_defs.h
+++ b/usr.sbin/npppd/npppd/npppd_defs.h
@@ -34,7 +34,7 @@
#endif
#ifndef NPPPD_MAX_SERVERS
-/** RADIUSサーバの数 */
+/** numbers of RADIUS servers */
#define NPPPD_MAX_SERVERS 8
#endif
@@ -42,26 +42,26 @@
#define NPPPD_TIMER_TICK_IVAL 4
#endif
-/** 認証レルム終了化処理のインターバル時間(sec) */
+/** interval time in seconds of authentication realm finalizer */
#define NPPPD_AUTH_REALM_FINALIZER_INTERVAL 300
#ifndef NPPPD_MAX_IPCP_CONFIG
-/** IPCP設定の数 */
+/** numbers of IPCP configurations */
#define NPPPD_MAX_IPCP_CONFIG 1
#endif
#ifndef NPPPD_MAX_IFACE
-/** PPP集約インタフェース(tun や pppac) の数 */
+/** numbers of PPP concentration interfaces */
#define NPPPD_MAX_IFACE 1
#endif
#ifndef NPPPD_MAX_POOL
-/** プールの数 */
+/** numbers of pool */
#define NPPPD_MAX_POOL 1
#endif
#ifndef NPPPD_MAX_PPTP
-/** ローカル認証レルムの数 */
+/** numbers of local authentication realms */
#define NPPPD_MAX_PPTP 2
#endif
@@ -69,17 +69,17 @@
#define NPPPD_DEFAULT_AUTH_LOCAL_RELOADABLE 0
#endif
-/** 同一ユーザが接続できる最大の PPPセッション数のデフォルト */
+/** default value of maximum PPP sessions per user */
#define NPPPD_DEFAULT_USER_MAX_PPP 3
#ifndef NPPPD_DEFAULT_MAX_PPP
-/** 同時に接続できる最大の PPPセッション数のデフォルト */
+/** default value of maximum PPP sessions in system */
#define NPPPD_DEFAULT_MAX_PPP 8192
#endif
-#define NPPPD_UID -1 /* 特に指定しない */
+#define NPPPD_UID -1 /* not specified */
#ifndef NPPPD_GID
-/** npppd 実行時のグループID。*/
+/** group id when npppd is working */
#define NPPPD_GID 0
#endif
@@ -98,15 +98,18 @@
#endif
#ifndef DEFAULT_RTSOCK_EVENT_DELAY
-/** Routing ソケットイベントを受けてから、処理を開始するまでの待ち時間(秒)*/
+/**
+ * delay time in seconds until npppd starts working when routing socket event
+ * receive
+ */
#define DEFAULT_RTSOCK_EVENT_DELAY 5
#endif
#ifndef DEFAULT_RTSOCK_SEND_NPKTS
-/** Routing ソケットに書き込む際に一度に書くパケット数*/
+/** numbers of packets to write to routing socket once */
#define DEFAULT_RTSOCK_SEND_NPKTS 16
#endif
#ifndef DEFAULT_RTSOCK_SEND_WAIT_MILLISEC
-/** Routing ソケットへの連続書き込みで間隔を空ける時間(ミリ秒) */
+/** wait time in milliseconds to write to routing socket in-sequence */
#define DEFAULT_RTSOCK_SEND_WAIT_MILLISEC 0
#endif
diff --git a/usr.sbin/npppd/npppd/npppd_iface.c b/usr.sbin/npppd/npppd/npppd_iface.c
index 7fc370bbab9..9a57cefcd71 100644
--- a/usr.sbin/npppd/npppd/npppd_iface.c
+++ b/usr.sbin/npppd/npppd/npppd_iface.c
@@ -23,10 +23,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: npppd_iface.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: npppd_iface.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/**@file
- * npppd がカーネルとインタフェースするためのインタフェース。NetBSD の
- * tun(4) や SEIL の pppac(4) を利用するための実装です。
+ * The interface of npppd and kernel.
+ * This is an implementation to use tun(4).
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -96,7 +96,7 @@ static int npppd_iface_pipex_disable(npppd_iface *_this);
#endif /* USE_NPPPD_PIPEX */
-/** npppd_iface の初期化 */
+/** initialize npppd_iface */
void
npppd_iface_init(npppd_iface *_this, const char *ifname)
{
@@ -123,7 +123,7 @@ npppd_iface_setup_ip(npppd_iface *_this)
changed = 0;
memset(&ifr, 0, sizeof(ifr));
- /* インタフェースに割り当てられたアドレスを取得 */
+ /* get address which was assigned to interface */
assigned.s_addr = INADDR_NONE;
memset(&ifr, 0, sizeof(ifr));
memset(&ifra, 0, sizeof(ifra));
@@ -134,13 +134,13 @@ npppd_iface_setup_ip(npppd_iface *_this)
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
npppd_iface_log(_this, LOG_ERR,
"socket() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
if (ioctl(sock, SIOCGIFADDR, &ifr) != 0) {
if (errno != EADDRNOTAVAIL) {
npppd_iface_log(_this, LOG_ERR,
"get ip address failed: %m");
- goto reigai;
+ goto fail;
}
assigned.s_addr = 0;
} else
@@ -153,7 +153,7 @@ npppd_iface_setup_ip(npppd_iface *_this)
if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
npppd_iface_log(_this, LOG_ERR,
"ioctl(,SIOCGIFFLAGS) failed: %m");
- goto reigai;
+ goto fail;
}
if_flags = ifr.ifr_flags;
@@ -165,7 +165,7 @@ npppd_iface_setup_ip(npppd_iface *_this)
npppd_iface_log(_this, LOG_ERR,
"delete ipaddress %s failed: %m",
_this->ifname);
- goto reigai;
+ goto fail;
}
if (ioctl(sock, SIOCGIFADDR, &ifr) != 0) {
if (errno == EADDRNOTAVAIL)
@@ -173,7 +173,7 @@ npppd_iface_setup_ip(npppd_iface *_this)
npppd_iface_log(_this, LOG_ERR,
"cannot get ipaddress %s failed: %m",
_this->ifname);
- goto reigai;
+ goto fail;
}
} while (1);
@@ -183,7 +183,7 @@ npppd_iface_setup_ip(npppd_iface *_this)
if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) {
npppd_iface_log(_this, LOG_ERR,
"disabling %s failed: %m", _this->ifname);
- goto reigai;
+ goto fail;
}
sin0 = (struct sockaddr_in *)&ifra.ifra_addr;
@@ -203,11 +203,11 @@ npppd_iface_setup_ip(npppd_iface *_this)
if (ioctl(sock, SIOCAIFADDR, &ifra) != 0 && errno != EEXIST) {
/*
- * alias リクエストなので EEXIST?
+ * alias request, so EEXIST?
*/
npppd_iface_log(_this, LOG_ERR,
"Cannot assign tun device ip address: %m");
- goto reigai;
+ goto fail;
}
assigned.s_addr = _this->ip4addr.s_addr;
@@ -216,8 +216,7 @@ npppd_iface_setup_ip(npppd_iface *_this)
if (npppd_iface_ip_is_ready(_this)) {
if (changed) {
/*
- * I/F アドレスを使っている PPPセッションがあったら、
- * 切断する。
+ * If there is a PPP session which was assigned interface IP address, disconnect it.
*/
ppp = npppd_get_ppp_by_ip(_this->npppd, _this->ip4addr);
if (ppp != NULL) {
@@ -233,11 +232,10 @@ npppd_iface_setup_ip(npppd_iface *_this)
if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) {
npppd_iface_log(_this, LOG_ERR,
"enabling %s failed: %m", _this->ifname);
- goto reigai;
+ goto fail;
}
/*
- * ホスト自身からの _this->ip4addr への通信ができるように、
- * 経路追加。
+ * Add routing entry to communicate from host itself to _this->ip4addr.
*/
gw.s_addr = htonl(INADDR_LOOPBACK);
in_host_route_add(&_this->ip4addr, &gw, LOOPBACK_IFNAME, 0);
@@ -245,14 +243,14 @@ npppd_iface_setup_ip(npppd_iface *_this)
close(sock); sock = -1;
return 0;
-reigai:
+fail:
if (sock >= 0)
close(sock);
return 1;
}
-/** トンネルエンドアドレスの設定 */
+/** set tunnel end address */
int
npppd_iface_reinit(npppd_iface *_this)
{
@@ -278,7 +276,7 @@ npppd_iface_reinit(npppd_iface *_this)
return 0;
}
-/** npppd_iface の開始 */
+/** start npppd_iface */
int
npppd_iface_start(npppd_iface *_this)
{
@@ -287,18 +285,18 @@ npppd_iface_start(npppd_iface *_this)
NPPPD_IFACE_ASSERT(_this != NULL);
- /* デバイスファイルオープン */
+ /* open device file */
snprintf(buf, sizeof(buf), "/dev/%s", _this->ifname);
if ((_this->devf = open(buf, O_RDWR, 0600)) < 0) {
npppd_iface_log(_this, LOG_ERR, "open(%s) failed: %m", buf);
- goto reigai;
+ goto fail;
}
x = 1;
if (ioctl(_this->devf, FIONBIO, &x) != 0) {
npppd_iface_log(_this, LOG_ERR,
"ioctl(FIONBIO) failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
x = IFF_BROADCAST;
@@ -306,7 +304,7 @@ npppd_iface_start(npppd_iface *_this)
npppd_iface_log(_this, LOG_ERR,
"ioctl(TUNSIFMODE=IFF_BROADCAST) failed in %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
event_set(&_this->ev, _this->devf, EV_READ | EV_PERSIST,
@@ -314,7 +312,7 @@ npppd_iface_start(npppd_iface *_this)
event_add(&_this->ev, NULL);
if (npppd_iface_setup_ip(_this) != 0)
- goto reigai;
+ goto fail;
#ifdef USE_NPPPD_PIPEX
if (npppd_iface_pipex_enable(_this) != 0) {
@@ -329,7 +327,7 @@ npppd_iface_start(npppd_iface *_this)
: "(not assigned)");
return 0;
-reigai:
+fail:
if (_this->devf >= 0) {
event_del(&_this->ev);
close(_this->devf);
@@ -339,7 +337,7 @@ reigai:
return -1;
}
-/** npppd_iface の利用を停止します。*/
+/** stop to use npppd_iface */
void
npppd_iface_stop(npppd_iface *_this)
{
@@ -362,7 +360,7 @@ npppd_iface_stop(npppd_iface *_this)
event_del(&_this->ev);
}
-/** npppd_iface の終了化 */
+/** finalize npppd_iface */
void
npppd_iface_fini(npppd_iface *_this)
{
@@ -373,11 +371,11 @@ npppd_iface_fini(npppd_iface *_this)
/***********************************************************************
- * PIPEX 関連
+ * PIPEX related functions
***********************************************************************/
#ifdef USE_NPPPD_PIPEX
-/** PPPAC インタフェースの PIPEX を有効化します */
+/** enable PIPEX on PPPAC interface */
int
npppd_iface_pipex_enable(npppd_iface *_this)
{
@@ -386,7 +384,7 @@ npppd_iface_pipex_enable(npppd_iface *_this)
return ioctl(_this->devf, PIPEXSMODE, &enable);
}
-/** PPPAC インタフェースの PIPEX を無効化します */
+/** disable PIPEX on PPPAC interface */
int
npppd_iface_pipex_disable(npppd_iface *_this)
{
@@ -399,9 +397,9 @@ npppd_iface_pipex_disable(npppd_iface *_this)
/***********************************************************************
- * I/O関連
+ * I/O related functions
***********************************************************************/
-/** I/O イベントハンドラ */
+/** I/O event handler */
static void
npppd_iface_io_event_handler(int fd, short evtype, void *data)
{
@@ -434,14 +432,14 @@ npppd_iface_io_event_handler(int fd, short evtype, void *data)
return;
}
-/** npppd_iface_network_input_delegate の引数を表す型 */
+/** structure of argument of npppd_iface_network_input_delegate */
struct npppd_iface_network_input_arg{
npppd_iface *_this;
u_char *pktp;
int lpktp;
};
-/** 個々の PPP についての処理を行うコールバック関数 */
+/** callback function which works for each PPP session */
static int
npppd_iface_network_input_delegate(struct radish *radish, void *args0)
{
@@ -458,12 +456,12 @@ npppd_iface_network_input_delegate(struct radish *radish, void *args0)
return 0;
#ifdef USE_NPPPD_MPPE
if (MPPE_READY(ppp)) {
- /* MPPE が開始していれば MPPE 経由で */
+ /* output via MPPE if MPPE started */
mppe_pkt_output(&ppp->mppe, PPP_PROTO_IP, args->pktp,
args->lpktp);
} else if (MPPE_REQUIRED(ppp)) {
- /* MPPE 開始してないけど MPPE必須の場合 */
- /* マルチキャストなのでログには残さない. */
+ /* in case MPPE not started but MPPE is mandatory, */
+ /* it is not necessary to log because of multicast. */
return 0;
}
#endif
@@ -496,7 +494,7 @@ npppd_iface_network_input_ipv4(npppd_iface *_this, u_char *pktp, int lpktp)
input_arg._this = _this;
input_arg.pktp = pktp;
input_arg.lpktp = lpktp;
- /* デリゲート */
+ /* delegate */
rd_walktree(((npppd *)(_this->npppd))->rd,
npppd_iface_network_input_delegate, &input_arg);
return;
@@ -520,11 +518,11 @@ npppd_iface_network_input_ipv4(npppd_iface *_this, u_char *pktp, int lpktp)
#ifdef USE_NPPPD_MPPE
if (MPPE_READY(ppp)) {
- /* MPPE が開始していれば MPPE 経由で */
+ /* output via MPPE if MPPE started */
mppe_pkt_output(&ppp->mppe, PPP_PROTO_IP, pktp, lpktp);
return;
} else if (MPPE_REQUIRED(ppp)) {
- /* MPPE 開始してないけど MPPE必須の場合 */
+ /* in case MPPE not started but MPPE is mandatory */
ppp_log(ppp, LOG_WARNING, "A packet received from network, "
"but MPPE is not started.");
return;
@@ -534,8 +532,8 @@ npppd_iface_network_input_ipv4(npppd_iface *_this, u_char *pktp, int lpktp)
}
/**
- * ネットワーク(tun)側 から入力があった場合に呼び出します。現在は IPv4 の
- * パケットが入力されることを仮定しています。
+ * This function is called when an input packet come from network(tun).
+ * Currently, it assumes that it input IPv4 packet.
*/
static void
npppd_iface_network_input(npppd_iface *_this, u_char *pktp, int lpktp)
@@ -561,7 +559,7 @@ npppd_iface_network_input(npppd_iface *_this, u_char *pktp, int lpktp)
}
}
-/** トンネルデバイスに書き込みます。*/
+/** write to tunnel device */
void
npppd_iface_write(npppd_iface *_this, int proto, u_char *pktp, int lpktp)
{
@@ -586,9 +584,9 @@ npppd_iface_write(npppd_iface *_this, int proto, u_char *pktp, int lpktp)
}
/***********************************************************************
- * 雑多
+ * misc functions
***********************************************************************/
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/** Log it which starts the label based on this instance. */
static int
npppd_iface_log(npppd_iface *_this, int prio, const char *fmt, ...)
{
diff --git a/usr.sbin/npppd/npppd/npppd_iface.h b/usr.sbin/npppd/npppd/npppd_iface.h
index 1cad06b70ea..ee0f2def7a6 100644
--- a/usr.sbin/npppd/npppd/npppd_iface.h
+++ b/usr.sbin/npppd/npppd/npppd_iface.h
@@ -27,37 +27,36 @@
#define NPPPD_INTERFACE_H 1
typedef struct _npppd_iface {
- /** ベースとなる npppd */
+ /** base of npppd structure */
void *npppd;
- /** インタフェース名 */
+ /** interface name */
char ifname[IFNAMSIZ];
- /** デバイスファイルのデスクリプタ */
+ /** file descriptor for device file */
int devf;
- /** 割り当てられた IPv4 アドレス */
+ /** assigned IPv4 address */
struct in_addr ip4addr;
- /** event(3) 用メンバー */
+ /** for event(3) */
struct event ev;
- /** 同一PPPユーザが接続できる最大の PPPセッション数 */
+ /** maximum PPP sessions per user */
int user_max_session;
- /** 接続できる最大の PPPセッション数 */
+ /** maximum PPP sessions */
int max_session;
- /** 接続中の PPPセッション数 */
+ /** PPP sessions already connected */
int nsession;
int /**
- * npppd_iface の処理としてIPアドレスをセットするか。
- * <p>0 であれば、npppd_iface は、セットされた IPアドレスを
- * 参照するだけです。</p>
+ * whether set IP address as npppd_iface's work or not.
+ * <p>if 0, npppd_iface only refers IP address already set.</p>
*/
set_ip4addr:1,
- /** 初期化済みフラグ */
+ /** initialized flag */
initialized:1;
} npppd_iface;
-/** インタフェースのIPアドレスは使用できるか */
+/** whether interface IP address is usable or not */
#define npppd_iface_ip_is_ready(int) \
((int)->initialized != 0 && (int)->ip4addr.s_addr != INADDR_ANY)
diff --git a/usr.sbin/npppd/npppd/npppd_local.h b/usr.sbin/npppd/npppd/npppd_local.h
index 2a292084968..ad9e8b37b68 100644
--- a/usr.sbin/npppd/npppd/npppd_local.h
+++ b/usr.sbin/npppd/npppd/npppd_local.h
@@ -27,7 +27,7 @@
#define _NPPPD_LOCAL_H 1
#ifndef NPPPD_BUFSZ
-/** バッファサイズ */
+/** buffer size */
#define NPPPD_BUFSZ BUFSZ
#endif
@@ -72,17 +72,17 @@
#ifdef USE_NPPPD_NPPPD_CTL
typedef struct _npppd_ctl {
- /** イベントコンテキスト */
+ /** event context */
struct event ev_sock;
- /** ソケット */
+ /** socket */
int sock;
- /** 有効/無効 */
+ /** enabled or disabled */
int enabled;
- /** 親 npppd */
+ /** parent of npppd structure */
void *npppd;
- /** ソケットのパス名 */
+ /** pathname of socket */
char pathname[MAXPATHLEN];
- /** 最大メッセージ長 */
+ /** maximum length of message */
int max_msgsz;
} npppd_ctl;
#endif
@@ -90,73 +90,73 @@ typedef struct _npppd_ctl {
#include "addr_range.h"
#include "npppd_pool.h"
-/** プールを示す型 */
+/** structure of pool */
struct _npppd_pool {
- /** 基となる npppd */
+ /** base of npppd structure */
npppd *npppd;
- /** ラベル名 */
+ /** name of label */
char label[NPPPD_GENERIC_NAME_LEN];
- /** 名前(name) */
+ /** name */
char name[NPPPD_GENERIC_NAME_LEN];
- /** sockaddr_npppd 配列のサイズ */
+ /** size of sockaddr_npppd array */
int addrs_size;
- /** sockaddr_npppd 配列 */
+ /** pointer indicated to sockaddr_npppd array */
struct sockaddr_npppd *addrs;
- /** 動的に割り当てるアドレスのリスト */
+ /** list of addresses dynamically allocated */
slist dyna_addrs;
- int /** 初期化済 */
+ int /** whether initialized or not */
initialized:1,
- /** 利用中 */
+ /** whether in use or not */
running:1;
};
-/** IPCP設定を示す型 */
+/** structure of IPCP configuration */
typedef struct _npppd_ipcp_config {
- /** 名前 */
+ /** name */
char name[NPPPD_GENERIC_NAME_LEN];
- /** ラベル(紐付けるため) */
+ /** label (to associate with npppd structure) */
char label[NPPPD_GENERIC_NAME_LEN];
- /** 親 npppd へのポインタ */
+ /** pointer indicated to parent npppd structure */
npppd *npppd;
/**
- * プライマリDNSサーバ。先方に通知しない場合は INADDR_NONE。
- * ネットワークバイトオーダー。
+ * primary DNS server. INADDR_NONE if not inform peer this.
+ * specified in network byte order.
*/
struct in_addr dns_pri;
- /** セカンダリDNSサーバ。先方に通知しない場合は INADDR_NONE。
- * ネットワークバイトオーダー。
+ /** secondary DNS server. INADDR_NONE if not inform peer this.
+ * specified in network byte order.
*/
struct in_addr dns_sec;
/**
- * プライマリWINSサーバ。先方に通知しない場合は INADDR_NONE。
- * ネットワークバイトオーダー。
+ * primary WINS server. INADDR_NONE if not inform peer this.
+ * specified in network byte order.
*/
struct in_addr nbns_pri;
/**
- * セカンダリWINSサーバ。先方に通知しない場合は INADDR_NONE。
- * ネットワークバイトオーダー。
+ * secondary WINS server. INADDR_NONE if not inform peer this.
+ * specified in network byte order.
*/
struct in_addr nbns_sec;
/**
- * IPアドレス割り当て方法のビットフラグ。
+ * bit flag which specifies the way of IP address assignment.
* @see #NPPPD_IP_ASSIGN_FIXED
* @see #NPPPD_IP_ASSIGN_USER_SELECT
* @see #NPPPD_IP_ASSIGN_RADIUS
*/
int ip_assign_flags;
- int /** DNS サーバとしてトンネル終端アドレスを使う */
+ int /** whether use tunnel end point address as DNS server or not */
dns_use_tunnel_end:1,
- /** 初期化済かどうか */
+ /** whether initialized or not */
initialized:1,
reserved:30;
} npppd_ipcp_config;
-/** インタフェースの IPCP 設定やプールアドレスへの参照を保持する型 */
+/** structure which holds an interface of IPCP configuration and references of pool address */
typedef struct _npppd_iface_binding {
npppd_ipcp_config *ipcp;
slist pools;
@@ -166,79 +166,79 @@ typedef struct _npppd_iface_binding {
* npppd
*/
struct _npppd {
- /** イベントハンドラー */
+ /** event handler */
struct event ev_sigterm, ev_sigint, ev_sighup, ev_timer;
- /** PPPを集約するインターフェース */
+ /** interface which concentrates PPP */
npppd_iface iface[NPPPD_MAX_IFACE];
- /** インタフェースの IPCP 設定やプールアドレスへの参照 */
+ /** reference of interface of IPCP configuration and pool address */
npppd_iface_binding iface_bind[NPPPD_MAX_IFACE];
- /** アドレスプール */
+ /** address pool */
npppd_pool pool[NPPPD_MAX_POOL];
- /** radish プール、割り当てアドレス管理用 */
+ /** radish pool which uses to manage allocated address */
struct radish_head *rd;
- /** IPCP 設定 */
+ /** IPCP configuration */
npppd_ipcp_config ipcp_config[NPPPD_MAX_IPCP_CONFIG];
- /** ユーザ名 → slist of npppd_ppp のマップ */
+ /** map of username to slist of npppd_ppp */
hash_table *map_user_ppp;
- /** 認証レルム */
+ /** authentication realms */
slist realms;
- /** 認証レルム終了化処理のインターバル時間(sec) */
+ /** interval time(in seconds) which finalizes authentication realms */
int auth_finalizer_itvl;
- /** 設定ファイル名 */
+ /** name of configuration file */
char config_file[MAXPATHLEN];
- /** PIDファイル名 */
+ /** name of pid file */
char pidpath[MAXPATHLEN];
- /** プロセス ID */
+ /** process id */
pid_t pid;
#ifdef USE_NPPPD_L2TP
- /** L2TP デーモン */
+ /** structure of L2TP daemon */
l2tpd l2tpd;
#endif
#ifdef USE_NPPPD_PPTP
- /** PPTP デーモン */
+ /** structure of PPTP daemon */
pptpd pptpd;
#endif
#ifdef USE_NPPPD_PPPOE
- /** PPPOE デーモン */
+ /** structure of PPPOE daemon */
pppoed pppoed;
#endif
- /** 設定ファイル */
+ /** configuration file */
struct properties * properties;
- /** ユーザ設定ファイル */
+ /** user properties file */
struct properties * users_props;
#ifdef USE_NPPPD_NPPPD_CTL
npppd_ctl ctl;
#endif
- /** 起動してからの秒数。*/
+ /** the time in seconds which process was started.*/
uint32_t secs;
- /** 設定再読み込みを何秒猶予するか */
+ /** delay time in seconds reload configuration */
int16_t delayed_reload;
- /** 設定再読み込みカウンタ */
+ /** counter of reload configuration */
int16_t reloading_count;
- /** 処理済みのルーティングイベントシリアル */
+ /** serial number of routing event which was completed */
int rtev_event_serial;
- /** 接続できる最大の PPPセッション数 */
+ /** maximum PPP sessions */
int max_session;
- int /** 終了処理中 */
+ int /** whether finalizing or not */
finalizing:1,
- /** 終了処理完了 */
+ /** whether finalize completed or not */
finalized:1;
};
diff --git a/usr.sbin/npppd/npppd/npppd_pool.c b/usr.sbin/npppd/npppd/npppd_pool.c
index 69351eea873..aa25d3bea13 100644
--- a/usr.sbin/npppd/npppd/npppd_pool.c
+++ b/usr.sbin/npppd/npppd/npppd_pool.c
@@ -80,9 +80,9 @@ static int npppd_pool_regist_radish(npppd_pool *, struct in_addr_range *,
/***********************************************************************
- * npppd_pool オブジェクト操作
+ * npppd_pool object management
***********************************************************************/
-/** npppd_poll を初期化します */
+/** Initialize npppd_poll. */
int
npppd_pool_init(npppd_pool *_this, npppd *base, const char *name)
{
@@ -97,20 +97,20 @@ npppd_pool_init(npppd_pool *_this, npppd *base, const char *name)
return 0;
}
-/** npppd_pool の使用を開始します */
+/** Start to use npppd_pool. */
int
npppd_pool_start(npppd_pool *_this)
{
- return 0; // やることなし。
+ return 0; /* nothing to do */
}
-/* 設定テンプレート展開 */;
+/* expand config template */;
NAMED_PREFIX_CONFIG_DECL(npppd_pool_config, npppd_pool, npppd->properties,
"pool", label);
NAMED_PREFIX_CONFIG_FUNCTIONS(npppd_pool_config, npppd_pool, npppd->properties,
"pool", label);
-/** npppd_poll を終了化します */
+/** Finalize npppd_poll. */
void
npppd_pool_uninit(npppd_pool *_this)
{
@@ -124,7 +124,7 @@ npppd_pool_uninit(npppd_pool *_this)
_this->npppd = NULL;
}
-/** 設定を再読み込みします。*/
+/** Reload configuration. */
int
npppd_pool_reload(npppd_pool *_this)
{
@@ -144,32 +144,32 @@ npppd_pool_reload(npppd_pool *_this)
val = _this->label;
strlcpy(_this->name, val, sizeof(_this->name));
- /* 動的アドレスプール */
+ /* dynamic address pool */
val0 = NULL;
val = npppd_pool_config_str(_this, "dyna_pool");
if (val != NULL) {
if (in_addr_range_list_add_all(&dyna_pool, val) != 0) {
npppd_pool_log(_this, LOG_WARNING,
"parse error at 'dyna_pool': %s", val);
- goto reigai;
+ goto fail;
}
val0 = val;
}
- /* 固定アドレスプール */
+ /* static address pool */
val = npppd_pool_config_str(_this, "pool");
if (val != NULL) {
if (in_addr_range_list_add_all(&pool, val) != 0) {
npppd_pool_log(_this, LOG_WARNING,
"parse error at 'pool': %s", val);
- goto reigai;
+ goto fail;
}
if (val0 != NULL)
/* Aggregate */
in_addr_range_list_add_all(&pool, val0);
}
- /* RADISH 登録準備 */
+ /* preparing to register address with RADISH. */
addrs_size = 0;
for (range = dyna_pool; range != NULL; range = range->next)
addrs_size++;
@@ -178,17 +178,17 @@ npppd_pool_reload(npppd_pool *_this)
if ((addrs = calloc(addrs_size + 1, sizeof(struct sockaddr_npppd)))
== NULL) {
- /* +1 しているのは calloc(0) を回避するため */
+ /* addr_size + 1 because of avoiding calloc(0). */
npppd_pool_log(_this, LOG_WARNING,
"calloc() failed in %s: %m", __func__);
- goto reigai;
+ goto fail;
}
- /* 動的プール => RADISH 登録 */
+ /* Register dynamic pool address with RADISH. */
count = 0;
for (i = 0, range = dyna_pool; range != NULL; range = range->next, i++){
if (npppd_pool_regist_radish(_this, range, &addrs[count], 1))
- goto reigai;
+ goto fail;
if (count == 0)
strlcat(buf0, "dyn_pool=[", sizeof(buf0));
else
@@ -201,10 +201,10 @@ npppd_pool_reload(npppd_pool *_this)
if (i > 0)
strlcat(buf0, "] ", sizeof(buf0));
- /* 固定プール => RADISH 登録 */
+ /* Register static pool address with RADISH. */
for (i = 0, range = pool; range != NULL; range = range->next, i++) {
if (npppd_pool_regist_radish(_this, range, &addrs[count], 0))
- goto reigai;
+ goto fail;
if (i == 0)
strlcat(buf0, "pool=[", sizeof(buf0));
else
@@ -242,7 +242,7 @@ npppd_pool_reload(npppd_pool *_this)
in_addr_range_list_remove_all(&dyna_pool);
return 0;
-reigai:
+fail:
in_addr_range_list_remove_all(&pool);
in_addr_range_list_remove_all(&dyna_pool);
@@ -281,14 +281,14 @@ npppd_pool_regist_radish(npppd_pool *_this, struct in_addr_range *range,
if ((snp0 = rd_lookup(SA(&sin4a), SA(&sin4b),
_this->npppd->rd)) != NULL) {
/*
- * radish ツリーは、初期化直後で POOL のエントリしかないことを
- * 仮定。
+ * Immediately after the radish tree is initialized,
+ * assuming that it has only POOL entry.
*/
NPPPD_POOL_ASSERT(snp0->snp_type != SNP_PPP);
npool0 = snp0->snp_data_ptr;
if (!is_dynamic && npool0 == _this)
- /* 動的アドレスとして登録済 */
+ /* Already registered as dynamic pool address. */
return 0;
npppd_pool_log(_this, LOG_WARNING,
@@ -296,7 +296,7 @@ npppd_pool_regist_radish(npppd_pool *_this, struct in_addr_range *range,
A(range->addr), netmask2prefixlen(range->mask),
npool0->name, (snp0->snp_type == SNP_POOL)
? "static" : "dynamic");
- goto reigai;
+ goto fail;
}
if ((rval = rd_insert(SA(&sin4a), SA(&sin4b), _this->npppd->rd,
snp)) != 0) {
@@ -304,11 +304,11 @@ npppd_pool_regist_radish(npppd_pool *_this, struct in_addr_range *range,
npppd_pool_log(_this, LOG_WARNING,
"rd_insert(%d.%d.%d.%d/%d) failed: %m",
A(range->addr), netmask2prefixlen(range->mask));
- goto reigai;
+ goto fail;
}
return 0;
-reigai:
+fail:
return 1;
}
@@ -316,7 +316,7 @@ reigai:
/***********************************************************************
* API
***********************************************************************/
-/** 動的アドレスを割り当てます */
+/** Assign dynamic pool address. */
uint32_t
npppd_pool_get_dynamic(npppd_pool *_this, npppd_ppp *ppp)
{
@@ -336,12 +336,12 @@ npppd_pool_get_dynamic(npppd_pool *_this, npppd_ppp *ppp)
result = slist_itr_next(&_this->dyna_addrs);
if (result == NULL)
break;
- /* シャッフル */
+ /* shuffle */
if ((uint32_t)result == SHUFLLE_MARK) {
/*
- * 使えるアドレスが無くなると length > 1 でも、
- * shuffle を連続してツモる。2回ツモったら、
- * つまり使えるアドレスがない。
+ * In case of no address to use,
+ * keep suffling and get address if length > 1.
+ * If succeed to get address twice, it means no address to use.
*/
if (shuffle_cnt++ > 0) {
result = NULL;
@@ -359,30 +359,29 @@ npppd_pool_get_dynamic(npppd_pool *_this, npppd_ppp *ppp)
switch (npppd_pool_get_assignability(_this, (uint32_t)result,
0xffffffffL, &snp)) {
case ADDRESS_OK:
- /* 成功するのはココだけ。 */
+ /* only succeed here */
return (uint32_t)result;
default:
- /* インタフェースのアドレスだった場合 */
+ /* In case that the pool address is same as interface address, */
/*
- * リストから削除しているので、インタフェースのアドレ
- * スだけを再変更すると、アドレスをリークしていく問題
- * があるが、現実装では、アドレスだけを変更していくこ
- * とはないので問題ない。運用上も、プールを変更せず、
- * tunnel-end-address だけを変更していく、というのは、
- * 定常的に発生するとは考えづらい。
+ * Because the pool address is deleted from the list,
+ * It has issue of address leak when interface address is changed.
+ * But it will make no problem because there is no situation that
+ * changing the pool address only in current implementation.
+ * In opration, It is hard to assume that the pool address is not
+ * changed and the tunnel-end-address is changed periodically.
*/
continue;
case ADDRESS_BUSY:
sin4.sin_addr.s_addr = htonl((uint32_t)result);
/*
- * 設定再読み込みにより、アクティブな PPP セッションが
- * リセットされた
+ * Because of reloading configuration, reset active PPP session.
*/
NPPPD_POOL_ASSERT(snp != NULL);
NPPPD_POOL_ASSERT(snp->snp_type == SNP_PPP);
ppp0 = snp->snp_data_ptr;
ppp0->assigned_pool = _this;
- ppp0->assign_dynapool = 1; /* 返却よろしく */
+ ppp0->assign_dynapool = 1; /* need to return */
continue;
}
break;
@@ -404,7 +403,7 @@ npppd_is_ifcace_ip4addr(npppd *_this, uint32_t ip4addr)
return 0;
}
-/** IPアドレスを割り当てます */
+/** Assign IP address. */
int
npppd_pool_assign_ip(npppd_pool *_this, npppd_ppp *ppp)
{
@@ -422,7 +421,7 @@ npppd_pool_assign_ip(npppd_pool *_this, npppd_ppp *ppp)
ip4 = ntohl(ppp->ppp_framed_ip_address.s_addr);
- /* 動的アドレスリストに含まれたらそこから取り外す。 */
+ /* If the address contains dynamic pool address list, delete it. */
slist_itr_first(&_this->dyna_addrs);
while (slist_itr_has_next(&_this->dyna_addrs)) {
if ((uint32_t)slist_itr_next(
@@ -438,7 +437,7 @@ npppd_pool_assign_ip(npppd_pool *_this, npppd_ppp *ppp)
if (rd_delete(SA(&addr), SA(&mask), _this->npppd->rd, &rtent) == 0) {
snp = rtent;
- /* 重複エントリあり。プールから PPPへの差し替え */
+ /* It has duplicate address entry. change from pool to PPP. */
NPPPD_POOL_ASSERT(snp != NULL);
NPPPD_POOL_ASSERT(snp->snp_type != SNP_PPP);
ppp->snp.snp_next = snp;
@@ -460,7 +459,7 @@ npppd_pool_assign_ip(npppd_pool *_this, npppd_ppp *ppp)
return 0;
}
-/** IPアドレスを解放します */
+/** Release IP address. */
void
npppd_pool_release_ip(npppd_pool *_this, npppd_ppp *ppp)
{
@@ -475,7 +474,10 @@ npppd_pool_release_ip(npppd_pool *_this, npppd_ppp *ppp)
.sin_len = sizeof(struct sockaddr_in),
};
- /* _this == NULL 設定変更によりプールは解放された */
+ /*
+ * _this == NULL the pool address is released becaus of changing
+ * configuration.
+ */
if (!ppp_ip_assigned(ppp))
return;
@@ -493,14 +495,14 @@ npppd_pool_release_ip(npppd_pool *_this, npppd_ppp *ppp)
snp = item;
if (_this != NULL && ppp->assign_dynapool != 0)
- /* 動的リストに返却 */
+ /* return to dynamic address pool list */
slist_add(&((npppd_pool *)ppp->assigned_pool)->dyna_addrs,
(void *)ntohl(ppp->ppp_framed_ip_address.s_addr));
if (snp != NULL && snp->snp_next != NULL) {
/*
- * radish エントリがリストになっていて、アドレス/マスクが
- * 一致していれば、次のエントリを再登録。
+ * Radish entry is registered to list, if address/mask of
+ * this entry and the next is the same, the next is registered again.
*/
if (rd_insert(SA(&addr), SA(&mask), ppp->pppd->rd,
snp->snp_next) != 0) {
@@ -518,10 +520,10 @@ npppd_pool_release_ip(npppd_pool *_this, npppd_ppp *ppp)
}
/**
- * 指定したアドレスが割り当て可能かどうか。
- * @return {@link ::#ADDRESS_OK}、{@link ::#ADDRESS_RESERVED}、
- * {@link ::#ADDRESS_BUSY}、{@link ::#ADDRESS_INVALID} もしくは
- * {@link ::#ADDRESS_OUT_OF_POOL} が返ります。
+ * Check if specified address is assignable.
+ * @return {@link ::#ADDRESS_OK} or {@link ::#ADDRESS_RESERVED} or
+ * {@link ::#ADDRESS_BUSY} or {@link ::#ADDRESS_INVALID} or
+ * {@link ::#ADDRESS_OUT_OF_POOL}
*/
int
npppd_pool_get_assignability(npppd_pool *_this, uint32_t ip4addr,
@@ -548,7 +550,7 @@ npppd_pool_get_assignability(npppd_pool *_this, uint32_t ip4addr,
if (npppd_is_ifcace_ip4addr(_this->npppd, sin4.sin_addr.s_addr))
return ADDRESS_RESERVED;
- /* インタフェースのアドレスは割り振らない */
+ /* Not to assign interface address */
if (rd_match(SA(&sin4), _this->npppd->rd, &radish)) {
do {
@@ -574,17 +576,18 @@ npppd_pool_get_assignability(npppd_pool *_this, uint32_t ip4addr,
return ADDRESS_OUT_OF_POOL;
}
/***********************************************************************
- * 雑多
+ * miscellaneous functions
***********************************************************************/
/**
- * ホストアドレスとして正しいか。
+ * Check if valid host address.
* <pre>
- * ナチュラルマスクのブロードキャストアドレスをホストとして利用すると、
- * いくつか問題があるので「正しくない」とする。問題とは、
- *
- * (1) BSD系は、該当アドレスは転送せず、自分宛として処理する。
- * (2) [IDGW-DEV 4405]『IPアドレスに .255 が割り当てられた Windows マシン
- * から L2TP/IPsec を利用できない問題』</pre>
+ * There are some issues that it uses host address as broadcast address
+ * in natural mask, so it is not correct.
+ * The issue is as follows:
+ * (1) BSDs treat the following packet as it is not forwarded and
+ * is received as the packet to myself.
+ * (2) The issue that Windows can't use L2TP/IPsec when Windows is assigned
+ * IP address .255.</pre>
*/
static int
is_valid_host_address(uint32_t addr)
@@ -602,7 +605,7 @@ is_valid_host_address(uint32_t addr)
return 0;
}
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/** Record log that begins the label based this instance. */
static int
npppd_pool_log(npppd_pool *_this, int prio, const char *fmt, ...)
{
@@ -611,9 +614,8 @@ npppd_pool_log(npppd_pool *_this, int prio, const char *fmt, ...)
va_list ap;
/*
- * npppd_pool_release_ip は _this == NULL で呼ばれるので
- * NPPPD_POOL_ASSERT(_this != NULL);
- * できない
+ * npppd_pool_release_ip is called as _this == NULL,
+ * so it can't NPPPD_POOL_ASSERT(_this != NULL).
*/
va_start(ap, fmt);
snprintf(logbuf, sizeof(logbuf), "pool name=%s %s",
diff --git a/usr.sbin/npppd/npppd/npppd_pool.h b/usr.sbin/npppd/npppd/npppd_pool.h
index f09b9505aac..7456b52d21e 100644
--- a/usr.sbin/npppd/npppd/npppd_pool.h
+++ b/usr.sbin/npppd/npppd/npppd_pool.h
@@ -28,11 +28,11 @@
typedef struct _npppd_pool npppd_pool;
-#define ADDRESS_OK 0 /** 割り当て可能 */
-#define ADDRESS_RESERVED 1 /** 予約アドレス */
-#define ADDRESS_BUSY 2 /** 使用中 */
-#define ADDRESS_INVALID 3 /** 利用不能アドレス */
-#define ADDRESS_OUT_OF_POOL 4 /** 管理外 */
+#define ADDRESS_OK 0 /** address is assignable. */
+#define ADDRESS_RESERVED 1 /** address is reserved. */
+#define ADDRESS_BUSY 2 /** address is busy. */
+#define ADDRESS_INVALID 3 /** address is unusable. */
+#define ADDRESS_OUT_OF_POOL 4 /** address is out of pool. */
#ifdef __cplusplus
extern "C" {
diff --git a/usr.sbin/npppd/npppd/npppd_subr.c b/usr.sbin/npppd/npppd/npppd_subr.c
index 43d2a365f15..b26c89bff64 100644
--- a/usr.sbin/npppd/npppd/npppd_subr.c
+++ b/usr.sbin/npppd/npppd/npppd_subr.c
@@ -24,9 +24,9 @@
* SUCH DAMAGE.
*/
/**@file
- * npppd の補助的な関数を提供します。
+ * This file provides helper functions for npppd.
*/
-/* $Id: npppd_subr.c,v 1.3 2010/01/31 05:49:51 yasuoka Exp $ */
+/* $Id: npppd_subr.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/cdefs.h>
#ifndef LINT
__COPYRIGHT(
@@ -86,8 +86,8 @@ skip_space(const char *s)
}
/**
- * resolv.conf からネームサーバの IPv4 のエントリを読み出します。
- * resolv.conf のパスは、resolv.h の _PATH_RESCONF を使います。
+ * Read and store IPv4 address of name server from resolv.conf.
+ * The path of resolv.conf is taken from _PATH_RESCONF in resolv.h.
*/
int
load_resolv_conf(struct in_addr *pri, struct in_addr *sec)
@@ -121,11 +121,10 @@ load_resolv_conf(struct in_addr *pri, struct in_addr *sec)
addr = sec;
if (inet_aton(ap, addr) != 1) {
/*
- * FIXME IPv6 使ってるの場合 IPv6 アドレスが入
- * っているかもしれない。とりあえず、continue。
+ * FIXME: If configured IPv6, it may have IPv6
+ * FIXME: address. For the present, continue.
*/
continue;
- //goto reigai;
}
addr->s_addr = addr->s_addr;
if (++i >= 2)
@@ -139,7 +138,7 @@ end_loop:
return 0;
}
-// 経路追加削除
+/* Add and delete routing entry. */
static int
in_route0(int type, struct in_addr *dest, struct in_addr *mask,
struct in_addr *gate, int mtu, const char *ifname, uint32_t rtm_flags)
@@ -147,7 +146,7 @@ in_route0(int type, struct in_addr *dest, struct in_addr *mask,
struct rt_msghdr *rtm;
struct sockaddr_in sdest, smask, sgate;
struct sockaddr_dl *sdl;
- char dl_buf[512]; // enough size
+ char dl_buf[512]; /* enough size */
char *cp, buf[sizeof(*rtm) + sizeof(struct sockaddr_in) * 3 +
sizeof(dl_buf) + 128];
const char *strtype;
@@ -262,20 +261,20 @@ in_route0(int type, struct in_addr *dest, struct in_addr *mask,
if ((sock = priv_socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC)) < 0) {
log_printf(LOG_ERR, "socket() failed in %s() on %s : %m",
__func__, strtype);
- goto reigai;
+ goto fail;
}
dummy = 0;
if ((flags = fcntl(sock, F_GETFL, dummy)) < 0) {
log_printf(LOG_ERR, "fcntl(,F_GETFL) failed on %s : %m",
__func__);
- goto reigai;
+ goto fail;
}
if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) {
log_printf(LOG_ERR, "fcntl(,F_SETFL) failed on %s : %m",
__func__);
- goto reigai;
+ goto fail;
}
if ((rval = priv_send(sock, buf, rtm->rtm_msglen, 0)) <= 0) {
@@ -289,7 +288,7 @@ in_route0(int type, struct in_addr *dest, struct in_addr *mask,
"write() failed in %s on %s : %m", __func__,
strtype);
}
- goto reigai;
+ goto fail;
}
close(sock);
@@ -298,7 +297,7 @@ in_route0(int type, struct in_addr *dest, struct in_addr *mask,
return 0;
#ifndef NPPPD_USE_RTEV_WRITE
-reigai:
+fail:
if (sock >= 0)
close(sock);
#endif
@@ -306,7 +305,7 @@ reigai:
return 1;
}
-/** ホスト経路を追加 */
+/** Add host routing entry. */
int
in_host_route_add(struct in_addr *dest, struct in_addr *gate,
const char *ifname, int mtu)
@@ -314,14 +313,14 @@ in_host_route_add(struct in_addr *dest, struct in_addr *gate,
return in_route0(RTM_ADD, dest, NULL, gate, mtu, ifname, 0);
}
-/** ホスト経路を削除 */
+/** Delete host routing entry. */
int
in_host_route_delete(struct in_addr *dest, struct in_addr *gate)
{
return in_route0(RTM_DELETE, dest, NULL, gate, 0, NULL, 0);
}
-/** ネット経路を追加 */
+/** Add network routing entry. */
int
in_route_add(struct in_addr *dest, struct in_addr *mask, struct in_addr *gate,
const char *ifname, uint32_t rtm_flags, int mtu)
@@ -329,7 +328,7 @@ in_route_add(struct in_addr *dest, struct in_addr *mask, struct in_addr *gate,
return in_route0(RTM_ADD, dest, mask, gate, mtu, ifname, rtm_flags);
}
-/** ネット経路を削除 */
+/** Delete network routing entry. */
int
in_route_delete(struct in_addr *dest, struct in_addr *mask,
struct in_addr *gate, uint32_t rtm_flags)
@@ -337,7 +336,6 @@ in_route_delete(struct in_addr *dest, struct in_addr *mask,
return in_route0(RTM_DELETE, dest, mask, gate, 0, NULL, rtm_flags);
}
-// 従来 ppp の ip.c より流用
/**
* Check whether a packet should reset idle timer
* Returns 1 to don't reset timer (i.e. the packet is "idle" packet)
@@ -349,8 +347,8 @@ ip_is_idle_packet(const struct ip * pip, int len)
const struct udphdr *uh;
/*
- * フラグメントされたパケットはアイドルパケットではない
- * (フラグメントするほど長いパケットはアイドルパケットではない)
+ * Fragmented packet is not idle packet.
+ * (Long packet which needs to fragment is not idle packet.)
*/
ip_off = ntohs(pip->ip_off);
if ((ip_off & IP_MF) || ((ip_off & IP_OFFMASK) != 0))
@@ -360,7 +358,7 @@ ip_is_idle_packet(const struct ip * pip, int len)
case IPPROTO_IGMP:
return 1;
case IPPROTO_ICMP:
- /* 長さは足りている? */
+ /* Is length enough? */
if (pip->ip_hl * 4 + 8 > len)
return 1;
@@ -374,13 +372,13 @@ ip_is_idle_packet(const struct ip * pip, int len)
case IPPROTO_UDP:
case IPPROTO_TCP:
/*
- * UDP も TCP も、ポートの部分は同じなので、そこだけは共用で
- * きる。
+ * The place of port number of UDP and TCP is the same,
+ * so can be shared.
*/
uh = (const struct udphdr *) (((const char *) pip) +
(pip->ip_hl * 4));
- /* 長さは足りている? */
+ /* Is length enough? */
if (pip->ip_hl * 4 + sizeof(struct udphdr) > len)
return 1;
@@ -409,7 +407,7 @@ ip_is_idle_packet(const struct ip * pip, int len)
}
/***********************************************************************
- * プールしているアドレスへの経路追加/削除
+ * Add and delete routing entry for the pool address.
***********************************************************************/
void
in_addr_range_add_route(struct in_addr_range *range)
@@ -444,7 +442,7 @@ in_addr_range_delete_route(struct in_addr_range *range)
}
-/* #inlude <arpa/nameser_compat.h> も GETSHORT を定義している */
+/* GETSHORT is also defined in #inlude <arpa/nameser_compat.h>. */
#undef GETCHAR
#undef GETSHORT
#undef PUTSHORT
@@ -512,9 +510,10 @@ in_addr_range_delete_route(struct in_addr_range *range)
}
/**
- * IPパケットが MTU 以下となるように mss を調整します。
- * @param pktp IPパケットのポインタ
- * @param lpktp 長さ
+ * Adjust mss to make IP packet be shorter than or equal MTU.
+ *
+ * @param pktp pointer that indicates IP packet
+ * @param lpktp length
* @param mtu MTU
*/
int
@@ -530,7 +529,7 @@ adjust_tcp_mss(u_char *pktp, int lpktp, int mtu)
pip = (struct ip *)pktp;
ip_off = ntohs(pip->ip_off);
- /* TCP じゃないパケットやフラグメントされたパケットは対象外 */
+ /* exclude non-TCP packet or fragmented packet. */
if (pip->ip_p != IPPROTO_TCP || (ip_off & IP_MF) != 0 ||
(ip_off & IP_OFFMASK) != 0)
return 0;
@@ -538,12 +537,12 @@ adjust_tcp_mss(u_char *pktp, int lpktp, int mtu)
pktp += pip->ip_hl << 2;
lpktp -= pip->ip_hl << 2;
- /* 壊れてる */
+ /* broken packet */
if (sizeof(struct tcphdr) > lpktp)
return 1;
th = (struct tcphdr *)pktp;
- /* MSS は SYN がセットされたセグメントに限る。(See RFC 793) */
+ /* MSS is selected only from SYN segment. (See RFC 793) */
if ((th->th_flags & TH_SYN) == 0)
return 0;
diff --git a/usr.sbin/npppd/npppd/npppd_tun.c b/usr.sbin/npppd/npppd/npppd_tun.c
index fe4df1613cf..844f0b43ce0 100644
--- a/usr.sbin/npppd/npppd/npppd_tun.c
+++ b/usr.sbin/npppd/npppd/npppd_tun.c
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
/**@file
- * {@link ::_npppd_tun トンネルデバイス} に関する処理を提供します。
+ * This file provides functions on {@link ::_npppd_tun tunnel device}.
*/
#include <sys/types.h>
#include <sys/time.h>
@@ -59,8 +59,8 @@ static void npppd_tundev_io_event_handler (int, short, void *);
/**
- * {@link ::_npppd_tun トンネルデバイスインスタンス}を初期化します。
- * @param minor デバイスマイナー番号
+ * Initialize {@link ::_npppd_tun instance of tunnel device}.
+ * @param minor device minor number
*/
void
npppd_tundev_init(npppd *_this, int minor)
@@ -73,7 +73,7 @@ npppd_tundev_init(npppd *_this, int minor)
}
/**
- * {@link ::_npppd_tun トンネルデバイスインスタンス}を開始します。
+ * Start {@link ::_npppd_tun instance of tunnel device}.
*/
int
npppd_tundev_start(npppd *_this)
@@ -89,14 +89,13 @@ npppd_tundev_start(npppd *_this)
if ((_this->tun_file = open(buf, O_RDWR, 0600)) < 0) {
log_printf(LOG_ERR, "open(%s) failed in %s(): %m",
buf, __func__);
- goto reigai;
+ goto fail;
}
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
log_printf(LOG_ERR, "socket() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
- // ifconfig tun1 10.0.0.1 netmask 255.255.255.25
memset(&ifra, 0, sizeof(ifra));
snprintf(ifra.ifra_name, sizeof(ifra.ifra_name), "tun%d",
@@ -119,7 +118,7 @@ npppd_tundev_start(npppd *_this)
if (ioctl(sock, SIOCAIFADDR, &ifra) != 0 && errno != EEXIST) {
log_printf(LOG_ERR, "Cannot assign tun device ip address: %m");
- goto reigai;
+ goto fail;
}
close(sock);
@@ -127,7 +126,7 @@ npppd_tundev_start(npppd *_this)
if (ioctl(_this->tun_file, FIONBIO, &x) != 0) {
log_printf(LOG_ERR, "ioctl(FIONBIO) failed in %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
event_set(&_this->ev_tun, _this->tun_file, EV_READ | EV_PERSIST,
npppd_tundev_io_event_handler, _this);
@@ -136,7 +135,7 @@ npppd_tundev_start(npppd *_this)
log_printf(LOG_INFO, "Opened /dev/tun%d", _this->tun_minor);
return 0;
-reigai:
+fail:
if (_this->tun_file >= 0)
close(_this->tun_file);
_this->tun_file = -1;
@@ -145,7 +144,7 @@ reigai:
}
/**
- * トンネルデバイスに関する処理を終了します。
+ * Stop process on tunnel device.
*/
void
npppd_tundev_stop(npppd *_this)
@@ -159,7 +158,7 @@ npppd_tundev_stop(npppd *_this)
}
/**
- * IPアドレスをセットします。
+ * Set IP address.
*/
int
npppd_tundev_set_ip_addr(npppd *_this)
@@ -200,7 +199,7 @@ npppd_tundev_io_event_handler(int fd, short evtype, void *data)
}
/**
- * トンネルデバイスに書き込みます。
+ * Write to tunnel device.
*/
void
npppd_tundev_write(npppd *_this, uint8_t *pktp, int lpktp)
diff --git a/usr.sbin/npppd/npppd/pap.c b/usr.sbin/npppd/npppd/pap.c
index ae1029d49df..b7168d00a32 100644
--- a/usr.sbin/npppd/npppd/pap.c
+++ b/usr.sbin/npppd/npppd/pap.c
@@ -23,16 +23,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: pap.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: pap.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/**@file
- * Password Authentication Protocol (PAP) の実装
+ * This file provides Password Authentication Protocol (PAP) handlers.
* @author Yasuoka Masahiko
*/
-/*
- * Windows 2000 で PAP を行うと、8秒間に10個の AuthReq が届きタイムアウト
- * この値は CHAP の場合の半分以下なので、Radius 要求のタイムアウトの値は、
- * CHAP と PAP で別々に設定できたほうが良いかもしれない。
- */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -146,7 +141,7 @@ pap_stop(pap *_this)
return 0;
}
-/** PAP のパケット受信 */
+/** Receiving PAP packet */
int
pap_input(pap *_this, u_char *pktp, int lpktp)
{
@@ -177,15 +172,15 @@ pap_input(pap *_this, u_char *pktp, int lpktp)
return -1;
}
- /* ユーザ名を取り出し */
+ /* retribute the username */
#define remlen (lpktp - (pktp1 - pktp))
if (remlen < 1)
- goto reigai;
+ goto fail;
GETCHAR(len, pktp1);
if (len <= 0)
- goto reigai;
+ goto fail;
if (remlen < len)
- goto reigai;
+ goto fail;
if (len > 0)
memcpy(name, pktp1, len);
name[len] = '\0';
@@ -193,20 +188,20 @@ pap_input(pap *_this, u_char *pktp, int lpktp)
if (_this->state != PAP_STATE_STARTING) {
/*
- * まったく同じ要求を2度受け取った場合は、先方の再送による
- * もの。UserName が同じならば続行する。
+ * Receiving identical message again, it must be the message
+ * retransmit by the peer. Continue if the username is same.
*/
if ((_this->state == PAP_STATE_AUTHENTICATING ||
_this->state == PAP_STATE_SENT_RESPONSE) &&
strcmp(_this->name, name) == 0) {
- /* 続行 */
+ /* continue */
} else {
pap_log(_this, LOG_ERR,
"Received AuthReq is not same as before. "
"(%d,%s) != (%d,%s)", id, name, _this->auth_id,
_this->name);
_this->auth_id = id;
- goto reigai;
+ goto fail;
}
}
if (_this->state == PAP_STATE_AUTHENTICATING)
@@ -216,12 +211,12 @@ pap_input(pap *_this, u_char *pktp, int lpktp)
_this->state = PAP_STATE_AUTHENTICATING;
- /* パスワードを取り出し */
+ /* retribute the password */
if (remlen < 1)
- goto reigai;
+ goto fail;
GETCHAR(len, pktp1);
if (remlen < len)
- goto reigai;
+ goto fail;
if (len > 0)
memcpy(password, pktp1, len);
@@ -229,7 +224,7 @@ pap_input(pap *_this, u_char *pktp, int lpktp)
pap_authenticate(_this, password);
return 0;
-reigai:
+fail:
pap_response(_this, 0, DEFAULT_FAILURE_MESSAGE);
return -1;
}
@@ -242,7 +237,7 @@ pap_authenticate(pap *_this, const char *password)
if (!npppd_ppp_is_realm_ready(_this->ppp->pppd, _this->ppp)) {
pap_log(_this, LOG_INFO,
"username=\"%s\" realm is not ready.", _this->name);
- goto reigai;
+ goto fail;
/* NOTREACHED */
}
#if USE_NPPPD_RADIUS
@@ -258,7 +253,7 @@ pap_authenticate(pap *_this, const char *password)
/* NOTREACHED */
}
}
-reigai:
+fail:
pap_response(_this, 0, DEFAULT_FAILURE_MESSAGE);
}
@@ -310,7 +305,6 @@ pap_response(pap *_this, int authok, const char *mes)
"logtype=Failure username=\"%s\" realm=%s", _this->name,
realm);
pap_stop(_this);
- /* 失敗したら ppp 終了 */
ppp_stop_ex(_this->ppp, "Authentication Required",
PPP_DISCON_AUTH_FAILED, PPP_PROTO_PAP, 1 /* peer */, NULL);
} else {
@@ -321,12 +315,11 @@ pap_response(pap *_this, int authok, const char *mes)
realm);
pap_stop(_this);
ppp_auth_ok(_this->ppp);
- // 再送要求に答えるために pap_stop でのセットを上書きします。
+ /* reset the state to response request of retransmision. */
_this->state = PAP_STATE_SENT_RESPONSE;
}
}
-/** PAP認証 */
static void
pap_local_authenticate(pap *_this, const char *username, const char *password)
{
@@ -395,40 +388,37 @@ pap_radius_authenticate(pap *_this, const char *username, const char *password)
if ((rad_setting = npppd_get_radius_req_setting(_this->ppp->pppd,
_this->ppp)) == NULL)
- goto reigai;
+ goto fail;
if ((radpkt = radius_new_request_packet(RADIUS_CODE_ACCESS_REQUEST))
== NULL)
- goto reigai;
+ goto fail;
if (radius_prepare(rad_setting, _this, &radctx,
pap_radius_response, _this->ppp->auth_timeout) != 0) {
radius_delete_packet(radpkt);
- goto reigai;
+ goto fail;
}
if (ppp_set_radius_attrs_for_authreq(_this->ppp, rad_setting, radpkt)
!= 0)
- goto reigai;
+ goto fail;
if (radius_put_string_attr(radpkt, RADIUS_TYPE_USER_NAME,
npppd_ppp_get_username_for_auth(_this->ppp->pppd, _this->ppp,
username, buf0)) != 0)
- goto reigai;
+ goto fail;
if (_this->radctx != NULL)
radius_cancel_request(_this->radctx);
_this->radctx = radctx;
- /*
- * RADIUS User-Password アートリビュートの作成
- * (RFC 2865, "5.2. User-Password")
- */
+ /* Create RADIUS User-Password Attribute (RFC 2865, 5.2.) */
s = radius_get_server_secret(_this->radctx);
s_len = strlen(s);
- memset(pass, 0, sizeof(pass)); // null-padding
+ memset(pass, 0, sizeof(pass)); /* null padding */
passlen = MIN(strlen(password), sizeof(pass));
memcpy(pass, password, passlen);
if ((passlen % 16) != 0)
@@ -456,12 +446,12 @@ pap_radius_authenticate(pap *_this, const char *username, const char *password)
if (radius_put_raw_attr(radpkt, RADIUS_TYPE_USER_PASSWORD, pass,
passlen) != 0)
- goto reigai;
+ goto fail;
radius_request(_this->radctx, radpkt);
return;
-reigai:
+fail:
if (_this->radctx != NULL)
radius_cancel_request(_this->radctx);
pap_log(_this, LOG_ERR, "%s() failed: %m", __func__);
@@ -480,7 +470,7 @@ pap_radius_response(void *context, RADIUS_PACKET *pkt, int flags)
_this = context;
radctx = _this->radctx;
- _this->radctx = NULL; /* 大事 */
+ _this->radctx = NULL; /* important */
if (pkt == NULL) {
if (flags & RADIUS_REQUST_TIMEOUT) {
@@ -509,14 +499,14 @@ pap_radius_response(void *context, RADIUS_PACKET *pkt, int flags)
radctx, "bad authenticator");
goto auth_failed;
}
- // 認証 OK
+ /* Autentication succeeded */
pap_response(_this, 1, DEFAULT_SUCCESS_MESSAGE);
- ppp_proccess_radius_framed_ip(_this->ppp, pkt);
+ ppp_process_radius_framed_ip(_this->ppp, pkt);
radius_delete_packet(pkt);
return;
auth_failed:
- // 認証 NG
+ /* Autentication failure */
pap_log(_this, LOG_WARNING, "Radius authentication request failed: %s",
reason);
if (pkt != NULL)
diff --git a/usr.sbin/npppd/npppd/ppp.c b/usr.sbin/npppd/npppd/ppp.c
index 5b7014fcfc6..c2ee777c2d6 100644
--- a/usr.sbin/npppd/npppd/ppp.c
+++ b/usr.sbin/npppd/npppd/ppp.c
@@ -23,9 +23,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: ppp.c,v 1.2 2010/01/13 07:49:44 yasuoka Exp $ */
+/* $Id: ppp.c,v 1.3 2010/07/01 03:38:17 yasuoka Exp $ */
/**@file
- * {@link :: _npppd_ppp PPPインスタンス} に関する処理を提供します。
+ * This file provides PPP(Point-to-Point Protocol, RFC 1661) and
+ * {@link :: _npppd_ppp PPP instance} related functions.
*/
#include <sys/types.h>
#include <sys/socket.h>
@@ -87,15 +88,15 @@ static void ppp_on_network_pipex(npppd_ppp *);
#define AUTH_IS_EAP(ppp) ((ppp)->peer_auth == PPP_AUTH_EAP)
/*
- * 終了処理
- * ppp_lcp_finished LCP が終了
- * 先方が TermReq
- * こちらが TermReq (ppp_stop から状態遷移で)
- * ppp_phy_downed 物理層が切れた
+ * About termination procedures:
+ * ppp_lcp_finished LCP is terminated
+ * Terminate-Request by the peer.
+ * Terminate-Request by ourself. (From ppp_stop())
+ * ppp_phy_downed Down the datalink/physical.
*
- * どちらも ppp_stop0、ppp_down_others を呼び出している。
+ * On both cases, ppp_stop0 and ppp_down_others are called.
*/
-/** npppd_ppp オブジェクトを生成。 */
+/** Create a npppd_ppp instance */
npppd_ppp *
ppp_create()
{
@@ -116,8 +117,8 @@ ppp_create()
}
/**
- * npppd_ppp を初期化します。
- * npppd_ppp#mru npppd_ppp#phy_label は呼び出し前にセットしてください。
+ * Initialize the npppd_ppp instance
+ * Set npppd_ppp#mru and npppd_ppp#phy_label before call this function.
*/
int
ppp_init(npppd *pppd, npppd_ppp *_this)
@@ -150,9 +151,7 @@ ppp_init(npppd *pppd, npppd_ppp *_this)
_this->use_pipex = ppp_config_str_equal(_this, "pipex.enabled", "true",
1);
#endif
- /*
- * ログの設定を読み込む。
- */
+ /* load the logging configuration */
_this->log_dump_in =
ppp_config_str_equal(_this, "log.in.pktdump", "true", 0);
_this->log_dump_out =
@@ -167,7 +166,7 @@ ppp_init(npppd *pppd, npppd_ppp *_this)
pap_init(&_this->pap, _this);
chap_init(&_this->chap, _this);
- /* アイドルタイマー関連 */
+ /* load the idle timer configuration */
_this->timeout_sec = ppp_config_int(_this, "idle_timeout", 0);
if (!evtimer_initialized(&_this->idle_event))
evtimer_set(&_this->idle_event, ppp_idle_timeout, _this);
@@ -216,12 +215,9 @@ ppp_set_tunnel_label(npppd_ppp *_this, char *buf, int lbuf)
}
}
/**
- * npppd_ppp を開始します。
- * npppd_ppp#phy_context
- * npppd_ppp#send_packet
- * npppd_ppp#phy_close
- * npppd_ppp#phy_info
- * は呼び出し前にセットしてください。
+ * Start the npppd_ppp.
+ * Set npppd_ppp#phy_context, npppd_ppp#send_packet, npppd_ppp#phy_close and
+ * npppd_ppp#phy_info before call this function.
*/
void
ppp_start(npppd_ppp *_this)
@@ -235,9 +231,7 @@ ppp_start(npppd_ppp *_this)
_this->start_time = time(NULL);
_this->start_monotime = get_monosec();
- /*
- * 下位レイヤの情報をログに残す。
- */
+ /* log the lower layer information */
ppp_set_tunnel_label(_this, label, sizeof(label));
ppp_log(_this, LOG_INFO, "logtype=Started tunnel=%s(%s)",
_this->phy_label, label);
@@ -245,10 +239,7 @@ ppp_start(npppd_ppp *_this)
lcp_lowerup(&_this->lcp);
}
-/**
- * Dialin proxy の準備をします。dialin proxy できない場合には、0 以外が
- * 返ります。
- */
+/** Prepare "dialin proxy". Return 0 if "dialin proxy" is not available. */
int
ppp_dialin_proxy_prepare(npppd_ppp *_this, dialin_proxy_info *dpi)
{
@@ -295,10 +286,11 @@ ppp_stop(npppd_ppp *_this, const char *reason)
}
/**
- * PPP を停止し、npppd_ppp オブジェクトを破棄します。
- * @param reason 停止の理由。特に理由がなければ NULL を指定します。
- * この値で LCP の TermReq パケットの reason フィールドに格納されて、
- * 先方に通知されます。
+ * Stop the PPP and destroy the npppd_ppp instance
+ * @param reason Reason of stopping the PPP. Specify NULL if there is
+ * no special reason. This reason will be used as a
+ * reason field of LCP Terminate-Request message and
+ * notified to the peer.
* @param code disconnect code in {@link ::npppd_ppp_disconnect_code}.
* @param proto control protocol number. see RFC3145.
* @param direction disconnect direction. see RFC 3145
@@ -333,16 +325,13 @@ ppp_stop0(npppd_ppp *_this)
_this->phy_close = NULL;
/*
- * PPTP(GRE) の NAT/ブラックホール検出
+ * NAT/Blackhole detection for PPTP(GRE)
*/
if (_this->lcp.dialin_proxy != 0 &&
_this->lcp.dialin_proxy_lcp_renegotiation == 0) {
- /*
- * dialin-proxy、再ネゴシエーション無しでは LCPのやりとりは
- * ない
- */
- } else if (_this->lcp.recv_ress == 0) { // 応答なし
- if (_this->lcp.recv_reqs == 0) // 要求なし
+ /* No LCP packets on dialin proxy without LCP renegotiation */
+ } else if (_this->lcp.recv_ress == 0) { /* No responses */
+ if (_this->lcp.recv_reqs == 0) /* No requests */
ppp_log(_this, LOG_WARNING, "no PPP frames from the "
"peer. router/NAT issue? (may have filtered out)");
else
@@ -392,8 +381,8 @@ ppp_stop0(npppd_ppp *_this)
}
/**
- * npppd_ppp オブジェクトを破棄します。ppp_start をコール後は、ppp_stop() を
- * を使用し、この関数は使いません。
+ * Destroy the npppd_ppp instance. Don't use this function after calling
+ * the ppp_start, please use ppp_stop() instead.
*/
void
ppp_destroy(void *ctx)
@@ -402,9 +391,11 @@ ppp_destroy(void *ctx)
if (_this->proxy_authen_resp != NULL)
free(_this->proxy_authen_resp);
+
/*
- * ppp_stop しても、先方から PPP フレームが届き、また開始してしま
- * っている場合があるので、再度 down, stop
+ * Down/stop the protocols again to make sure they are stopped
+ * even if ppp_stop is done. They might be change their state
+ * by receiving packets from the peer.
*/
fsm_lowerdown(&_this->ccp.fsm);
fsm_lowerdown(&_this->ipcp.fsm);
@@ -418,7 +409,7 @@ ppp_destroy(void *ctx)
}
/************************************************************************
- * プロトコルに関するイベント
+ * Protocol events
************************************************************************/
static const char *
ppp_peer_auth_string(npppd_ppp *_this)
@@ -433,9 +424,7 @@ ppp_peer_auth_string(npppd_ppp *_this)
}
}
-/**
- * LCPがアップした場合に呼び出されます。
- */
+/** called when the lcp is up */
void
ppp_lcp_up(npppd_ppp *_this)
{
@@ -448,9 +437,9 @@ ppp_lcp_up(npppd_ppp *_this)
}
#endif
/*
- * 相手が大きな MRU を指定しても、自分の MRU 以下にする。ここで、
- * peer_mtu を縮めれると、経路 MTU が縮むので、MRU を越えるような
- * パケットは到達しないようになる。(ことを期待している)
+ * Use our MRU value even if the peer insists on larger value.
+ * We set the peer_mtu here, the value will be used as the MTU of the
+ * routing entry. So we will not receive packets larger than the MTU.
*/
if (_this->peer_mru > _this->mru)
_this->peer_mru = _this->mru;
@@ -479,8 +468,8 @@ ppp_lcp_up(npppd_ppp *_this)
}
/**
- * LCPが終了した場合に呼び出されます。
- * <p>STOPPED また CLOSED ステートに入った場合に呼び出されます。</p>
+ * This function will be called the LCP is terminated.
+ * (On entering STOPPED or CLOSED state)
*/
void
ppp_lcp_finished(npppd_ppp *_this)
@@ -494,11 +483,11 @@ ppp_lcp_finished(npppd_ppp *_this)
}
/**
- * 物理層が切断された場合に物理層から呼び出されます。
+ * This function will be called by the physical layer when it is down.
* <p>
- * 物理層が PPPフレームを入出力できないという状況でこの関数を呼び出して
- * ください。紳士的に PPP を切断する場合には、{@link ::#ppp_stop} を使い
- * ます。</p>
+ * Use this function only on such conditions that the physical layer cannot
+ * input or output PPP frames. Use {@link ::ppp_stop()} instead if we can
+ * disconnect PPP gently.</p>
*/
void
ppp_phy_downed(npppd_ppp *_this)
@@ -524,14 +513,14 @@ proto_name(uint16_t proto)
case PPP_PROTO_MPPE: return "mppe";
case PPP_PROTO_NCP | NCP_CCP: return "ccp";
case PPP_PROTO_NCP | NCP_IPCP: return "ipcp";
- // 以下ログ出力用
+ /* following protocols are just for logging */
case PPP_PROTO_NCP | NCP_IP6CP: return "ip6cp";
case PPP_PROTO_ACSP: return "acsp";
}
return "unknown";
}
-/** 認証が成功した場合に呼び出されます。*/
+/** This function is called on authentication succeed */
void
ppp_auth_ok(npppd_ppp *_this)
{
@@ -555,7 +544,7 @@ ppp_auth_ok(npppd_ppp *_this)
}
}
if (_this->peer_auth != 0) {
- /* ユーザ毎の最大接続数を制限する */
+ /* Limit the number of connections per the user */
if (!npppd_check_user_max_session(_this->pppd, _this)) {
ppp_log(_this, LOG_WARNING,
"user %s exceeds user-max-session limit",
@@ -592,7 +581,7 @@ ppp_auth_ok(npppd_ppp *_this)
return;
}
-/** event からコールバックされるイベントハンドラです */
+/** timer event handler for idle timer */
static void
ppp_idle_timeout(int fd, short evtype, void *context)
{
@@ -604,13 +593,12 @@ ppp_idle_timeout(int fd, short evtype, void *context)
ppp_stop(_this, NULL);
}
-/** アイドルタイマーをリセットします。アイドルでは無い場合に呼び出します。 */
+/** reset the idle-timer. Call this function when the PPP is not idle. */
void
ppp_reset_idle_timeout(npppd_ppp *_this)
{
struct timeval tv;
- //PPP_DBG((_this, LOG_INFO, "%s", __func__));
evtimer_del(&_this->idle_event);
if (_this->timeout_sec > 0) {
tv.tv_usec = 0;
@@ -620,7 +608,7 @@ ppp_reset_idle_timeout(npppd_ppp *_this)
}
}
-/** IPCP が完了した場合に呼び出されます */
+/** This function is called when IPCP is opened */
void
ppp_ipcp_opened(npppd_ppp *_this)
{
@@ -661,7 +649,7 @@ ppp_ipcp_opened(npppd_ppp *_this)
#endif
}
-/** CCP が Opened になった場合に呼び出されます。*/
+/** This function is called when CCP is opened */
void
ppp_ccp_opened(npppd_ppp *_this)
{
@@ -682,13 +670,13 @@ ppp_ccp_opened(npppd_ppp *_this)
}
/************************************************************************
- * ネットワーク I/O 関連
+ * Network I/O related functions
************************************************************************/
/**
- * パケット受信
- * @param flags 受信したパケットについての情報をフラグで表します。
- * 現在、PPP_IO_FLAGS_MPPE_ENCRYPTED が指定される場合があります。
- * @return 成功した場合に 0 が返り、失敗した場合に 1 が返ります。
+ * Receive the PPP packet.
+ * @param flags Indicate information of received packet by bit flags.
+ * {@link ::PPP_IO_FLAGS_MPPE_ENCRYPTED} may be used.
+ * @return return 0 on success. return 1 on failure.
*/
static int
ppp_recv_packet(npppd_ppp *_this, unsigned char *pkt, int lpkt, int flags)
@@ -717,18 +705,18 @@ ppp_recv_packet(npppd_ppp *_this, unsigned char *pkt, int lpkt, int flags)
if (!psm_opt_is_accepted(&_this->lcp, acfc) &&
_this->logged_no_address == 0) {
/*
- * パケット落ちが発生する環境では、こちらは LCP
- * が確立していないのに、Windows 側が完了していて、
- * ACFC されたパケットが届く。
+ * On packet loss condition, we may receive ACFC'ed
+ * packets before our LCP is opened because the peer's
+ * LCP is opened already.
*/
ppp_log(_this, LOG_INFO,
"%s: Rcvd broken frame. ACFC is not accepted, "
"but received ppp frame that has no address.",
__func__);
/*
- * Yamaha RTX-1000 では、ACFC を Reject するのに、
- * パケットにアドレスは入っていないので、ログが
- * 大量に出力されてしまう。
+ * Log this once because it may be noisy.
+ * For example, Yahama RTX-1000 refuses to use ACFC
+ * but it send PPP frames without the address field.
*/
_this->logged_no_address = 1;
}
@@ -769,7 +757,7 @@ ppp_recv_packet(npppd_ppp *_this, unsigned char *pkt, int lpkt, int flags)
return 2; /* handled by PIPEX */
case PPP_PROTO_NCP | NCP_CCP:
if (lpkt - (inp - pkt) < 4)
- break; /* エラーだが fsm.c で処理 */
+ break; /* error but do it on fsm.c */
if (*inp == 0x0e || /* Reset-Request */
*inp == 0x0f /* Reset-Ack */) {
return 2; /* handled by PIPEX */
@@ -781,40 +769,44 @@ ppp_recv_packet(npppd_ppp *_this, unsigned char *pkt, int lpkt, int flags)
}
#endif /* USE_NPPPD_PIPEX */
- // MPPE のチェック
switch (proto) {
#ifdef USE_NPPPD_MPPE
case PPP_PROTO_IP:
+ /* Checks for MPPE */
if ((flags & PPP_IO_FLAGS_MPPE_ENCRYPTED) == 0) {
if (MPPE_REQUIRED(_this)) {
- /* MPPE 必須なのに、生 IP。*/
+ /* MPPE is required but naked ip */
if (_this->logged_naked_ip == 0) {
ppp_log(_this, LOG_INFO,
"mppe is required but received "
"naked IP.");
- /* ログに残すのは最初の 1 回だけ */
+ /* log this once */
_this->logged_naked_ip = 1;
}
/*
- * Windows は、MPPE 未確立、IPCP 確立の状態で
- * 生IPパケットを投げてくる※1。CCP がパケット
- * ロスなどで確立が遅れた場合、高確率でこの状
- * 態に陥る。ここで ppp_stop する場合、パケット
- * ロスや順序入れ換えが発生する環境では、『繋
- * がらない』現象にみえる。
- * (※1 少なくとも Windows 2000 Pro SP4)
- ppp_stop(_this, "Encryption is required.");
+ * Windows sends naked IP packets in condition
+ * such that MPPE is not opened and IPCP is not
+ * opened(*1). This occurs at a high
+ * probability when the CCP establishment is
+ * delayed because of packet loss etc. If we
+ * call ppp_stop() here, Windows on the packet
+ * loss condition etc cannot not connect us.
+ * So we don't call ppp_stop() here.
+ * (*1) At least Microsof Windows 2000
+ * Professional SP4 does.
*/
+ /*ppp_stop(_this, "Encryption is required.");*/
+
return 1;
}
if (MPPE_READY(_this)) {
- /* MPPE 確立したのに、生 IP。*/
+ /* MPPE is opened but naked ip packet */
ppp_log(_this, LOG_WARNING,
- "mppe is avaliable but received naked IP.");
+ "mppe is available but received naked IP.");
}
}
- /* else MPPE からの入力 */
+ /* else input from MPPE */
break;
case PPP_PROTO_MPPE:
#ifdef USE_NPPPD_MPPE
@@ -868,7 +860,7 @@ ppp_recv_packet(npppd_ppp *_this, unsigned char *pkt, int lpkt, int flags)
lpkt - (inp - pkt));
goto handled;
}
- // ネゴする必要のない場合は Protocol Reject
+ /* protocol-reject if MPPE is not necessary */
#endif
break;
case NCP_IPCP: /* IPCP */
@@ -878,7 +870,7 @@ ppp_recv_packet(npppd_ppp *_this, unsigned char *pkt, int lpkt, int flags)
}
}
}
- /* ProtoRej ログに残す */
+ /* Protocol reject. Log it with protocol number */
ppp_log(_this, LOG_INFO, "unhandled protocol %s, %d(%04x)",
proto_name(proto), proto, proto);
@@ -902,7 +894,7 @@ handled:
return 0;
}
-/** PPPに出力する場合に呼び出します。 */
+/** This function is called to output PPP packets */
inline void
ppp_output(npppd_ppp *_this, uint16_t proto, u_char code, u_char id,
u_char *datap, int ldata)
@@ -912,15 +904,14 @@ ppp_output(npppd_ppp *_this, uint16_t proto, u_char code, u_char id,
outp = _this->outpacket_buf;
- /* LCPは圧縮を使わない */
+ /* No header compressions for LCP */
is_lcp = (proto == PPP_PROTO_LCP)? 1 : 0;
-
if (_this->has_acf == 0 ||
- (!is_lcp && psm_peer_opt_is_accepted(&_this->lcp, acfc))) {
+ (!is_lcp && psm_peer_opt_is_accepted(&_this->lcp, acfc))) {
/*
- * Address and Control Field (ACF) がそもそも無い場合や
- * ACFC がネゴされている場合は ACF を追加しない。
+ * Don't add ACF(Address and Control Field) if ACF is not
+ * needed on this link or ACFC is negotiated.
*/
} else {
PUTCHAR(PPP_ALLSTATIONS, outp);
@@ -977,8 +968,9 @@ ppp_output(npppd_ppp *_this, uint16_t proto, u_char code, u_char id,
}
/**
- * PPP 出力用のバッファ領域を返します。ヘッダ圧縮によるズレを補正します。
- * バッファ領域の長さは npppd_ppp#mru 以上です。
+ * Return the buffer space for PPP output. The returned pointer will be
+ * adjusted for header compression. The length of the space is larger than
+ * {@link npppd_ppp#mru}.
*/
u_char *
ppp_packetbuf(npppd_ppp *_this, int proto)
@@ -995,7 +987,7 @@ ppp_packetbuf(npppd_ppp *_this, int proto)
return _this->outpacket_buf + (PPP_HDRLEN - save);
}
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/** Record log that begins the label based this instance. */
int
ppp_log(npppd_ppp *_this, int prio, const char *fmt, ...)
{
@@ -1017,11 +1009,11 @@ ppp_log(npppd_ppp *_this, int prio, const char *fmt, ...)
#ifdef USE_NPPPD_RADIUS
#define UCHAR_BUFSIZ 255
/**
- * RADIUS パケットの Framed-IP-Address アートリビュートと Framed-IP-Netmask
- * アートリビュートを処理します。
+ * Process the Framed-IP-Address attribute and the Framed-IP-Netmask
+ * attribute of given RADIUS packet.
*/
void
-ppp_proccess_radius_framed_ip(npppd_ppp *_this, RADIUS_PACKET *pkt)
+ppp_process_radius_framed_ip(npppd_ppp *_this, RADIUS_PACKET *pkt)
{
struct in_addr ip4;
@@ -1036,8 +1028,8 @@ ppp_proccess_radius_framed_ip(npppd_ppp *_this, RADIUS_PACKET *pkt)
}
/**
- * RADIUS 認証要求用の RADIUSアートリビュートをセットします。
- * 成功した場合には 0 が返ります。
+ * Set RADIUS attributes for RADIUS authentication request.
+ * Return 0 on success.
*/
int
ppp_set_radius_attrs_for_authreq(npppd_ppp *_this,
@@ -1045,17 +1037,17 @@ ppp_set_radius_attrs_for_authreq(npppd_ppp *_this,
{
/* RFC 2865 "5.4 NAS-IP-Address" or RFC3162 "2.1. NAS-IPv6-Address" */
if (radius_prepare_nas_address(rad_setting, radpkt) != 0)
- goto reigai;
+ goto fail;
/* RFC 2865 "5.6. Service-Type" */
if (radius_put_uint32_attr(radpkt, RADIUS_TYPE_SERVICE_TYPE,
RADIUS_SERVICE_TYPE_FRAMED) != 0)
- goto reigai;
+ goto fail;
/* RFC 2865 "5.7. Framed-Protocol" */
if (radius_put_uint32_attr(radpkt, RADIUS_TYPE_FRAMED_PROTOCOL,
RADIUS_FRAMED_PROTOCOL_PPP) != 0)
- goto reigai;
+ goto fail;
if (_this->calling_number[0] != '\0') {
if (radius_put_string_attr(radpkt,
@@ -1063,13 +1055,13 @@ ppp_set_radius_attrs_for_authreq(npppd_ppp *_this,
return 1;
}
return 0;
-reigai:
+fail:
return 1;
}
#endif
#ifdef USE_NPPPD_PIPEX
-/** Network が有効になった時の callback 関数 PIPEX 用*/
+/** The callback function on network is available for pipex */
static void
ppp_on_network_pipex(npppd_ppp *_this)
{
@@ -1083,13 +1075,13 @@ ppp_on_network_pipex(npppd_ppp *_this)
if (_this->assigned_ip4_enabled != 0 &&
(!MPPE_MUST_NEGO(_this) || _this->ccp.fsm.state == OPENED)) {
- /* IPCP が完了し,MPPE 不要または MPPE 完了した場合 */
+ /* IPCP is opened and MPPE is not required or MPPE is opened */
npppd_ppp_pipex_enable(_this->pppd, _this);
ppp_log(_this, LOG_NOTICE, "Using pipex=%s",
(_this->pipex_enabled != 0)? "yes" : "no");
_this->pipex_started = 1;
}
- /* else CCP or IPCP 待ち */
+ /* else wait CCP or IPCP */
}
#endif
@@ -1097,7 +1089,7 @@ ppp_on_network_pipex(npppd_ppp *_this)
#ifdef USE_NPPPD_LINKID
#include "linkid.h"
#endif
-/** 端末IDをセットします */
+/** Set client authentication Id */
void
ppp_set_client_auth_id(npppd_ppp *_this, const char *client_auth_id)
{
diff --git a/usr.sbin/npppd/npppd/ppp.h b/usr.sbin/npppd/npppd/ppp.h
index 32090bc1e59..38774146c24 100644
--- a/usr.sbin/npppd/npppd/ppp.h
+++ b/usr.sbin/npppd/npppd/ppp.h
@@ -97,30 +97,28 @@
#define INADDR_USER_SELECT (htonl(0xFFFFFFFFL))
#define INADDR_NAS_SELECT (htonl(0xFFFFFFFEL))
-/** トンネルタイプ定数 */
-#define PPP_TUNNEL_NONE 0 /** トンネルタイプ無し */
-#define PPP_TUNNEL_L2TP 1 /** L2TP トンネルタイプ */
-#define PPP_TUNNEL_PPTP 2 /** PPTP トンネルタイプ */
-#define PPP_TUNNEL_PPPOE 3 /** PPPoE トンネルタイプ */
+/** Constants of tunnel type */
+#define PPP_TUNNEL_NONE 0 /** None Tunnel Type */
+#define PPP_TUNNEL_L2TP 1 /** L2TP Tunnel Type */
+#define PPP_TUNNEL_PPTP 2 /** PPTP Tunnel Type */
+#define PPP_TUNNEL_PPPOE 3 /** PPPoE Tunnel Type */
-/** デフォルトの LCP ECHO 試行間隔(sec) */
+/** Default LCP ECHO interval (sec) */
#define DEFAULT_LCP_ECHO_INTERVAL 300
-/** デフォルトの LCP ECHO 再試行間隔(sec) */
+/** Default LCP ECHO retry interval (sec) */
#define DEFAULT_LCP_ECHO_RETRY_INTERVAL 60
-/** デフォルトの LCP ECHO 再試行回数(sec) */
+/** Default LCP ECHO number of retry */
#define DEFAULT_LCP_ECHO_MAX_RETRIES 3
-/** MRU に MPPE/CCP ヘッダ分が含まれているかどうか */
+/** MRU includes MPPE/CCP header (XXX delete this) */
/* #define MRU_INCLUDES_MPPE_CCP */
-/** length for phone number */
+/** Length for phone number */
#define NPPPD_PHONE_NUMBER_LEN 32
-/**
- * PPP Disconnect Codes based on RFC 3145
- */
+/** PPP Disconnect Codes based on RFC 3145 */
typedef enum _npppd_ppp_disconnect_code {
/*
* 3.1. Global Errors
@@ -233,12 +231,10 @@ typedef struct _npppd_ppp npppd_ppp;
#include <radius_req.h>
#endif
-/**
- * LCP の型
- */
+/** Type for LCP */
typedef struct _lcp {
fsm fsm;
- /** LCP オプション */
+ /** LCP options */
struct _opt {
uint8_t mru;
uint8_t pfc;
@@ -249,52 +245,50 @@ typedef struct _lcp {
uint8_t chapms_v2;
uint8_t eap;
} opt;
- /** 最後の認証方式の提案 */
+ /** Authentication method of the last Configure-Request */
uint32_t lastauth;
- /** マジック番号 */
+ /** Magic number */
uint32_t magic_number;
- /** 先方のマジック番号 */
+ /** Peer's magic number */
uint32_t peer_magic_number;
/** context for event(3) */
struct evtimer_wrap timerctx;
- /** echo の送信間隔(秒) */
+ /** echo internval (sec) */
int echo_interval;
- /** echo の最大連続失敗回数 */
+ /** echo max retries */
int echo_max_retries;
- /** echo reply を待つ時間 */
+ /** wait to echo repy (sec) */
int echo_retry_interval;
- /** echo の失敗回数 */
+ /** failure count of echo */
int echo_failures;
- // NAT/ブラックホール検出のために
- /** 受信した LCP 要求 */
+ /* for NAT/Blackhole detection */
+ /** received LCP requests */
int8_t recv_reqs;
- /** 受信した LCP の応答 */
+ /** received LCP responses */
int8_t recv_ress;
+
/*
- * Windows 2000 は ConfigReq に MRU は含まれず、送信した ConfigReq
- * にたいして Nak を返してくる。
+ * XXX
*/
uint32_t xxxmru;
- /** 認証メソッド順 */
+ /** order of authentication methods */
int auth_order[16];
- uint32_t /** dialin proxy したかどうか */
+ uint32_t /** doing dialin proxy */
dialin_proxy:1,
- /** LCP を再調停するかどうか */
+ /** do lcp renegotiation? */
dialin_proxy_lcp_renegotiation:1;
} lcp;
-/**
- * CHAP の型
- */
+/** Type for CHAP */
typedef struct _chap {
npppd_ppp *ppp;
/** context for event(3) */
@@ -315,9 +309,7 @@ typedef struct _chap {
#endif
} chap;
-/**
- * PAP の型
- */
+/** Type for PAP */
typedef struct _pap {
npppd_ppp *ppp;
uint32_t state;
@@ -328,9 +320,7 @@ typedef struct _pap {
#endif
} pap;
-/**
- * EAP
- */
+/** Type for EAP */
#ifdef USE_NPPPD_EAP_RADIUS
#define PPP_EAP_FLAG_NAK_RESPONSE 0x01
typedef struct _eap {
@@ -355,9 +345,7 @@ typedef struct _eap {
} eap;
#endif
-/**
- * CCP の型
- */
+/** Type for CCP */
typedef struct _ccp {
npppd_ppp *ppp;
fsm fsm;
@@ -367,9 +355,7 @@ typedef struct _ccp {
uint mppe_rej;
} ccp;
-/**
- * IPCP の型
- */
+/** Type for IPCP */
typedef struct _ipcp {
fsm fsm;
npppd_ppp *ppp;
@@ -382,7 +368,7 @@ typedef struct _ipcp {
struct in_addr nbns_sec;
} ipcp;
-/** パケットの recv/send 等デリゲートする際に使う関数ポインタ */
+/** Function pointer to delegate packet send/recv */
typedef int (*npppd_iofunc) (
npppd_ppp *ppp,
unsigned char *bytes,
@@ -390,7 +376,7 @@ typedef int (*npppd_iofunc) (
int flags
);
-/** オリジナルのパケットは MPPE で暗号化されていたことを示します。 */
+/** Flag indicates the orignal packet was encrypted by MPPE */
#define PPP_IO_FLAGS_MPPE_ENCRYPTED 0x0001
typedef void (*npppd_voidfunc) (
@@ -417,9 +403,7 @@ typedef struct _mppe_rc4 {
uint8_t session_key[MPPE_KEYLEN];
} mppe_rc4_t;
-/**
- * MPPE の型
- */
+/** Type for MPPE */
typedef struct _mppe {
npppd_ppp *ppp;
uint8_t master_key[MPPE_KEYLEN];
@@ -429,8 +413,8 @@ typedef struct _mppe {
/*
* configuration parameters.
*/
- uint16_t enabled :1, /* if 0 MPPE しない */
- required :1, /* if 1 MPPE なしで通信不可*/
+ uint16_t enabled :1, /* if 0 No MPPE */
+ required :1, /* if 1 MPPE is optional */
mode_auto :1,
keylen_auto :1,
mode_stateless :1,
@@ -441,9 +425,7 @@ typedef struct _mppe {
} mppe;
#endif
-/**
- * Type for phone number. Can be to use as a struct sockaddr.
- */
+/** Type for phone number. Can be to use as a struct sockaddr. */
typedef struct _npppd_phone_number {
#define NPPPD_AF_PHONE_NUMBER (AF_MAX + 0)
/** total length */
@@ -454,55 +436,45 @@ typedef struct _npppd_phone_number {
char pn_number[NPPPD_PHONE_NUMBER_LEN + 1];
} npppd_phone_number;
-/**
- * npppd_ppp 型。
- */
+/** Type for PPP */
struct _npppd_ppp {
npppd *pppd;
int id;
- /*
- * 入出力
- */
- uint8_t *outpacket_buf; /** 出力バッファ */
- npppd_iofunc send_packet; /** send to phy */
- npppd_iofunc recv_packet; /** recv from phy */
+ /* Input and output */
+ uint8_t *outpacket_buf; /** buffer space for output */
+ npppd_iofunc send_packet; /** send to physical layer */
+ npppd_iofunc recv_packet; /** recv from physical layer */
- /** アイドルタイムアウトイベント */
+ /** event context for idle-timer's timer */
struct event idle_event;
- /** アイドルタイムアウトの値 */
+ /** idle-timer value (sec) */
int timeout_sec;
- /*
- * 物理層
- */
- int tunnel_type; /** PPPトンネルタイプ */
+
+ /** Physical layer */
+ int tunnel_type; /** PPP Tunnel TYpe */
uint16_t mru; /** MRU */
uint16_t peer_mru; /** Peer's MRU */
- void *phy_context; /** 物理層のコンテキスト */
- char phy_label[16]; /** 物理層のラベル */
+ void *phy_context; /** Context of physical layer */
+ char phy_label[16]; /** Label for physical layer */
union {
struct sockaddr_in peer_in;/** {L2TP,PPTP}/IPv4 */
#if defined(USE_NPPPD_PPPOE)
struct sockaddr_dl peer_dl;/** PPPoE */
#endif
npppd_phone_number peer_pn;/** DialIn */
- } phy_info; /** 物理層の情報 */
+ } phy_info; /** Info of physical layer */
char calling_number[NPPPD_PHONE_NUMBER_LEN + 1];
npppd_voidfunc phy_close; /** close line */
/*
- * 切断。以下のどのケースでも、phy_close が呼ばれます。
- * - PPP側から切断
- * - 物理層側から ppp_close
- * - 物理層側から ppp_phy_downed
- *
- * phy_close が呼ばれた直後に ppp は解放されるので、以後アクセスして
- * はいけない。
+ * phy_close() will be called by any cases disconnecting. ppp will be
+ * freed just after phy_close() is called. Don't touch the ppp after
+ * then.
*/
- /** 認証レルム */
+ /** authentication realm */
void *realm;
- /*
- * プロトコル
- */
+
+ /* protocols */
lcp lcp; /** lcp */
chap chap; /** chap */
pap pap; /** pap */
@@ -512,8 +484,8 @@ struct _npppd_ppp {
ccp ccp; /** ccp */
ipcp ipcp; /** ccp */
- char username[MAX_USERNAME_LENGTH]; /** リモートユーザ名 */
- int ifidx; /** 集約インタフェースの index*/
+ char username[MAX_USERNAME_LENGTH]; /** Remote username */
+ int ifidx; /** interface index */
/** Proxy Authen Response */
u_char *proxy_authen_resp;
@@ -521,7 +493,7 @@ struct _npppd_ppp {
int lproxy_authen_resp;
/**
- * 先方に要求する認証方式
+ * Authentication methods that requires to the peer.
* <pre>
* PAP 0xC023
* EAP 0xC227
@@ -537,78 +509,79 @@ struct _npppd_ppp {
uint8_t mppe_started;
mppe mppe;
#endif
- /** 割り当てる/たIPアドレス */
+ /** Assiging/Assigned IP Address */
struct sockaddr_npppd snp;
#define ppp_framed_ip_address snp.snp_addr
#define ppp_framed_ip_netmask snp.snp_mask
#define ppp_ip_assigned(p) (p->ppp_framed_ip_address.s_addr != 0)
- /** 割り当てで使用したプール */
+ /** Address pool used by IP asssignment */
void *assigned_pool;
struct in_addr realm_framed_ip_address;
struct in_addr realm_framed_ip_netmask;
- uint8_t /** Address and Control Filed があるか */
+ uint8_t /** data link have the Address and Control Field? */
has_acf:1,
- /** TCP MSS を MRU 以下に調整するかどうか */
+ /** adjust TCP MSS to smaller than the MRU? */
adjust_mss:1,
- /** 認証は一回限り */
+ /** authentication once */
auth_runonce:1,
- /** PIPEX を使うかどうか */
+ /** use pipex? */
use_pipex:1,
- /** PIPEX を開始したかどうか(使えたかどうかは別) */
+ /** pipex is started? (even if it is not available) */
pipex_started:1,
- /** PIPEX を使っているかどうか */
+ /** pipex is enabled? */
pipex_enabled:1,
reserved:3;
- uint8_t /** 動的割り当てかどうか */
+ uint8_t /** IP address is assigned from dynamic address pool */
assign_dynapool:1,
- /** 割り当てたアドレスが有効かどうか */
+ /** assigned IP address is enabled? */
assigned_ip4_enabled:1,
assigned_ip4_rcvd:6;
- /** 入力パケットをダンプするか */
- uint8_t log_dump_in:1,
- /** 出力パケットをダンプするか */
+ uint8_t /** dump input packet? */
+ log_dump_in:1,
+ /** dump output packet? */
log_dump_out:1,
log_rcvd:6;
- uint8_t /** 生IPが流れたというログを出力済みかどうか */
+ uint8_t /** "receiving naked IP packet" is logged already? */
logged_naked_ip:1,
- /** 課金開始のログを出力したかどうか */
+ /** "accounting start" is logged already? */
logged_acct_start:1,
/**
- * Addressフィルードが無いというログを出力済かどうか。
+ * "receiving packet without address field" is logged
+ * already?
*/
logged_no_address:1,
logged_rcvd:5;
#ifdef NPPPD_USE_CLIENT_AUTH
-/** 端末認証 ID の長さ */
+/** Length of client authentication ID */
#define NPPPD_CLIENT_AUTH_ID_MAXLEN 32
char client_auth_id[NPPPD_CLIENT_AUTH_ID_MAXLEN + 1];
int has_client_auth_id;
#endif
/*
- * 統計情報
+ * Statistical informations
*/
- /** 開始時刻 */
+ /** Start time */
time_t start_time;
- /** 開始時刻(相対時間) */
+ /** Start time (in monotime) */
time_t start_monotime;
- /** 終了時刻(相対時間) */
+ /** End time (in monotime) */
time_t end_monotime;
- /** 入力パケット数 */
+ /** Number of input packets */
uint32_t ipackets;
- /** 出力パケット数 */
+ /** Number of output packets */
uint32_t opackets;
- /** 入力エラーパケット数 */
+ /** Number of input error packets */
uint32_t ierrors;
- /** 出力エラーパケット数 */
+ /** Number of output error packets */
uint32_t oerrors;
- /** 入力パケットバイト*/
+ /** Number of input packet bytes */
uint64_t ibytes;
- /** 出力パケットバイト*/
+ /** Number of output packet bytes */
uint64_t obytes;
/*
@@ -655,20 +628,20 @@ typedef struct _dialin_proxy_info {
#define DIALIN_PROXY_IS_REQUESTED(dpi) \
(((dpi)->last_sent_lcp.ldata > 0)? 1 : 0)
-/** MPPE をネゴすべき */
+/** MPPE must be negotiated */
#define MPPE_MUST_NEGO(ppp) \
(((ppp)->mppe.enabled != 0) && \
(((ppp)->peer_auth == PPP_AUTH_CHAP_MS_V2) || \
((ppp)->peer_auth == PPP_AUTH_EAP)))
-/** MPPE 必須 */
+/** MPPE is required */
#define MPPE_REQUIRED(ppp) \
(((ppp)->mppe.enabled != 0) && ((ppp)->mppe.required != 0))
-/** MPPE 利用可 */
+/** MPPE is ready to use */
#define MPPE_READY(ppp) ((ppp)->mppe_started != 0)
-/* NetBSD:/usr/src/usr.sbin/pppd/pppd/pppd.h より。*/
+/* Adapted from NetBSD:/usr/src/usr.sbin/pppd/pppd/pppd.h */
/*
* Inline versions of get/put char/short/long.
* Pointer is advanced; we assume that both arguments
@@ -729,34 +702,34 @@ typedef struct _dialin_proxy_info {
#endif
/*
- * MRU は MPPE/CCP ヘッダをカバーするかどうか。
+ * Does MRU cover MPPE/CCP header?
*
* RFC 1331:
- * The Maximum-Receive-Unit covers only the Data Link Layer
- * Information field. It does not include the header,
- * padding, FCS, nor any transparency bits or bytes.
+ * The Maximum-Receive-Unit covers only the Data Link Layer Information
+ * field. It does not include the header, padding, FCS, nor any
+ * transparency bits or bytes.
*
- * Windows XP:
- * MRU で通知する値と、Windows が TCP MSS として使う値を比較すると、
- * 単純に 40 (IPヘッダとTCPヘッダ) バイトの差だけである。つまり、セ
- * グメントサイズが MSS ぴったりの TCP パケットを送信すると、その PPP
- * パケットは、MRU + 4 オクテットとなる。MPPE を使わない場合は、ぴっ
- * たり MRU となる。
+ * On Windows XP:
+ * Comparing the MRU indicated by Windows and TCP MSS indicated by the
+ * same Windows, Windows uses MRU minus 40 octets as a TCP MSS value
+ * simply. So a TCP/IP packet that has max segment size with MPPE
+ * requires MRU + 4 octets. If the packet witout MPPE requires just MRU
+ * octets.
*
- * 「MRU は MPPE/CCP ヘッダをカバーする」と実装した場合、このホスト上で、
- * MRU + 4 とならないような動作を行わねばならないことになる。
+ * If MRU doesn't cover MPPE/CCP header, we need to avoid sending MRU + 4
+ * octets packet.
*/
#if !defined(USE_NPPPD_MPPE)
-/* MPPE 使わない場合は何もしない */
+/* Do nothing if we don't do MPPE */
#define MRU_IPMTU(mru) (mru)
#define MRU_PKTLEN(mru, proto) (mru)
#else
#ifdef MRU_INCLUDES_MPPE_CCP
-/* MRU は MPPE/CCP ヘッダをカバーする */
+/* MRU covers MPPE/CCP header */
#define MRU_IPMTU(mru) ((mru) - CCP_MPPE_HEADER_LEN)
#define MRU_PKTLEN(mru, proto) (mru)
#else
-/* MRU は MPPE/CCP ヘッダをカバーしない */
+/* MRU doesn't cover MPPE/CCP header */
#define MRU_IPMTU(mru) (mru)
#define MRU_PKTLEN(mru, proto) (((proto) == PPP_PROTO_MPPE) \
? (mru) + CCP_MPPE_HEADER_LEN : (mru))
@@ -794,7 +767,7 @@ int ppp_config_str_equali (npppd_ppp *, const char *, const char *, int
int ppp_log (npppd_ppp *, int, const char *, ...) __printflike(3,4);
void ppp_reset_idle_timeout(npppd_ppp *);
#ifdef USE_NPPPD_RADIUS
-void ppp_proccess_radius_framed_ip (npppd_ppp *, RADIUS_PACKET *);
+void ppp_process_radius_framed_ip (npppd_ppp *, RADIUS_PACKET *);
int ppp_set_radius_attrs_for_authreq (npppd_ppp *, radius_req_setting *, RADIUS_PACKET *);
#endif
void ppp_set_client_auth_id(npppd_ppp *, const char *);
diff --git a/usr.sbin/npppd/npppd/psm-opt.h b/usr.sbin/npppd/npppd/psm-opt.h
index b7a36657381..b52ee5faddc 100644
--- a/usr.sbin/npppd/npppd/psm-opt.h
+++ b/usr.sbin/npppd/npppd/psm-opt.h
@@ -27,28 +27,21 @@
#define PSM_H 1
/**@file
- * <p>PPPステートマシンのオプションのネゴシエーション状態を保持、変更するための
- * マクロ。</p>
- * <p>
- * オプションは LCP、CCP など fsm から導出された型に保持する。
- * <pre>
- * struct lcp {
- * fsm fsm;
- * struct {
- * uint8_t pfc;
- * uint8_t acfc;
- * } opt;
- * };</pre></p>
- * <p>
- * 使用例:
- * <pre>
- * if (!psm_opt_is_accepted(_this->lcp, pcf)) {
- * // LCP の Protocol Field Compression を accept している
- * }</pre></p>
- * <p>
- * fsm ではなく、導出されたクラスに保持することにしたので、fsm という名前
- * は使わず psm のサフィックスを使った。</p>
- * $Id: psm-opt.h,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+ * This files provides helper macros for negotiating configuration options.
+ *<p>Example:<pre>
+ * struct lcp {
+ * struct {
+ * uint8_t pfc; // bit flags for LCP PFC option
+ * uint8_t acfc; // bit flags for LCP ACFC option
+ * } opt;
+ * }
+ * if (psm_opt_is_accepted(lcp, pfc)) {
+ * // We've accepted "Protocol Field Compression" option.
+ * }
+ * // Mark peer rejects "Address and Control Field Compression" option.
+ * psm_peer_opt_set_reject(lcp, acfc, true)
+ * </pre></p>
+ * $Id: psm-opt.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
#define PSM_OPT_REQUEST_OURS 0x01
diff --git a/usr.sbin/npppd/npppd/radius+.c b/usr.sbin/npppd/npppd/radius+.c
index 35de1c72bb4..4d7ead7406c 100644
--- a/usr.sbin/npppd/npppd/radius+.c
+++ b/usr.sbin/npppd/npppd/radius+.c
@@ -84,8 +84,10 @@ static int radius_ensure_add_capacity(RADIUS_PACKET* packet, size_t capacity)
size_t newsize;
void* newptr;
- // 最大サイズは 64KB
- // 安全のため(?)、少し小さい値をリミットにしている。
+ /*
+ * The maximum size is 64KB.
+ * We use little bit smaller value for our safety(?).
+ */
if(ntohs(packet->pdata->length) + capacity > 0xfe00)
return 1;
@@ -203,7 +205,7 @@ int radius_check_response_authenticator(const RADIUS_PACKET* packet,
MD5_CTX ctx;
unsigned char authenticator0[16];
- /* 呼び出し前に必ず radius_set_request_packet*/
+ /* Assume radius_set_request_packet() was called before calling */
if (packet->request == NULL)
return -1;
diff --git a/usr.sbin/npppd/npppd/radius_chap_const.h b/usr.sbin/npppd/npppd/radius_chap_const.h
index 1ab69485fe4..1756c5b4cc2 100644
--- a/usr.sbin/npppd/npppd/radius_chap_const.h
+++ b/usr.sbin/npppd/npppd/radius_chap_const.h
@@ -23,9 +23,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/*
- * idsrv/idradiusd より。
- */
#pragma pack(1)
struct RADIUS_CHAP_PASSWORD {
@@ -55,10 +52,11 @@ struct RADIUS_MS_CHAP2_SUCCESS {
struct RADIUS_MPPE_KEY {
char salt[2];
- char key[253]; /*
- * key は RFC では 16 * n byteの長さ,
- * ここでは salt + key = 255 byte (radius attribute サイズ)
- */
+ char key[253];
+ /*
+ * XXX: Having maximum size for RADIUS attribute is required to prevent
+ * XXX: oveflow by radius_get_vs_raw_attr().
+ */
};
struct RADIUS_MS_CHAP2_ERROR {
diff --git a/usr.sbin/npppd/npppd/radius_common.c b/usr.sbin/npppd/npppd/radius_common.c
index 010557c4a60..0d981cb08f1 100644
--- a/usr.sbin/npppd/npppd/radius_common.c
+++ b/usr.sbin/npppd/npppd/radius_common.c
@@ -23,11 +23,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
/**@file
- * RADIUS 関連共通関数。
- *
+ * This file provides functions commonly used for RADIUS request.
* @author Yasuoka Masahiko
- * $Id: radius_common.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+ * $Id: radius_common.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -46,7 +46,6 @@
#include "radius_common.h"
-/** RADIUS パケットの Framed-IP-Address アートリビュートを処理します。 */
void
ppp_proccess_radius_framed_ip_address(npppd_ppp *_this, RADIUS_PACKET *pkt)
{
@@ -66,7 +65,6 @@ ppp_proccess_radius_framed_ip_address(npppd_ppp *_this, RADIUS_PACKET *pkt)
}
-/** npppd に設定された {@link ::radius_req_setting} を取り出します。 */
radius_req_setting *
npppd_get_radius_req_setting(npppd *_this)
{
diff --git a/usr.sbin/npppd/npppd/radius_req.c b/usr.sbin/npppd/npppd/radius_req.c
index f58aef23583..70888b86425 100644
--- a/usr.sbin/npppd/npppd/radius_req.c
+++ b/usr.sbin/npppd/npppd/radius_req.c
@@ -23,11 +23,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: radius_req.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
/**@file
- * radius+ ライブラリと event(3) を組み合わせた、RADIUS 要求のためのユーティ
- * リティ。
+ * This file provides functions for RADIUS request using radius+.c and event(3).
* @author Yasuoka Masahiko
+ * $Id: radius_req.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -76,9 +75,8 @@ static int select_srcaddr(struct sockaddr const *, struct sockaddr *, socklen_t
#endif
/**
- * RADIUS リクエストを送信します。指定した pkt(RADIUS パケット) は、この実装
- * 内部で解放されます。
- * @param pkt 要求する RADIUS パケット。
+ * Send RADIUS request message. The pkt(RADIUS packet) will be released
+ * by this implementation.
*/
void
radius_request(RADIUS_REQUEST_CTX ctx, RADIUS_PACKET *pkt)
@@ -97,10 +95,9 @@ radius_request(RADIUS_REQUEST_CTX ctx, RADIUS_PACKET *pkt)
}
/**
- * NAS-IP-Address または NAS-IPv6-Address を準備します。
- * setting->server[setting->curr_server].sock にローカルアドレスがセッ
- * トされていない場合には、サーバのアドレスから自動でローカルアドレスを
- * セットします。
+ * Prepare NAS-IP-Address or NAS-IPv6-Address. If
+ * setting->server[setting->curr_server].sock is not initialized, address
+ * will be selected automatically.
*/
int
radius_prepare_nas_address(radius_req_setting *setting,
@@ -128,12 +125,12 @@ radius_prepare_nas_address(radius_req_setting *setting,
&setting->server[setting->curr_server].peer,
(struct sockaddr *)sin4, &socklen) != 0) {
RADIUS_REQ_ASSERT("NOTREACHED" == NULL);
- goto reigai;
+ goto fail;
}
}
if (radius_put_ipv4_attr(pkt, RADIUS_TYPE_NAS_IP_ADDRESS,
sin4->sin_addr) != 0)
- goto reigai;
+ goto fail;
break;
case AF_INET6:
socklen = sizeof(*sin6);
@@ -142,37 +139,35 @@ radius_prepare_nas_address(radius_req_setting *setting,
&setting->server[setting->curr_server].peer,
(struct sockaddr *)sin4, &socklen) != 0) {
RADIUS_REQ_ASSERT("NOTREACHED" == NULL);
- goto reigai;
+ goto fail;
}
}
if (radius_put_raw_attr(pkt, RADIUS_TYPE_NAS_IPV6_ADDRESS,
sin6->sin6_addr.s6_addr, sizeof(sin6->sin6_addr.s6_addr))
!= 0)
- goto reigai;
+ goto fail;
break;
}
return 0;
-reigai:
+fail:
return 1;
}
/**
- * RADIUS リクエストを送信する準備を行います。
- * <p>
- * 応答があった場合やタイムアウトなどのエラーは、指定した関数を呼び出(コール
- * バック)して通知します。</p>
- * <p>
- * pctx に書き出されるコンテキストと応答コールバック関数で指定される
- * 応答パケットは、この実装内部で解放されます。</p>
- * @param setting RADIUS サーバや問い合わせの設定
- * @param context 呼び出し側コンテキスト
- * @param pctx RADIUS リクエストコンテキスト(RADIUS_REQUEST_CTX)
- * を書き出す領域を指定します。キャンセルする場合などに、
- * 使用します。NULL を指定しても構いません。
- * @param response_fn 応答を受信あるいはタイムアウトした時に呼び出す関数を
- * 関数ポインタで指定します。
- * @param timeout 応答タイムアウトまでの秒数
+ * Prepare sending RADIUS request. This implementation will call back to
+ * notice that it receives the response or it fails for timeouts to the
+ * The context that is set as 'pctx' and response packet that is given
+ * by the callback function will be released by this implementation internally.
+ * @param setting Setting for RADIUS server or request.
+ * @param context Context for the caller.
+ * @param pctx Pointer to the space for context of RADIUS request
+ * (RADIUS_REQUEST_CTX). This will be used for canceling.
+ * NULL can be specified when you don't need.
+ * @param response_fn Specify callback function as a pointer. The function
+ * will be called when it receives a response or when
+ * request fails for timeouts.
+ * @param timeout response timeout in second.
*/
int
radius_prepare(radius_req_setting *setting, void *context,
@@ -189,12 +184,12 @@ radius_prepare(radius_req_setting *setting, void *context,
return 1;
if ((lap = malloc(sizeof(struct overlapped))) == NULL) {
log_printf(LOG_ERR, "malloc() failed in %s: %m", __func__);
- goto reigai;
+ goto fail;
}
sin6 = &setting->server[setting->curr_server].peer.sin6;
if ((sock = socket(sin6->sin6_family, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
log_printf(LOG_ERR, "socket() failed in %s: %m", __func__);
- goto reigai;
+ goto fail;
}
memset(lap, 0, sizeof(struct overlapped));
memcpy(&lap->ss, &setting->server[setting->curr_server].peer,
@@ -211,7 +206,7 @@ radius_prepare(radius_req_setting *setting, void *context,
*pctx = lap;
return 0;
-reigai:
+fail:
if (lap != NULL)
free(lap);
@@ -219,8 +214,8 @@ reigai:
}
/**
- * RADIUS 要求をキャンセルします。
- * @param {@link radius_request()} で受け取ったコンテキスト
+ * Cancel the RADIUS request.
+ * @param The context received by {@link radius_request()}
*/
void
radius_cancel_request(RADIUS_REQUEST_CTX ctx)
@@ -237,13 +232,12 @@ radius_cancel_request(RADIUS_REQUEST_CTX ctx)
radius_delete_packet(lap->pkt);
lap->pkt = NULL;
}
- /* あえて no comment。*/
memset(lap->secret, 0x41, sizeof(lap->secret));
free(lap);
}
-/** このコンテキストで利用している RADIUS サーバの共有秘密鍵を返します。*/
+/** Return the shared secret for RADIUS server that is used by this context. */
const char *
radius_get_server_secret(RADIUS_REQUEST_CTX ctx)
{
@@ -255,7 +249,7 @@ radius_get_server_secret(RADIUS_REQUEST_CTX ctx)
return lap->secret;
}
-/** このコンテキストで利用している RADIUS サーバのアドレスを返します。*/
+/** Return the address of RADIUS server that is used by this context. */
struct sockaddr *
radius_get_server_address(RADIUS_REQUEST_CTX ctx)
{
@@ -356,16 +350,16 @@ select_srcaddr(struct sockaddr const *dst, struct sockaddr *src,
sock = -1;
if ((sock = socket(dst->sa_family, SOCK_DGRAM, IPPROTO_UDP)) < 0)
- goto reigai;
+ goto fail;
if (connect(sock, dst, dst->sa_len) != 0)
- goto reigai;
+ goto fail;
if (getsockname(sock, src, srclen) != 0)
- goto reigai;
+ goto fail;
close(sock);
return 0;
-reigai:
+fail:
if (sock >= 0)
close(sock);
diff --git a/usr.sbin/npppd/npppd/radius_req.h b/usr.sbin/npppd/npppd/radius_req.h
index d0a4f0c1016..eed43ab36b7 100644
--- a/usr.sbin/npppd/npppd/radius_req.h
+++ b/usr.sbin/npppd/npppd/radius_req.h
@@ -26,60 +26,51 @@
#ifndef RADIUS_REQ_H
#define RADIUS_REQ_H 1
-/** RADIUS 共有秘密鍵の最大長 */
+/** maximum number of length for RADIUS shared secret */
#define MAX_RADIUS_SECRET 128
-/** RADIUS サーバの最大数 */
+/** maximum number of RADIUS server */
#define MAX_RADIUS_SERVERS 16
-/** RADIUS 要求が失敗した */
+/** RADIUS request failed */
#define RADIUS_REQUST_ERROR 0x0001
-/** RADIUS 要求がタイムアウトした */
+/** RADIUS request timed out */
#define RADIUS_REQUST_TIMEOUT 0x0002
-/** Authenticator チェックは OK */
+/** response has valid authenticator */
#define RADIUS_REQUST_CHECK_AUTHENTICTOR_OK 0x0010
-/** Authenticator チェックはしていない */
+/** authenticator is not checked */
#define RADIUS_REQUST_CHECK_AUTHENTICTOR_NO_CHECK 0x0020
-/** RADIUS 応答を受信するコールバック関数の型 */
+/** type for callback function to receive the RADIUS response */
typedef void (radius_response)(void *context, RADIUS_PACKET *pkt, int flags);
-/** RADIUS 要求/応答を行うためのコンテキストを示す型 */
+/** type for context to handle RADIUS request / response */
typedef void * RADIUS_REQUEST_CTX;
-/** RADIUS 要求の設定を示す型 */
+/** type for setting of RADIUS request */
typedef struct _radius_req_setting
{
- /** サーバ配列 */
+ /** RADIUS Servers */
struct {
+ /** Server's address */
union {
- /** サーバの IPv6 アドレス */
- struct sockaddr_in6 sin6;
- /** サーバの IPv4 アドレス */
- struct sockaddr_in sin4;
- } /** サーバのアドレス */ peer;
+ struct sockaddr_in6 sin6;
+ struct sockaddr_in sin4;
+ } peer;
+ /** Our address */
union {
- /** サーバの IPv6 アドレス */
- struct sockaddr_in6 sin6;
- /** サーバの IPv4 アドレス */
- struct sockaddr_in sin4;
- } /** サーバのアドレス */ sock;
+ struct sockaddr_in6 sin6;
+ struct sockaddr_in sin4;
+ } sock;
char secret[MAX_RADIUS_SECRET];
- /** このアドレスが有効かどうか */
- int enabled;
+ int enabled;
} server[MAX_RADIUS_SERVERS];
- /**
- * 現在使用しているサーバのインデックス。
- * <p>
- * これを変更する仕組みは、radius_req.c では実装していません。npppd
- * では npppd.c、npppd_auth.c
- * あたりで実装しています。</p>
- */
+ /** Index of current server */
int curr_server;
- /** リクエストタイムアウト(秒) */
+ /** request timeout(in second) */
int timeout;
} radius_req_setting;
diff --git a/usr.sbin/npppd/npppd/radiusconst.h b/usr.sbin/npppd/npppd/radiusconst.h
index 8d3c18e75fb..51bdeb251a9 100644
--- a/usr.sbin/npppd/npppd/radiusconst.h
+++ b/usr.sbin/npppd/npppd/radiusconst.h
@@ -23,7 +23,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* 漢字コードはEUC 漢字コードはEUC */
/*
* radiusconst.h :
* RADIUS constatnts
diff --git a/usr.sbin/npppd/npppdctl/Makefile b/usr.sbin/npppd/npppdctl/Makefile
index 828a27ba992..a278712558a 100644
--- a/usr.sbin/npppd/npppdctl/Makefile
+++ b/usr.sbin/npppd/npppdctl/Makefile
@@ -1,12 +1,11 @@
#
-# $Id: Makefile,v 1.1 2010/01/13 07:49:44 yasuoka Exp $
+# $Id: Makefile,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
#
-NOMAN= #defined
-
.include <bsd.own.mk>
PROG= npppdctl
SRCS= npppdctl.c debugutil.c
+MAN= npppdctl.8
CPPFLAGS+= -I${.CURDIR}/../npppd -I${.CURDIR}/../common
diff --git a/usr.sbin/npppd/npppdctl/npppdctl.c b/usr.sbin/npppd/npppdctl/npppdctl.c
index 5d5300a9b8d..b5119ed1860 100644
--- a/usr.sbin/npppd/npppdctl/npppdctl.c
+++ b/usr.sbin/npppd/npppdctl/npppdctl.c
@@ -23,23 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/*-
- * Copyright (c) 2005
- * Internet Initiative Japan Inc. All rights reserved.
- */
-/**@file
- * vdipwho との互換性を保ちつつ併せて次の機能を提供します。
- * <ul>
- * <li>利用状況<br>
- * vdipwho 接続中のユーザ名、割り当てアドレス、開始時刻、レイヤ 2 のプロト
- * コル名、レイヤ 2 の接続元アドレス</li>
- * <li>(-s オプション) 統計情報を表示します。<br>
- * npppd の ppp の Id、ユーザ名、入出力バイト、パケット、エラー数</li>
- * <li>(-d オプション) 切断機能<br>
- * 指定した PPP ユーザ名の全ての接続を切断します。<br>
- * </ul>
- */
-/* $Id: npppdctl.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: npppdctl.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -70,25 +54,25 @@
#endif
#define DEFAULT_TIMEOUT 5
-/** UNIX ドメインデータグラムの待ち受け用ファイル。*/
+/** Filename template for listening soccket of UNIX domain datagram */
char dgramsock[] = "/tmp/npppdctl.XXXXXX";
-/** npppd 側のソケットアドレス */
+/** Daemon side socket address */
struct sockaddr_un peersock;
-/** ソケット */
+/** Socket descriptor */
int sock = -1;
-/** UNIXタイム表示 (vdipwho由来) */
+/** Show 'since' field as unix time. */
int uflag = 0;
-/** 名前を引かない (vdipwho由来) */
+/** Don't convert addresses/ports to names */
int nflag = 0;
-/** 受信バッファサイズ */
+/** Receive buffer size */
int rcvbuf_sz = DEFAULT_NPPPD_CTL_MAX_MSGSZ;
-/** 長い行。80桁抑制しない */
+/** Use long line to display information */
int lflag = 0;
static void usage (void);
@@ -103,7 +87,7 @@ static void print_stat(struct npppd_who *);
static const char *progname = NULL;
-/** 使い方を表示します。 */
+/** show usage */
static void
usage(void)
{
@@ -111,7 +95,7 @@ usage(void)
fprintf(stderr,
"usage: %s [-slnuh] [-d ppp_user] [-r rcvbuf_sz] [-p npppd_ctl_path]\n"
" %s -c [-r rcvbuf_sz] {ppp_id | ip} auth_id\n"
- "usage: %s [-r]\n"
+ "usage: %s -R\n"
"\t-R: Reset the routing table.\n"
"\t-c: Set the client auth's auth-id.\n"
"\t-d: Disconnect specified user.\n"
@@ -131,7 +115,7 @@ on_signal(int notused)
exit(1);
}
-/** nppdctl エントリポイント */
+/** entry point of 'npppdctl' command */
int
main(int argc, char *argv[])
{
@@ -188,11 +172,11 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- // UNIX ドメインデータグラムの待ち受け用ファイル。
+ /* create a listening socket for unix domain datagram. */
if ((fdgramsock = mkstemp(dgramsock)) < 0)
err(1, "mkstemp");
- // 終了時に削除するフック
+ /* set the hook that deletes the listening socket on exiting */
if (atexit(on_exit) != 0)
err(1, "atexit");
signal(SIGINT, on_signal);
@@ -210,12 +194,12 @@ main(int argc, char *argv[])
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0)
err(1, "setsockopt(SO_RCVTIMEO)");
- // 待ち受けソケット準備
+ /* Prepare a listening socket */
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
sun.sun_len = sizeof(sun);
strlcpy(sun.sun_path, dgramsock, sizeof(sun.sun_path));
- // mkstemp でファイルを作ってしまっているので、削除
+ /* delete the file that is created by mkstemp */
close(fdgramsock); unlink(dgramsock);
if (bind(sock, (struct sockaddr *)&sun, sizeof(sun)) != 0)
@@ -223,7 +207,7 @@ main(int argc, char *argv[])
if (chmod(dgramsock, 0600) != 0)
err(1, "chmod(%s,%d)", dgramsock, 0600);
- // npppd に接続するソケット
+ /* Prepare a socket for sending to the daemon */
memset(&peersock, 0, sizeof(peersock));
peersock.sun_family = AF_UNIX;
peersock.sun_len = sizeof(peersock);
@@ -250,7 +234,7 @@ main(int argc, char *argv[])
return 0;
}
-/** 終了処理。待ち受けソケットを消します。*/
+/** exiting hook. delete the listening socket */
static void
on_exit(void)
{
@@ -260,11 +244,11 @@ on_exit(void)
}
/**
- * vdipwho と同じ出力をします。
- * <p>
- * 出力例
-<pre>name assigned since proto from
-yasuoka3 10.0.0.116 Aug 02 21:10 L2TP 192.168.159.103:1701</pre></p>
+ * This function displays connected ppp link one by one.
+<pre>
+name assigned since proto from
+username 10.0.0.116 Aug 02 21:10 L2TP 192.168.159.103:1701
+</pre></p>
*/
static void
npppd_who(int show_stat)
@@ -382,7 +366,7 @@ print_stat(struct npppd_who *w)
(double)w->obytes/1024, w->opackets, w->oerrors);
}
-/** ユーザ名で切断 */
+/** disconnect by username */
static void
npppd_disconnect(const char *username)
{
@@ -406,8 +390,10 @@ npppd_disconnect(const char *username)
}
/**
- * str に指定した文字列が、NULLポインタまたは空文字列の場合 "<none>" に変更し
- * て返します。それ以外の場合は、指定した文字列をそのまま返します。
+ * make sure "str" is not NULL or not zero length string.
+ * <p>
+ * When NULL pointer or zero length string is specified as "str", this function
+ * returns "<none>". Otherwise it returns the "str" without modification.</p>
*/
static const char *
eat_null(const char *str)
diff --git a/usr.sbin/npppd/pppoe/pppoe.h b/usr.sbin/npppd/pppoe/pppoe.h
index eaa3f63edf9..b9d31f0fd2f 100644
--- a/usr.sbin/npppd/pppoe/pppoe.h
+++ b/usr.sbin/npppd/pppoe/pppoe.h
@@ -27,7 +27,7 @@
#define PPPOE_H 1
/*
- * プロトコル上の定数 (RFC 2516)
+ * Constant variables and types from PPPoE protocol (RFC 2516)
*/
#define PPPOE_RFC2516_TYPE 0x01
#define PPPOE_RFC2516_VER 0x01
@@ -58,7 +58,7 @@
#define PPPOE_TAG_AC_SYSTEM_ERROR 0x0202
#define PPPOE_TAG_GENERIC_ERROR 0x0203
-/** PPPoE ヘッダ */
+/** PPPoE Protocol Header */
struct pppoe_header {
#if _BYTE_ORDER == _BIG_ENDIAN
uint8_t ver:4, type:4;
@@ -70,7 +70,7 @@ struct pppoe_header {
uint16_t length;
} __attribute__((__packed__));
-/** PPPoE TLV ヘッダ */
+/** PPPoE TLV Header */
struct pppoe_tlv {
uint16_t type;
uint16_t length;
@@ -78,9 +78,9 @@ struct pppoe_tlv {
} __attribute__((__packed__));
/*
- * 実装
+ * Constant variables and types for implementions
*/
-/** デフォルトの物理層ラベル */
+/** Default data link layer label */
#define PPPOED_DEFAULT_LAYER2_LABEL "PPPoE"
#define PPPOED_CONFIG_BUFSIZ 65535
@@ -88,14 +88,11 @@ struct pppoe_tlv {
#define PPPOED_PHY_LABEL_SIZE 16
/*
- * pppoed ステータス
+ * pppoed status
*/
-/** 初期状態 */
-#define PPPOED_STATE_INIT 0
-/** 走行中 */
-#define PPPOED_STATE_RUNNING 1
-/** 停止j状態 */
-#define PPPOED_STATE_STOPPED 2
+#define PPPOED_STATE_INIT 0 /** Initial */
+#define PPPOED_STATE_RUNNING 1 /** Running */
+#define PPPOED_STATE_STOPPED 2 /** Stopped */
#define pppoed_is_stopped(pppoed) \
(((pppoed)->state == PPPOED_STATE_STOPPED)? 1 : 0)
@@ -104,95 +101,86 @@ struct pppoe_tlv {
#define PPPOED_LISTENER_INVALID_INDEX UINT16_MAX
-/** PPPoE デーモン待ち受け型 */
+/** PPPoE listener type */
typedef struct _pppoed_listener {
- /** bpf(4) デバイスファイルのディスクリプタ */
+ /** Descriptor of bpf(4) */
int bpf;
- /** bpf 用のイベントコンテキスト */
+ /** Context of event(3) for the descriptor of bpf(4) */
struct event ev_bpf;
- /** PPPoE デーモン自身 */
+ /** Pointer to base PPPoE daemon */
struct _pppoed *self;
- /** イーサネットアドレス */
+ /** Ethernet address */
u_char ether_addr[ETHER_ADDR_LEN];
- /** インデックス番号 */
+ /** Listener index numbered by the base PPPoE daemon */
uint16_t index;
- /** 待ち受けるインタフェース名 */
+ /** Listening interface name */
char listen_ifname[IF_NAMESIZE];
- /** 物理層のラベル */
+ /** Label of physcal layer */
char phy_label[PPPOED_PHY_LABEL_SIZE];
} pppoed_listener;
-/** PPPoE デーモンを示す型です。*/
+/** PPPoE daemon type */
typedef struct _pppoed {
- /** PPPoE デーモンの Id */
+ /** PPPoE daemon Id */
int id;
- /** 待ち受けリスト */
+ /** List of {@link pppoed_listener} */
slist listener;
- /** このデーモンの状態 */
+ /** Status of this daemon */
int state;
- /** タイムアウトイベント **/
- /** セッション番号 => pppoe_session のハッシュマップ */
+ /** Hashmap that maps from session number to {@link pppoe_session} */
hash_table *session_hash;
- /** 空きセッション番号リスト */
+ /** List of free session numbers */
slist session_free_list;
- /** クッキー所持セッションのハッシュマップ */
+ /** Hashmap that contains uniq cookie value */
hash_table *acookie_hash;
- /** 次のクッキー番号 */
+ /** Next cookie number */
uint32_t acookie_next;
- /** 設定プロパティ */
+ /** Configuration {@link struct properties properties} */
struct properties *config;
- /** フラグ */
+ /** Flags */
uint32_t
desc_in_pktdump:1,
desc_out_pktdump:1,
session_in_pktdump:1,
session_out_pktdump:1,
listen_incomplete:1,
- /* phy_label_with_ifname:1, PPPoE は不要 */
reserved:27;
} pppoed;
-/** PPPoE セッションを示す型です */
+/** PPPoE session type */
typedef struct _pppoe_session {
+ /** State of this session */
int state;
- /** 親 PPPoE デーモン */
+ /** Pointer to base {@link pppoed *} PPPoE daemon */
pppoed *pppoed;
- /** PPP コンテキスト */
+ /** Pointer to the PPP context */
void *ppp;
- /** セッション Id */
+ /** Session id */
int session_id;
- /** クッキー番号 */
+ /** Cookie number */
int acookie;
- /** 対抗のイーサネットアドレス */
+ /** Peer ethernet address */
u_char ether_addr[ETHER_ADDR_LEN];
- /** リスナインデックス */
+ /** Index of listener */
uint16_t listener_index;
- /** イーサヘッダキャッシュ */
+ /** Cache for ethernet frame header */
struct ether_header ehdr;
-
- /** echo の送信間隔(秒) */
- int lcp_echo_interval;
- /** echo の最大連続失敗回数 */
- int lcp_echo_max_failure;
-
- /** 終了処理のための event コンテキスト */
+ int lcp_echo_interval; /* XXX can remove */
+ int lcp_echo_max_failure; /* XXX can remove */
+ /** Context of event(3) for disposing */
struct event ev_disposing;
} pppoe_session;
-/** pppoe_session の状態が初期状態であることを示す定数です */
-#define PPPOE_SESSION_STATE_INIT 0
-
-/** pppoe_session の状態が走行状態であることを示す定数です */
-#define PPPOE_SESSION_STATE_RUNNING 1
-
-/** pppoe_session の状態が終了中であることを示す定数です */
-#define PPPOE_SESSION_STATE_DISPOSING 2
+#define PPPOE_SESSION_STATE_INIT 0 /** Inital */
+#define PPPOE_SESSION_STATE_RUNNING 1 /** Running */
+#define PPPOE_SESSION_STATE_DISPOSING 2 /** Disposing */
-#define pppoed_need_polling(pppoed) (((pppoed)->listen_incomplete != 0)? 1 : 0)
+#define pppoed_need_polling(pppoed) \
+ (((pppoed)->listen_incomplete != 0)? 1 : 0)
#ifdef __cplusplus
extern "C" {
diff --git a/usr.sbin/npppd/pppoe/pppoe_local.h b/usr.sbin/npppd/pppoe/pppoe_local.h
index 5cd602296ec..558df704020 100644
--- a/usr.sbin/npppd/pppoe/pppoe_local.h
+++ b/usr.sbin/npppd/pppoe/pppoe_local.h
@@ -33,7 +33,7 @@
#define PPPOED_SHUTDOWN_TIMEOUT 5
#ifndef PPPOE_NSESSION
-/** PPPoE 最大接続数 */
+/** PPPoE maximum number of sessions */
#define PPPOE_NSESSION 10000
#endif
#define PPPOE_NLISTENER 512
@@ -47,10 +47,12 @@
#define pppoe_session_sock_bpf(session) \
((pppoed_listener *)slist_get(&(session)->pppoed->listener, \
(session)->listener_index))->bpf
-/** pptp_ctrl から、リスナーの物理層のラベルを取り出すマクロ */
+
+/** macro is to get the physical layer label by {@link pppoe_session} */
#define PPPOE_SESSION_LISTENER_LABEL(session) \
((pppoed_listener *)slist_get(&(session)->pppoed->listener, \
(session)->listener_index))->phy_label
+/** macro is to get the interface name by {@link pppoe_session} */
#define PPPOE_SESSION_LISTENER_IFNAME(session) \
((pppoed_listener *)slist_get(&(session)->pppoed->listener, \
(session)->listener_index))->listen_ifname
diff --git a/usr.sbin/npppd/pppoe/pppoe_session.c b/usr.sbin/npppd/pppoe/pppoe_session.c
index b1fef50a04d..131395af11e 100644
--- a/usr.sbin/npppd/pppoe/pppoe_session.c
+++ b/usr.sbin/npppd/pppoe/pppoe_session.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pppoe_session.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,10 +24,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
/**@file
- * PPPoE セッションの実装。
- * $Id: pppoe_session.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $
+ * Session management of PPPoE protocol
+ * $Id: pppoe_session.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $
*/
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
@@ -79,7 +82,7 @@ static void pppoe_session_close_by_ppp(npppd_ppp *);
static int pppoe_session_bind_ppp (pppoe_session *);
static void pppoe_session_dispose_event(int, short, void *);
-/** PPPoE セッションコンテキストを初期化します */
+/* Initialize PPPoE session context */
int
pppoe_session_init(pppoe_session *_this, pppoed *_pppoed, int idx,
int session_id, u_char *ether_addr)
@@ -100,7 +103,7 @@ pppoe_session_init(pppoe_session *_this, pppoed *_pppoed, int idx,
return 0;
}
-/** PPPoE セッションを切断します */
+/* Disconnect PPPoE session */
void
pppoe_session_disconnect(pppoe_session *_this)
{
@@ -109,7 +112,7 @@ pppoe_session_disconnect(pppoe_session *_this)
if (_this->state != PPPOE_SESSION_STATE_DISPOSING) {
pppoe_session_send_PADT(_this);
- /* 解放処理は、 単体の event で。*/
+ /* free process should be par event */
tv.tv_usec = 0;
tv.tv_sec = 0;
evtimer_add(&_this->ev_disposing, &tv);
@@ -119,7 +122,7 @@ pppoe_session_disconnect(pppoe_session *_this)
ppp_phy_downed(_this->ppp);
}
-/** PPPoE セッションを停止します */
+/* Stop PPPoE session */
void
pppoe_session_stop(pppoe_session *_this)
{
@@ -128,14 +131,14 @@ pppoe_session_stop(pppoe_session *_this)
}
-/** PPPoE セッションの終了処理を行います。 */
+/* Finish PPPoE session */
void
pppoe_session_fini(pppoe_session *_this)
{
evtimer_del(&_this->ev_disposing);
}
-/* event(3) からの callback */
+/* call back function from event(3) */
static void
pppoe_session_dispose_event(int fd, short ev, void *ctx)
{
@@ -145,9 +148,9 @@ pppoe_session_dispose_event(int fd, short ev, void *ctx)
pppoed_pppoe_session_close_notify(_this->pppoed, _this);
}
-/***********************************************************************
- * I/O 関連
- ***********************************************************************/
+/*
+ * I/O
+ */
void
pppoe_session_input(pppoe_session *_this, u_char *pkt, int lpkt)
{
@@ -167,11 +170,11 @@ pppoe_session_input(pppoe_session *_this, u_char *pkt, int lpkt)
if (rval == 2) {
/*
- * 現在 NPPPD PPPOE は bpf によって PIPEX が転送する
- * パケットも同時に受信して処理するため,統計情報が
- * 多重にカウントされてしまう.
- * PIPEX で処理する種類のパケットだった場合は
- * 統計情報をカウントする前に関数を抜ける必要がある.
+ * Quit this function before statistics counter
+ * is processed when the packet will be processed by
+ * PIPEX. Because current NPPPD PPPOE implementation
+ * is recieving all packet from BPF even though the
+ * PIPEX will process it.
*/
} else if (rval != 0) {
ppp->ierrors++;
@@ -245,6 +248,7 @@ pppoe_session_send_PADT(pppoe_session *_this)
return -1;
}
bytebuffer_clear(buf);
+
/*
* PPPoE Header
*/
@@ -279,7 +283,7 @@ pppoe_session_send_PADT(pppoe_session *_this)
return rval;
}
-/** PADS を送信します */
+/* send PADS */
static int
pppoe_session_send_PADS(pppoe_session *_this, struct pppoe_tlv *hostuniq,
struct pppoe_tlv *service_name)
@@ -354,7 +358,7 @@ pppoe_session_send_PADS(pppoe_session *_this, struct pppoe_tlv *hostuniq,
return rval;
}
-/** PADR を受信した時に呼び出されます */
+/* process PADR from the peer */
int
pppoe_session_recv_PADR(pppoe_session *_this, slist *tag_list)
{
@@ -375,13 +379,10 @@ pppoe_session_recv_PADR(pppoe_session *_this, slist *tag_list)
}
if (ac_cookie) {
- /*
- * cookie を既にもっているセッションが
- * いるとまずい
- */
+ /* avoid a session which has already has cookie. */
if (hash_lookup(pppoed0->acookie_hash,
(void *)ac_cookie->value) != NULL)
- goto reigai;
+ goto fail;
_this->acookie = *(uint32_t *)(ac_cookie->value);
hash_insert(pppoed0->acookie_hash, (void *)_this->acookie,
@@ -389,18 +390,18 @@ pppoe_session_recv_PADR(pppoe_session *_this, slist *tag_list)
}
if (pppoe_session_send_PADS(_this, hostuniq, service_name) != 0)
- goto reigai;
+ goto fail;
if (pppoe_session_bind_ppp(_this) != 0)
- goto reigai;
+ goto fail;
_this->state = PPPOE_SESSION_STATE_RUNNING;
return 0;
-reigai:
+fail:
return -1;
}
-/** PADT を受信した時に呼び出されます */
+/* process PADT from the peer */
int
pppoe_session_recv_PADT(pppoe_session *_this, slist *tag_list)
{
@@ -412,9 +413,9 @@ pppoe_session_recv_PADT(pppoe_session *_this, slist *tag_list)
return 0;
}
-/***********************************************************************
- * ログ関連
- ***********************************************************************/
+/*
+ * Log
+ */
static void
pppoe_session_log(pppoe_session *_this, int prio, const char *fmt, ...)
{
@@ -434,9 +435,9 @@ pppoe_session_log(pppoe_session *_this, int prio, const char *fmt, ...)
va_end(ap);
}
-/***********************************************************************
- * PPP関連
- ***********************************************************************/
+/*
+ * PPP
+ */
static int
pppoe_session_ppp_output(npppd_ppp *ppp, u_char *pkt, int lpkt, int flag)
{
@@ -459,6 +460,7 @@ pppoe_session_ppp_output(npppd_ppp *ppp, u_char *pkt, int lpkt, int flag)
return 0;
}
+
static void
pppoe_session_close_by_ppp(npppd_ppp *ppp)
{
@@ -467,11 +469,13 @@ pppoe_session_close_by_ppp(npppd_ppp *ppp)
_this = ppp->phy_context;
PPPOE_SESSION_ASSERT(_this != NULL);
if (_this != NULL)
- _this->ppp = NULL; // pptp_call_disconnect より先に。
+ /* do this before pptp_call_disconnect() */
+ _this->ppp = NULL;
+
pppoe_session_disconnect(_this);
}
-/** ppp の bind。*/
+/* bind for PPP */
static int
pppoe_session_bind_ppp(pppoe_session *_this)
{
@@ -481,7 +485,7 @@ pppoe_session_bind_ppp(pppoe_session *_this)
ppp = NULL;
if ((ppp = ppp_create()) == NULL)
- goto reigai;
+ goto fail;
PPPOE_SESSION_ASSERT(_this->ppp == NULL);
@@ -510,7 +514,7 @@ pppoe_session_bind_ppp(pppoe_session *_this)
memcpy(&ppp->phy_info.peer_dl, &sdl, sizeof(sdl));
if (ppp_init(npppd_get_npppd(), ppp) != 0)
- goto reigai;
+ goto fail;
ppp->has_acf = 0;
@@ -518,7 +522,7 @@ pppoe_session_bind_ppp(pppoe_session *_this)
ppp_start(ppp);
return 0;
-reigai:
+fail:
pppoe_session_log(_this, LOG_ERR, "failed binding ppp");
if (ppp != NULL)
diff --git a/usr.sbin/npppd/pppoe/pppoed.c b/usr.sbin/npppd/pppoe/pppoed.c
index 9c9b52d9dc4..f3103b31a89 100644
--- a/usr.sbin/npppd/pppoe/pppoed.c
+++ b/usr.sbin/npppd/pppoe/pppoed.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pppoed.c,v 1.5 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -24,12 +25,9 @@
* SUCH DAMAGE.
*/
/**@file
- * PPPoEサーバの実装。
- * <dl>
- * <dt>RFC 2516</dt>
- * <dd>A Method for Transmitting PPP Over Ethernet (PPPoE)</dd>
- * </dl>
- * $Id: pppoed.c,v 1.4 2010/01/31 05:49:51 yasuoka Exp $
+ * This file provides the PPPoE(RFC2516) server(access concentrator)
+ * implementaion.
+ * $Id: pppoed.c,v 1.5 2010/07/01 03:38:17 yasuoka Exp $
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -103,10 +101,11 @@ static const char *pppoe_code_string(int);
static const char *pppoe_tag_string(int);
#endif
-/***********************************************************************
- * デーモン関連
- ***********************************************************************/
-/** PPPoE デーモンを初期化します */
+/*
+ * daemon
+ */
+
+/* initialize PPPoE daemon */
int
pppoed_init(pppoed *_this)
{
@@ -121,7 +120,7 @@ pppoed_init(pppoed *_this)
PPPOE_SESSION_HASH_SIZ)) == NULL) {
pppoed_log(_this, LOG_ERR, "hash_create() failed on %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
slist_init(&_this->session_free_list);
@@ -129,10 +128,10 @@ pppoed_init(pppoed *_this)
(void *)PPPOED_SESSION_SHUFFLE_MARK) == NULL) {
pppoed_log(_this, LOG_ERR, "slist_add() failed on %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
- /* XXX クッキーハッシュの初期化 */
+ /* XXX initialize hash of cookies */
if ((_this->acookie_hash = hash_create(
(int (*) (const void *, const void *))session_id_cmp,
(uint32_t (*) (const void *, int))session_id_hash,
@@ -156,14 +155,14 @@ pppoed_init(pppoed *_this)
if (slist_add(&_this->session_free_list, (void *)id) == NULL) {
pppoed_log(_this, LOG_ERR,
"slist_add() failed on %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
}
_this->state = PPPOED_STATE_INIT;
return 0;
-reigai:
+fail:
pppoed_uninit(_this);
return 1;
}
@@ -177,7 +176,7 @@ pppoed_listener_init(pppoed *_this, pppoed_listener *listener)
listener->index = PPPOED_LISTENER_INVALID_INDEX;
}
-/** リスナをリロードします */
+/* reload listner */
int
pppoed_reload_listeners(pppoed *_this)
{
@@ -190,9 +189,9 @@ pppoed_reload_listeners(pppoed *_this)
return rval;
}
-/**
- * 他人宛のパケットを受信するかも(see bpf(4))。自分宛とブロードキャスト宛
- * は弾く。
+/*
+ * Reject any packet except the packet to self and broadcasts,
+ * as bpf(4) potentially receive packets for others.
*/
#define REJECT_FOREIGN_ADDRESS 1
@@ -219,13 +218,13 @@ pppoed_listener_start(pppoed_listener *_this, int restart)
#ifndef REJECT_FOREIGN_ADDRESS
BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
#else
- /* ff:ff:ff:ff:ff:ff 宛 */
+ /* to ff:ff:ff:ff:ff:ff */
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0),
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0xffffffff, 0, 3),
BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4),
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0xffff, 0, 1),
BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
- /* 自分の Mac 宛 */
+ /* to self */
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0),
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K,
ETHER_FIRST_INT(_this->ether_addr), 0, 3),
@@ -272,34 +271,34 @@ pppoed_listener_start(pppoed_listener *_this, int restart)
if (!found) {
pppoed_log(_pppoed, log_level, "%s is not available.",
_this->listen_ifname);
- goto reigai;
+ goto fail;
}
/* Open /dev/bpfXX */
- /* FIXME: NetBSD 3.0 では、/dev/bpf 一つで何度も開けるらしい */
+ /* FIXME: /dev/bpf of NetBSD3.0 can simultaneity open */
for (i = 0; i < 256; i++) {
snprintf(buf, sizeof(buf), "/dev/bpf%d", i);
if ((_this->bpf = priv_open(buf, O_RDWR, 0600)) >= 0) {
break;
} else if (errno == ENXIO || errno == ENOENT)
- break; /* これ以上探してもみつからないはず */
+ break; /* no more entries */
}
if (_this->bpf < 0) {
pppoed_log(_pppoed, log_level, "Cannot open bpf");
- goto reigai;
+ goto fail;
}
ival = BPF_CAPTURE_SIZ;
if (ioctl(_this->bpf, BIOCSBLEN, &ival) != 0) {
pppoed_log(_pppoed, log_level, "ioctl(bpf, BIOCSBLEN(%d)): %m",
ival);
- goto reigai;
+ goto fail;
}
ival = 1;
if (ioctl(_this->bpf, BIOCIMMEDIATE, &ival) != 0) {
pppoed_log(_pppoed, log_level, "Cannot start bpf on %s: %m",
_this->listen_ifname);
- goto reigai;
+ goto fail;
}
/* bind interface */
@@ -308,7 +307,7 @@ pppoed_listener_start(pppoed_listener *_this, int restart)
if (ioctl(_this->bpf, BIOCSETIF, &ifreq) != 0) {
pppoed_log(_pppoed, log_level, "Cannot start bpf on %s: %m",
_this->listen_ifname);
- goto reigai;
+ goto fail;
}
/* set linklocal address */
@@ -320,7 +319,7 @@ pppoed_listener_start(pppoed_listener *_this, int restart)
/* set filter */
if (ioctl(_this->bpf, BIOCSETF, &bf_filter) != 0) {
pppoed_log(_pppoed, log_level, "ioctl(bpf, BIOCSETF()): %m");
- goto reigai;
+ goto fail;
}
event_set(&_this->ev_bpf, _this->bpf, EV_READ | EV_PERSIST,
@@ -334,7 +333,7 @@ pppoed_listener_start(pppoed_listener *_this, int restart)
_this->ether_addr[5]);
return 0;
-reigai:
+fail:
if (_this->bpf >= 0) {
close(_this->bpf);
_this->bpf = -1;
@@ -343,7 +342,7 @@ reigai:
return 1;
}
-/** PPPoE デーモンを開始します */
+/* start PPPoE daemon */
int
pppoed_start(pppoed *_this)
{
@@ -371,6 +370,7 @@ pppoed_start(pppoed *_this)
return rval;
}
+/* stop listener */
static void
pppoed_listener_stop(pppoed_listener *_this)
{
@@ -393,7 +393,7 @@ pppoed_listener_stop(pppoed_listener *_this)
}
}
-/** PPPoE デーモンを停止します */
+/* stop PPPoE daemon */
void
pppoed_stop(pppoed *_this)
{
@@ -424,7 +424,7 @@ pppoed_stop(pppoed *_this)
pppoed_log(_this, LOG_NOTICE, "Stopped");
}
-/** PPPoE デーモンを解放します */
+/* uninitialize (free) PPPoE daemon */
void
pppoed_uninit(pppoed *_this)
{
@@ -437,11 +437,13 @@ pppoed_uninit(pppoed *_this)
_this->acookie_hash = NULL;
}
slist_fini(&_this->session_free_list);
- slist_fini(&_this->listener); // stop メンバは解放済。
+ /* listener themself has been released already */
+ slist_fini(&_this->listener);
+
_this->config = NULL;
}
-/** PPPoE セッションが close された時に呼び出されます。*/
+/* it called when the PPPoE session was closed */
void
pppoed_pppoe_session_close_notify(pppoed *_this, pppoe_session *session)
{
@@ -457,9 +459,9 @@ pppoed_pppoe_session_close_notify(pppoed *_this, pppoe_session *session)
free(session);
}
-/***********************************************************************
- * 設定関連
- ***********************************************************************/
+/*
+ * PPPoE Configuration
+ */
#define CFG_KEY(p, s) config_key_prefix((p), (s))
#define VAL_SEP " \t\r\n"
@@ -467,7 +469,7 @@ CONFIG_FUNCTIONS(pppoed_config, pppoed, config);
PREFIXED_CONFIG_FUNCTIONS(pppoed_listener_config, pppoed_listener, self->config,
phy_label);
-/** PPPoE デーモンの設定を再読み込みします */
+/* reload configurations for the PPPoE daemon */
int
pppoed_reload(pppoed *_this, struct properties *config, const char *name,
int default_enabled)
@@ -492,7 +494,7 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
_this->config = config;
if (pppoed_config_str_equal(_this, CFG_KEY(name, "enabled"), "true",
default_enabled)) {
- // false にした直後に true にされるかもしれない。
+ /* avoid false->true flapping */
if (pppoed_is_stopped(_this) || !pppoed_is_running(_this))
do_start = 1;
} else {
@@ -524,7 +526,7 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
if (getifaddrs(&ifa0) != 0) {
pppoed_log(_this, LOG_ERR,
"getifaddrs() failed on %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
count = 0;
val = pppoed_config_str(_this, CFG_KEY(name, "interface"));
@@ -537,7 +539,7 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
strlcpy(buf, val, sizeof(buf));
label = NULL;
- // タブ、スペース区切りで、複数指定可能
+ /* it accepts multiple entries with tab/space separation */
for (i = 0, cp = buf;
(tok = strsep(&cp, VAL_SEP)) != NULL;) {
if (*tok == '\0')
@@ -550,9 +552,9 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
if (count >= countof(listeners)) {
pppoed_log(_this, LOG_ERR,
"Too many listeners");
- goto reigai;
+ goto fail;
}
- /* インタフェースの実在確認 */
+ /* check the interface exist or not */
found = 0;
for (ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next) {
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
@@ -566,7 +568,7 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
if (!found) {
pppoed_log(_this, LOG_ERR,
"interface %s is not found", tok);
- goto reigai;
+ goto fail;
}
strlcpy(listeners[count].ifname, tok,
sizeof(listeners[count].ifname));
@@ -584,7 +586,7 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
}
if (slist_add_all(&rmlist, &_this->listener) != 0)
- goto reigai;
+ goto fail;
for (i = 0; i < count; i++) {
found = 0;
@@ -600,7 +602,7 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
}
if (!found) {
if ((l = malloc(sizeof(pppoed_listener))) == NULL)
- goto reigai;
+ goto fail;
pppoed_listener_init(_this, l);
}
l->self = _this;
@@ -611,18 +613,18 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
if (slist_add(&newlist, l) == NULL) {
pppoed_log(_this, LOG_ERR,
"slist_add() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
}
if (slist_set_size(&_this->listener, count) != 0)
- goto reigai;
+ goto fail;
- /* 使わなくなったリスナの停止 */
+ /* garbage collection of listner context */
slist_itr_first(&rmlist);
while (slist_itr_has_next(&rmlist)) {
l = slist_itr_next(&rmlist);
- /* 派生した PPPoEセッションの考慮 */
+ /* handle child PPPoE session */
if (_this->session_hash != NULL) {
for (hl = hash_first(_this->session_hash); hl != NULL;
hl = hash_next(_this->session_hash)) {
@@ -635,10 +637,10 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
free(l);
}
slist_remove_all(&_this->listener);
- /* slist_set_size しているので、失敗しないはず */
+ /* as slist_set_size-ed, it must not fail */
(void)slist_add_all(&_this->listener, &newlist);
- /* インデックスのリセット */
+ /* reset indexes */
slist_itr_first(&newlist);
for (i = 0; slist_itr_has_next(&newlist); i++) {
l = slist_itr_next(&newlist);
@@ -664,7 +666,7 @@ pppoed_reload(pppoed *_this, struct properties *config, const char *name,
return 1;
return 0;
-reigai:
+fail:
slist_fini(&rmlist);
slist_fini(&newlist);
if (ifa0 != NULL)
@@ -672,9 +674,11 @@ reigai:
return 1;
}
-/***********************************************************************
- * I/O 関連
- ***********************************************************************/
+
+/*
+ * I/O
+ */
+
static void
pppoed_io_event(int fd, short evmask, void *ctx)
{
@@ -702,7 +706,8 @@ pppoed_io_event(int fd, short evmask, void *ctx)
ether->ether_type = ntohs(ether->ether_type);
if (memcmp(ether->ether_shost, _this->ether_addr,
ETHER_ADDR_LEN) == 0)
- goto next_pkt; // 自分パケット
+ /* the packet is from myself */
+ goto next_pkt;
off = bpf->bh_hdrlen + sizeof(struct ether_header);
if (lpkt < off + sizeof(struct pppoe_header)) {
pppoed_log(_this->self, LOG_WARNING,
@@ -759,7 +764,8 @@ pppoed_input(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], int is_disc,
"pppoe length field.";
goto bad_packet;
}
- lpkt = pppoe->length; /* PPPoEヘッダの値を使う */
+ /* use PPPoE heade value as lpkt */
+ lpkt = pppoe->length;
if (pppoe->type != PPPOE_RFC2516_TYPE ||
pppoe->ver != PPPOE_RFC2516_VER) {
@@ -786,7 +792,7 @@ pppoed_input(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], int is_disc,
if (lpkt < 4) {
reason = "tlv list is broken. "
"Remaining octet is too short.";
- goto reigai;
+ goto fail;
}
tlv = (struct pppoe_tlv *)p_tlvspace;
GETSHORT(tlv->type, pkt);
@@ -795,7 +801,7 @@ pppoed_input(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], int is_disc,
lpkt -= 4;
if (tlv->length > lpkt) {
reason = "tlv list is broken. length is wrong.";
- goto reigai;
+ goto fail;
}
if (tlv->length > 0) {
memcpy(&tlv->value, pkt, tlv->length);
@@ -815,7 +821,7 @@ pppoed_input(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], int is_disc,
if (tlv->type == PPPOE_TAG_END_OF_LIST)
break;
if (slist_add(&tag_list, tlv) == NULL) {
- goto reigai;
+ goto fail;
}
}
switch (pppoe->code) {
@@ -838,7 +844,7 @@ pppoed_input(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], int is_disc,
slist_fini(&tag_list);
return;
-reigai:
+fail:
slist_fini(&tag_list);
bad_packet:
pppoed_log(_this->self, LOG_INFO,
@@ -894,10 +900,10 @@ pppoed_recv_PADR(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN],
if ((session = malloc(sizeof(pppoe_session))) == NULL) {
pppoed_log(_pppoed, LOG_ERR, "malloc() failed on %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
- /* セッション Id の作成 */
+ /* create session_id */
shuffle_cnt = 0;
do {
session_id = (int)slist_remove_first(
@@ -911,7 +917,7 @@ pppoed_recv_PADR(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN],
__func__);
slist_add(&_pppoed->session_free_list,
(void *)PPPOED_SESSION_SHUFFLE_MARK);
- goto reigai;
+ goto fail;
}
slist_shuffle(&_pppoed->session_free_list);
slist_add(&_pppoed->session_free_list,
@@ -920,16 +926,16 @@ pppoed_recv_PADR(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN],
if (pppoe_session_init(session, _pppoed, _this->index, session_id,
shost) != 0)
- goto reigai;
+ goto fail;
hash_insert(_pppoed->session_hash, (void *)session_id, session);
if (pppoe_session_recv_PADR(session, tag_list) != 0)
- goto reigai;
+ goto fail;
session = NULL; /* don't free */
- /* FALL THROUGH */
-reigai:
+ /* FALLTHROUGH */
+fail:
if (session != NULL)
pppoe_session_fini(session);
return;
@@ -972,7 +978,7 @@ pppoed_recv_PADI(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN],
len = tlv0->length;
if (len >= sizeof(sn))
- goto reigai;
+ goto fail;
memcpy(sn, tlv0->value, len);
sn[len] = '\0';
@@ -990,7 +996,7 @@ pppoed_recv_PADI(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN],
shost[2], shost[3], shost[4], shost[5], sn, tlv_hostuniq?
pppoed_tlv_value_string(tlv_hostuniq) : "none",
_this->listen_ifname);
- goto reigai;
+ goto fail;
}
pppoed_log(_this->self, LOG_INFO,
@@ -1047,8 +1053,8 @@ pppoed_recv_PADI(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN],
*/
if (_this->self->acookie_hash != NULL) {
/*
- * ac-cookie の次の値を探す。
- * (uint32_t の空間で値がループします)
+ * search next ac-cookie.
+ * (XXX it will loop in uint32_t boundaly)
*/
do {
_this->self->acookie_next += 1;
@@ -1093,15 +1099,15 @@ pppoed_recv_PADI(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN],
shost[3], shost[4], shost[5], service_name, ac_name,
tlv_hostuniq? pppoed_tlv_value_string(tlv_hostuniq) : "none",
_this->listen_ifname);
- // FALL THROUGH
-reigai:
+ /* FALLTHROUGH */
+fail:
bytebuffer_unwrap(buf);
bytebuffer_destroy(buf);
}
-/***********************************************************************
- * ログ関連
- ***********************************************************************/
+/*
+ * log
+ */
static void
pppoed_log(pppoed *_this, int prio, const char *fmt, ...)
{
@@ -1177,9 +1183,9 @@ pppoed_tlv_value_string(struct pppoe_tlv *tlv)
return _tlv_string_value;
}
-/***********************************************************************
- * 雑多な関数
- ***********************************************************************/
+/*
+ * misc
+ */
static int
session_id_cmp(void *a, void *b)
{
diff --git a/usr.sbin/npppd/pptp/pptp.h b/usr.sbin/npppd/pptp/pptp.h
index c0438865a53..71d45725d3c 100644
--- a/usr.sbin/npppd/pptp/pptp.h
+++ b/usr.sbin/npppd/pptp/pptp.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: pptp.h,v 1.3 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -26,9 +27,9 @@
#ifndef PPTP_H
#define PPTP_H 1
-/************************************************************************
- * プロトコル上の定数
- ************************************************************************/
+/*
+ * PPTP protocol constants
+ */
#define PPTP_MES_TYPE_CTRL 1
#define PPTP_MAGIC_COOKIE 0x1a2b3c4d
#define PPTP_RFC_2637_VERSION 0x0100
@@ -37,57 +38,57 @@
#define PPTP_MAX_CALL 8192
#endif
+/* Start-Control-Connection-Request */
+#define PPTP_CTRL_MES_CODE_SCCRQ 1
-/** Start-Control-Connection-Request */
-#define PPTP_CTRL_MES_CODE_SCCRQ 1
+/* Start-Control-Connection-Reply */
+#define PPTP_CTRL_MES_CODE_SCCRP 2
-/** Start-Control-Connection-Reply */
-#define PPTP_CTRL_MES_CODE_SCCRP 2
+/* Stop-Control-Connection-Request */
+#define PPTP_CTRL_MES_CODE_StopCCRQ 3
-/** Stop-Control-Connection-Request */
-#define PPTP_CTRL_MES_CODE_StopCCRQ 3
+/* Stop-Control-Connection-Reply */
+#define PPTP_CTRL_MES_CODE_StopCCRP 4
-/** Stop-Control-Connection-Reply */
-#define PPTP_CTRL_MES_CODE_StopCCRP 4
+/* Echo-Request */
+#define PPTP_CTRL_MES_CODE_ECHO_RQ 5
-/** Echo-Request */
-#define PPTP_CTRL_MES_CODE_ECHO_RQ 5
+/* Echo-Reply */
+#define PPTP_CTRL_MES_CODE_ECHO_RP 6
-/** Echo-Reply */
-#define PPTP_CTRL_MES_CODE_ECHO_RP 6
+/* Outgoing-Call-Request */
+#define PPTP_CTRL_MES_CODE_OCRQ 7
-/** Outgoing-Call-Request */
-#define PPTP_CTRL_MES_CODE_OCRQ 7
+/* Outgoing-Call-Reply */
+#define PPTP_CTRL_MES_CODE_OCRP 8
-/** Outgoing-Call-Reply */
-#define PPTP_CTRL_MES_CODE_OCRP 8
+/* Incoming-Call-Request */
+#define PPTP_CTRL_MES_CODE_ICRQ 9
-/** Incoming-Call-Request */
-#define PPTP_CTRL_MES_CODE_ICRQ 9
+/* Incoming-Call-Reply */
+#define PPTP_CTRL_MES_CODE_ICRP 10
-/** Incoming-Call-Reply */
-#define PPTP_CTRL_MES_CODE_ICRP 10
+/* Incoming-Call-Connected */
+#define PPTP_CTRL_MES_CODE_ICCN 11
-/** Incoming-Call-Connected */
-#define PPTP_CTRL_MES_CODE_ICCN 11
+/* Call-Clear-Request */
+#define PPTP_CTRL_MES_CODE_CCR 12
-/** Call-Clear-Request */
-#define PPTP_CTRL_MES_CODE_CCR 12
+/* Call-Disconnect-Notify */
+#define PPTP_CTRL_MES_CODE_CDN 13
-/** Call-Disconnect-Notify */
-#define PPTP_CTRL_MES_CODE_CDN 13
+/* Set-Link-Info */
+#define PPTP_CTRL_MES_CODE_SLI 15
-/** Set-Link-Info */
-#define PPTP_CTRL_MES_CODE_SLI 15
+#define PPTP_CTRL_FRAMING_ASYNC 1
+#define PPTP_CTRL_FRAMING_SYNC 2
-#define PPTP_CTRL_FRAMING_ASYNC 1
-#define PPTP_CTRL_FRAMING_SYNC 2
+#define PPTP_CTRL_BEARER_ANALOG 1
+#define PPTP_CTRL_BEARER_DIGITAL 2
-#define PPTP_CTRL_BEARER_ANALOG 1
-#define PPTP_CTRL_BEARER_DIGITAL 2
-/* Start-Control-Connection-Reply の Result Code */
+/* Result Code: Start-Control-Connection-Reply */
#define PPTP_SCCRP_RESULT_SUCCESS 1
#define PPTP_SCCRP_RESULT_GENERIC_ERROR 2
#define PPTP_SCCRP_RESULT_CHANNEL_EXISTS 3
@@ -102,7 +103,7 @@
#define PPTP_ERROR_BAD_CALL 4
#define PPTP_ERROR_PAC_ERROR 5
-/* Outgoing-Call-Reply の Result Code */
+/* Result Code: Outgoing-Call-Reply */
#define PPTP_OCRP_RESULT_CONNECTED 1
#define PPTP_OCRP_RESULT_GENERIC_ERROR 2
#define PPTP_OCRP_RESULT_NO_CARRIER 3
@@ -111,16 +112,16 @@
#define PPTP_OCRP_RESULT_TIMEOUT 6
#define PPTP_OCRP_RESULT_DO_NOT_ACCEPT 7
-/* Echo-Reply の Result Code */
+/* Result Code: Echo-Reply */
#define PPTP_ECHO_RP_RESULT_OK 1
#define PPTP_ECHO_RP_RESULT_GENERIC_ERROR 2
-/* Stop-Control-Connection-Request の Reason */
+/* Reason code of the Stop-Control-Connection-Request */
#define PPTP_StopCCRQ_REASON_NONE 1
#define PPTP_StopCCRQ_REASON_STOP_PROTOCOL 2
#define PPTP_StopCCRQ_REASON_STOP_LOCAL_SHUTDOWN 3
-/* Stop-Control-Connection-Response の Result */
+/* Result code of the Stop-Control-Connection-Response */
#define PPTP_StopCCRP_RESULT_OK 1
#define PPTP_StopCCRP_RESULT_GENERIC_ERROR 2
@@ -129,17 +130,17 @@
#define PPTP_CDN_RESULT_ADMIN_SHUTDOWN 3
#define PPTP_CDN_RESULT_REQUEST 4
-/** デフォルトの待ち受け TCP ポート番号 */
+/* Default TCP port number */
#define PPTPD_DEFAULT_TCP_PORT 1723
#define PPTP_GRE_PROTOCOL_TYPE 0x880b
#define PPTP_GRE_VERSION 1
-/************************************************************************
- * この実装の定数
- ************************************************************************/
-/* pptpd ステータス */
+/*
+ * Constants of the NPPPD implementation
+ */
+/* pptpd status */
#define PPTPD_STATE_INIT 0
#define PPTPD_STATE_RUNNING 1
#define PPTPD_STATE_SHUTTING_DOWN 2
@@ -152,7 +153,7 @@
#define PPTPD_DEFAULT_LAYER2_LABEL "PPTP"
-/** ステートマシン */
+/* pptp control state code */
#define PPTP_CTRL_STATE_IDLE 0
#define PPTP_CTRL_STATE_WAIT_CTRL_REPLY 1
#define PPTP_CTRL_STATE_ESTABLISHED 2
@@ -167,28 +168,30 @@
#define PPTP_CALL_DEFAULT_MAXWINSZ 64
#endif
+/* Connection speed that nofified by OCRP */
+/* XXX: currently we use fixed value */
#ifndef PPTP_CALL_CONNECT_SPEED
-/** 接続スピード。OCRP で通知する値で、現在は 10Mbps で固定 */
#define PPTP_CALL_CONNECT_SPEED 10000000
#endif
+/* Initial packet processing delay that nofified by OCRP */
#ifndef PPTP_CALL_INITIAL_PPD
-/** OCRP で通知する。初期 Packet Processing Dealy */
#define PPTP_CALL_INITIAL_PPD 0
#endif
+/* PPTP_CALL_NMAX_INSEQ specifies N packets was backwarded,
+ * when sequence# backwarded */
#ifndef PPTP_CALL_NMAX_INSEQ
-/** シーケンスが戻った場合に何パケットまでを戻ったとみなすか。*/
#define PPTP_CALL_NMAX_INSEQ 64
#endif
-/** call のステートマシン */
+/* pptp call state machine */
#define PPTP_CALL_STATE_IDLE 0
#define PPTP_CALL_STATE_WAIT_CONN 1
#define PPTP_CALL_STATE_ESTABLISHED 2
#define PPTP_CALL_STATE_CLEANUP_WAIT 3
-/* タイムアウト関連 */
+/* Timeout */
#define PPTPD_SHUTDOWN_TIMEOUT 5
#define PPTPD_IDLE_TIMEOUT 60
@@ -199,72 +202,51 @@
#define PPTP_CTRL_DEFAULT_ECHO_TIMEOUT 60
#define PPTP_CTRL_StopCCRP_WAIT_TIME 3
-/** アドレスは最大何個 bind 可能か。*/
+/* MAXIMUM bindable IP addresses */
#ifndef PPTP_NLISTENER
#define PPTP_NLISTENER 6
#endif
-/** PPTPデーモンが停止したかどうかを返します。 */
+/* Utility macro */
#define pptpd_is_stopped(pptpd) \
(((pptpd)->state != PPTPD_STATE_SHUTTING_DOWN && \
(pptpd)->state != PPTPD_STATE_RUNNING)? 1 : 0)
-/** PPTPデーモンが停止処理中かどうかを返します。 */
#define pptpd_is_shutting_down(pptpd) \
(((pptpd)->state == PPTPD_STATE_SHUTTING_DOWN)? 1 : 0)
-/************************************************************************
- * 型
- ************************************************************************/
-/** PPTP デーモンの型*/
+/*
+ * types
+ */
struct _pptpd;
-/** PPTP デーモン待ち受け型 */
+
typedef struct _pptpd_listener {
- /** イベントコンテキスト */
- struct event ev_sock;
- /** GREイベントコンテキスト */
- struct event ev_sock_gre;
- /** PPTPD 自身 */
+ struct event ev_sock; /* event context */
+ struct event ev_sock_gre; /* GRE event context */
struct _pptpd *self;
- /** インデックス番号 */
uint16_t index;
- /** 待ち受けソケット */
- int sock;
- /** GREソケット */
- int sock_gre;
- /** 待ち受けアドレス TCP */
- struct sockaddr_in bind_sin;
- /** 待ち受けアドレス GRE */
- struct sockaddr_in bind_sin_gre;
- /** 物理層のラベル */
+ int sock; /* listing socket */
+ int sock_gre; /* GRE socket */
+ struct sockaddr_in bind_sin; /* listing TCP address */
+ struct sockaddr_in bind_sin_gre; /* listing GRE address */
char phy_label[16];
} pptpd_listener;
-/** PPTP デーモンの型*/
typedef struct _pptpd {
- /** インスタンスの Id */
unsigned id;
- /** 待ち受けリスト */
- slist listener;
- /** ステート */
+ slist listener; /* list of listeners */
int state;
- /** タイマーイベントコンテキスト */
- struct event ev_timer;
- /** PPTP コントロールのリスト */
- slist ctrl_list;
+ struct event ev_timer; /* timer event context */
+ slist ctrl_list; /* list of PPTP controls */
- /** 設定 */
struct properties *config;
- /** 空きコールリスト */
- slist call_free_list;
- /** コールId => Call マップ */
- hash_table *call_id_map;
- /** 接続を許可するIPv4ネットワーク */
+ slist call_free_list; /* Free call lists */
+ hash_table *call_id_map; /* table to map between callid and call */
+ /* ipv4 networks that is permitted to connect */
struct in_addr_range *ip4_allow;
- /** フラグ */
- uint32_t
+ uint32_t /* flags */
initialized:1,
ctrl_in_pktdump:1,
ctrl_out_pktdump:1,
@@ -277,105 +259,70 @@ typedef struct _pptpd {
((pptpd_listener *)slist_get(&(ctrl)->pptpd->listener,\
(ctrl)->listener_index))->sock_gre
-/** pptp_ctrl から、リスナーの物理層のラベルを取り出すマクロ */
+/* get listner's physical layer label from pptp_ctrl */
#define PPTP_CTRL_LISTENER_LABEL(ctrl) \
((pptpd_listener *)slist_get(&(ctrl)->pptpd->listener,\
(ctrl)->listener_index))->phy_label
-/** PPTP コントロールの型*/
typedef struct _pptp_ctrl {
- /** 親 pptpd */
- pptpd *pptpd;
- /** リスナー インデックス番号*/
+ pptpd *pptpd; /* parents */
uint16_t listener_index;
- /** インスタンスの Id */
unsigned id;
- /** ステート */
int state;
- /** 物理層のラベル */
char phy_label[16];
- /** ソケット */
int sock;
- /** 先方のアドレス */
struct sockaddr_storage peer;
- /** 当方のアドレス */
struct sockaddr_storage our;
- /** イベントコンテキスト */
struct event ev_sock;
- /** タイマーイベントコンテキスト */
struct event ev_timer;
- /** アイドル状態から ECHO 送信までの秒数。0以下は無効。*/
- int echo_interval;
- /** ECHO のタイムアウト */
+ int echo_interval; /* periods between idle state to ECHO transmit */
int echo_timeout;
- /** 送信可能かどうか。送信バッファが埋まっていないか */
- int send_ready;
- /** 受信バッファ */
+ int send_ready; /* ready to send */
bytebuffer *recv_buf;
- /** 送信バッファ */
bytebuffer *send_buf;
- /** コールのリスト */
slist call_list;
- /** 最後にコントロールメッセージを送信した時間 */
- time_t last_snd_ctrl;
- /** 最後にコントロールメッセージを受信を送信した時間 */
- time_t last_rcv_ctrl;
- /** Echo Request の identifier */
- uint32_t echo_seq;
+ time_t last_snd_ctrl; /* timestamp of latest ctrl message sent */
+ time_t last_rcv_ctrl; /* timestamp of latest ctrl message receieved */
+ uint32_t echo_seq; /* identifier of Echo Request */
- int16_t /** I/O イベント処理中。*/
+ int16_t /* flags : processing I/O events */
on_io_event:1,
reserved:15;
-
} pptp_ctrl;
-/** PPTP コールの型 */
typedef struct _pptp_call {
- /** 親コントロール */
- pptp_ctrl *ctrl;
- /** コールID*/
+ pptp_ctrl *ctrl; /* parent */
unsigned id;
- /** 受信インタフェース番号 */
- int ifidx;
+ int ifidx; /* recieve interface index */
- /** ステート */
int state;
- /** 先方のコールID*/
unsigned peers_call_id;
void *ppp;
- /** 次の確認応答 */
- uint32_t snd_una;
- /** 次の送信シーケンス番号 */
- uint32_t snd_nxt;
-
- /** 受信シーケンス番号 */
- uint32_t rcv_nxt;
- /** 応答確認した受信シーケンス番号 */
- uint32_t rcv_acked;
-
- /** カレントウィンドウサイズ */
- int winsz;
- /** 最大ウィンドウサイズ */
- int maxwinsz;
- /** 先方の最大ウィンドウサイズ*/
+ uint32_t snd_una; /* next ack notification */
+ uint32_t snd_nxt; /* next transmit sequence # */
+
+ uint32_t rcv_nxt; /* recieved sequence # */
+ uint32_t rcv_acked; /* latest acked recieved sequence # */
+
+ int winsz; /* current window size */
+ int maxwinsz; /* maximum window size */
int peers_maxwinsz;
time_t last_io;
-
} pptp_call;
-/************************************************************************
- * 関数プロトタイプ
- ************************************************************************/
+/*
+ * function prototypes
+ */
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/usr.sbin/npppd/pptp/pptp_call.c b/usr.sbin/npppd/pptp/pptp_call.c
index 0bdc6835638..400ec0ed0ce 100644
--- a/usr.sbin/npppd/pptp/pptp_call.c
+++ b/usr.sbin/npppd/pptp/pptp_call.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pptp_call.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,15 +24,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: pptp_call.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
-/**@file
- * PPTPコールの実装。PACを仮定しています。
- */
+/* $Id: pptp_call.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
+/**@file PPTP Call */
+/* currently it supports PAC mode only */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
-#include <netinet/in.h>
#include <sys/time.h>
+#include <netinet/in.h>
+#include <net/if_dl.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -54,6 +55,8 @@
#include "pptp_local.h"
#include "pptp_subr.h"
+#include "npppd.h"
+
#ifdef PPTP_CALL_DEBUG
#define PPTP_CALL_DBG(x) pptp_call_log x
#define PPTP_CALL_ASSERT(x) ASSERT(x)
@@ -79,6 +82,9 @@ static void pptp_call_OCRP_string (struct pptp_ocrp *, char *, int);
static void pptp_call_ppp_input (pptp_call *, unsigned char *, int);
static char * pptp_call_state_string(int);
+static int pptp_call_ppp_output (npppd_ppp *, unsigned char *, int, int);
+static void pptp_call_closed_by_ppp (npppd_ppp *);
+
/* not used
static int pptp_call_send_SLI (pptp_call *);
*/
@@ -89,13 +95,12 @@ static int pptp_call_send_SLI (pptp_call *);
#define SEQ_GE(a,b) ((int)((a) - (b)) >= 0)
#define SEQ_SUB(a,b) ((int32_t)((a) - (b)))
-/** 切り上げ割算 */
+/* round-up division */
#define RUPDIV(n,d) (((n) + ((d) - ((n) % (d)))) / (d))
-/***********************************************************************
- * インスタンス操作関連
- ***********************************************************************/
-/** pptp_call インスタンスを生成します */
+/*
+ * instance related functions
+ */
pptp_call *
pptp_call_create(void)
{
@@ -107,7 +112,6 @@ pptp_call_create(void)
return _this;
}
-/** pptp_call インスタンスを初期化します */
int
pptp_call_init(pptp_call *_this, pptp_ctrl *ctrl)
{
@@ -123,7 +127,6 @@ pptp_call_init(pptp_call *_this, pptp_ctrl *ctrl)
return 1;
}
-/** pptp_call インスタンスを開始します */
int
pptp_call_start(pptp_call *_this)
{
@@ -132,7 +135,7 @@ pptp_call_start(pptp_call *_this)
return 0;
}
-/** pptp_call インスタンスを終了します */
+
int
pptp_call_stop(pptp_call *_this)
{
@@ -145,7 +148,6 @@ pptp_call_stop(pptp_call *_this)
return 0;
}
-/** pptp_call インスタンスを解放します */
void
pptp_call_destroy(pptp_call *_this)
{
@@ -153,7 +155,6 @@ pptp_call_destroy(pptp_call *_this)
free(_this);
}
-/** PPTPコールを切断します。*/
void
pptp_call_disconnect(pptp_call *_this, int result, int error, const char *
statistics)
@@ -168,10 +169,10 @@ pptp_call_disconnect(pptp_call *_this, int result, int error, const char *
pptp_call_notify_down(_this);
}
-/***********************************************************************
- * コントロールパケットの入出力
- ***********************************************************************/
-/** コントロールパケットの入力 */
+/*
+ * PPTP control packet I/O
+ */
+
void
pptp_call_input(pptp_call *_this, int mes_type, u_char *pkt, int lpkt)
{
@@ -244,12 +245,9 @@ bad_state:
pptp_call_state_string(_this->state));
}
-/**
- * Set-Link-Info の受信
- * <p>
- * この実装では『同期フレーム』しかサポートしないので、ACCM
- * (Asynchronous Control Character Map) は、保持しない。</p>
- */
+/* receive Set-Link-Info */
+/* XXX: this implementation is only supporting "Sync-Frame",
+ * ACCM (Asynchronous Control Character Map) will be discarded */
static int
pptp_call_recv_SLI(pptp_call *_this, u_char *pkt, int lpkt)
{
@@ -277,15 +275,12 @@ pptp_call_recv_SLI(pptp_call *_this, u_char *pkt, int lpkt)
}
#if 0
-/*
- * 『PPTPパススルー』機能をサポートする一部のルータは、PAC から SLI を
- * を受信すると、以後 PAC => PNS の 1723/tcp パケットを落すモノがある
- * ようです。(今のところ富士通製 FLASHWAVE がそんな感じ)
+/* Some route implementation which has "PPTP pass-through" function
+ * will discard 1723/tcp packet between PAC and PNS, when it recognize
+ * SLI from PAC. (for example, FLASHWAVE by Fujitsu).
*
- * このため、使い途のわからない SLI は npppd からは送信しないことにしました。
- * See idgw-develop 5916
+ * To avoid avobe situation, npppd send well-known SLI only.
*/
-/** SLI の送信 */
static int
pptp_call_send_SLI(pptp_call *_this)
{
@@ -320,28 +315,28 @@ pptp_call_send_SLI(pptp_call *_this)
}
#endif
-/** Call-Clear-Request の受信 */
+/* Receive Call-Clear-Request */
static int
pptp_call_recv_CCR(pptp_call *_this, u_char *pkt, int lpkt)
{
struct pptp_ccr *ccr;
- // サイズ検査
+ /* check size */
PPTP_CALL_ASSERT(lpkt >= sizeof(struct pptp_ccr));
if (lpkt < sizeof(struct pptp_ccr)) {
- // call_id チェック済みでここに呼ばれるので、起こり得ない。
+ /* never happen, should KASSERT() here? */
return 1;
}
ccr = (struct pptp_ccr *)pkt;
- // バイトオーダー
+ /* convert byte-order */
ccr->call_id = ntohs(ccr->call_id);
pptp_call_log(_this, LOG_INFO, "RecvCCR call_id=%u", ccr->call_id);
return 0;
}
-/** Call-Disconnect-Notify の送信 */
+/* Send Call-Disconnect-Notify */
static void
pptp_call_send_CDN(pptp_call *_this, int result, int error, int cause,
const char *statistics)
@@ -383,7 +378,7 @@ pptp_call_send_CDN(pptp_call *_this, int result, int error, int cause,
pptp_ctrl_output(_this->ctrl, NULL, sizeof(struct pptp_cdn));
}
-/** Outgoing-Call-Reply の送信 */
+/* Send Outgoing-Call-Reply */
static int
pptp_call_send_OCRP(pptp_call *_this, int result, int error, int cause)
{
@@ -430,14 +425,14 @@ pptp_call_send_OCRP(pptp_call *_this, int result, int error, int cause)
return 0;
}
-/** Outgoing-Call-Request を受信 */
+/* Receive Outgoing-Call-Request */
static int
pptp_call_recv_OCRQ(pptp_call *_this, u_char *pkt, int lpkt)
{
char logbuf[512];
struct pptp_ocrq *ocrq;
- // サイズ検査
+ /* check size */
if (lpkt < sizeof(struct pptp_ocrq)) {
pptp_call_log(_this, LOG_ERR, "Received bad OCRQ: packet too "
"short: %d < %d", lpkt, (int)sizeof(struct pptp_ocrq));
@@ -445,7 +440,7 @@ pptp_call_recv_OCRQ(pptp_call *_this, u_char *pkt, int lpkt)
}
ocrq = (struct pptp_ocrq *)pkt;
- // バイトオーダー
+ /* convert byte-order */
ocrq->call_id = ntohs(ocrq->call_id);
ocrq->call_serial_number = ntohs(ocrq->call_serial_number);
ocrq->recv_winsz = ntohs(ocrq->recv_winsz);
@@ -466,11 +461,12 @@ pptp_call_recv_OCRQ(pptp_call *_this, u_char *pkt, int lpkt)
return 0;
}
-/***********************************************************************
- * GRE の入出力
- ***********************************************************************/
-/** GREからパケット受信 */
+/*
+ * GRE I/O
+ */
+
+/* Reciver packet via GRE */
void
pptp_call_gre_input(pptp_call *_this, uint32_t seq, uint32_t ack,
int input_flags, u_char *pkt, int pktlen)
@@ -501,16 +497,16 @@ pptp_call_gre_input(pptp_call *_this, uint32_t seq, uint32_t ack,
if (input_flags & PPTP_GRE_PKT_ACK_PRESENT) {
if (ack + 1 == _this->snd_una) {
- /* 前回受信した ack から進んでいないだけ */
+ /* nothing to do */
} else if (SEQ_LT(ack, _this->snd_una)) {
- /* ack が戻った */
+ /* ack sequence# was rewinded */
if (abs(ack - _this->snd_una) < PPTP_CALL_NMAX_INSEQ) {
- /* ちょっと戻るのはパケット順入れ替わり。*/
+ /* packet reordered ? */
log_prio = LOG_DEBUG;
}
reason = "ack out of sequence";
goto bad_pkt;
- // FALL THROUGH
+ /* FALLTHROUGH */
} else if (SEQ_GT(ack, _this->snd_nxt)) {
reason = "ack for unknown sequence.";
goto bad_pkt;
@@ -523,20 +519,17 @@ pptp_call_gre_input(pptp_call *_this, uint32_t seq, uint32_t ack,
if ((input_flags & PPTP_GRE_PKT_SEQ_PRESENT) == 0)
return; /* ack only packet */
- // seq チェック
+ /* check sequence# */
if (SEQ_LT(seq, _this->rcv_nxt)) {
- /* 順番入れ替わり、届くのが遅れた? */
+ /* reorderd, delayed delivery? */
if (abs(seq - _this->rcv_nxt) < PPTP_CALL_NMAX_INSEQ)
log_prio = LOG_DEBUG;
reason = "out of sequence";
goto bad_pkt;
} else if (SEQ_GE(seq, _this->rcv_nxt + _this->maxwinsz)){
- /*
- * どんなにおかしくても受信せざるをえない。
- *
- * FIXME: パケットロスが 4096 発を超えると MPPE の状態が復元
- * できないが。
- */
+ /* MUST Process them */
+ /* XXX FIXME: if over 4096 packets lost, it can not
+ * fix MPPE state */
pptp_call_log(_this, LOG_INFO,
"Received packet caused window overflow. seq=%u(%u-%u), "
"may lost %d packets.", seq, _this->rcv_nxt,
@@ -544,13 +537,14 @@ pptp_call_gre_input(pptp_call *_this, uint32_t seq, uint32_t ack,
SEQ_SUB(seq, _this->rcv_nxt));
}
seq++;
- /* TODO: パケットロスは ppp->ierrors でカウントすべきか? */
+ /* XXX : TODO: should it counts lost packets ppp->ierrors
+ * and update ppp->ierrors counter? */
_this->rcv_nxt = seq;
if (SEQ_SUB(seq, _this->rcv_acked) > RUPDIV(_this->winsz, 2)) {
/*
* Multi-packet acknowledgement.
- * window size の半分を超えた場合のみ ack する
+ * send ack when it reachs to half of window size
*/
PPTP_CALL_DBG((_this, LOG_DEBUG, "rcv window size=%u %u %u\n",
SEQ_SUB(seq, _this->rcv_acked), seq, _this->rcv_acked));
@@ -566,11 +560,8 @@ bad_pkt:
ack, _this->snd_una, _this->snd_nxt);
}
-/**
- * GREに出力
- * @param fseq SEQフィールドを含めるかどうか。
- * @param fack ACKフィールドを含めるかどうか。
- */
+/* output to GRE */
+/* flags: fseq: contain SEQ field, fack: contain ACK field */
static int
pptp_call_gre_output(pptp_call *_this, int fseq, int fack, u_char *pkt,
int lpkt)
@@ -589,7 +580,7 @@ pptp_call_gre_output(pptp_call *_this, int fseq, int fack, u_char *pkt,
grehdr = (struct pptp_gre_header *)opkt;
opkt += sizeof(struct pptp_gre_header);
- /* GREヘッダ*/
+ /* GRE header */
grehdr->K = 1;
grehdr->ver = PPTP_GRE_VERSION;
grehdr->protocol_type = htons(PPTP_GRE_PROTOCOL_TYPE);
@@ -651,16 +642,11 @@ pptp_call_gre_output(pptp_call *_this, int fseq, int fack, u_char *pkt,
return (sz > 0)? 0 : 1;
}
-/************************************************************************
- * npppd の物理層として
- ************************************************************************/
-#include <net/if_dl.h>
-#include "npppd.h"
-
-static int pptp_call_ppp_output (npppd_ppp *, unsigned char *, int, int);
-static void pptp_call_closed_by_ppp (npppd_ppp *);
+/*
+ * npppd physical layer functions
+ */
-/** PPTP の物理層が終了したことを、PPP に確実に伝える。*/
+/* notify to ppp that the PPTP physical layer is already downed */
static void
pptp_call_notify_down(pptp_call *_this)
{
@@ -669,7 +655,7 @@ pptp_call_notify_down(pptp_call *_this)
}
-/** ppp にパケットを入力します。 */
+/* input packet to ppp */
static void
pptp_call_ppp_input(pptp_call *_this, u_char *pkt, int pktlen)
{
@@ -694,7 +680,7 @@ pptp_call_ppp_input(pptp_call *_this, u_char *pkt, int pktlen)
}
}
-/** ppp からパケットが出力される時に呼び出されます。 */
+/* it called when ppp outputs packet */
static int
pptp_call_ppp_output(npppd_ppp *ppp, unsigned char *bytes, int nbytes,
int flags)
@@ -717,7 +703,7 @@ pptp_call_ppp_output(npppd_ppp *ppp, unsigned char *bytes, int nbytes,
return 0;
}
-/** ppp で切断された場合に呼び出されます。 */
+/* it called when pptp call was closed at ppp */
static void
pptp_call_closed_by_ppp(npppd_ppp *ppp)
{
@@ -728,7 +714,8 @@ pptp_call_closed_by_ppp(npppd_ppp *ppp)
_this = ppp->phy_context;
- _this->ppp = NULL; // pptp_call_disconnect より先に。
+ /* do this before pptp_call_disconnect() */
+ _this->ppp = NULL;
if (_this->state != PPTP_CALL_STATE_CLEANUP_WAIT) {
pptp_call_disconnect(_this, PPTP_CDN_RESULT_LOST_CARRIER, 0,
@@ -737,7 +724,7 @@ pptp_call_closed_by_ppp(npppd_ppp *ppp)
pptp_call_log(_this, LOG_NOTICE, "logtype=PPPUnbind");
}
-/** ppp の bind。*/
+/* bind() for ppp */
static int
pptp_call_bind_ppp(pptp_call *_this)
{
@@ -745,7 +732,7 @@ pptp_call_bind_ppp(pptp_call *_this)
ppp = NULL;
if ((ppp = ppp_create()) == NULL)
- goto reigai;
+ goto fail;
PPTP_CALL_ASSERT(_this->ppp == NULL);
@@ -765,28 +752,27 @@ pptp_call_bind_ppp(pptp_call *_this)
_this->ctrl->peer.ss_len);
if (ppp_init(npppd_get_npppd(), ppp) != 0)
- goto reigai;
+ goto fail;
pptp_call_log(_this, LOG_NOTICE, "logtype=PPPBind ppp=%d", ppp->id);
ppp_start(ppp);
return 0;
-reigai:
+fail:
pptp_call_log(_this, LOG_ERR, "failed binding ppp");
if (ppp != NULL)
ppp_destroy(ppp);
_this->ppp = NULL;
- //pptp_call_disconnect(_this, PPTP_CDN_RCODE_BUSY, 0, NULL);
return 1;
}
-/***********************************************************************
- * その他ユーティリティ関数
- ***********************************************************************/
+/*
+ * utility functions
+ */
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/* logging with the label for the instance */
static void
pptp_call_log(pptp_call *_this, int prio, const char *fmt, ...)
{
@@ -805,7 +791,7 @@ pptp_call_log(pptp_call *_this, int prio, const char *fmt, ...)
va_end(ap);
}
-/** Outgoing-Call-Request パケットを文字列で表現する */
+/* convert Outgoing-Call-Request packet to strings */
static void
pptp_call_OCRQ_string(struct pptp_ocrq *ocrq, char *buf, int lbuf)
{
@@ -820,7 +806,7 @@ pptp_call_OCRQ_string(struct pptp_ocrq *ocrq, char *buf, int lbuf)
ocrq->subaddress);
}
-/** Outgoing-Call-Reply パケットを文字列で表現する */
+/* convert Outgoing-Call-Reply packet to strings */
void
pptp_call_OCRP_string(struct pptp_ocrp *ocrp, char *buf, int lbuf)
{
diff --git a/usr.sbin/npppd/pptp/pptp_ctrl.c b/usr.sbin/npppd/pptp/pptp_ctrl.c
index 7d8941bbc11..5ba995b0632 100644
--- a/usr.sbin/npppd/pptp/pptp_ctrl.c
+++ b/usr.sbin/npppd/pptp/pptp_ctrl.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pptp_ctrl.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -24,9 +25,10 @@
* SUCH DAMAGE.
*/
/**@file
- * PPTP(RFC 2637) コントロール接続部の実装。PACのみ。
+ * PPTP(RFC 2637) control connection implementation.
+ * currently it only support PAC part
*/
-/* $Id: pptp_ctrl.c,v 1.1 2010/01/11 04:20:57 yasuoka Exp $ */
+/* $Id: pptp_ctrl.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -55,7 +57,7 @@
#include "pptp_local.h"
#include "pptp_subr.h"
-/** 2 秒毎に pptp_ctrl_timeout */
+/* periods of pptp_ctrl_timeout */
#define PPTP_CTRL_TIMEOUT_IVAL_SEC 2
#ifdef PPTP_CTRL_DEBUG
@@ -90,9 +92,9 @@ static int pptp_ctrl_call_input (pptp_ctrl *, int, u_char *, int);
static const char *pptp_ctrl_state_string (int);
static void pptp_ctrl_fini(pptp_ctrl *);
-/************************************************************************
- * pptp_ctrl インスタンス操作
- ************************************************************************/
+/*
+ * pptp_ctrl instance operation functions
+ */
pptp_ctrl *
pptp_ctrl_create(void)
{
@@ -118,12 +120,12 @@ pptp_ctrl_init(pptp_ctrl *_this)
if ((_this->recv_buf = bytebuffer_create(PPTP_BUFSIZ)) == NULL) {
pptp_ctrl_log(_this, LOG_ERR, "bytebuffer_create() failed at "
"%s(): %m", __func__);
- goto reigai;
+ goto fail;
}
if ((_this->send_buf = bytebuffer_create(PPTP_BUFSIZ)) == NULL) {
pptp_ctrl_log(_this, LOG_ERR, "bytebuffer_create() failed at "
"%s(): %m", __func__);
- goto reigai;
+ goto fail;
}
_this->last_rcv_ctrl = curr_time;
_this->last_snd_ctrl = curr_time;
@@ -134,7 +136,7 @@ pptp_ctrl_init(pptp_ctrl *_this)
evtimer_set(&_this->ev_timer, pptp_ctrl_timeout, _this);
return 0;
-reigai:
+fail:
return 1;
}
@@ -150,8 +152,7 @@ pptp_ctrl_start(pptp_ctrl *_this)
PPTP_CTRL_ASSERT(_this != NULL);
PPTP_CTRL_ASSERT(_this->sock >= 0);
- /* ログ用にアドレス=>文字列変換 */
-
+ /* convert address to strings for logging */
strlcpy(hbuf0, "<unknown>", sizeof(hbuf0));
strlcpy(sbuf0, "<unknown>", sizeof(sbuf0));
strlcpy(hbuf1, "<unknown>", sizeof(hbuf1));
@@ -166,7 +167,7 @@ pptp_ctrl_start(pptp_ctrl *_this)
if (getsockname(_this->sock, (struct sockaddr *)&sock, &socklen) != 0) {
pptp_ctrl_log(_this, LOG_ERR,
"getsockname() failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
if (getnameinfo((struct sockaddr *)&sock, sock.ss_len, hbuf1,
sizeof(hbuf1), sbuf1, sizeof(sbuf1),
@@ -180,21 +181,21 @@ pptp_ctrl_start(pptp_ctrl *_this)
if ((ival = fcntl(_this->sock, F_GETFL, 0)) < 0) {
pptp_ctrl_log(_this, LOG_ERR,
"fcntl(F_GET_FL) failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
} else if (fcntl(_this->sock, F_SETFL, ival | O_NONBLOCK) < 0) {
pptp_ctrl_log(_this, LOG_ERR,
"fcntl(F_SET_FL) failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
pptp_ctrl_set_io_event(_this);
pptp_ctrl_reset_timeout(_this);
return 0;
-reigai:
+fail:
return 1;
}
-/** タイマー処理 */
+/* Timer */
static void
pptp_ctrl_timeout(int fd, short event, void *ctx)
{
@@ -207,7 +208,7 @@ pptp_ctrl_timeout(int fd, short event, void *ctx)
curr_time = get_monosec();
PPTP_CTRL_DBG((_this, DEBUG_LEVEL_3, "enter %s()", __func__));
- /* call のクリーンアップ */
+ /* clean up call */
i = 0;
while (i < slist_length(&_this->call_list)) {
call = slist_get(&_this->call_list, i);
@@ -220,7 +221,7 @@ pptp_ctrl_timeout(int fd, short event, void *ctx)
i++;
}
- /* ステートマシン、Timeout処理 */
+ /* State machine: Timeout */
switch (_this->state) {
default:
case PPTP_CTRL_STATE_WAIT_CTRL_REPLY:
@@ -250,7 +251,6 @@ pptp_ctrl_timeout(int fd, short event, void *ctx)
}
break;
case PPTP_CTRL_STATE_WAIT_STOP_REPLY:
- // お片付け
if (curr_time - _this->last_snd_ctrl >
PPTP_CTRL_StopCCRP_WAIT_TIME) {
pptp_ctrl_log(_this, LOG_WARNING,
@@ -273,7 +273,7 @@ pptp_ctrl_reset_timeout(pptp_ctrl *_this)
switch (_this->state) {
case PPTP_CTRL_STATE_DISPOSING:
- tv.tv_sec = 0; /* すぐに call back */
+ tv.tv_sec = 0; /* call back immidiatly */
tv.tv_usec = 0;
break;
default:
@@ -285,10 +285,10 @@ pptp_ctrl_reset_timeout(pptp_ctrl *_this)
}
/**
- * PPTPコントロールコネクションを終了します。
- * @result Stop-Control-Connection-Request(StopCCRQ) の result に指定する
- * 値。0 を指定すると、StopCCRQ を送信せずに、終了します。また、
- * プロトコル上、StopCCRQ を送信する必要がない場合も送信しません。
+ * Terminate PPTP control connection
+ * @result The value for Stop-Control-Connection-Request(StopCCRQ) result.
+ This function will not sent StopCCRQ when the value == 0 and
+ the specification does not require to sent it.
* @see ::#PPTP_StopCCRQ_REASON_STOP_PROTOCOL
* @see ::#PPTP_StopCCRQ_REASON_STOP_LOCAL_SHUTDOWN
*/
@@ -300,7 +300,8 @@ pptp_ctrl_stop(pptp_ctrl *_this, int result)
switch (_this->state) {
case PPTP_CTRL_STATE_WAIT_STOP_REPLY:
- // 返事待ち。pptp_ctrl_timeout で処理されます。
+ /* waiting responce. */
+ /* this state will timeout by pptp_ctrl_timeout */
break;
case PPTP_CTRL_STATE_ESTABLISHED:
if (result != 0) {
@@ -313,7 +314,7 @@ pptp_ctrl_stop(pptp_ctrl *_this, int result)
_this->state = PPTP_CTRL_STATE_WAIT_STOP_REPLY;
break;
}
- // FALL THROUGH
+ /* FALLTHROUGH */
default:
pptp_ctrl_fini(_this);
}
@@ -321,7 +322,7 @@ pptp_ctrl_stop(pptp_ctrl *_this, int result)
}
-/** PPTP コントロールを終了化します。*/
+/* finish PPTP control */
static void
pptp_ctrl_fini(pptp_ctrl *_this)
{
@@ -344,9 +345,9 @@ pptp_ctrl_fini(pptp_ctrl *_this)
if (_this->on_io_event != 0) {
/*
- * I/O イベントハンドラ内での終了化処理は、最後まで行うと
- * 例外処理が複雑になるので、途中までしか行わす、続きは、
- * タイマイベントハンドラで行う。
+ * as the complete terminate process needs complicated
+ * exception handling, do partially at here.
+ * rest of part will be handled by timer-event-handler.
*/
PPTP_CTRL_DBG((_this, LOG_DEBUG, "Disposing"));
_this->state = PPTP_CTRL_STATE_DISPOSING;
@@ -359,11 +360,11 @@ pptp_ctrl_fini(pptp_ctrl *_this)
pptp_ctrl_log (_this, LOG_NOTICE, "logtype=Finished");
- /* この後 _this は使用できない */
+ /* disable _this */
pptpd_ctrl_finished_notify(_this->pptpd, _this);
}
-/* PPTP コントロールコンテキストを解放します。*/
+/* free PPTP control context */
void
pptp_ctrl_destroy(pptp_ctrl *_this)
{
@@ -378,10 +379,10 @@ pptp_ctrl_destroy(pptp_ctrl *_this)
free(_this);
}
-/************************************************************************
- * ネットワーク I/O
- ************************************************************************/
-/** I/O イベントディスパッチャ */
+/*
+ * network I/O
+ */
+/* I/O event dispather */
static void
pptp_ctrl_io_event(int fd, short evmask, void *ctx)
{
@@ -396,7 +397,7 @@ pptp_ctrl_io_event(int fd, short evmask, void *ctx)
if ((evmask & EV_WRITE) != 0) {
if (pptp_ctrl_output_flush(_this) != 0 ||
_this->state == PPTP_CTRL_STATE_DISPOSING)
- goto reigai;
+ goto fail;
_this->send_ready = 1;
}
if ((evmask & EV_READ) != 0) {
@@ -407,12 +408,12 @@ pptp_ctrl_io_event(int fd, short evmask, void *ctx)
pptp_ctrl_log(_this, LOG_INFO,
"Connection closed by foreign host");
pptp_ctrl_fini(_this);
- goto reigai;
+ goto fail;
} else if (errno != EAGAIN && errno != EINTR) {
pptp_ctrl_log(_this, LOG_INFO,
"read() failed at %s(): %m", __func__);
pptp_ctrl_fini(_this);
- goto reigai;
+ goto fail;
}
}
bytebuffer_put(_this->recv_buf, BYTEBUFFER_PUT_DIRECT, sz);
@@ -433,20 +434,20 @@ pptp_ctrl_io_event(int fd, short evmask, void *ctx)
if (pptp_ctrl_input(_this, pkt, hdrlen) != 0 ||
_this->state == PPTP_CTRL_STATE_DISPOSING) {
bytebuffer_compact(_this->recv_buf);
- goto reigai;
+ goto fail;
}
}
bytebuffer_compact(_this->recv_buf);
}
if (pptp_ctrl_output_flush(_this) != 0)
- goto reigai;
+ goto fail;
pptp_ctrl_set_io_event(_this);
-reigai:
+fail:
_this->on_io_event = 0;
}
-/** イベントマスクを設定する */
+/* set i/o event mask */
static void
pptp_ctrl_set_io_event(pptp_ctrl *_this)
{
@@ -470,11 +471,11 @@ pptp_ctrl_set_io_event(pptp_ctrl *_this)
}
/**
- * PPTPコントロールパケットを出力します。
- * @param pkt パケットの領域へのポインタ。
- * bytebuffer を使って、_this->send_buf に追記している場合には、
- * NULL を指定します。
- * @param lpkt パケットの長さ。
+ * Output PPTP control packet
+ * @param pkt pointer to packet buffer.
+ * when it was appended by _this-.send_buf using bytebuffer,
+ * specify NULL.
+ * @param lpkt packet length
*/
void
pptp_ctrl_output(pptp_ctrl *_this, u_char *pkt, int lpkt)
@@ -482,29 +483,34 @@ pptp_ctrl_output(pptp_ctrl *_this, u_char *pkt, int lpkt)
PPTP_CTRL_ASSERT(_this != NULL);
PPTP_CTRL_ASSERT(lpkt > 0);
+ /* just put the packet into the buffer now. send it later */
bytebuffer_put(_this->send_buf, pkt, lpkt);
- /* 実際には書くのは後 */
if (_this->on_io_event != 0) {
- /* pptp_ctrl_io_event で pptp_ctrl_output_flush を呼び出し */
+ /*
+ * pptp_ctrl_output_flush() will be called by the end of
+ * the I/O event handler.
+ */
} else {
/*
- * I/O イベントハンドラからの呼出しではない場合は、
- * pptp_ctrl_output_flush() を呼び出す必要があるが flush =>
- * write 失敗 => finalize となると、この関数呼び出し側に例外
- * 処理を実装し煩雑になるので、write ready イベントで発行し
- * てもらって、そこで flush。
+ * When this function is called by other than I/O event handler,
+ * we need to call pptp_ctrl_output_flush(). However if we do
+ * it here, then we need to consider the situation
+ * 'flush => write failure => finalize'. The situation requires
+ * the caller function to handle the exception and causes
+ * complication. So we call pptp_ctrl_output_flush() by the
+ * the next send ready event.
*/
- _this->send_ready = 0;
- pptp_ctrl_set_io_event(_this);
+ _this->send_ready = 0; /* clear 'send ready' */
+ pptp_ctrl_set_io_event(_this); /* wait 'send ready */
}
return;
}
-/** Stop-Control-Connection-Request の送信 */
+/* Send Stop-Control-Connection-Request */
-/** 実際にパケット送信 */
+/* flush output packet */
static int
pptp_ctrl_output_flush(pptp_ctrl *_this)
{
@@ -514,10 +520,10 @@ pptp_ctrl_output_flush(pptp_ctrl *_this)
curr_time = get_monosec();
if (bytebuffer_position(_this->send_buf) <= 0)
- return 0; // nothing to write
+ return 0; /* nothing to write */
if (_this->send_ready == 0) {
pptp_ctrl_set_io_event(_this);
- return 0; // not ready to write
+ return 0; /* not ready to write */
}
bytebuffer_flip(_this->send_buf);
@@ -543,13 +549,13 @@ pptp_ctrl_output_flush(pptp_ctrl *_this)
return 0;
}
-/** Start-Control-Connection-Request、-Reply パケットを文字列で表現する */
+/* convert Start-Control-Connection-{Request,Reply} packet to strings */
static void
pptp_ctrl_SCCRx_string(struct pptp_scc *scc, u_char *buf, int lbuf)
{
char buf1[128], buf2[128], buf3[128];
- // 64バイトギリギリまで入っている場合があるので
+ /* sanity check */
strlcpy(buf1, scc->host_name, sizeof(buf1));
strlcpy(buf2, scc->vendor_string, sizeof(buf2));
@@ -569,14 +575,14 @@ pptp_ctrl_SCCRx_string(struct pptp_scc *scc, u_char *buf, int lbuf)
scc->firmware_revision, scc->firmware_revision, buf1, buf2);
}
-/** Start-Control-Connection-Request を受信 */
+/* receive Start-Control-Connection-Request */
static int
pptp_ctrl_recv_SCCRQ(pptp_ctrl *_this, u_char *pkt, int lpkt)
{
char logbuf[512];
struct pptp_scc *scc;
- // サイズ検査
+ /* sanity check */
if (lpkt < sizeof(struct pptp_scc)) {
pptp_ctrl_log(_this, LOG_ERR, "Received bad SCCRQ: packet too "
"short: %d < %d", lpkt, (int)sizeof(struct pptp_scc));
@@ -584,14 +590,13 @@ pptp_ctrl_recv_SCCRQ(pptp_ctrl *_this, u_char *pkt, int lpkt)
}
scc = (struct pptp_scc *)pkt;
- // バイトオーダー
scc->protocol_version = ntohs(scc->protocol_version);
scc->framing_caps = htonl(scc->framing_caps);
scc->bearer_caps = htonl(scc->bearer_caps);
scc->max_channels = htons(scc->max_channels);
scc->firmware_revision = htons(scc->firmware_revision);
- // プロトコルバージョン
+ /* check protocol version */
if (scc->protocol_version != PPTP_RFC_2637_VERSION) {
pptp_ctrl_log(_this, LOG_ERR, "Received bad SCCRQ: "
"unknown protocol version %d", scc->protocol_version);
@@ -604,7 +609,7 @@ pptp_ctrl_recv_SCCRQ(pptp_ctrl *_this, u_char *pkt, int lpkt)
return 0;
}
-/** Stop-Control-Connection-Reply の受信 */
+/* Receive Stop-Control-Connection-Reply */
static int
pptp_ctrl_recv_StopCCRP(pptp_ctrl *_this, u_char *pkt, int lpkt)
{
@@ -652,7 +657,7 @@ pptp_ctrl_send_StopCCRQ(pptp_ctrl *_this, int reason)
return 0;
}
-/** Stop-Control-Connection-Request を受信 */
+/* Receive Stop-Control-Connection-Request */
static int
pptp_ctrl_recv_StopCCRQ(pptp_ctrl *_this, u_char *pkt, int lpkt)
{
@@ -672,9 +677,7 @@ pptp_ctrl_recv_StopCCRQ(pptp_ctrl *_this, u_char *pkt, int lpkt)
return 0;
}
-
-
-/** Stop-Control-Connection-Reply を送信 */
+/* Send Stop-Control-Connection-Reply */
static int
pptp_ctrl_send_StopCCRP(pptp_ctrl *_this, int result, int error)
{
@@ -707,7 +710,7 @@ pptp_ctrl_send_StopCCRP(pptp_ctrl *_this, int result, int error)
return 0;
}
-/** Start-Control-Connection-Reply を送信 */
+/* Send Start-Control-Connection-Reply */
static int
pptp_ctrl_send_SCCRP(pptp_ctrl *_this, int result, int error)
{
@@ -731,22 +734,22 @@ pptp_ctrl_send_SCCRP(pptp_ctrl *_this, int result, int error)
scc->protocol_version = PPTP_RFC_2637_VERSION;
scc->result_code = result;
scc->error_code = error;
- // 同期フレームしかサポートせず。
- //scc->framing_caps = PPTP_CTRL_FRAMING_ASYNC;
+
+ /* XXX only support sync frames */
scc->framing_caps = PPTP_CTRL_FRAMING_SYNC;
scc->bearer_caps = PPTP_CTRL_BEARER_DIGITAL;
- scc->max_channels = 4; // XX 設定?
+ scc->max_channels = 4; /* XXX */
scc->firmware_revision = MAJOR_VERSION << 8 | MINOR_VERSION;
- // 63文字で切れても気にしない
-
- // ホスト名
+ /* this implementation only support these strings up to
+ * 63 character */
+ /* host name */
if ((val = pptp_ctrl_config_str(_this, "pptp.host_name")) == NULL)
val = "";
strlcpy(scc->host_name, val, sizeof(scc->host_name));
- // ベンダ名
+ /* vender name */
if ((val = pptp_ctrl_config_str(_this, "pptp.vendor_name")) == NULL)
val = PPTPD_DEFAULT_VENDOR_NAME;
@@ -766,7 +769,7 @@ pptp_ctrl_send_SCCRP(pptp_ctrl *_this, int result, int error)
return 0;
}
-/** ECHO の受信 => 返信 */
+/* receive ECHO and reply */
static void
pptp_ctrl_process_echo_req(pptp_ctrl *_this, u_char *pkt, int lpkt)
{
@@ -804,7 +807,7 @@ pptp_ctrl_process_echo_req(pptp_ctrl *_this, u_char *pkt, int lpkt)
PPTP_CTRL_DBG((_this, LOG_DEBUG, "SendEchoReply"));
}
-/** Echo-Reply の受信 */
+/* receiver Echo-Reply */
static int
pptp_ctrl_recv_echo_rep(pptp_ctrl *_this, u_char *pkt, int lpkt)
{
@@ -833,7 +836,7 @@ pptp_ctrl_recv_echo_rep(pptp_ctrl *_this, u_char *pkt, int lpkt)
return 0;
}
-/** Echo-Request の送信 */
+/* send Echo-Request */
static void
pptp_ctrl_send_echo_req(pptp_ctrl *_this)
{
@@ -858,7 +861,7 @@ pptp_ctrl_send_echo_req(pptp_ctrl *_this)
PPTP_CTRL_DBG((_this, LOG_DEBUG, "SendEchoReq"));
}
-/* Call-Disconnect-Notify の送信 */
+/* send Call-Disconnect-Notify */
static void
pptp_ctrl_send_CDN(pptp_ctrl *_this, int result, int error, int cause,
const char *statistics)
@@ -891,7 +894,7 @@ pptp_ctrl_send_CDN(pptp_ctrl *_this, int result, int error, int cause,
pptp_ctrl_output(_this, NULL, sizeof(struct pptp_cdn));
}
-/** コントロールパケット受信 */
+/* receive Control-packet */
static int
pptp_ctrl_input(pptp_ctrl *_this, u_char *pkt, int lpkt)
{
@@ -904,14 +907,13 @@ pptp_ctrl_input(pptp_ctrl *_this, u_char *pkt, int lpkt)
curr_time = get_monosec();
hdr = (struct pptp_ctrl_header *)pkt;
- // バイトオーダー
hdr->length = ntohs(hdr->length);
hdr->pptp_message_type = ntohs(hdr->pptp_message_type);
hdr->magic_cookie = ntohl(hdr->magic_cookie);
hdr->control_message_type = ntohs(hdr->control_message_type);
hdr->reserved0 = ntohs(hdr->reserved0);
- // 長さ検査
+ /* sanity check */
PPTP_CTRL_ASSERT(hdr->length <= lpkt);
_this->last_rcv_ctrl = curr_time;
@@ -924,21 +926,23 @@ pptp_ctrl_input(pptp_ctrl *_this, u_char *pkt, int lpkt)
show_hd(debug_get_debugfp(), pkt, lpkt);
}
- /* パケット検査 */
- // メッセージタイプ
+ /* inspect packet body */
+ /* message type */
if (hdr->pptp_message_type != PPTP_MES_TYPE_CTRL) {
snprintf(errmes, sizeof(errmes), "unknown message type %d",
hdr->pptp_message_type);
goto bad_packet;
}
- // マジッククッキー
+ /* magic cookie */
if (hdr->magic_cookie != PPTP_MAGIC_COOKIE) {
snprintf(errmes, sizeof(errmes), "wrong magic %08x != %08x",
hdr->magic_cookie, PPTP_MAGIC_COOKIE);
goto bad_packet;
}
- // ECHO Reply は別処理。ステートが交錯する可能性があるので。*/
+ /* As there is possibility of state conflicts,
+ * ECHO Reply requiries special care.
+ */
switch (hdr->control_message_type) {
case PPTP_CTRL_MES_CODE_ECHO_RP:
if (pptp_ctrl_recv_echo_rep(_this, pkt, lpkt) != 0) {
@@ -947,9 +951,9 @@ pptp_ctrl_input(pptp_ctrl *_this, u_char *pkt, int lpkt)
}
return 0;
}
+
/*
- * ステートマシン
- * - 正常に処理が終わったら、return する。
+ * State machine
*/
switch (_this->state) {
case PPTP_CTRL_STATE_IDLE:
@@ -973,7 +977,7 @@ pptp_ctrl_input(pptp_ctrl *_this, u_char *pkt, int lpkt)
case PPTP_CTRL_MES_CODE_ECHO_RQ:
pptp_ctrl_process_echo_req(_this, pkt, lpkt);
return 0;
- //コール関連パケットは、pptp_call_input にディスパッチ
+ /* dispatch to pptp_call_input() if it is call-related-packet */
case PPTP_CTRL_MES_CODE_SLI:
case PPTP_CTRL_MES_CODE_ICRQ:
case PPTP_CTRL_MES_CODE_ICRP:
@@ -1008,7 +1012,7 @@ pptp_ctrl_input(pptp_ctrl *_this, u_char *pkt, int lpkt)
}
break;
case PPTP_CTRL_STATE_WAIT_CTRL_REPLY:
- // PAC の実装だけなので
+ /* XXX this implementation only support PAC mode */
break;
}
pptp_ctrl_log(_this, LOG_WARNING,
@@ -1024,7 +1028,7 @@ bad_packet:
return 0;
}
-/** PPTP Call 関連のメッセージを受信 */
+/* receiver PPTP Call related messages */
static int
pptp_ctrl_call_input(pptp_ctrl *_this, int mes_type, u_char *pkt, int lpkt)
{
@@ -1040,7 +1044,7 @@ pptp_ctrl_call_input(pptp_ctrl *_this, int mes_type, u_char *pkt, int lpkt)
lpkt -= sizeof(struct pptp_ctrl_header);
reason = "(no reason)";
- // callId
+ /* sanity check */
if (lpkt < 4) {
reason = "received packet is too short";
goto badpacket;
@@ -1050,7 +1054,7 @@ pptp_ctrl_call_input(pptp_ctrl *_this, int mes_type, u_char *pkt, int lpkt)
switch (mes_type) {
case PPTP_CTRL_MES_CODE_SLI: /* PNS <=> PAC */
- /* SLI だけは、こちらの Call-ID が入っている */
+ /* only SLI contains Call-ID of this peer */
for (i = 0; i < slist_length(&_this->call_list); i++) {
call = slist_get(&_this->call_list, i);
if (call->id == call_id)
@@ -1064,13 +1068,15 @@ pptp_ctrl_call_input(pptp_ctrl *_this, int mes_type, u_char *pkt, int lpkt)
goto call_searched;
case PPTP_CTRL_MES_CODE_ICRP: /* PNS => PAC */
/*
- * ICRQ は投げないのでこのメッセージは受信しないが、いちおう
- * pptp_call.c 側で処理させる
+ * as this implementation never sent ICRQ, this case
+ * should not happen.
+ * But just to make sure, pptp_call.c can handle this
+ * message.
*/
- // FALL THROUGH
+ /* FALLTHROUGH */
case PPTP_CTRL_MES_CODE_OCRQ: /* PNS => PAC */
case PPTP_CTRL_MES_CODE_CCR: /* PNS => PAC */
- // リニアサーチでよい。
+ /* liner-search will be enough */
for (i = 0; i < slist_length(&_this->call_list); i++) {
call = slist_get(&_this->call_list, i);
if (call->peers_call_id == call_id)
@@ -1083,7 +1089,7 @@ pptp_ctrl_call_input(pptp_ctrl *_this, int mes_type, u_char *pkt, int lpkt)
goto call_searched;
}
if (mes_type == PPTP_CTRL_MES_CODE_OCRQ) {
- // 新しい Call を作成
+ /* make new call */
if (call != NULL) {
pptp_call_input(call, mes_type, pkt0, lpkt0);
return 0;
@@ -1091,13 +1097,13 @@ pptp_ctrl_call_input(pptp_ctrl *_this, int mes_type, u_char *pkt, int lpkt)
if ((call = pptp_call_create()) == NULL) {
pptp_ctrl_log(_this, LOG_ERR,
"pptp_call_create() failed: %m");
- goto reigai;
+ goto fail;
}
if (pptp_call_init(call, _this) != 0) {
pptp_ctrl_log(_this, LOG_ERR,
"pptp_call_init() failed: %m");
pptp_call_destroy(call);
- goto reigai;
+ goto fail;
}
slist_add(&_this->call_list, call);
}
@@ -1112,28 +1118,28 @@ call_searched:
case PPTP_CTRL_MES_CODE_ICRQ: /* PAC => PNS */
case PPTP_CTRL_MES_CODE_ICCN: /* PAC => PNS */
case PPTP_CTRL_MES_CODE_CDN: /* PAC => PNS */
- /* 以上 PNS 用なので、受信しない */
+ /* don't receive because above messages are only of PNS */
default:
break;
}
reason = "Message type is unexpected.";
- // FALL THROUGH
+ /* FALLTHROUGH */
badpacket:
pptp_ctrl_log(_this, LOG_INFO,
"Received a bad %s(%d) call_id=%d: %s",
pptp_ctrl_mes_type_string(mes_type), mes_type, call_id, reason);
return 0;
-reigai:
+fail:
pptp_ctrl_stop(_this, PPTP_StopCCRQ_REASON_STOP_PROTOCOL);
return 0;
}
-/************************************************************************
- * 雑多な関数
- ************************************************************************/
+/*
+ * utilities
+ */
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/* logging with the label of the instance */
static void
pptp_ctrl_log(pptp_ctrl *_this, int prio, const char *fmt, ...)
{
diff --git a/usr.sbin/npppd/pptp/pptp_local.h b/usr.sbin/npppd/pptp/pptp_local.h
index 1cd6e3755dd..59e66a3849f 100644
--- a/usr.sbin/npppd/pptp/pptp_local.h
+++ b/usr.sbin/npppd/pptp/pptp_local.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: pptp_local.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -58,7 +59,7 @@ struct pptp_gre_header {
} __attribute__((__packed__));
-/** PPTPコントロールパケットの(ヘッダ)共通部分 */
+/* Commont part of the PPTP control packet */
struct pptp_ctrl_header {
uint16_t length;
uint16_t pptp_message_type;
@@ -67,7 +68,7 @@ struct pptp_ctrl_header {
uint16_t reserved0;
} __attribute__((__packed__));
-/** Start-Control-Connection-{Request,Reply} パケット */
+/* Start-Control-Connection-{Request,Reply} packet */
struct pptp_scc {
struct pptp_ctrl_header header;
uint16_t protocol_version;
@@ -81,7 +82,7 @@ struct pptp_scc {
u_char vendor_string[64];
} __attribute__((__packed__));
-/** Outgoing-Call-Request パケット */
+/* Outgoing-Call-Request packet */
struct pptp_ocrq {
struct pptp_ctrl_header header;
uint16_t call_id;
@@ -98,7 +99,7 @@ struct pptp_ocrq {
u_char subaddress[64];
} __attribute__((__packed__));
-/** Outgoing-Call-Reply パケット */
+/* Outgoing-Call-Reply packet */
struct pptp_ocrp {
struct pptp_ctrl_header header;
uint16_t call_id;
@@ -112,13 +113,13 @@ struct pptp_ocrp {
uint32_t physical_channel_id;
} __attribute__((__packed__));
-/** Echo-Request パケット */
+/* Echo-Request packet */
struct pptp_echo_rq {
struct pptp_ctrl_header header;
uint32_t identifier;
} __attribute__((__packed__));
-/** Echo-Reply パケット */
+/* Echo-Reply packet */
struct pptp_echo_rp {
struct pptp_ctrl_header header;
uint32_t identifier;
@@ -127,7 +128,7 @@ struct pptp_echo_rp {
uint16_t reserved1;
} __attribute__((__packed__));
-/** Set-Link-Info パケット */
+/* Set-Link-Info packet */
struct pptp_sli {
struct pptp_ctrl_header header;
uint16_t peers_call_id;
@@ -151,14 +152,14 @@ struct pptp_stop_ccrp {
} __attribute__((__packed__));
-/** Call-Clear-Request パケット */
+/* Call-Clear-Request packet */
struct pptp_ccr {
struct pptp_ctrl_header header;
uint16_t call_id;
uint16_t reserved1;
} __attribute__((__packed__));
-/** Call-Disconnect-Notify パケット */
+/* Call-Disconnect-Notify packet */
struct pptp_cdn {
struct pptp_ctrl_header header;
uint16_t call_id;
diff --git a/usr.sbin/npppd/pptp/pptp_subr.c b/usr.sbin/npppd/pptp/pptp_subr.c
index 370fab840fd..389a2684a7c 100644
--- a/usr.sbin/npppd/pptp/pptp_subr.c
+++ b/usr.sbin/npppd/pptp/pptp_subr.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pptp_subr.c,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,9 +24,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/**@file
- * PPTPの補助的な関数
- */
+
+/* utility functions for the pptp.c */
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -42,7 +43,7 @@
#include "pptp_local.h"
#include "pptp_subr.h"
-/** Faming Capability ビットをカンマ区切りの文字列で返す */
+/* convert the Faming Capability bit as CSV strings */
const char *
pptp_framing_string(uint32_t bits)
{
@@ -58,7 +59,8 @@ pptp_framing_string(uint32_t bits)
return "";
}
-/** Bearer Capability ビットをカンマ区切りの文字列で返す */
+
+/* convert the Bearer Capability bit as CSV strings */
const char *
pptp_bearer_string(uint32_t bits)
{
@@ -74,7 +76,7 @@ pptp_bearer_string(uint32_t bits)
return "";
}
-/** コントロールパケットのヘッダ(共通部分)を作成する */
+/* build common header part of a control packet */
void
pptp_init_header(struct pptp_ctrl_header *header, int length, int ctrl_mes_type)
{
@@ -123,7 +125,9 @@ static struct _label_name {
NAME_VAL(PPTP_CDN_RESULT_ADMIN_SHUTDOWN),
NAME_VAL(PPTP_CDN_RESULT_REQUEST),
};
-// _label_name を使ったマクロ。値を渡すと文字列で返す。
+
+
+/* value to strings convert macros */
#define LABEL_TO_STRING(func_name, label_names, prefix_len) \
const char * \
func_name(int code) \
diff --git a/usr.sbin/npppd/pptp/pptp_subr.h b/usr.sbin/npppd/pptp/pptp_subr.h
index a09c82cc98f..4604393390b 100644
--- a/usr.sbin/npppd/pptp/pptp_subr.h
+++ b/usr.sbin/npppd/pptp/pptp_subr.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: pptp_subr.h,v 1.2 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
diff --git a/usr.sbin/npppd/pptp/pptpd.c b/usr.sbin/npppd/pptp/pptpd.c
index 9d8c268cdbd..626db3d8217 100644
--- a/usr.sbin/npppd/pptp/pptpd.c
+++ b/usr.sbin/npppd/pptp/pptpd.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pptpd.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -23,10 +24,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: pptpd.c,v 1.3 2010/01/31 05:49:51 yasuoka Exp $ */
+/* $Id: pptpd.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $ */
+
/**@file
- * PPTPデーモンの実装。現在は PAC(PPTP Access Concentrator) としての実装
- * のみです。
+ * This file provides a implementation of PPTP daemon. Currently it
+ * provides functions for PAC (PPTP Access Concentrator) only.
+ * $Id: pptpd.c,v 1.4 2010/07/01 03:38:17 yasuoka Exp $
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -90,7 +93,7 @@ static void pptp_gre_header_string (struct pptp_gre_header *, char *, int);
#define PPTPD_SHUFFLE_MARK -1
-/** PPTPデーモンを初期化します */
+/* initialize pptp daemon */
int
pptpd_init(pptpd *_this)
{
@@ -115,7 +118,7 @@ pptpd_init(pptpd *_this)
slist_init(&_this->ctrl_list);
slist_init(&_this->call_free_list);
- /* Call-ID シャッフル */
+ /* randomize call id */
for (i = 0; i < countof(call) ; i++)
call[i] = i + 1;
for (i = countof(call); i > 1; i--) {
@@ -124,10 +127,9 @@ pptpd_init(pptpd *_this)
call[m] = call[i - 1];
call[i - 1] = call0;
}
- /* 必要個だけを slist に */
+
for (i = 0; i < MIN(PPTP_MAX_CALL, countof(call)); i++)
slist_add(&_this->call_free_list, (void *)(uintptr_t)call[i]);
- /* 末尾に SHUFFLE_MARK。次回は slist_shuffle で shuflle される */
slist_add(&_this->call_free_list, (void *)PPTPD_SHUFFLE_MARK);
if (_this->call_id_map == NULL)
@@ -137,13 +139,7 @@ pptpd_init(pptpd *_this)
return 0;
}
-/**
- * {@link ::pptpd PPTPデーモン}に{@link ::pptpd_listener リスナ}を追加します。
- * @param _this {@link ::pptpd PPTPデーモン}
- * @param idx リスナのインデックス
- * @param label 物理層としてのラベル。"PPTP" など
- * @param bindaddr 待ち受けるアドレス
- */
+/* add a listner to pptpd daemon context */
int
pptpd_add_listener(pptpd *_this, int idx, const char *label,
struct sockaddr *bindaddr)
@@ -168,12 +164,12 @@ pptpd_add_listener(pptpd *_this, int idx, const char *label,
pptpd_log(_this, LOG_ERR,
"Invalid argument error on %s(): idx must be %d but %d",
__func__, slist_length(&_this->listener), idx);
- goto reigai;
+ goto fail;
}
if ((plistener = malloc(sizeof(pptpd_listener))) == NULL) {
pptpd_log(_this, LOG_ERR, "malloc() failed in %s: %m",
__func__);
- goto reigai;
+ goto fail;
}
memset(plistener, 0, sizeof(pptpd_listener));
@@ -181,16 +177,13 @@ pptpd_add_listener(pptpd *_this, int idx, const char *label,
memcpy(&plistener->bind_sin, bindaddr, bindaddr->sa_len);
memcpy(&plistener->bind_sin_gre, bindaddr, bindaddr->sa_len);
- /* ポート番号が省略された場合は、デフォルト (1723/tcp)を使う */
if (plistener->bind_sin.sin_port == 0)
plistener->bind_sin.sin_port = htons(PPTPD_DEFAULT_TCP_PORT);
- /*
- * raw ソケットで、INADDR_ANY と明示的な IP アドレス指定したソケット両
- * 方を bind した場合、パケットは両方のソケットで受信される。この状態が
- * 発生すると、パケットが重複して受信したように見えてしまうため、このよ
- * うな設定は許さないこととした。
- */
+ /* When a raw socket binds both of an INADDR_ANY and specific IP
+ * address sockets, packets will be recieved by those sockets
+ * simultaneously. To avoid this duplicate receives, not
+ * permit such kind of configuration */
inaddr_any = 0;
slist_itr_first(&_this->listener);
while (slist_itr_has_next(&_this->listener)) {
@@ -203,7 +196,7 @@ pptpd_add_listener(pptpd *_this, int idx, const char *label,
if (inaddr_any > 0 && idx > 0) {
log_printf(LOG_ERR, "configuration error at pptpd.listener_in: "
"combination 0.0.0.0 and other address is not allowed.");
- goto reigai;
+ goto fail;
}
plistener->bind_sin_gre.sin_port = 0;
@@ -216,10 +209,10 @@ pptpd_add_listener(pptpd *_this, int idx, const char *label,
if (slist_add(&_this->listener, plistener) == NULL) {
pptpd_log(_this, LOG_ERR, "slist_add() failed in %s: %m",
__func__);
- goto reigai;
+ goto fail;
}
return 0;
-reigai:
+fail:
if (plistener != NULL)
free(plistener);
return 1;
@@ -243,7 +236,6 @@ pptpd_uninit(pptpd *_this)
}
slist_fini(&_this->listener);
if (_this->call_id_map != NULL) {
- // アイテムの削除?
hash_free(_this->call_id_map);
}
if (_this->ip4_allow != NULL)
@@ -256,7 +248,6 @@ pptpd_uninit(pptpd *_this)
(void *)(call->id | (call->ctrl->listener_index << 16))
#define CALL_ID(item) ((uint32_t)item & 0xffff)
-/** PPTPを割り当てます */
int
pptpd_assign_call(pptpd *_this, pptp_call *call)
{
@@ -290,7 +281,6 @@ pptpd_assign_call(pptpd *_this, pptp_call *call)
return -1;
}
-/** PPTPを解放します。*/
void
pptpd_release_call(pptpd *_this, pptp_call *call)
{
@@ -320,11 +310,10 @@ pptpd_listener_start(pptpd_listener *_this)
if (_this->phy_label[0] == '\0')
strlcpy(_this->phy_label, PPTPD_DEFAULT_LAYER2_LABEL,
sizeof(_this->phy_label));
- // 1723/tcp
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
pptpd_log(_this->self, LOG_ERR, "socket() failed at %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
ival = 1;
if(setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &ival, sizeof(ival)) < 0){
@@ -345,11 +334,11 @@ pptpd_listener_start(pptpd_listener *_this)
if ((ival = fcntl(sock, F_GETFL, 0)) < 0) {
pptpd_log(_this->self, LOG_ERR,
"fcntl(F_GET_FL) failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
} else if (fcntl(sock, F_SETFL, ival | O_NONBLOCK) < 0) {
pptpd_log(_this->self, LOG_ERR,
"fcntl(F_SET_FL) failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
if (bind(sock, (struct sockaddr *)&_this->bind_sin,
_this->bind_sin.sin_len) != 0) {
@@ -357,14 +346,14 @@ pptpd_listener_start(pptpd_listener *_this)
"bind(%s:%u) failed at %s(): %m",
inet_ntoa(_this->bind_sin.sin_addr),
ntohs(_this->bind_sin.sin_port), __func__);
- goto reigai;
+ goto fail;
}
if (listen(sock, PPTP_BACKLOG) != 0) {
pptpd_log(_this->self, LOG_ERR,
"listen(%s:%u) failed at %s(): %m",
inet_ntoa(_this->bind_sin.sin_addr),
ntohs(_this->bind_sin.sin_port), __func__);
- goto reigai;
+ goto fail;
}
#ifdef NPPPD_FAKEBIND
if (!wildcardbinding)
@@ -379,7 +368,7 @@ pptpd_listener_start(pptpd_listener *_this)
if ((sock_gre = priv_socket(AF_INET, SOCK_RAW, IPPROTO_GRE)) < 0) {
pptpd_log(_this->self, LOG_ERR, "socket() failed at %s(): %m",
__func__);
- goto reigai;
+ goto fail;
}
#ifdef NPPPD_FAKEBIND
if (!wildcardbinding)
@@ -395,11 +384,11 @@ pptpd_listener_start(pptpd_listener *_this)
if ((ival = fcntl(sock_gre, F_GETFL, 0)) < 0) {
pptpd_log(_this->self, LOG_ERR,
"fcntl(F_GET_FL) failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
} else if (fcntl(sock_gre, F_SETFL, ival | O_NONBLOCK) < 0) {
pptpd_log(_this->self, LOG_ERR,
"fcntl(F_SET_FL) failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
if (bind(sock_gre, (struct sockaddr *)&bind_sin_gre,
bind_sin_gre.sin_len) != 0) {
@@ -407,7 +396,7 @@ pptpd_listener_start(pptpd_listener *_this)
"bind(%s:%u) failed at %s(): %m",
inet_ntoa(bind_sin_gre.sin_addr),
ntohs(bind_sin_gre.sin_port), __func__);
- goto reigai;
+ goto fail;
}
#ifdef NPPPD_FAKEBIND
if (!wildcardbinding)
@@ -418,7 +407,7 @@ pptpd_listener_start(pptpd_listener *_this)
if (setsockoptfromto(sock) != 0) {
pptpd_log(_this->self, LOG_ERR,
"setsockoptfromto() failed in %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
#else
/* nothing to do */
@@ -439,7 +428,7 @@ pptpd_listener_start(pptpd_listener *_this)
event_add(&_this->ev_sock_gre, NULL);
return 0;
-reigai:
+fail:
if (sock >= 0)
close(sock);
if (sock_gre >= 0)
@@ -450,7 +439,7 @@ reigai:
return 1;
}
-/** PPTPデーモンを開始します */
+
int
pptpd_start(pptpd *_this)
{
@@ -481,7 +470,6 @@ pptpd_listener_close_gre(pptpd_listener *_this)
_this->sock_gre = -1;
}
-/** GREの待ち受けソケットを close します */
static void
pptpd_close_gre(pptpd *_this)
{
@@ -494,7 +482,6 @@ pptpd_close_gre(pptpd *_this)
}
}
-/** 1723/tcp の待ち受けソケットを close します */
static void
pptpd_listener_close_1723(pptpd_listener *_this)
{
@@ -507,7 +494,7 @@ pptpd_listener_close_1723(pptpd_listener *_this)
}
_this->sock = -1;
}
-/** 1723/tcp の待ち受けソケットを close します */
+
static void
pptpd_close_1723(pptpd *_this)
{
@@ -520,7 +507,6 @@ pptpd_close_1723(pptpd *_this)
}
}
-/** PPTPデーモンを本当に終了します。**/
void
pptpd_stop_immediatly(pptpd *_this)
{
@@ -529,10 +515,7 @@ pptpd_stop_immediatly(pptpd *_this)
if (event_initialized(&_this->ev_timer))
evtimer_del(&_this->ev_timer);
if (_this->state != PPTPD_STATE_STOPPED) {
- /*
- * pptp_ctrl_stop を呼び出すと、この関数が再度呼ばれる可能
- * 性がある。このため、このstate 変更は重要。
- */
+ /* lock, to avoid multiple call from pptp_ctrl_stop() */
_this->state = PPTPD_STATE_STOPPED;
pptpd_close_1723(_this);
@@ -558,7 +541,6 @@ pptpd_stop_timeout(int fd, short event, void *ctx)
pptpd_stop_immediatly(_this);
}
-/** PPTPデーモンを終了します */
void
pptpd_stop(pptpd *_this)
{
@@ -569,7 +551,8 @@ pptpd_stop(pptpd *_this)
if (event_initialized(&_this->ev_timer))
evtimer_del(&_this->ev_timer);
pptpd_close_1723(_this);
- /* このあたりの動作は l2tpd_stop とあわせるべき */
+
+ /* XXX: use common procedure with l2tpd_stop */
if (pptpd_is_stopped(_this))
return;
@@ -585,7 +568,6 @@ pptpd_stop(pptpd *_this)
nctrl++;
}
if (nctrl > 0) {
- // タイマーセット
tv.tv_sec = PPTPD_SHUTDOWN_TIMEOUT;
tv.tv_usec = 0;
@@ -597,9 +579,9 @@ pptpd_stop(pptpd *_this)
pptpd_stop_immediatly(_this);
}
-/***********************************************************************
- * 設定関連
- ***********************************************************************/
+/*
+ * PPTP Configuration
+ */
#define CFG_KEY(p, s) config_key_prefix((p), (s))
#define VAL_SEP " \t\r\n"
@@ -618,11 +600,11 @@ pptpd_reload(pptpd *_this, struct properties *config, const char *name,
ASSERT(_this != NULL);
ASSERT(config != NULL);
- _this->config = config; /* 現在は copy しなくて大丈夫 */
+ _this->config = config;
do_start = 0;
if (pptpd_config_str_equal(_this, CFG_KEY(name, "enabled"), "true",
default_enabled)) {
- // false にした直後に true にされるかもしれない。
+ /* avoid false-true flap */
if (pptpd_is_shutting_down(_this))
pptpd_stop_immediatly(_this);
if (pptpd_is_stopped(_this))
@@ -634,7 +616,7 @@ pptpd_reload(pptpd *_this, struct properties *config, const char *name,
}
if (do_start && pptpd_init(_this) != 0)
return 1;
- // pptpd_init でリセットされてしまうので。
+ /* set again as pptpd_init will reset it */
_this->config = config;
_this->ctrl_in_pktdump = pptpd_config_str_equal(_this,
@@ -648,7 +630,7 @@ pptpd_reload(pptpd *_this, struct properties *config, const char *name,
_this->phy_label_with_ifname = pptpd_config_str_equal(_this,
CFG_KEY(name, "label_with_ifname"), "true", 0);
- // ip4_allow をパース
+ /* parse ip4_allow */
in_addr_range_list_remove_all(&_this->ip4_allow);
val = pptpd_config_str(_this, CFG_KEY(name, "ip4_allow"));
if (val != NULL) {
@@ -672,12 +654,10 @@ pptpd_reload(pptpd *_this, struct properties *config, const char *name,
}
if (do_start) {
- /*
- * 起動直後と、pptpd.enable が false -> true に変更された
- * 場合に、do_start。すべてのリスナーが、初期化された状態を
- * 仮定できる
- */
- // pptpd.listener_in の読み込む
+ /* in the case of 1) cold-booted and 2) pptpd.enable
+ * toggled "false" to "true" do this, because we can
+ * assume that all pptpd listner are initialized. */
+
val = pptpd_config_str(_this, CFG_KEY(name, "listener_in"));
if (val != NULL) {
if (strlen(val) >= sizeof(buf)) {
@@ -689,7 +669,8 @@ pptpd_reload(pptpd *_this, struct properties *config, const char *name,
strlcpy(buf, val, sizeof(buf));
label = NULL;
- // タブ、スペース区切りで、複数指定可能
+ /* it can accept multple velues with tab/space
+ * separation */
for (i = 0, cp = buf;
(tok = strsep(&cp, VAL_SEP)) != NULL;) {
if (*tok == '\0')
@@ -733,9 +714,9 @@ pptpd_reload(pptpd *_this, struct properties *config, const char *name,
return 0;
}
-/***********************************************************************
- * I/O関連
- ***********************************************************************/
+/*
+ * I/O functions
+ */
static void
pptpd_log_access_deny(pptpd *_this, const char *reason, struct sockaddr *peer)
{
@@ -751,7 +732,7 @@ pptpd_log_access_deny(pptpd *_this, const char *reason, struct sockaddr *peer)
hostbuf, servbuf, reason);
}
-/** 1723/tcp の IOイベントハンドラ */
+/* I/O event handler of 1723/tcp */
static void
pptpd_io_event(int fd, short evmask, void *ctx)
{
@@ -768,7 +749,7 @@ pptpd_io_event(int fd, short evmask, void *ctx)
PPTPD_ASSERT(_this != NULL);
if ((evmask & EV_READ) != 0) {
- for (;;) { // EAGAIN まで 連続して accept
+ for (;;) { /* accept till EAGAIN occured */
peerlen = sizeof(peer);
if ((newsock = accept(listener->sock,
(struct sockaddr *)&peer, &peerlen)) < 0) {
@@ -790,7 +771,7 @@ pptpd_io_event(int fd, short evmask, void *ctx)
}
break;
}
- // 送信元チェック
+ /* check peer */
switch (peer.ss_family) {
case AF_INET:
if (!in_addr_range_list_includes(
@@ -804,21 +785,21 @@ pptpd_io_event(int fd, short evmask, void *ctx)
reason = "address family is not supported.";
break;
}
- // 許可されていない
+ /* not permitted */
pptpd_log_access_deny(_this, reason,
(struct sockaddr *)&peer);
close(newsock);
continue;
- // NOTREACHED
+ /* NOTREACHED */
accept:
- // 許可
+ /* permitted, can accepted */
pptp_ctrl_start_by_pptpd(_this, newsock,
listener->index, (struct sockaddr *)&peer);
}
}
}
-/** GRE の IOイベントハンドラー */
+/* I/O event handeler of GRE */
static void
pptpd_gre_io_event(int fd, short evmask, void *ctx)
{
@@ -836,7 +817,7 @@ pptpd_gre_io_event(int fd, short evmask, void *ctx)
if (evmask & EV_READ) {
for (;;) {
- // Block するまで読む
+ /* read till bloked */
peerlen = sizeof(peer);
if ((sz = recvfrom(listener->sock_gre, pkt, sizeof(pkt),
0, (struct sockaddr *)&peer, &peerlen)) <= 0) {
@@ -854,7 +835,7 @@ pptpd_gre_io_event(int fd, short evmask, void *ctx)
}
}
-/** GREの受信 → pptp_call に配送 */
+/* recieve GRE then route to pptp_call */
static void
pptpd_gre_input(pptpd_listener *listener, struct sockaddr *peer, u_char *pkt,
int lpkt)
@@ -882,7 +863,7 @@ pptpd_gre_input(pptpd_listener *listener, struct sockaddr *peer, u_char *pkt,
NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
pptpd_log(_this, LOG_ERR,
"getnameinfo() failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
if (_this->data_in_pktdump != 0) {
pptpd_log(_this, LOG_DEBUG, "PPTP Data input packet dump");
@@ -892,21 +873,18 @@ pptpd_gre_input(pptpd_listener *listener, struct sockaddr *peer, u_char *pkt,
pptpd_log(_this, LOG_ERR,
"Received malformed GRE packet: address family is not "
"supported: peer=%s af=%d", hbuf0, peer->sa_family);
- goto reigai;
+ goto fail;
}
if (lpkt < sizeof(struct ip)) {
pptpd_log(_this, LOG_ERR,
"Received a short length packet length=%d, from %s", lpkt,
hbuf0);
- goto reigai;
+ goto fail;
}
iphdr = (struct ip *)pkt;
- // IPヘッダは ntohs 済み NetBSD の場合
-#if !defined(__NetBSD__)
iphdr->ip_len = ntohs(iphdr->ip_len);
-#endif
hlen = iphdr->ip_hl * 4;
if (iphdr->ip_len > lpkt ||
@@ -915,7 +893,7 @@ pptpd_gre_input(pptpd_listener *listener, struct sockaddr *peer, u_char *pkt,
"Received a broken packet: ip_hl=%d iplen=%d lpkt=%d", hlen,
iphdr->ip_len, lpkt);
show_hd(debug_get_debugfp(), pkt, lpkt);
- goto reigai;
+ goto fail;
}
pkt += hlen;
lpkt -= hlen;
@@ -962,7 +940,7 @@ pptpd_gre_input(pptpd_listener *listener, struct sockaddr *peer, u_char *pkt,
}
- // pptp_call に配送
+ /* route to pptp_call */
call_id = grehdr->call_id;
hl = hash_lookup(_this->call_id_map,
@@ -981,11 +959,11 @@ bad_gre:
"Received malformed GRE packet: %s: peer=%s sock=%s %s seq=%u: "
"ack=%u ifidx=%d", reason, hbuf0, inet_ntoa(iphdr->ip_dst), logbuf,
seq, ack, listener->index);
-reigai:
+fail:
return;
}
-/** PPTPコントロールを開始します。(新しい接続があれば呼び出される。) */
+/* start PPTP control, when new connection is established */
static void
pptp_ctrl_start_by_pptpd(pptpd *_this, int sock, int listener_index,
struct sockaddr *peer)
@@ -997,9 +975,9 @@ pptp_ctrl_start_by_pptpd(pptpd *_this, int sock, int listener_index,
ctrl = NULL;
if ((ctrl = pptp_ctrl_create()) == NULL)
- goto reigai;
+ goto fail;
if (pptp_ctrl_init(ctrl) != 0)
- goto reigai;
+ goto fail;
memset(&ctrl->peer, 0, sizeof(ctrl->peer));
memcpy(&ctrl->peer, peer, peer->sa_len);
@@ -1012,15 +990,16 @@ pptp_ctrl_start_by_pptpd(pptpd *_this, int sock, int listener_index,
&sslen) != 0) {
pptpd_log(_this, LOG_WARNING,
"getsockname() failed at %s(): %m", __func__);
- goto reigai;
+ goto fail;
}
- /* "L2TP%em0.mru" などと、インタフェースで設定を変更する場合 */
+
+ /* change with interface name, ex) "L2TP%em0.mru" */
if (_this->phy_label_with_ifname != 0) {
if (get_ifname_by_sockaddr((struct sockaddr *)&ctrl->our,
ifname) == NULL) {
pptpd_log_access_deny(_this,
"could not get interface informations", peer);
- goto reigai;
+ goto fail;
}
if (pptpd_config_str_equal(_this,
config_key_prefix("pptpd.interface", ifname), "accept", 0)){
@@ -1031,11 +1010,11 @@ pptp_ctrl_start_by_pptpd(pptpd *_this, int sock, int listener_index,
snprintf(ctrl->phy_label, sizeof(ctrl->phy_label),
"%s", PPTP_CTRL_LISTENER_LABEL(ctrl));
} else {
- /* このインタフェースは許可されていない。*/
+ /* the interface is not permitted */
snprintf(msgbuf, sizeof(msgbuf),
"'%s' is not allowed by config.", ifname);
pptpd_log_access_deny(_this, msgbuf, peer);
- goto reigai;
+ goto fail;
}
} else
strlcpy(ctrl->phy_label, PPTP_CTRL_LISTENER_LABEL(ctrl),
@@ -1048,18 +1027,17 @@ pptp_ctrl_start_by_pptpd(pptpd *_this, int sock, int listener_index,
ctrl->echo_timeout = ival;
if (pptp_ctrl_start(ctrl) != 0)
- goto reigai;
+ goto fail;
slist_add(&_this->ctrl_list, ctrl);
return;
-reigai:
+fail:
close(sock);
pptp_ctrl_destroy(ctrl);
return;
}
-/** PPTPコントロールが終了後に通知してきます。*/
void
pptpd_ctrl_finished_notify(pptpd *_this, pptp_ctrl *ctrl)
{
@@ -1081,14 +1059,14 @@ pptpd_ctrl_finished_notify(pptpd *_this, pptp_ctrl *ctrl)
PPTPD_DBG((_this, LOG_DEBUG, "Remains %d ctrls", nctrl));
if (pptpd_is_shutting_down(_this) && nctrl == 0)
- // シャットダウン中最後の一人
pptpd_stop_immediatly(_this);
}
-/***********************************************************************
- * その他、ユーティリティ関数
- ***********************************************************************/
-/** このインスタンスに基づいたラベルから始まるログを記録します。 */
+/*
+ * utility functions
+ */
+
+/* logging with the this PPTP instance */
static void
pptpd_log(pptpd *_this, int prio, const char *fmt, ...)
{
@@ -1118,7 +1096,7 @@ pptp_call_hash(const void *ctx, int size)
return (uint32_t)ctx % size;
}
-/** GREパケットヘッダを文字列として */
+/* convert GRE packet header to strings */
static void
pptp_gre_header_string(struct pptp_gre_header *grehdr, char *buf, int lbuf)
{