阅读:1376回复:2
TDI_Connect 驱动编程我想在TDI_CONNECT中得到远程地址,可是每次得到的IP地址都不对,端口是对的,请各们大虾帮忙看哈!!谢谢!! case TDI_CONNECT: if ( pIrp->AssociatedIrp.SystemBuffer ) { KdPrint(( "$$$$$$$$$ pIrp->AssociatedIrp.SystemBuffer \n" )); TDI_CONNECTION_INFORMATION senddatagram = *(TDI_CONNECTION_INFORMATION*)pIrp->AssociatedIrp.SystemBuffer; TRANSPORT_ADDRESS transport = *(TRANSPORT_ADDRESS*)senddatagram.RemoteAddress; TA_ADDRESS address = transport.Address[0]; TDI_ADDRESS_IP addressip = *(TDI_ADDRESS_IP*)address.Address; ULONG dwIP = 0; USHORT dwPort = 0; KdPrint(("$$$$$$$$ tdi_create_addrobj_complete2: address : %x:%u\n", dwIP = ntohl(addressip.in_addr), dwPort = ntohs(addressip.sin_port) )); KdPrint(( "$$$$$$$$ the ip address is: %d.%d.%d.%d ip port is: %d \n", (dwIP&0xff000000)>>24, (dwIP&0xff0000)>>16, (dwIP&0xff00)>>8, (dwIP&0xff), dwPort )); } break; |
|
沙发#
发布于:2008-12-19 10:55
下面是ntol和ntos的两个函数:
ULONG ntohl ( ULONG netlong ) { ULONG result = 0; ((char *)&result)[0] = ((char *)&netlong)[3]; ((char *)&result)[1] = ((char *)&netlong)[2]; ((char *)&result)[2] = ((char *)&netlong)[1]; ((char *)&result)[3] = ((char *)&netlong)[0]; return result; } USHORT ntohs ( USHORT netshort) { USHORT result = 0; ((char *)&result)[0] = ((char *)&netshort)[1]; ((char *)&result)[1] = ((char *)&netshort)[0]; return result; } |
|
板凳#
发布于:2008-12-19 14:10
高手都去哪儿了呀,嘿嘿 搞定了,参数错了!!
|
|