Win32 API 日本語リファレンス
ホームNetworking.WinSock › WSAPROTOCOL_INFOA

WSAPROTOCOL_INFOA

構造体
サイズx64: 372 バイト / x86: 372 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwServiceFlags1DWORD4+0+0プロトコルが提供するサービスを示すフラグ群(その1)である。
dwServiceFlags2DWORD4+4+4予約フラグ群(その2)である。
dwServiceFlags3DWORD4+8+8予約フラグ群(その3)である。
dwServiceFlags4DWORD4+12+12予約フラグ群(その4)である。
dwProviderFlagsDWORD4+16+16プロバイダ固有の動作を示すフラグ群である。
ProviderIdGUID16+20+20プロトコルを提供するプロバイダを識別するGUIDである。
dwCatalogEntryIdDWORD4+36+36Winsockカタログ内でのエントリ一意IDである。
ProtocolChainWSAPROTOCOLCHAIN32+40+40このプロトコルを構成するプロトコルチェーン情報である。
iVersionINT4+72+72プロトコルのバージョン番号である。
iAddressFamilyINT4+76+76プロトコルが使用するアドレスファミリである。
iMaxSockAddrINT4+80+80ソケットアドレスの最大長をバイト単位で示す。
iMinSockAddrINT4+84+84ソケットアドレスの最小長をバイト単位で示す。
iSocketTypeINT4+88+88プロトコルのソケットタイプである。
iProtocolINT4+92+92プロトコル番号である。
iProtocolMaxOffsetINT4+96+96iProtocolから加算可能な最大オフセット値である。
iNetworkByteOrderINT4+100+100ネットワークバイトオーダ(ビッグ/リトルエンディアン)を示す値である。
iSecuritySchemeINT4+104+104プロトコルが使用するセキュリティスキームを示す値である。
dwMessageSizeDWORD4+108+108送受信可能なメッセージの最大サイズである。
dwProviderReservedDWORD4+112+112プロバイダ予約フィールドである。
szProtocolCHAR256+116+116プロトコルの名前文字列(ANSI、固定長)である。

各言語での定義

#include <windows.h>

// WSAPROTOCOLCHAIN  (x64 32 / x86 32 バイト)
typedef struct WSAPROTOCOLCHAIN {
    INT ChainLen;
    DWORD ChainEntries[7];
} WSAPROTOCOLCHAIN;

// WSAPROTOCOL_INFOA  (x64 372 / x86 372 バイト)
typedef struct WSAPROTOCOL_INFOA {
    DWORD dwServiceFlags1;
    DWORD dwServiceFlags2;
    DWORD dwServiceFlags3;
    DWORD dwServiceFlags4;
    DWORD dwProviderFlags;
    GUID ProviderId;
    DWORD dwCatalogEntryId;
    WSAPROTOCOLCHAIN ProtocolChain;
    INT iVersion;
    INT iAddressFamily;
    INT iMaxSockAddr;
    INT iMinSockAddr;
    INT iSocketType;
    INT iProtocol;
    INT iProtocolMaxOffset;
    INT iNetworkByteOrder;
    INT iSecurityScheme;
    DWORD dwMessageSize;
    DWORD dwProviderReserved;
    CHAR szProtocol[256];
} WSAPROTOCOL_INFOA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSAPROTOCOLCHAIN
{
    public int ChainLen;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] public uint[] ChainEntries;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSAPROTOCOL_INFOA
{
    public uint dwServiceFlags1;
    public uint dwServiceFlags2;
    public uint dwServiceFlags3;
    public uint dwServiceFlags4;
    public uint dwProviderFlags;
    public Guid ProviderId;
    public uint dwCatalogEntryId;
    public WSAPROTOCOLCHAIN ProtocolChain;
    public int iVersion;
    public int iAddressFamily;
    public int iMaxSockAddr;
    public int iMinSockAddr;
    public int iSocketType;
    public int iProtocol;
    public int iProtocolMaxOffset;
    public int iNetworkByteOrder;
    public int iSecurityScheme;
    public uint dwMessageSize;
    public uint dwProviderReserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public sbyte[] szProtocol;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSAPROTOCOLCHAIN
    Public ChainLen As Integer
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=7)> Public ChainEntries() As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSAPROTOCOL_INFOA
    Public dwServiceFlags1 As UInteger
    Public dwServiceFlags2 As UInteger
    Public dwServiceFlags3 As UInteger
    Public dwServiceFlags4 As UInteger
    Public dwProviderFlags As UInteger
    Public ProviderId As Guid
    Public dwCatalogEntryId As UInteger
    Public ProtocolChain As WSAPROTOCOLCHAIN
    Public iVersion As Integer
    Public iAddressFamily As Integer
    Public iMaxSockAddr As Integer
    Public iMinSockAddr As Integer
    Public iSocketType As Integer
    Public iProtocol As Integer
    Public iProtocolMaxOffset As Integer
    Public iNetworkByteOrder As Integer
    Public iSecurityScheme As Integer
    Public dwMessageSize As UInteger
    Public dwProviderReserved As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Public szProtocol() As SByte
