raw socket in winCE

Windows CE-based devices support raw sockets. To enhance security, only trusted applications are allowed to open raw sockets. The TCP/IP service providers may support the SOCK_RAW socket type.

Note Raw sockets are supported only for IPv4. SOCK_RAW is not supported for IPv6 or any other protocol.
There are two types of such sockets:

The first type assumes a known protocol type as written in the IP header. An example of the first type of socket is ICMP.
The second type allows any protocol number. An example of the second type would be an experimental protocol that is not supported by the service provider.
If a service provider supports SOCK_RAW sockets for a range of protocols or installs itself over the default raw sockets protocol chain, the provider should set the PFL_HIDDEN flag when calling the WSCInstallProvider function. This flag is prevents the name of the provider from appearing in the query to WSAEnumProtocols. This is useful for the applications that are checking for protocol support.

Providers should set the PFL_Hidden flag while calling the WSCInstallProvider function.

The following rules are applied to the operations over SOCK_RAW sockets:

When an application sends a datagram it may or may not include the IP header at the front of the outgoing datagrams depending on the IP_HDRINCL option set for the socket. The IP_HDRINCL option can be set by calling the setsockopt (Windows Sockets) function.
Note If the IP_HDRINCL option set for the socket, Windows CE checks the header to ensure that the protocol field is not set to TCP. If it is, then the WSAEPROTONOSUPPORT error code is returned.
An application always gets the IP header at the front of each received datagram regardless of the IP_HDRINCL option.
Received datagrams are copied into all SOCK_RAW sockets that satisfy the following conditions:
The protocol number specified for the socket should match the protocol number in the IP header of the received datagram.
If a local IP address is defined for the socket, it should correspond to the destination address as specified in the IP header of the received datagram. An application may specify the local IP address by calling bind functions. If no local IP address is specified for the socket, the datagrams are copied into the socket regardless of the destination IP address in the IP header of the received datagram.
If a foreign address is defined for the socket, it should correspond to the source address as specified in the IP header of the received datagram. An application may specify the foreign IP address by calling connect functions. If no foreign IP address is specified for the socket, the datagrams are copied into the socket regardless of the source IP address in the IP header of the received datagram.
It is important to understand that SOCK_RAW sockets may get many unexpected datagrams. For example, a PING program may use SOCK_RAW sockets to send ICMP echo requests. While the application is expecting ICMP echo resp

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7447630/viewspace-915801/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7447630/viewspace-915801/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值