[pso] [tema5] struct fwr_t
Alexandru Trifan
alexandru.trifan at gmail.com
Mon Apr 30 23:23:33 EEST 2007
1. De ce:
typedef struct fwr {
unsigned int ip_src, ip_dst, ip_src_mask, ip_dst_mask;
unsigned int port_src[2], port_dst[2];
} fwr_t;
si nu:
typedef struct fwr {
unsigned int ip_src, ip_dst, ip_src_mask, ip_dst_mask;
unsigned short port_src[2], port_dst[2];
} fwr_t;
?
Oricum peste tot porturile sunt retinute pe 16 biti.
2. Adresele IP si port-urile din headere (iphdr, tcphdr, udphdr) sunt
specificate tot in network byte order? Daca da, atunci dupa ce se
executa aceasta sectiune:
unsigned short port;
struct fwr_t fwr;
/* read structure from userspace here */
port = fwr.port_src[0];
variabila port nu va contine in mod corect numarul portului, nu?
Trebuie sa folosesc ntohl, apoi cast la unsigned short, apoi htons la
loc, in mod inutil? Sau ma insel eu? Cred ca s-ar fi rezolvat
specificand porturile ca unsigned short in structura fwr.
--
Regards,
Alexandru Trifan [alexandru.trifan at gmail.com]
More information about the pso
mailing list