Subversion Repositories HelenOS

Rev

Rev 4722 | Rev 4743 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4722 Rev 4728
Line 59... Line 59...
59
    }
59
    }
60
    data = ( uint8_t * ) packet_prefix( packet, sizeof( ip_header_t ) + padding );
60
    data = ( uint8_t * ) packet_prefix( packet, sizeof( ip_header_t ) + padding );
61
    if( ! data ) return ENOMEM;
61
    if( ! data ) return ENOMEM;
62
    while( padding -- ) data[ sizeof( ip_header_t ) + padding ] = IPOPT_NOOP;
62
    while( padding -- ) data[ sizeof( ip_header_t ) + padding ] = IPOPT_NOOP;
63
    header = ( ip_header_ref ) data;
63
    header = ( ip_header_ref ) data;
64
    header->ihl = ( uint8_t ) ( sizeof( ip_header_t ) + ipopt_length ) / 4;
64
    header->header_length = IP_COMPUTE_HEADER_LENGTH( sizeof( ip_header_t ) + ipopt_length );
65
    header->ttl = ttl ? (( ttl <= MAXTTL ) ? ttl : MAXTTL ) : IPDEFTTL;
65
    header->ttl = ttl ? (( ttl <= MAXTTL ) ? ttl : MAXTTL ) : IPDEFTTL;
66
    header->tos = tos;
66
    header->tos = tos;
67
    header->protocol = protocol;
67
    header->protocol = protocol;
68
    if( dont_fragment ) header->flags = IPFLAG_DONT_FRAGMENT;
68
    if( dont_fragment ) header->flags = IPFLAG_DONT_FRAGMENT;
69
    return EOK;
69
    return EOK;
Line 80... Line 80...
80
    if( protocol ) * protocol = header->protocol;
80
    if( protocol ) * protocol = header->protocol;
81
    if( ttl ) * ttl = header->ttl;
81
    if( ttl ) * ttl = header->ttl;
82
    if( tos ) * tos = header->tos;
82
    if( tos ) * tos = header->tos;
83
    if( dont_fragment ) * dont_fragment = header->flags & IPFLAG_DONT_FRAGMENT;
83
    if( dont_fragment ) * dont_fragment = header->flags & IPFLAG_DONT_FRAGMENT;
84
    if( ipopt_length ){
84
    if( ipopt_length ){
85
        * ipopt_length = header->ihl * 4 - sizeof( ip_header_t );
85
        * ipopt_length = IP_HEADER_LENGTH( header ) - sizeof( ip_header_t );
86
        return sizeof( ip_header_t );
86
        return sizeof( ip_header_t );
87
    }else{
87
    }else{
88
        return header->ihl * 4;
88
        return IP_HEADER_LENGTH( header );
89
    }
89
    }
90
}
90
}
91
 
91
 
92
size_t ip_client_header_length( packet_t packet ){
92
size_t ip_client_header_length( packet_t packet ){
93
    ip_header_ref   header;
93
    ip_header_ref   header;
Line 95... Line 95...
95
    header = ( ip_header_ref ) packet_get_data( packet );
95
    header = ( ip_header_ref ) packet_get_data( packet );
96
    if(( ! header )
96
    if(( ! header )
97
    || ( packet_get_data_length( packet ) < sizeof( ip_header_t ))){
97
    || ( packet_get_data_length( packet ) < sizeof( ip_header_t ))){
98
        return 0;
98
        return 0;
99
    }
99
    }
100
    return header->ihl * 4u;
100
    return IP_HEADER_LENGTH( header );
101
}
101
}
102
 
102
 
103
int ip_client_set_pseudo_header_data_length( ip_pseudo_header_ref header, size_t headerlen, size_t data_length ){
103
int ip_client_set_pseudo_header_data_length( ip_pseudo_header_ref header, size_t headerlen, size_t data_length ){
104
    ipv4_pseudo_header_ref  header_in;
104
    ipv4_pseudo_header_ref  header_in;
105
 
105