Changes in uspace/lib/net/il/ip_client.c [ccca251:9b9d1c95] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/il/ip_client.c
rccca251 r9b9d1c95 48 48 * 49 49 * @param[in] packet The packet. 50 * @return The IP header length in bytes.51 * @return Zero if there is no IP header.52 */ 53 size_t ip_client_header_length(packet_t *packet)54 { 55 ip_header_ t *header;56 57 header = (ip_header_ t *) packet_get_data(packet);50 * @returns The IP header length in bytes. 51 * @returns Zero if there is no IP header. 52 */ 53 size_t ip_client_header_length(packet_t packet) 54 { 55 ip_header_ref header; 56 57 header = (ip_header_ref) packet_get_data(packet); 58 58 if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t))) 59 59 return 0; … … 72 72 * @param[out] header The constructed IPv4 pseudo header. 73 73 * @param[out] headerlen The length of the IP pseudo header in bytes. 74 * @return EOK on success.75 * @return EBADMEM if the header and/or the headerlen parameter is74 * @returns EOK on success. 75 * @returns EBADMEM if the header and/or the headerlen parameter is 76 76 * NULL. 77 * @return EINVAL if the source address and/or the destination77 * @returns EINVAL if the source address and/or the destination 78 78 * address parameter is NULL. 79 * @return EINVAL if the source address length is less than struct79 * @returns EINVAL if the source address length is less than struct 80 80 * sockaddr length. 81 * @return EINVAL if the source address length differs from the81 * @returns EINVAL if the source address length differs from the 82 82 * destination address length. 83 * @return EINVAL if the source address family differs from the83 * @returns EINVAL if the source address family differs from the 84 84 * destination family. 85 * @return EAFNOSUPPORT if the address family is not supported.86 * @return ENOMEM if there is not enough memory left.85 * @returns EAFNOSUPPORT if the address family is not supported. 86 * @returns ENOMEM if there is not enough memory left. 87 87 */ 88 88 int … … 91 91 size_t data_length, void **header, size_t *headerlen) 92 92 { 93 ipv4_pseudo_header_ t *header_in;93 ipv4_pseudo_header_ref header_in; 94 94 struct sockaddr_in *address_in; 95 95 … … 109 109 110 110 *headerlen = sizeof(*header_in); 111 header_in = (ipv4_pseudo_header_ t *) malloc(*headerlen);111 header_in = (ipv4_pseudo_header_ref) malloc(*headerlen); 112 112 if (!header_in) 113 113 return ENOMEM; … … 124 124 125 125 // TODO IPv6 126 #if 0 127 case AF_INET6: 126 /* case AF_INET6: 128 127 if (addrlen != sizeof(struct sockaddr_in6)) 129 128 return EINVAL; … … 131 130 address_in6 = (struct sockaddr_in6 *) addr; 132 131 return EOK; 133 #endif 132 */ 134 133 135 134 default: … … 149 148 * disabled. 150 149 * @param[in] ipopt_length The prefixed IP options length in bytes. 151 * @return EOK on success.152 * @return ENOMEM if there is not enough memory left in the packet.153 */ 154 int 155 ip_client_prepare_packet(packet_t *packet, ip_protocol_t protocol, ip_ttl_t ttl,150 * @returns EOK on success. 151 * @returns ENOMEM if there is not enough memory left in the packet. 152 */ 153 int 154 ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, 156 155 ip_tos_t tos, int dont_fragment, size_t ipopt_length) 157 156 { 158 ip_header_ t *header;157 ip_header_ref header; 159 158 uint8_t *data; 160 159 size_t padding; 161 160 162 /* 163 * Compute the padding if IP options are set 164 * multiple of 4 bytes 165 */ 161 // compute the padding if IP options are set 162 // multiple of 4 bytes 166 163 padding = ipopt_length % 4; 167 164 if (padding) { … … 170 167 } 171 168 172 / * Prefix the header */169 // prefix the header 173 170 data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding); 174 171 if (!data) 175 172 return ENOMEM; 176 173 177 / * Add the padding */174 // add the padding 178 175 while (padding--) 179 176 data[sizeof(ip_header_t) + padding] = IPOPT_NOOP; 180 177 181 / * Set the header */182 header = (ip_header_ t *) data;178 // set the header 179 header = (ip_header_ref) data; 183 180 header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + 184 181 ipopt_length); … … 206 203 * @param[out] ipopt_length The IP options length in bytes. May be NULL if not 207 204 * desired. 208 * @return The prefixed IP header length in bytes on success.209 * @return ENOMEM if the packet is too short to contain the IP205 * @returns The prefixed IP header length in bytes on success. 206 * @returns ENOMEM if the packet is too short to contain the IP 210 207 * header. 211 208 */ 212 209 int 213 ip_client_process_packet(packet_t *packet, ip_protocol_t *protocol,210 ip_client_process_packet(packet_t packet, ip_protocol_t *protocol, 214 211 ip_ttl_t *ttl, ip_tos_t *tos, int *dont_fragment, size_t *ipopt_length) 215 212 { 216 ip_header_ t *header;217 218 header = (ip_header_ t *) packet_get_data(packet);213 ip_header_ref header; 214 215 header = (ip_header_ref) packet_get_data(packet); 219 216 if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t))) 220 217 return ENOMEM; … … 241 238 * @param[in] headerlen The length of the IP pseudo header in bytes. 242 239 * @param[in] data_length The data length to be set. 243 * @return EOK on success.244 * @return EBADMEM if the header parameter is NULL.245 * @return EINVAL if the headerlen parameter is not IPv4 pseudo240 * @returns EOK on success. 241 * @returns EBADMEM if the header parameter is NULL. 242 * @returns EINVAL if the headerlen parameter is not IPv4 pseudo 246 243 * header length. 247 244 */ … … 250 247 size_t data_length) 251 248 { 252 ipv4_pseudo_header_ t *header_in;249 ipv4_pseudo_header_ref header_in; 253 250 254 251 if (!header) … … 256 253 257 254 if (headerlen == sizeof(ipv4_pseudo_header_t)) { 258 header_in = (ipv4_pseudo_header_ t *) header;255 header_in = (ipv4_pseudo_header_ref) header; 259 256 header_in->data_length = htons(data_length); 260 257 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.