実装に関連する2つの問題があります-
特定のリンク層アドレスをテキストから標準形式に変換できる機能が必要です。これは
inet_pton()
、特定の IP アドレスをテキストから標準の IPv4/IPv6 形式に変換する IP アドレスの n/w 層に同様の機能があるようにです。b/w リンク層アドレスと 48 ビット MAC アドレスに違いはありますか (特に IPv6 の場合)?
いいえの場合、私が間違っていなければ、リンク層アドレスも常に 48 ビットの長さにする必要があります。
前もって感謝します。些細なことが欠けている場合はご容赦ください。
編集 :
わかりました..白黒リンク層アドレスとイーサネットMACアドレスの違いは明らかです。データリンク層アドレスにはいくつかの種類がありますが、イーサネット MAC アドレスはその 1 つにすぎません。
ここで、もう 1 つの問題が発生します... 最初の質問で述べたように、コマンド ラインから指定されたリンク層アドレスを標準形式に変換する必要があります。ここで提供される解決策は、イーサネット MAC アドレスに対してのみ機能します。
そのための標準機能はありませんか?私がやりたいことは、ユーザーが ICMP ルーター アドバタイズメント メッセージにあるさまざまなオプションの値を入力するアプリケーションを作成することですRFC 4861
。
Option Formats
Neighbor Discovery messages include zero or more options, some of
which may appear multiple times in the same message. Options should
be padded when necessary to ensure that they end on their natural
64-bit boundaries. All options are of the form:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length | ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
~ ... ~
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Fields:
Type 8-bit identifier of the type of option. The
options defined in this document are:
Option Name Type
Source Link-Layer Address 1
Target Link-Layer Address 2
Prefix Information 3
Redirected Header 4
MTU 5
Length 8-bit unsigned integer. The length of the option
(including the type and length fields) in units of
8 octets. The value 0 is invalid. Nodes MUST
silently discard an ND packet that contains an
option with length zero.
4.6.1. Source/Target Link-layer Address
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length | Link-Layer Address ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Fields:
Type
1 for Source Link-layer Address
2 for Target Link-layer Address
Length The length of the option (including the type and
length fields) in units of 8 octets. For example,
the length for IEEE 802 addresses is 1
[IPv6-ETHER].
Link-Layer Address
The variable length link-layer address.
The content and format of this field (including
byte and bit ordering) is expected to be specified
in specific documents that describe how IPv6
operates over different link layers. For instance,
[IPv6-ETHER].
もう 1 つ、私は C++ があまり得意ではありません。C の代替案を教えてください。ありがとう。