End Structure
import ctypes
from ctypes import wintypes

class WSAPROTOCOLCHAIN(ctypes.Structure):
    _fields_ = [
        ("ChainLen", ctypes.c_int),
        ("ChainEntries", wintypes.DWORD * 7),
    ]

class WSAPROTOCOL_INFOA(ctypes.Structure):
    _fields_ = [
        ("dwServiceFlags1", wintypes.DWORD),
        ("dwServiceFlags2", wintypes.DWORD),
        ("dwServiceFlags3", wintypes.DWORD),
        ("dwServiceFlags4", wintypes.DWORD),
        ("dwProviderFlags", wintypes.DWORD),
        ("ProviderId", GUID),
        ("dwCatalogEntryId", wintypes.DWORD),
        ("ProtocolChain", WSAPROTOCOLCHAIN),
        ("iVersion", ctypes.c_int),
        ("iAddressFamily", ctypes.c_int),
        ("iMaxSockAddr", ctypes.c_int),
        ("iMinSockAddr", ctypes.c_int),
        ("iSocketType", ctypes.c_int),
        ("iProtocol", ctypes.c_int),
        ("iProtocolMaxOffset", ctypes.c_int),
        ("iNetworkByteOrder", ctypes.c_int),
        ("iSecurityScheme", ctypes.c_int),
        ("dwMessageSize", wintypes.DWORD),
        ("dwProviderReserved", wintypes.DWORD),
        ("szProtocol", ctypes.c_byte * 256),
    ]
#[repr(C)]
pub struct WSAPROTOCOLCHAIN {
    pub ChainLen: i32,
    pub ChainEntries: [u32; 7],
}

#[repr(C)]
pub struct WSAPROTOCOL_INFOA {
    pub dwServiceFlags1: u32,
    pub dwServiceFlags2: u32,
    pub dwServiceFlags3: u32,
    pub dwServiceFlags4: u32,
    pub dwProviderFlags: u32,
    pub ProviderId: GUID,
    pub dwCatalogEntryId: u32,
    pub ProtocolChain: WSAPROTOCOLCHAIN,
    pub iVersion: i32,
    pub iAddressFamily: i32,
    pub iMaxSockAddr: i32,
    pub iMinSockAddr: i32,
    pub iSocketType: i32,
    pub iProtocol: i32,
    pub iProtocolMaxOffset: i32,
    pub iNetworkByteOrder: i32,
    pub iSecurityScheme: i32,
    pub dwMessageSize: u32,
    pub dwProviderReserved: u32,
    pub szProtocol: [i8; 256],
}
import "golang.org/x/sys/windows"

type WSAPROTOCOLCHAIN struct {
	ChainLen int32
	ChainEntries [7]uint32
}

type WSAPROTOCOL_INFOA struct {
	dwServiceFlags1 uint32
	dwServiceFlags2 uint32
	dwServiceFlags3 uint32
	dwServiceFlags4 uint32
	dwProviderFlags uint32
	ProviderId windows.GUID
	dwCatalogEntryId uint32
	ProtocolChain WSAPROTOCOLCHAIN
	iVersion int32
	iAddressFamily int32
	iMaxSockAddr int32
	iMinSockAddr int32
	iSocketType int32
	iProtocol int32
	iProtocolMaxOffset int32
	iNetworkByteOrder int32
	iSecurityScheme int32
	dwMessageSize uint32
	dwProviderReserved uint32
	szProtocol [256]int8
}
type
  WSAPROTOCOLCHAIN = record
    ChainLen: Integer;
    ChainEntries: array[0..6] of DWORD;
  end;

  WSAPROTOCOL_INFOA = record
    dwServiceFlags1: DWORD;
    dwServiceFlags2: DWORD;
    dwServiceFlags3: DWORD;
    dwServiceFlags4: DWORD;
    dwProviderFlags: DWORD;
    ProviderId: TGUID;
    dwCatalogEntryId: DWORD;
    ProtocolChain: WSAPROTOCOLCHAIN;
    iVersion: Integer;
    iAddressFamily: Integer;
    iMaxSockAddr: Integer;
    iMinSockAddr: Integer;
    iSocketType: Integer;
    iProtocol: Integer;
    iProtocolMaxOffset: Integer;
    iNetworkByteOrder: Integer;
    iSecurityScheme: Integer;
    dwMessageSize: DWORD;
    dwProviderReserved: DWORD;
    szProtocol: array[0..255] of Shortint;
  end;
const WSAPROTOCOLCHAIN = extern struct {
    ChainLen: i32,
    ChainEntries: [7]u32,
};

