Changeset 28a3e74 in mainline
- Timestamp:
- 2011-04-02T09:22:46Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 250dbef, b2a081ae
- Parents:
- ea53529
- Location:
- uspace
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
rea53529 r28a3e74 195 195 wchar_t c = str_decode(buff, &offset, bytes); 196 196 if (c == 0) { 197 / / reached end of string197 /* Reached end of string */ 198 198 break; 199 199 } … … 228 228 int rc; 229 229 230 // reset global state 231 // TODO: move to structure? 230 /* 231 * reset global state 232 * TODO: move to structure? 233 */ 232 234 paging_enabled = false; 233 235 chars_remaining = 0; -
uspace/app/stats/stats.c
rea53529 r28a3e74 265 265 /* Threads */ 266 266 if ((off = arg_parse_short_long(argv[i], "-t", "--task=")) != -1) { 267 / / TODO: Support for 64b range267 /* TODO: Support for 64b range */ 268 268 int tmp; 269 269 int ret = arg_parse_int(argc, argv, &i, &tmp, off); -
uspace/app/trace/trace.c
rea53529 r28a3e74 53 53 #include <libc.h> 54 54 55 / / Temporary: service and method names55 /* Temporary: service and method names */ 56 56 #include "proto.h" 57 57 #include <ipc/services.h> -
uspace/drv/isa/isa.c
rea53529 r28a3e74 83 83 static bool isa_enable_fun_interrupt(ddf_fun_t *fnode) 84 84 { 85 / / TODO85 /* TODO */ 86 86 87 87 return false; -
uspace/lib/c/generic/adt/measured_strings.c
rea53529 r28a3e74 74 74 new->length = length; 75 75 new->value = ((uint8_t *) new) + sizeof(measured_string_t); 76 / / append terminating zero explicitly - to be safe76 /* Append terminating zero explicitly - to be safe */ 77 77 memcpy(new->value, string, new->length); 78 78 new->value[new->length] = '\0'; -
uspace/lib/drv/generic/driver.c
rea53529 r28a3e74 402 402 get_remote_method(rem_iface, iface_method_idx); 403 403 if (iface_method_ptr == NULL) { 404 / / the interface has not such method404 /* The interface has not such method */ 405 405 printf("%s: driver_connection_gen error - " 406 406 "invalid interface method.", driver->name); -
uspace/lib/net/generic/generic.c
rea53529 r28a3e74 106 106 return EBADMEM; 107 107 108 / / request the address108 /* Request the address */ 109 109 message_id = async_send_1(phone, (sysarg_t) message, 110 110 (sysarg_t) device_id, NULL); … … 112 112 async_wait_for(message_id, &result); 113 113 114 / / if not successful114 /* If not successful */ 115 115 if ((string == EOK) && (result != EOK)) { 116 / / clear the data116 /* Clear the data */ 117 117 free(*address); 118 118 free(*data); … … 242 242 return EBADMEM; 243 243 244 / / request the translation244 /* Request the translation */ 245 245 message_id = async_send_3(phone, (sysarg_t) message, 246 246 (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL); … … 249 249 async_wait_for(message_id, &result); 250 250 251 / / if not successful251 /* If not successful */ 252 252 if ((string == EOK) && (result != EOK)) { 253 / / clear the data253 /* Clear the data */ 254 254 free(*translation); 255 255 free(*data); -
uspace/lib/net/generic/net_checksum.c
rea53529 r28a3e74 52 52 uint16_t compact_checksum(uint32_t sum) 53 53 { 54 / / shorten to the 16 bits54 /* Shorten to the 16 bits */ 55 55 while (sum >> 16) 56 56 sum = (sum & 0xffff) + (sum >> 16); … … 72 72 size_t index; 73 73 74 / / sum all the 16 bit fields74 /* Sum all the 16 bit fields */ 75 75 for (index = 0; index + 1 < length; index += 2) 76 76 seed += (data[index] << 8) + data[index + 1]; 77 77 78 / / last odd byte with zero padding78 /* Last odd byte with zero padding */ 79 79 if (index + 1 == length) 80 80 seed += data[index] << 8; … … 94 94 size_t index; 95 95 96 / / process full bytes96 /* Process full bytes */ 97 97 while (length >= 8) { 98 / / add the data98 /* Add the data */ 99 99 seed ^= (*data) << 24; 100 100 101 / / for each added bit101 /* For each added bit */ 102 102 for (index = 0; index < 8; ++index) { 103 / / if the first bit is set103 /* If the first bit is set */ 104 104 if (seed & 0x80000000) { 105 / / shift and divide the checksum105 /* Shift and divide the checksum */ 106 106 seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE); 107 107 } else { 108 / / shift otherwise108 /* shift otherwise */ 109 109 seed <<= 1; 110 110 } 111 111 } 112 112 113 / / move to the next byte113 /* Move to the next byte */ 114 114 ++data; 115 115 length -= 8; 116 116 } 117 117 118 / / process the odd bits118 /* Process the odd bits */ 119 119 if (length > 0) { 120 / / add the data with zero padding120 /* Add the data with zero padding */ 121 121 seed ^= ((*data) & (0xff << (8 - length))) << 24; 122 122 123 / / for each added bit123 /* For each added bit */ 124 124 for (index = 0; index < length; ++index) { 125 / / if the first bit is set125 /* If the first bit is set */ 126 126 if (seed & 0x80000000) { 127 / / shift and divide the checksum127 /* Shift and divide the checksum */ 128 128 seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE); 129 129 } else { 130 / / shift otherwise130 /* Shift otherwise */ 131 131 seed <<= 1; 132 132 } … … 148 148 size_t index; 149 149 150 / / process full bytes150 /* Process full bytes */ 151 151 while (length >= 8) { 152 / / add the data152 /* Add the data */ 153 153 seed ^= (*data); 154 154 155 / / for each added bit155 /* For each added bit */ 156 156 for (index = 0; index < 8; ++index) { 157 / / if the last bit is set157 /* If the last bit is set */ 158 158 if (seed & 1) { 159 / / shift and divide the checksum159 /* Shift and divide the checksum */ 160 160 seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE); 161 161 } else { 162 / / shift otherwise162 /* Shift otherwise */ 163 163 seed >>= 1; 164 164 } 165 165 } 166 166 167 / / move to the next byte167 /* Move to the next byte */ 168 168 ++data; 169 169 length -= 8; 170 170 } 171 171 172 / / process the odd bits172 /* Process the odd bits */ 173 173 if (length > 0) { 174 / / add the data with zero padding174 /* Add the data with zero padding */ 175 175 seed ^= (*data) >> (8 - length); 176 176 177 177 for (index = 0; index < length; ++index) { 178 / / if the last bit is set178 /* If the last bit is set */ 179 179 if (seed & 1) { 180 / / shift and divide the checksum180 /* Shift and divide the checksum */ 181 181 seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE); 182 182 } else { 183 / / shift otherwise183 /* Shift otherwise */ 184 184 seed >>= 1; 185 185 } … … 198 198 uint16_t flip_checksum(uint16_t checksum) 199 199 { 200 / / flip, zero is returned as 0xFFFF (not flipped)200 /* Flip, zero is returned as 0xFFFF (not flipped) */ 201 201 checksum = ~checksum; 202 202 return checksum ? checksum : IP_CHECKSUM_ZERO; … … 216 216 uint16_t ip_checksum(uint8_t *data, size_t length) 217 217 { 218 / / compute, compact and flip the data checksum218 /* Compute, compact and flip the data checksum */ 219 219 return flip_checksum(compact_checksum(compute_checksum(0, data, 220 220 length))); -
uspace/lib/net/generic/packet_client.c
rea53529 r28a3e74 267 267 return NULL; 268 268 269 / / get a new packet269 /* Get a new packet */ 270 270 copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet), 271 271 PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix, … … 274 274 return NULL; 275 275 276 / / get addresses276 /* Get addresses */ 277 277 addrlen = packet_get_addr(packet, &src, &dest); 278 / / copy data278 /* Copy data */ 279 279 if ((packet_copy_data(copy, packet_get_data(packet), 280 280 PACKET_DATA_LENGTH(packet)) == EOK) && 281 / / copy addresses if present281 /* Copy addresses if present */ 282 282 ((addrlen <= 0) || 283 283 (packet_set_addr(copy, src, dest, addrlen) == EOK))) { -
uspace/lib/net/il/ip_client.c
rea53529 r28a3e74 123 123 return EOK; 124 124 125 / / TODO IPv6125 /* TODO IPv6 */ 126 126 /* case AF_INET6: 127 127 if (addrlen != sizeof(struct sockaddr_in6)) … … 159 159 size_t padding; 160 160 161 // compute the padding if IP options are set 162 // multiple of 4 bytes 161 /* 162 * Compute the padding if IP options are set 163 * multiple of 4 bytes 164 */ 163 165 padding = ipopt_length % 4; 164 166 if (padding) { … … 167 169 } 168 170 169 / / prefix the header171 /* Prefix the header */ 170 172 data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding); 171 173 if (!data) 172 174 return ENOMEM; 173 175 174 / / add the padding176 /* Add the padding */ 175 177 while (padding--) 176 178 data[sizeof(ip_header_t) + padding] = IPOPT_NOOP; 177 179 178 / / set the header180 /* Set the header */ 179 181 header = (ip_header_t *) data; 180 182 header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + … … 256 258 header_in->data_length = htons(data_length); 257 259 return EOK; 258 / / TODO IPv6260 /* TODO IPv6 */ 259 261 } else { 260 262 return EINVAL; -
uspace/lib/net/include/ip_client.h
rea53529 r28a3e74 54 54 socklen_t, struct sockaddr *, socklen_t, size_t, void **, size_t *); 55 55 56 / / TODO ipopt manipulation56 /* TODO ipopt manipulation */ 57 57 58 58 #endif -
uspace/lib/net/tl/icmp_client.c
rea53529 r28a3e74 81 81 *mtu = header->un.frag.mtu; 82 82 83 / / remove debug dump83 /* Remove debug dump */ 84 84 #ifdef CONFIG_DEBUG 85 85 printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, -
uspace/lib/net/tl/socket_core.c
rea53529 r28a3e74 91 91 int packet_id; 92 92 93 / / if bound93 /* If bound */ 94 94 if (socket->port) { 95 / / release the port95 /* Release the port */ 96 96 socket_port_release(global_sockets, socket); 97 97 } 98 98 99 / / release all received packets99 /* Release all received packets */ 100 100 while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0) 101 101 pq_release_remote(packet_phone, packet_id); … … 166 166 int rc; 167 167 168 / / create a wrapper168 /* Create a wrapper */ 169 169 socket_ref = malloc(sizeof(*socket_ref)); 170 170 if (!socket_ref) … … 172 172 173 173 *socket_ref = socket; 174 / / add the wrapper174 /* Add the wrapper */ 175 175 rc = socket_port_map_add(&socket_port->map, key, key_length, 176 176 socket_ref); … … 206 206 int rc; 207 207 208 / / create a wrapper208 /* Create a wrapper */ 209 209 socket_port = malloc(sizeof(*socket_port)); 210 210 if (!socket_port) … … 221 221 goto fail; 222 222 223 / / register the incomming port223 /* Register the incoming port */ 224 224 rc = socket_ports_add(global_sockets, port, socket_port); 225 225 if (rc < 0) … … 277 277 278 278 address_in = (struct sockaddr_in *) addr; 279 / / find the socket279 /* Find the socket */ 280 280 socket = socket_cores_find(local_sockets, socket_id); 281 281 if (!socket) 282 282 return ENOTSOCK; 283 283 284 / / bind a free port?284 /* Bind a free port? */ 285 285 if (address_in->sin_port <= 0) 286 286 return socket_bind_free_port(global_sockets, socket, 287 287 free_ports_start, free_ports_end, last_used_port); 288 288 289 / / try to find the port289 /* Try to find the port */ 290 290 socket_port = socket_ports_find(global_sockets, 291 291 ntohs(address_in->sin_port)); 292 292 if (socket_port) { 293 / / already used293 /* Already used */ 294 294 return EADDRINUSE; 295 295 } 296 296 297 / / if bound297 /* If bound */ 298 298 if (socket->port) { 299 / / release the port299 /* Release the port */ 300 300 socket_port_release(global_sockets, socket); 301 301 } … … 306 306 307 307 case AF_INET6: 308 / / TODO IPv6308 /* TODO IPv6 */ 309 309 break; 310 310 } … … 333 333 int index; 334 334 335 / / from the last used one335 /* From the last used one */ 336 336 index = last_used_port; 337 337 … … 339 339 ++index; 340 340 341 / / til the range end341 /* Till the range end */ 342 342 if (index >= free_ports_end) { 343 / / start from the range beginning343 /* Start from the range beginning */ 344 344 index = free_ports_start - 1; 345 345 do { 346 346 ++index; 347 / / til the last used one347 /* Till the last used one */ 348 348 if (index >= last_used_port) { 349 / / none found349 /* None found */ 350 350 return ENOTCONN; 351 351 } 352 352 } while (socket_ports_find(global_sockets, index)); 353 353 354 / / found, break immediately354 /* Found, break immediately */ 355 355 break; 356 356 } … … 384 384 socket_id = 1; 385 385 ++count; 386 / / only this branch for last_id386 /* Only this branch for last_id */ 387 387 } else { 388 388 if (socket_id < INT_MAX) { … … 425 425 return EINVAL; 426 426 427 / / store the socket427 /* Store the socket */ 428 428 if (*socket_id <= 0) { 429 429 positive = (*socket_id == 0); … … 441 441 return ENOMEM; 442 442 443 / / initialize443 /* Initialize */ 444 444 socket->phone = app_phone; 445 445 socket->port = -1; … … 493 493 int accepted_id; 494 494 495 / / find the socket495 /* Find the socket */ 496 496 socket = socket_cores_find(local_sockets, socket_id); 497 497 if (!socket) 498 498 return ENOTSOCK; 499 499 500 / / destroy all accepted sockets500 /* Destroy all accepted sockets */ 501 501 while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0) 502 502 socket_destroy(packet_phone, accepted_id, local_sockets, … … 535 535 next_packet = pq_next(packet); 536 536 if (!next_packet) { 537 / / write all if only one fragment537 /* Write all if only one fragment */ 538 538 rc = data_reply(packet_get_data(packet), 539 539 packet_get_data_length(packet)); 540 540 if (rc != EOK) 541 541 return rc; 542 / / store the total length542 /* Store the total length */ 543 543 *length = packet_get_data_length(packet); 544 544 } else { 545 / / count the packet fragments545 /* Count the packet fragments */ 546 546 fragments = 1; 547 547 next_packet = pq_next(packet); … … 549 549 ++fragments; 550 550 551 / / compute and store the fragment lengths551 /* Compute and store the fragment lengths */ 552 552 lengths = (size_t *) malloc(sizeof(size_t) * fragments + 553 553 sizeof(size_t)); … … 565 565 } 566 566 567 / / write the fragment lengths567 /* Write the fragment lengths */ 568 568 rc = data_reply(lengths, sizeof(int) * (fragments + 1)); 569 569 if (rc != EOK) { … … 573 573 next_packet = packet; 574 574 575 / / write the fragments575 /* Write the fragments */ 576 576 for (index = 0; index < fragments; ++index) { 577 577 rc = data_reply(packet_get_data(next_packet), … … 584 584 } 585 585 586 / / store the total length586 /* Store the total length */ 587 587 *length = lengths[fragments]; 588 588 free(lengths); … … 636 636 return; 637 637 638 / / find ports638 /* Find ports */ 639 639 socket_port = socket_ports_find(global_sockets, socket->port); 640 640 if (socket_port) { 641 / / find the socket641 /* Find the socket */ 642 642 socket_ref = socket_port_map_find(&socket_port->map, 643 643 socket->key, socket->key_length); … … 646 646 --socket_port->count; 647 647 648 / / release if empty648 /* Release if empty */ 649 649 if (socket_port->count <= 0) { 650 / / destroy the map650 /* Destroy the map */ 651 651 socket_port_map_destroy(&socket_port->map, free); 652 / / release the port652 /* Release the port */ 653 653 socket_ports_exclude(global_sockets, 654 654 socket->port, free); 655 655 } else { 656 / / remove656 /* Remove */ 657 657 socket_port_map_exclude(&socket_port->map, 658 658 socket->key, socket->key_length, free); … … 685 685 int rc; 686 686 687 / / find ports687 /* Find ports */ 688 688 socket_port = socket_ports_find(global_sockets, port); 689 689 if (!socket_port) 690 690 return ENOENT; 691 691 692 / / add the socket692 /* Add the socket */ 693 693 rc = socket_port_add_core(socket_port, socket, key, key_length); 694 694 if (rc != EOK) -
uspace/lib/net/tl/tl_common.c
rea53529 r28a3e74 255 255 int length; 256 256 257 / / detach the first packet and release the others257 /* Detach the first packet and release the others */ 258 258 next = pq_detach(packet); 259 259 if (next) … … 262 262 length = packet_get_addr(packet, &src, NULL); 263 263 if ((length > 0) && (!error) && (icmp_phone >= 0) && 264 // set both addresses to the source one (avoids the source address 265 // deletion before setting the destination one) 264 /* 265 * Set both addresses to the source one (avoids the source address 266 * deletion before setting the destination one) 267 */ 266 268 (packet_set_addr(packet, src, src, (size_t) length) == EOK)) { 267 269 return EOK; … … 299 301 return EINVAL; 300 302 301 / / get the data length303 /* Get the data length */ 302 304 if (!async_data_write_receive(&callid, &length)) 303 305 return EINVAL; 304 306 305 / / get a new packet307 /* Get a new packet */ 306 308 *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, 307 309 prefix + dimension->prefix, dimension->suffix); … … 309 311 return ENOMEM; 310 312 311 / / allocate space in the packet313 /* Allocate space in the packet */ 312 314 data = packet_suffix(*packet, length); 313 315 if (!data) { … … 316 318 } 317 319 318 / / read the data into the packet320 /* Read the data into the packet */ 319 321 rc = async_data_write_finalize(callid, data, length); 320 322 if (rc != EOK) { … … 323 325 } 324 326 325 / / set the packet destination address327 /* Set the packet destination address */ 326 328 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 327 329 if (rc != EOK) { -
uspace/lib/packet/generic/packet_server.c
rea53529 r28a3e74 112 112 size_t max_content, size_t max_suffix) 113 113 { 114 / / clear the packet content114 /* Clear the packet content */ 115 115 bzero(((void *) packet) + sizeof(packet_t), 116 116 packet->length - sizeof(packet_t)); 117 117 118 / / clear the packet header118 /* Clear the packet header */ 119 119 packet->order = 0; 120 120 packet->metric = 0; … … 151 151 assert(fibril_mutex_is_locked(&ps_globals.lock)); 152 152 153 / / already locked153 /* Already locked */ 154 154 packet = (packet_t *) mmap(NULL, length, PROTO_READ | PROTO_WRITE, 155 155 MAP_SHARED | MAP_ANONYMOUS, 0, 0); -
uspace/lib/softint/generic/multiplication.c
rea53529 r28a3e74 109 109 * result does not fit in signed one */ 110 110 if (SOFTINT_CHECK_OF && ((t2 < t1) || (t2 & (1ull << 63)))) { 111 / / error, overflow111 /* Error, overflow */ 112 112 return (neg ? INT64_MIN : INT64_MAX); 113 113 } -
uspace/srv/hw/irc/apic/apic.c
rea53529 r28a3e74 56 56 static int apic_enable_irq(sysarg_t irq) 57 57 { 58 / / FIXME: TODO58 /* FIXME: TODO */ 59 59 return ENOTSUP; 60 60 } -
uspace/srv/net/il/ip/ip.c
rea53529 r28a3e74 176 176 socklen_t addrlen; 177 177 178 / / detach the first packet and release the others178 /* Detach the first packet and release the others */ 179 179 next = pq_detach(packet); 180 180 if (next) … … 185 185 return ENOMEM; 186 186 187 / / get header187 /* Get header */ 188 188 header = (ip_header_t *) packet_get_data(packet); 189 189 if (!header) … … 192 192 } 193 193 194 / / only for the first fragment194 /* Only for the first fragment */ 195 195 if (IP_FRAGMENT_OFFSET(header)) 196 196 return EINVAL; 197 197 198 / / not for the ICMP protocol198 /* Not for the ICMP protocol */ 199 199 if (header->protocol == IPPROTO_ICMP) 200 200 return EPERM; 201 201 202 / / set the destination address202 /* Set the destination address */ 203 203 switch (header->version) { 204 204 case IPVERSION: … … 351 351 configuration = &names[0]; 352 352 353 / / get configuration353 /* Get configuration */ 354 354 rc = net_get_device_conf_req(ip_globals.net_phone, ip_netif->device_id, 355 355 &configuration, count, &data); … … 365 365 366 366 if (ip_netif->dhcp) { 367 / / TODO dhcp367 /* TODO dhcp */ 368 368 net_free_settings(configuration, data); 369 369 return ENOTSUP; … … 398 398 } 399 399 } else { 400 / / TODO ipv6 in separate module400 /* TODO ipv6 in separate module */ 401 401 net_free_settings(configuration, data); 402 402 return ENOTSUP; … … 419 419 } 420 420 421 / / binds the netif service which also initializes the device421 /* Bind netif service which also initializes the device */ 422 422 ip_netif->phone = nil_bind_service(ip_netif->service, 423 423 (sysarg_t) ip_netif->device_id, SERVICE_IP, … … 429 429 } 430 430 431 / / has to be after the device netif module initialization431 /* Has to be after the device netif module initialization */ 432 432 if (ip_netif->arp) { 433 433 if (route) { … … 445 445 } 446 446 447 / / get packet dimensions447 /* Get packet dimensions */ 448 448 rc = nil_packet_size_req(ip_netif->phone, ip_netif->device_id, 449 449 &ip_netif->packet_dimension); … … 463 463 464 464 if (gateway.s_addr) { 465 / / the default gateway465 /* The default gateway */ 466 466 ip_globals.gateway.address.s_addr = 0; 467 467 ip_globals.gateway.netmask.s_addr = 0; … … 512 512 ip_netif->arp->usage++; 513 513 514 / / print the settings514 /* Print the settings */ 515 515 printf("%s: Device registered (id: %d, phone: %d, ipv: %d, conf: %s)\n", 516 516 NAME, ip_netif->device_id, ip_netif->phone, ip_netif->ipv, 517 517 ip_netif->dhcp ? "dhcp" : "static"); 518 518 519 / / TODO ipv6 addresses519 /* TODO ipv6 addresses */ 520 520 521 521 char address[INET_ADDRSTRLEN]; … … 587 587 ip_netif_t *netif; 588 588 589 / / start with the last netif - the newest one589 /* Start with the last netif - the newest one */ 590 590 index = ip_netifs_count(&ip_globals.netifs) - 1; 591 591 while (index >= 0) { … … 629 629 size_t length; 630 630 631 / / copy first itself631 /* Copy first itself */ 632 632 memcpy(last, first, sizeof(ip_header_t)); 633 633 length = sizeof(ip_header_t); 634 634 next = sizeof(ip_header_t); 635 635 636 / / process all ip options636 /* Process all IP options */ 637 637 while (next < first->header_length) { 638 638 option = (ip_option_t *) (((uint8_t *) first) + next); 639 / / skip end or noop639 /* Skip end or noop */ 640 640 if ((option->type == IPOPT_END) || 641 641 (option->type == IPOPT_NOOP)) { 642 642 next++; 643 643 } else { 644 / / copy if told so or skip644 /* Copy if told so or skip */ 645 645 if (IPOPT_COPIED(option->type)) { 646 646 memcpy(((uint8_t *) last) + length, … … 648 648 length += option->length; 649 649 } 650 / / next option650 /* Next option */ 651 651 next += option->length; 652 652 } 653 653 } 654 654 655 / / align 4 byte boundary655 /* Align 4 byte boundary */ 656 656 if (length % 4) { 657 657 bzero(((uint8_t *) last) + length, 4 - (length % 4)); … … 789 789 790 790 header->total_length = htons(length); 791 / / unnecessary for all protocols791 /* Unnecessary for all protocols */ 792 792 header->header_checksum = IP_HEADER_CHECKSUM(header); 793 793 … … 916 916 return ENOMEM; 917 917 918 / / get header918 /* Get header */ 919 919 header = (ip_header_t *) packet_get_data(packet); 920 920 if (!header) 921 921 return EINVAL; 922 922 923 / / fragmentation forbidden?923 /* Fragmentation forbidden? */ 924 924 if(header->flags & IPFLAG_DONT_FRAGMENT) 925 925 return EPERM; 926 926 927 / / create the last fragment927 /* Create the last fragment */ 928 928 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length, 929 929 suffix, ((addrlen > addr_len) ? addrlen : addr_len)); … … 931 931 return ENOMEM; 932 932 933 / / allocate as much as originally933 /* Allocate as much as originally */ 934 934 last_header = (ip_header_t *) packet_suffix(new_packet, 935 935 IP_HEADER_LENGTH(header)); … … 939 939 ip_create_last_header(last_header, header); 940 940 941 / / trim the unused space941 /* Trim the unused space */ 942 942 rc = packet_trim(new_packet, 0, 943 943 IP_HEADER_LENGTH(header) - IP_HEADER_LENGTH(last_header)); … … 945 945 return ip_release_and_return(packet, rc); 946 946 947 / / biggest multiple of 8 lower than content948 / / TODO even fragmentation?947 /* Greatest multiple of 8 lower than content */ 948 /* TODO even fragmentation? */ 949 949 length = length & ~0x7; 950 950 … … 957 957 return ip_release_and_return(packet, rc); 958 958 959 / / mark the first as fragmented959 /* Mark the first as fragmented */ 960 960 header->flags |= IPFLAG_MORE_FRAGMENTS; 961 961 962 / / create middle framgents962 /* Create middle fragments */ 963 963 while (IP_TOTAL_LENGTH(header) > length) { 964 964 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, … … 981 981 } 982 982 983 / / finish the first fragment983 /* Finish the first fragment */ 984 984 header->header_checksum = IP_HEADER_CHECKSUM(header); 985 985 … … 1012 1012 1013 1013 next = packet; 1014 / / check all packets1014 /* Check all packets */ 1015 1015 while (next) { 1016 1016 length = packet_get_data_length(next); … … 1021 1021 } 1022 1022 1023 / / too long1023 /* Too long */ 1024 1024 result = ip_fragment_packet(next, content, prefix, 1025 1025 suffix, addr_len); … … 1027 1027 new_packet = pq_detach(next); 1028 1028 if (next == packet) { 1029 / / the new first packet of the queue1029 /* The new first packet of the queue */ 1030 1030 packet = new_packet; 1031 1031 } 1032 / / fragmentation needed?1032 /* Fragmentation needed? */ 1033 1033 if (result == EPERM) { 1034 1034 phone = ip_prepare_icmp_and_get_phone( 1035 1035 error, next, NULL); 1036 1036 if (phone >= 0) { 1037 / / fragmentation necessary ICMP1037 /* Fragmentation necessary ICMP */ 1038 1038 icmp_destination_unreachable_msg(phone, 1039 1039 ICMP_FRAG_NEEDED, content, next); … … 1080 1080 int rc; 1081 1081 1082 / / get destination hardware address1082 /* Get destination hardware address */ 1083 1083 if (netif->arp && (route->address.s_addr != dest.s_addr)) { 1084 1084 destination.value = route->gateway.s_addr ? … … 1102 1102 NULL); 1103 1103 if (phone >= 0) { 1104 / / unreachable ICMP if no routing1104 /* Unreachable ICMP if no routing */ 1105 1105 icmp_destination_unreachable_msg(phone, 1106 1106 ICMP_HOST_UNREACH, 0, packet); … … 1148 1148 int rc; 1149 1149 1150 // addresses in the host byte order 1151 // should be the next hop address or the target destination address 1150 /* 1151 * Addresses in the host byte order 1152 * Should be the next hop address or the target destination address 1153 */ 1152 1154 addrlen = packet_get_addr(packet, NULL, (uint8_t **) &addr); 1153 1155 if (addrlen < 0) … … 1174 1176 fibril_rwlock_read_lock(&ip_globals.netifs_lock); 1175 1177 1176 / / device specified?1178 /* Device specified? */ 1177 1179 if (device_id > 0) { 1178 1180 netif = ip_netifs_find(&ip_globals.netifs, device_id); … … 1190 1192 phone = ip_prepare_icmp_and_get_phone(error, packet, NULL); 1191 1193 if (phone >= 0) { 1192 / / unreachable ICMP if no routing1194 /* Unreachable ICMP if no routing */ 1193 1195 icmp_destination_unreachable_msg(phone, 1194 1196 ICMP_NET_UNREACH, 0, packet); … … 1198 1200 1199 1201 if (error) { 1200 // do not send for broadcast, anycast packets or network 1201 // broadcast 1202 /* 1203 * Do not send for broadcast, anycast packets or network 1204 * broadcast. 1205 */ 1202 1206 if (!dest->s_addr || !(~dest->s_addr) || 1203 1207 !(~((dest->s_addr & ~route->netmask.s_addr) | … … 1208 1212 } 1209 1213 1210 / / if the local host is the destination1214 /* Ff the local host is the destination */ 1211 1215 if ((route->address.s_addr == dest->s_addr) && 1212 1216 (dest->s_addr != IPV4_LOCALHOST_ADDRESS)) { 1213 / / find the loopback device to deliver1217 /* Find the loopback device to deliver */ 1214 1218 dest->s_addr = IPV4_LOCALHOST_ADDRESS; 1215 1219 route = ip_find_route(*dest); … … 1220 1224 NULL); 1221 1225 if (phone >= 0) { 1222 / / unreachable ICMP if no routing1226 /* Unreachable ICMP if no routing */ 1223 1227 icmp_destination_unreachable_msg(phone, 1224 1228 ICMP_HOST_UNREACH, 0, packet); … … 1252 1256 1253 1257 fibril_rwlock_write_lock(&ip_globals.netifs_lock); 1254 / / find the device1258 /* Find the device */ 1255 1259 netif = ip_netifs_find(&ip_globals.netifs, device_id); 1256 1260 if (!netif) { … … 1275 1279 in_addr_t destination; 1276 1280 1277 / / TODO search set ipopt route?1281 /* TODO search set ipopt route? */ 1278 1282 destination.s_addr = header->destination_address; 1279 1283 return destination; … … 1317 1321 if ((header->flags & IPFLAG_MORE_FRAGMENTS) || 1318 1322 IP_FRAGMENT_OFFSET(header)) { 1319 / / TODO fragmented1323 /* TODO fragmented */ 1320 1324 return ENOTSUP; 1321 1325 } … … 1344 1348 return ip_release_and_return(packet, rc); 1345 1349 1346 / / trim padding if present1350 /* Trim padding if present */ 1347 1351 if (!error && 1348 1352 (IP_TOTAL_LENGTH(header) < packet_get_data_length(packet))) { … … 1360 1364 phone = ip_prepare_icmp_and_get_phone(error, packet, header); 1361 1365 if (phone >= 0) { 1362 / / unreachable ICMP1366 /* Unreachable ICMP */ 1363 1367 icmp_destination_unreachable_msg(phone, 1364 1368 ICMP_PROT_UNREACH, 0, packet); … … 1417 1421 return ip_release_and_return(packet, ENOMEM); 1418 1422 1419 / / checksum1423 /* Checksum */ 1420 1424 if ((header->header_checksum) && 1421 1425 (IP_HEADER_CHECKSUM(header) != IP_CHECKSUM_ZERO)) { 1422 1426 phone = ip_prepare_icmp_and_get_phone(0, packet, header); 1423 1427 if (phone >= 0) { 1424 / / checksum error ICMP1428 /* Checksum error ICMP */ 1425 1429 icmp_parameter_problem_msg(phone, ICMP_PARAM_POINTER, 1426 1430 ((size_t) ((void *) &header->header_checksum)) - … … 1433 1437 phone = ip_prepare_icmp_and_get_phone(0, packet, header); 1434 1438 if (phone >= 0) { 1435 / / ttl exceeded ICMP1439 /* ttl exceeded ICMP */ 1436 1440 icmp_time_exceeded_msg(phone, ICMP_EXC_TTL, packet); 1437 1441 } … … 1439 1443 } 1440 1444 1441 / / process ipopt and get destination1445 /* Process ipopt and get destination */ 1442 1446 dest = ip_get_destination(header); 1443 1447 1444 / / set the addrination address1448 /* Set the destination address */ 1445 1449 switch (header->version) { 1446 1450 case IPVERSION: … … 1464 1468 phone = ip_prepare_icmp_and_get_phone(0, packet, header); 1465 1469 if (phone >= 0) { 1466 / / unreachable ICMP1470 /* Unreachable ICMP */ 1467 1471 icmp_destination_unreachable_msg(phone, 1468 1472 ICMP_HOST_UNREACH, 0, packet); … … 1472 1476 1473 1477 if (route->address.s_addr == dest.s_addr) { 1474 / / local delivery1478 /* Local delivery */ 1475 1479 return ip_deliver_local(device_id, packet, header, 0); 1476 1480 } … … 1484 1488 phone = ip_prepare_icmp_and_get_phone(0, packet, header); 1485 1489 if (phone >= 0) { 1486 / / unreachable ICMP if no routing1490 /* Unreachable ICMP if no routing */ 1487 1491 icmp_destination_unreachable_msg(phone, ICMP_HOST_UNREACH, 0, 1488 1492 packet); … … 1770 1774 header = (ip_header_t *)(data + offset); 1771 1775 1772 / / destination host unreachable?1776 /* Destination host unreachable? */ 1773 1777 if ((type != ICMP_DEST_UNREACH) || 1774 1778 (code != ICMP_HOST_UNREACH)) { 1775 / / no, something else1779 /* No, something else */ 1776 1780 break; 1777 1781 } … … 1787 1791 route = ip_routes_get_index(&netif->routes, 0); 1788 1792 1789 / / from the same network?1793 /* From the same network? */ 1790 1794 if (route && ((route->address.s_addr & route->netmask.s_addr) == 1791 1795 (header->destination_address & route->netmask.s_addr))) { 1792 / / clear the ARP mapping if any1796 /* Clear the ARP mapping if any */ 1793 1797 address.value = (uint8_t *) &header->destination_address; 1794 1798 address.length = sizeof(header->destination_address); … … 1844 1848 fibril_rwlock_read_lock(&ip_globals.lock); 1845 1849 route = ip_find_route(*dest); 1846 / / if the local host is the destination1850 /* If the local host is the destination */ 1847 1851 if (route && (route->address.s_addr == dest->s_addr) && 1848 1852 (dest->s_addr != IPV4_LOCALHOST_ADDRESS)) { 1849 / / find the loopback device to deliver1853 /* Find the loopback device to deliver */ 1850 1854 dest->s_addr = IPV4_LOCALHOST_ADDRESS; 1851 1855 route = ip_find_route(*dest); -
uspace/srv/net/nil/eth/eth.c
rea53529 r28a3e74 531 531 proto->service); 532 532 } else { 533 / / drop invalid/unknown533 /* Drop invalid/unknown */ 534 534 pq_release_remote(eth_globals.net_phone, 535 535 packet_get_id(packet)); -
uspace/srv/net/tl/tcp/tcp.c
rea53529 r28a3e74 299 299 return tcp_release_and_return(packet, NO_DATA); 300 300 301 // printf("header len %d, port %d \n", TCP_HEADER_LENGTH(header), 302 // ntohs(header->destination_port)); 303 301 #if 0 302 printf("header len %d, port %d \n", TCP_HEADER_LENGTH(header), 303 ntohs(header->destination_port)); 304 #endif 304 305 result = packet_get_addr(packet, (uint8_t **) &src, (uint8_t **) &dest); 305 306 if (result <= 0) … … 1062 1063 tcp_process_acknowledgement(socket, socket_data, header); 1063 1064 1064 socket_data->next_incoming = ntohl(header->sequence_number); // + 1;1065 socket_data->next_incoming = ntohl(header->sequence_number); /* + 1; */ 1065 1066 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1066 1067 socket_data->state = TCP_SOCKET_ESTABLISHED; -
uspace/srv/net/tl/tcp/tcp.h
rea53529 r28a3e74 190 190 int backlog; 191 191 192 // /** Segment size. */193 // size_t segment_size;194 195 192 /** 196 193 * Parent listening socket identifier. -
uspace/srv/vfs/vfs_ops.c
rea53529 r28a3e74 611 611 void vfs_open_node(ipc_callid_t rid, ipc_call_t *request) 612 612 { 613 / / FIXME: check for sanity of the supplied fs, dev and index613 /* FIXME: check for sanity of the supplied fs, dev and index */ 614 614 615 615 /*
Note:
See TracChangeset
for help on using the changeset viewer.