[pso] [tema5] struct fwr_t

cosminratiu at gmail.com cosminratiu at gmail.com
Tue May 1 01:12:42 EEST 2007


Trebuie oricum sa treci inapoi toate porturi in host byte order ca sa poti
face comparatia cu range-ul de porturi. Asa ca nu mai conteaza ca e int sau
short, folosesti ntohs si gata :).


On 4/30/07, Alexandru Trifan <alexandru.trifan at gmail.com> wrote:
>
> 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]
> _______________________________________________
> pso mailing list
> pso at cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/pso
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cursuri.cs.pub.ro/pipermail/pso/attachments/20070501/16dd3478/attachment.html


More information about the pso mailing list