Referring to the Netfilter hook code at this page
The port to be checked against is declared as:
/* Port we want to drop packets on */
static const uint16_t port = 25;
The comparison is made as:
return (tcph->dest == port) ? NF_DROP : NF_ACCEPT;
In case variable port was of type int32, how can we convert it to uint16_t so that it can be checked against tcph->dest.
Thanks.
TCP ports are only 16 bit wide, so if your
port-variable contains anything outside the range 0..65535, something is wrong anyway. Also, you should usentohsto account for endianess differences.So I suggest something like: