[317] | 1 | /*
|
---|
| 2 | * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
|
---|
| 3 | * Copyright (c) 1995-2003 by Internet Software Consortium
|
---|
| 4 | *
|
---|
| 5 | * Permission to use, copy, modify, and distribute this software for any
|
---|
| 6 | * purpose with or without fee is hereby granted, provided that the above
|
---|
| 7 | * copyright notice and this permission notice appear in all copies.
|
---|
| 8 | *
|
---|
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
---|
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
---|
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
---|
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
---|
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
---|
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
---|
| 15 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
---|
| 16 | *
|
---|
| 17 | * Internet Systems Consortium, Inc.
|
---|
| 18 | * 950 Charter Street
|
---|
| 19 | * Redwood City, CA 94063
|
---|
| 20 | * <info@isc.org>
|
---|
| 21 | * https://www.isc.org/
|
---|
| 22 | *
|
---|
| 23 | * This code is based on the original client state machine that was
|
---|
| 24 | * written by Elliot Poger. The code has been extensively hacked on
|
---|
| 25 | * by Ted Lemon since then, so any mistakes you find are probably his
|
---|
| 26 | * fault and not Elliot's.
|
---|
| 27 | */
|
---|
| 28 | /*
|
---|
| 29 | * WIDE Project DHCP Implementation
|
---|
| 30 | * Copyright (c) 1995-1997 Akihiro Tominaga
|
---|
| 31 | * Copyright (c) 1995-1997 WIDE Project
|
---|
| 32 | * All rights reserved.
|
---|
| 33 | *
|
---|
| 34 | * Permission to use, copy, modify and distribute this software and its
|
---|
| 35 | * documentation is hereby granted, provided the following conditions
|
---|
| 36 | * are satisfied,
|
---|
| 37 | *
|
---|
| 38 | * 1. Both the copyright notice and this permission notice appear in
|
---|
| 39 | * all copies of the software, derivative works or modified versions,
|
---|
| 40 | * and any portions thereof, and that both notices appear in
|
---|
| 41 | * supporting documentation.
|
---|
| 42 | * 2. All advertising materials mentioning features or use of this software
|
---|
| 43 | * must display the following acknowledgement:
|
---|
| 44 | * This product includes software developed by WIDE Project and
|
---|
| 45 | * its contributors.
|
---|
| 46 | * 3. Neither the name of WIDE Project nor the names of its contributors
|
---|
| 47 | * may be used to endorse or promote products derived from this software
|
---|
| 48 | * without specific prior written permission.
|
---|
| 49 | *
|
---|
| 50 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
|
---|
| 51 | * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
|
---|
| 52 | * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
|
---|
| 53 | * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
|
---|
| 54 | *
|
---|
| 55 | * Feedback of the results generated from any improvements or
|
---|
| 56 | * extensions made to this software would be much appreciated.
|
---|
| 57 | * Any such feedback should be sent to:
|
---|
| 58 | *
|
---|
| 59 | * Akihiro Tominaga
|
---|
| 60 | * WIDE Project
|
---|
| 61 | * Keio University, Endo 5322, Kanagawa, Japan
|
---|
| 62 | * (E-mail: dhcp-dist@wide.ad.jp)
|
---|
| 63 | *
|
---|
| 64 | * WIDE project has the rights to redistribute these changes.
|
---|
| 65 | */
|
---|
| 66 | /*
|
---|
| 67 | * TINET (TCP/IP Protocol Stack)
|
---|
| 68 | *
|
---|
| 69 | * Copyright (C) 2011 by Dep. of Computer Science and Engineering
|
---|
| 70 | * Tomakomai National College of Technology, JAPAN
|
---|
| 71 | *
|
---|
| 72 | * 上記著作権者は,以下の (1)~(4) の条件か,Free Software Foundation
|
---|
| 73 | * によって公表されている GNU General Public License の Version 2 に記
|
---|
| 74 | * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
|
---|
| 75 | * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
|
---|
| 76 | * 利用と呼ぶ)することを無償で許諾する.
|
---|
| 77 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 78 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 79 | * スコード中に含まれていること.
|
---|
| 80 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 81 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 82 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 83 | * の無保証規定を掲載すること.
|
---|
| 84 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 85 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 86 | * と.
|
---|
| 87 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 88 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 89 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 90 | * 報告すること.
|
---|
| 91 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 92 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 93 | *
|
---|
| 94 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 95 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
|
---|
| 96 | * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
|
---|
| 97 | * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
|
---|
| 98 | *
|
---|
| 99 | * @(#) $Id$
|
---|
| 100 | */
|
---|
| 101 |
|
---|
| 102 | #ifndef DHCP6_CLI_H
|
---|
| 103 | #define DHCP6_CLI_H
|
---|
| 104 |
|
---|
| 105 | #ifdef DHCP6_CLI_CFG
|
---|
| 106 |
|
---|
| 107 | #include <netinet/in.h>
|
---|
| 108 | #include <netapp/dhcp6.h>
|
---|
| 109 |
|
---|
| 110 | /*
|
---|
| 111 | * DHCP クライアントのスタックサイズ
|
---|
| 112 | */
|
---|
| 113 |
|
---|
| 114 | #define DHCP6_CLI_STACK_SIZE 1024 /* DHCP クライアントタスクのスタックサイズ */
|
---|
| 115 |
|
---|
| 116 | /*
|
---|
| 117 | * DHCP クライアントの優先度
|
---|
| 118 | */
|
---|
| 119 |
|
---|
| 120 | #define DHCP6_CLI_MAIN_PRIORITY 5 /* DHCP クライアントタスクの優先度 */
|
---|
| 121 |
|
---|
| 122 | /*
|
---|
| 123 | * コンパイル時コンフィギュレーション
|
---|
| 124 | */
|
---|
| 125 |
|
---|
| 126 | /*
|
---|
| 127 | * DHCPv6 動作モード
|
---|
| 128 | *
|
---|
| 129 | * #define DHCP6_CLI_CFG_MODE で指定する。
|
---|
| 130 | * 指定されていなければ、ステートレスに設定する。
|
---|
| 131 | *
|
---|
| 132 | */
|
---|
| 133 |
|
---|
| 134 | #define DHCP6_CLI_CFG_STATELESS 0 /* ステートレスに設定する。 */
|
---|
| 135 | #define DHCP6_CLI_CFG_STATEFULL 1 /* ステートフルに設定する。 */
|
---|
| 136 | #define DHCP6_CLI_CFG_RA 2 /* RA の M/O ビットにより設定する。 */
|
---|
| 137 | #define DHCP6_CLI_CFG_MODE_DEFAULT DHCP6_CLI_CFG_STATELESS
|
---|
| 138 |
|
---|
| 139 | /* IA の設定 */
|
---|
| 140 | #define DHCP6_CLI_CFG_IA_NA 1
|
---|
| 141 | //#define DHCP6_CLI_CFG_IA_TA 1
|
---|
| 142 | //#define DHCP6_CLI_CFG_IA_PD 1
|
---|
| 143 |
|
---|
| 144 | /* Rapid-commit の指定 */
|
---|
| 145 | //#define DHCP6_CLI_CFG_RAPID_COMMIT 1
|
---|
| 146 |
|
---|
| 147 | /* 推奨度の定義 */
|
---|
| 148 | #define DHCP6_CLI_CFG_PREFER_IA 50 /* IA_NA/TA/PD 当たりの推奨度 */
|
---|
| 149 | #define DHCP6_CLI_CFG_PREFER_IAADDR 100 /* アドレス当たりの推奨度 */
|
---|
| 150 |
|
---|
| 151 | /* DHCPv6 クライアントメッセージの受信リストサイズ(2以上指定すること) */
|
---|
| 152 | #define NUM_DHCP6_CLI_MSG_LIST 3
|
---|
| 153 |
|
---|
| 154 | /*
|
---|
| 155 | * DHCPv6 クライアントメッセージ構造体数【変更禁止】
|
---|
| 156 | * +1 は送信用
|
---|
| 157 | */
|
---|
| 158 | #define NUM_MPF_DHCP6_CLI_MSG (NUM_DHCP6_CLI_MSG_LIST+1)
|
---|
| 159 |
|
---|
| 160 | /* DHCP 必須オプションリスト */
|
---|
| 161 |
|
---|
| 162 | #ifndef DHCP6_CLI_CFG_REQUIRED_OLIST
|
---|
| 163 |
|
---|
| 164 | #if defined(USE_RESOLVER)
|
---|
| 165 |
|
---|
| 166 | #define DHCP6_CLI_CFG_REQUIRED_OLIST { \
|
---|
| 167 | DHCP6_OPT_NAME_SERVERS, \
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | #else /* of #if defined(USE_RESOLVER) */
|
---|
| 171 |
|
---|
| 172 | #endif /* of #if defined(USE_RESOLVER) */
|
---|
| 173 |
|
---|
| 174 | #endif /* of #ifndef DHCP6_CLI_CFG_REQUIRED_OLIST */
|
---|
| 175 |
|
---|
| 176 | /* DHCP 要求オプションリスト */
|
---|
| 177 |
|
---|
| 178 | #ifndef DHCP6_CLI_CFG_REQUEST_OLIST
|
---|
| 179 |
|
---|
| 180 | #if defined(USE_RESOLVER)
|
---|
| 181 |
|
---|
| 182 | #define DHCP6_CLI_CFG_REQUEST_OLIST { \
|
---|
| 183 | DHCP6_OPT_DOMAIN_SEARCH, \
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | #else /* of #if defined(USE_RESOLVER) */
|
---|
| 187 |
|
---|
| 188 | #endif /* of #if defined(USE_RESOLVER) */
|
---|
| 189 |
|
---|
| 190 | #endif /* of #ifndef DHCP6_CLI_CFG_REQUEST_OLIST */
|
---|
| 191 |
|
---|
| 192 | /*
|
---|
| 193 | * タイムアウト定数
|
---|
| 194 | * RFC3315 に規定されたタイミング定数は dhcp6.h 参照
|
---|
| 195 | */
|
---|
| 196 |
|
---|
| 197 | /* 標準メッセージの再送信タイムアウト */
|
---|
| 198 | #define TMO_DHCP6C_NORMAL ULONG_C(60*1000)
|
---|
| 199 |
|
---|
| 200 | /* 標準要求リース時間 */
|
---|
| 201 | #define TMO_DHCP6C_REQ_LEASE ULONG_C(7200*1000)
|
---|
| 202 |
|
---|
| 203 | /* メッセージ構造体獲得タイムアウト */
|
---|
| 204 | #define TMO_DHCP6C_MPF_GET ULONG_C(1000)
|
---|
| 205 |
|
---|
| 206 | /* メッセージ受信タイムアウト */
|
---|
| 207 | #define TMO_DHCP6C_RCV_DAT ULONG_C(1000)
|
---|
| 208 |
|
---|
| 209 | /*
|
---|
| 210 | * DHCPv6 クライアントメッセージ構造体
|
---|
| 211 | */
|
---|
| 212 |
|
---|
| 213 | typedef struct dhcp6_cli_msg {
|
---|
| 214 | /* 4バイト境界にアラインする。*/
|
---|
| 215 | T_DHCP6_MSG msg; /* DHCPv6 メッセージ構造体 */
|
---|
| 216 | struct dhcp6_cli_msg *next; /* リストの次のメッセージ構造体 */
|
---|
| 217 | SYSTIM rcv_time; /* 受信した時間 */
|
---|
| 218 | T_IPV6EP srv; /* サーバのIPv6アドレス/ポート番号 */
|
---|
| 219 | uint16_t len; /* msg の有効長 */
|
---|
| 220 | uint16_t prefer; /* msg の推奨度 */
|
---|
| 221 | uint16_t status; /* STATUS CODE オプションの status */
|
---|
| 222 | } T_DHCP6_CLI_MSG;
|
---|
| 223 |
|
---|
| 224 | /* prefer のフラグ */
|
---|
| 225 |
|
---|
| 226 | #define DHCP6_ClI_MSG_PREFER_ADDR UINT_C(0x8000) /* アドレス情報あり */
|
---|
| 227 | #define DHCP6_ClI_MSG_PREFER_REQUIRED UINT_C(0x4000) /* 必須オプションあり */
|
---|
| 228 | #define DHCP6_ClI_MSG_PREFER_REQUEST UINT_C(0x2000) /* 要求オプションあり */
|
---|
| 229 | #define DHCP6_ClI_MSG_PREFER_OPTION UINT_C(0x1000) /* PREFER オプションあり */
|
---|
| 230 | #define DHCP6_ClI_MSG_PREFER_FLAG_MASK UINT_C(0xf000)
|
---|
| 231 | #define DHCP6_ClI_MSG_PREFER_VALUE_MASK (~(DHCP6_ClI_MSG_PREFER_FLAG_MASK))
|
---|
| 232 |
|
---|
| 233 | /*
|
---|
| 234 | * STATUS CODE オプションが無い時の値
|
---|
| 235 | */
|
---|
| 236 |
|
---|
| 237 | #define DHCP6_CLI_STAT_UNDEFINED (-1)
|
---|
| 238 |
|
---|
| 239 | /*
|
---|
| 240 | * コールバック関数
|
---|
| 241 | */
|
---|
| 242 |
|
---|
| 243 | extern ER callback_nblk_dhcp6_cli (ID cepid, FN fncd, void *p_parblk);
|
---|
| 244 |
|
---|
| 245 | /*
|
---|
| 246 | * タスク
|
---|
| 247 | */
|
---|
| 248 |
|
---|
| 249 | extern void dhcp6_cli_task(intptr_t exinf);
|
---|
| 250 |
|
---|
| 251 | /*
|
---|
| 252 | * 関数
|
---|
| 253 | */
|
---|
| 254 |
|
---|
| 255 | extern ER dhcp6c_rel_info (void);
|
---|
| 256 | extern ER dhcp6c_renew_info (void);
|
---|
| 257 | extern ER dhcp6c_get_info (T_IN6_ADDR *addr, uint32_t *expire, uint32_t *renew,
|
---|
| 258 | uint32_t *rebind, uint32_t *deprefer, SYSTIM *bind_start);
|
---|
| 259 |
|
---|
| 260 | #endif /* of #ifdef DHCP6_CLI_CFG */
|
---|
| 261 |
|
---|
| 262 | #endif /* of #ifndef DHCP6_CLI_H */
|
---|