const WSAPROTOCOL_INFOA = extern struct {
    dwServiceFlags1: u32,
    dwServiceFlags2: u32,
    dwServiceFlags3: u32,
    dwServiceFlags4: u32,
    dwProviderFlags: u32,
    ProviderId: GUID,
    dwCatalogEntryId: u32,
    ProtocolChain: WSAPROTOCOLCHAIN,
    iVersion: i32,
    iAddressFamily: i32,
    iMaxSockAddr: i32,
    iMinSockAddr: i32,
    iSocketType: i32,
    iProtocol: i32,
    iProtocolMaxOffset: i32,
    iNetworkByteOrder: i32,
    iSecurityScheme: i32,
    dwMessageSize: u32,
    dwProviderReserved: u32,
    szProtocol: [256]i8,
};
type
  WSAPROTOCOLCHAIN {.bycopy.} = object
    ChainLen: int32
    ChainEntries: array[7, uint32]

  WSAPROTOCOL_INFOA {.bycopy.} = object
    dwServiceFlags1: uint32
    dwServiceFlags2: uint32
    dwServiceFlags3: uint32
    dwServiceFlags4: uint32
    dwProviderFlags: uint32
    ProviderId: GUID
    dwCatalogEntryId: uint32
    ProtocolChain: WSAPROTOCOLCHAIN
    iVersion: int32
    iAddressFamily: int32
    iMaxSockAddr: int32
    iMinSockAddr: int32
    iSocketType: int32
    iProtocol: int32
    iProtocolMaxOffset: int32
    iNetworkByteOrder: int32
    iSecurityScheme: int32
    dwMessageSize: uint32
    dwProviderReserved: uint32
    szProtocol: array[256, int8]
struct WSAPROTOCOLCHAIN
{
    int ChainLen;
    uint[7] ChainEntries;
}

struct WSAPROTOCOL_INFOA
{
    uint dwServiceFlags1;
    uint dwServiceFlags2;
    uint dwServiceFlags3;
    uint dwServiceFlags4;
    uint dwProviderFlags;
    GUID ProviderId;
    uint dwCatalogEntryId;
    WSAPROTOCOLCHAIN ProtocolChain;
    int iVersion;
    int iAddressFamily;
    int iMaxSockAddr;
    int iMinSockAddr;
    int iSocketType;
    int iProtocol;
    int iProtocolMaxOffset;
    int iNetworkByteOrder;
    int iSecurityScheme;
    uint dwMessageSize;
    uint dwProviderReserved;
    byte[256] szProtocol;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WSAPROTOCOL_INFOA サイズ: 372 バイト(x64)
dim st, 93    ; 4byte整数×93(構造体サイズ 372 / 4 切り上げ)
; dwServiceFlags1 : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwServiceFlags2 : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwServiceFlags3 : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwServiceFlags4 : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwProviderFlags : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ProviderId : GUID (+20, 16byte)  varptr(st)+20 を基点に操作(16byte:入れ子/配列)
; dwCatalogEntryId : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ProtocolChain : WSAPROTOCOLCHAIN (+40, 32byte)  varptr(st)+40 を基点に操作(32byte:入れ子/配列)
; iVersion : INT (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; iAddressFamily : INT (+76, 4byte)  st.19 = 値  /  値 = st.19   (lpoke/lpeek も可)
; iMaxSockAddr : INT (+80, 4byte)  st.20 = 値  /  値 = st.20   (lpoke/lpeek も可)
; iMinSockAddr : INT (+84, 4byte)  st.21 = 値  /  値 = st.21   (lpoke/lpeek も可)
; iSocketType : INT (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; iProtocol : INT (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; iProtocolMaxOffset : INT (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; iNetworkByteOrder : INT (+100, 4byte)  st.25 = 値  /  値 = st.25   (lpoke/lpeek も可)
; iSecurityScheme : INT (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; dwMessageSize : DWORD (+108, 4byte)  st.27 = 値  /  値 = st.27   (lpoke/lpeek も可)
; dwProviderReserved : DWORD (+112, 4byte)  st.28 = 値  /  値 = st.28   (lpoke/lpeek も可)
; szProtocol : CHAR (+116, 256byte)  varptr(st)+116 を基点に操作(256byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global WSAPROTOCOLCHAIN
    #field int ChainLen
    #field int ChainEntries 7
#endstruct

#defstruct global WSAPROTOCOL_INFOA
    #field int dwServiceFlags1
    #field int dwServiceFlags2
    #field int dwServiceFlags3
    #field int dwServiceFlags4
    #field int dwProviderFlags
    #field GUID ProviderId
    #field int dwCatalogEntryId
    #field WSAPROTOCOLCHAIN ProtocolChain
    #field int iVersion
    #field int iAddressFamily
    #field int iMaxSockAddr
    #field int iMinSockAddr
    #field int iSocketType
    #field int iProtocol
    #field int iProtocolMaxOffset
    #field int iNetworkByteOrder
    #field int iSecurityScheme
    #field int dwMessageSize
    #field int dwProviderReserved
    #field byte szProtocol 256
#endstruct

stdim st, WSAPROTOCOL_INFOA        ; NSTRUCT 変数を確保
st->dwServiceFlags1 = 100
mes "dwServiceFlags1=" + st->dwServiceFlags1