The protocol parameter becomes the protocol value in the IP header (SCTP is 132, for example).Īn application may not specify zero (0) as the protocol parameter for the socket, WSASocket, and WSPSocket functions if the type parameter is set to SOCK_RAW. To create a socket of type SOCK_RAW, call the socket or WSASocket function with the af parameter (address family) set to AF_INET or AF_INET6, the type parameter set to SOCK_RAW, and the protocol parameter set to the protocol number required. Search for the term RAW/IP or RAW/IPv6 in the Description field to find those protocols that support raw sockets. The output will include a list that contains some of the data from the WSAPROTOCOL_INFO structures supported on the local computer. The following command run from a CMD window will display data from the Winsock catalog on the console: On Windows XP and later, the NetSh.exe command can be used to determine if raw sockets are supported. These other members of the WSAPROTOCOL_INFO for SOCK_RAW normally specify that the protocol is connectionless, message-oriented, supports broadcast/multicast (the XP1_CONNECTIONLESS, XP1_MESSAGE_ORIENTED, XP1_SUPPORT_BROADCAST, and XP1_SUPPORT_MULTIPOINT bits are set in the dwServiceFlags1 member), and can have a maximum message size of 65,467 bytes. The other members in the WSAPROTOCOL_INFO structure indicate other properties of the protocol support for SOCK_RAW and indicate how a socket of SOCK_RAW should be treated. The iProtocol member of the WSAPROTOCOL_INFO structure may also be set to zero if the service provider allows an application to use a SOCK_RAW socket type for other network protocols other than the Internet Protocol for the address family. The iProtocol member of the WSAPROTOCOL_INFO structure may be set to IPROTO_IP. The iAddressFamily member in the WSAPROTOCOL_INFO structure should specify AF_INET or AF_INET6 and the iSocketType member of the WSAPROTOCOL_INFO structure should specify SOCK_RAW for one of the transport providers. If a Winsock service provider supports SOCK_RAW sockets for the AF_INET or AF_INET6 address families, the socket type of SOCK_RAW should be included in the WSAPROTOCOL_INFO structure returned by WSAEnumProtocols function for one or more of the available transport providers. An example of the second type would be an experimental protocol that is not directly supported by the Winsock service provider such as the Stream Control Transmission Protocol (SCTP). The second type allows any protocol type to be specified.An example of the first type of socket is a socket for the ICMP protocol (IP protocol type = 1) or the ICMPv6 protocol (IP procotol type = 58). The first type uses a known protocol type written in the IP header that is recognized by a Winsock service provider.There are two basic types of such raw sockets: The Windows Sockets 2 provider for TCP/IP included on Windows supports this SOCK_RAW socket type. Winsock service providers for the IP protocol may support a socket type of SOCK_RAW. To use raw sockets, an application needs to have detailed information on the underlying protocol being used. This is because most other protocols with the exception of ATM do not support raw sockets. This topic focuses only on raw sockets and the IPv4 and IPv6 protocols. A raw socket is a type of socket that allows access to the underlying transport provider.
0 Comments
Leave a Reply. |