Changeset b5e68c8 in mainline for uspace/lib/net/il/ip_client.c
- Timestamp:
- 2011-05-12T16:49:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f36787d7
- Parents:
- e80329d6 (diff), 750636a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/il/ip_client.c
re80329d6 rb5e68c8 48 48 * 49 49 * @param[in] packet The packet. 50 * @return sThe IP header length in bytes.51 * @return sZero if there is no IP header.52 */ 53 size_t ip_client_header_length(packet_t packet)54 { 55 ip_header_ refheader;56 57 header = (ip_header_ ref) packet_get_data(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); 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 sEOK on success.75 * @return sEBADMEM if the header and/or the headerlen parameter is74 * @return EOK on success. 75 * @return EBADMEM if the header and/or the headerlen parameter is 76 76 * NULL. 77 * @return sEINVAL if the source address and/or the destination77 * @return EINVAL if the source address and/or the destination 78 78 * address parameter is NULL. 79 * @return sEINVAL if the source address length is less than struct79 * @return EINVAL if the source address length is less than struct 80 80 * sockaddr length. 81 * @return sEINVAL if the source address length differs from the81 * @return EINVAL if the source address length differs from the 82 82 * destination address length. 83 * @return sEINVAL if the source address family differs from the83 * @return EINVAL if the source address family differs from the 84 84 * destination family. 85 * @return sEAFNOSUPPORT if the address family is not supported.86 * @return sENOMEM if there is not enough memory left.85 * @return EAFNOSUPPORT if the address family is not supported. 86 * @return 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_ refheader_in;93 ipv4_pseudo_header_t *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_ ref) malloc(*headerlen);111 header_in = (ipv4_pseudo_header_t *) malloc(*headerlen); 112 112 if (!header_in) 113 113 return ENOMEM; … … 124 124 125 125 // TODO IPv6 126 /* case AF_INET6: 126 #if 0 127 case AF_INET6: 127 128 if (addrlen != sizeof(struct sockaddr_in6)) 128 129 return EINVAL; … … 130 131 address_in6 = (struct sockaddr_in6 *) addr; 131 132 return EOK; 132 */ 133 #endif 133 134 134 135 default: … … 148 149 * disabled. 149 150 * @param[in] ipopt_length The prefixed IP options length in bytes. 150 * @return sEOK on success.151 * @return sENOMEM 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,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, 155 156 ip_tos_t tos, int dont_fragment, size_t ipopt_length) 156 157 { 157 ip_header_ refheader;158 ip_header_t *header; 158 159 uint8_t *data; 159 160 size_t padding; 160 161 161 // compute the padding if IP options are set 162 // multiple of 4 bytes 162 /* 163 * Compute the padding if IP options are set 164 * multiple of 4 bytes 165 */ 163 166 padding = ipopt_length % 4; 164 167 if (padding) { … … 167 170 } 168 171 169 / / prefix the header172 /* Prefix the header */ 170 173 data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding); 171 174 if (!data) 172 175 return ENOMEM; 173 176 174 / / add the padding177 /* Add the padding */ 175 178 while (padding--) 176 179 data[sizeof(ip_header_t) + padding] = IPOPT_NOOP; 177 180 178 / / set the header179 header = (ip_header_ ref) data;181 /* Set the header */ 182 header = (ip_header_t *) data; 180 183 header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + 181 184 ipopt_length); … … 203 206 * @param[out] ipopt_length The IP options length in bytes. May be NULL if not 204 207 * desired. 205 * @return sThe prefixed IP header length in bytes on success.206 * @return sENOMEM if the packet is too short to contain the IP208 * @return The prefixed IP header length in bytes on success. 209 * @return ENOMEM if the packet is too short to contain the IP 207 210 * header. 208 211 */ 209 212 int 210 ip_client_process_packet(packet_t packet, ip_protocol_t *protocol,213 ip_client_process_packet(packet_t *packet, ip_protocol_t *protocol, 211 214 ip_ttl_t *ttl, ip_tos_t *tos, int *dont_fragment, size_t *ipopt_length) 212 215 { 213 ip_header_ refheader;214 215 header = (ip_header_ ref) packet_get_data(packet);216 ip_header_t *header; 217 218 header = (ip_header_t *) packet_get_data(packet); 216 219 if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t))) 217 220 return ENOMEM; … … 238 241 * @param[in] headerlen The length of the IP pseudo header in bytes. 239 242 * @param[in] data_length The data length to be set. 240 * @return sEOK on success.241 * @return sEBADMEM if the header parameter is NULL.242 * @return sEINVAL if the headerlen parameter is not IPv4 pseudo243 * @return EOK on success. 244 * @return EBADMEM if the header parameter is NULL. 245 * @return EINVAL if the headerlen parameter is not IPv4 pseudo 243 246 * header length. 244 247 */ … … 247 250 size_t data_length) 248 251 { 249 ipv4_pseudo_header_ refheader_in;252 ipv4_pseudo_header_t *header_in; 250 253 251 254 if (!header) … … 253 256 254 257 if (headerlen == sizeof(ipv4_pseudo_header_t)) { 255 header_in = (ipv4_pseudo_header_ ref) header;258 header_in = (ipv4_pseudo_header_t *) header; 256 259 header_in->data_length = htons(data_length); 257 260 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.