Rev 4707 | Rev 4722 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4707 | Rev 4721 | ||
---|---|---|---|
Line 70... | Line 70... | ||
70 | 70 | ||
71 | int ip_client_process_packet( packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length ){ |
71 | int ip_client_process_packet( packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length ){ |
72 | ip_header_ref header; |
72 | ip_header_ref header; |
73 | 73 | ||
74 | header = ( ip_header_ref ) packet_get_data( packet ); |
74 | header = ( ip_header_ref ) packet_get_data( packet ); |
- | 75 | if(( ! header ) |
|
- | 76 | || ( packet_get_data_length( packet ) < sizeof( ip_header_t ))){ |
|
75 | if( ! header ) return ENOMEM; |
77 | return ENOMEM; |
- | 78 | } |
|
76 | if( protocol ) * protocol = header->protocol; |
79 | if( protocol ) * protocol = header->protocol; |
77 | if( ttl ) * ttl = header->ttl; |
80 | if( ttl ) * ttl = header->ttl; |
78 | if( tos ) * tos = header->tos; |
81 | if( tos ) * tos = header->tos; |
79 | if( dont_fragment ) * dont_fragment = header->flags & IPFLAG_DONT_FRAGMENT; |
82 | if( dont_fragment ) * dont_fragment = header->flags & IPFLAG_DONT_FRAGMENT; |
80 | if( ipopt_length ){ |
83 | if( ipopt_length ){ |
Line 83... | Line 86... | ||
83 | }else{ |
86 | }else{ |
84 | return header->ihl * 4; |
87 | return header->ihl * 4; |
85 | } |
88 | } |
86 | } |
89 | } |
87 | 90 | ||
88 | int ip_client_header_length( packet_t packet ){ |
91 | size_t ip_client_header_length( packet_t packet ){ |
89 | ip_header_ref header; |
92 | ip_header_ref header; |
90 | 93 | ||
91 | header = ( ip_header_ref ) packet_get_data( packet ); |
94 | header = ( ip_header_ref ) packet_get_data( packet ); |
92 | if( ! header ) return ENOMEM; |
95 | if(( ! header ) |
- | 96 | || ( packet_get_data_length( packet ) < sizeof( ip_header_t ))){ |
|
- | 97 | return 0; |
|
- | 98 | } |
|
93 | return header->ihl * 4; |
99 | return header->ihl * 4u; |
94 | } |
100 | } |
95 | 101 | ||
96 | /** @} |
102 | /** @} |
97 | */ |
103 | */ |