ホーム › NetworkManagement.Dns › DNS_WIRE_RECORD
DNS_WIRE_RECORD
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| RecordType | WORD | 2 | +0 | +0 | ワイヤ形式リソースレコードの種別を示す。 |
| RecordClass | WORD | 2 | +2 | +2 | ワイヤ形式リソースレコードのクラスを示す。通常はIN(値1)。 |
| TimeToLive | DWORD | 4 | +4 | +4 | レコードの有効期間(TTL)を秒単位で示す。 |
| DataLength | WORD | 2 | +8 | +8 | 後続するRDATAのバイト長を示す。 |
各言語での定義
#include <windows.h>
// DNS_WIRE_RECORD (x64 10 / x86 10 バイト)
#pragma pack(push, 1)
typedef struct DNS_WIRE_RECORD {
WORD RecordType;
WORD RecordClass;
DWORD TimeToLive;
WORD DataLength;
} DNS_WIRE_RECORD;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DNS_WIRE_RECORD
{
public ushort RecordType;
public ushort RecordClass;
public uint TimeToLive;
public ushort DataLength;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DNS_WIRE_RECORD
Public RecordType As UShort
Public RecordClass As UShort
Public TimeToLive As UInteger
Public DataLength As UShort
End Structureimport ctypes
from ctypes import wintypes
class DNS_WIRE_RECORD(ctypes.Structure):
_pack_ = 1
_fields_ = [
("RecordType", ctypes.c_ushort),
("RecordClass", ctypes.c_ushort),
("TimeToLive", wintypes.DWORD),
("DataLength", ctypes.c_ushort),
]#[repr(C, packed(1))]
pub struct DNS_WIRE_RECORD {
pub RecordType: u16,
pub RecordClass: u16,
pub TimeToLive: u32,
pub DataLength: u16,
}import "golang.org/x/sys/windows"
type DNS_WIRE_RECORD struct {
RecordType uint16
RecordClass uint16
TimeToLive uint32
DataLength uint16
}type
DNS_WIRE_RECORD = packed record
RecordType: Word;
RecordClass: Word;
TimeToLive: DWORD;
DataLength: Word;
end;const DNS_WIRE_RECORD = extern struct {
RecordType: u16,
RecordClass: u16,
TimeToLive: u32,
DataLength: u16,
};type
DNS_WIRE_RECORD {.packed.} = object
RecordType: uint16
RecordClass: uint16
TimeToLive: uint32
DataLength: uint16align(1)
struct DNS_WIRE_RECORD
{
ushort RecordType;
ushort RecordClass;
uint TimeToLive;
ushort DataLength;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_WIRE_RECORD サイズ: 10 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 10 / 4 切り上げ)
; RecordType : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; RecordClass : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; TimeToLive : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; DataLength : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_WIRE_RECORD, pack=1
#field short RecordType
#field short RecordClass
#field int TimeToLive
#field short DataLength
#endstruct
stdim st, DNS_WIRE_RECORD ; NSTRUCT 変数を確保
st->RecordType = 100
mes "RecordType=" + st->RecordType