B
bobfilar
I am working on a port enumerator and I am coming up with a problem.
Here is the part of my code that is giving me fits right now:
for (int i=0; i < (int) pTcpTable->dwNumEntries; i++) {
if(pTcpTable->table.dwState == MIB_TCP_STATE_LISTEN)
{
printf("localhost:%ld <---> %ld\n", pTcpTable->table.dwLocalPort,
pTcpTable->table.dwRemotePort & 0xFFFF);
}
Now when that prints out the Local port and remote ports it is not
print the right numbers. After some reseach I concluded that I needed
to use htons(), but the only problem is I dont know where to implement
it. Any help on what can do to convert DWORD to uINT or just to get it
to print the right info to the buffer?
Here is the part of my code that is giving me fits right now:
for (int i=0; i < (int) pTcpTable->dwNumEntries; i++) {
if(pTcpTable->table.dwState == MIB_TCP_STATE_LISTEN)
{
printf("localhost:%ld <---> %ld\n", pTcpTable->table.dwLocalPort,
pTcpTable->table.dwRemotePort & 0xFFFF);
}
Now when that prints out the Local port and remote ports it is not
print the right numbers. After some reseach I concluded that I needed
to use htons(), but the only problem is I dont know where to implement
it. Any help on what can do to convert DWORD to uINT or just to get it
to print the right info to the buffer?