Changeset 4639
- Timestamp:
- 11/12/08 16:09:24 (2 months ago)
- Files:
-
- trunk (modified) (1 prop)
- trunk/packages (modified) (1 prop)
- trunk/src/charon/config/traffic_selector.c (modified) (4 diffs)
- trunk/src/charon/config/traffic_selector.h (modified) (3 diffs)
- trunk/src/charon/encoding/payloads/traffic_selector_substructure.c (modified) (1 diff)
- trunk/src/charon/kernel/kernel_interface.c (modified) (1 prop)
- trunk/src/charon/plugins/kernel_klips (modified) (1 prop)
- trunk/src/charon/plugins/kernel_netlink (modified) (1 prop)
- trunk/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c (modified) (1 prop)
- trunk/src/charon/plugins/load_tester (modified) (1 prop)
- trunk/src/charon/plugins/sql/pool.c (modified) (3 diffs)
- trunk/src/charon/plugins/sql/sql_attribute.c (modified) (3 diffs)
- trunk/src/charon/sa/child_sa.c (modified) (12 diffs)
- trunk/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c (modified) (2 diffs)
- trunk/src/libstrongswan/utils/host.c (modified) (1 diff)
- trunk/src/libstrongswan/utils/host.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk
- Property svn:mergeinfo changed from
/branches/bus-refactor:4403-4432
/branches/kernel-interface:4343-4429
/branches/kernel-klips:4433-4617
/branches/two-sim:4101-4405 to
/branches/bus-refactor:4403-4432
/branches/ha:4456-4457,4459-4460,4478,4533,4627,4638
/branches/kernel-interface:4343-4429
/branches/kernel-klips:4433-4617
/branches/two-sim:4101-4405
- Property svn:mergeinfo changed from
trunk/packages
- Property svn:mergeinfo changed from
/branches/bus-refactor/build:4403-4432
/branches/kernel-interface/build:4343-4429
/branches/kernel-klips/packages:4433-4617
/branches/two-sim/build:4101-4405 to
/branches/bus-refactor/build:4403-4432
/branches/ha/packages:4456-4457,4459-4460,4478,4533,4627,4638
/branches/kernel-interface/build:4343-4429
/branches/kernel-klips/packages:4433-4617
/branches/two-sim/build:4101-4405
- Property svn:mergeinfo changed from
trunk/src/charon/config/traffic_selector.c
r4484 r4639 407 407 static chunk_t get_from_address(private_traffic_selector_t *this) 408 408 { 409 chunk_t from = chunk_empty;410 411 409 switch (this->type) 412 410 { 413 411 case TS_IPV4_ADDR_RANGE: 414 { 415 from.len = sizeof(this->from4); 416 from.ptr = malloc(from.len); 417 memcpy(from.ptr, this->from4, from.len); 418 break; 419 } 412 return chunk_create(this->from, sizeof(this->from4)); 420 413 case TS_IPV6_ADDR_RANGE: 421 { 422 from.len = sizeof(this->from6); 423 from.ptr = malloc(from.len); 424 memcpy(from.ptr, this->from6, from.len); 425 break; 426 } 427 } 428 return from; 414 return chunk_create(this->from, sizeof(this->from6)); 415 default: 416 return chunk_empty; 417 } 429 418 } 430 419 … … 434 423 static chunk_t get_to_address(private_traffic_selector_t *this) 435 424 { 436 chunk_t to = chunk_empty;437 438 425 switch (this->type) 439 426 { 440 427 case TS_IPV4_ADDR_RANGE: 441 { 442 to.len = sizeof(this->to4); 443 to.ptr = malloc(to.len); 444 memcpy(to.ptr, this->to4, to.len); 445 break; 446 } 428 return chunk_create(this->to, sizeof(this->to4)); 447 429 case TS_IPV6_ADDR_RANGE: 448 { 449 to.len = sizeof(this->to6); 450 to.ptr = malloc(to.len); 451 memcpy(to.ptr, this->to6, to.len); 452 break; 453 } 454 } 455 return to; 430 return chunk_create(this->to, sizeof(this->to6)); 431 default: 432 return chunk_empty; 433 } 456 434 } 457 435 … … 524 502 } 525 503 return FALSE; 504 } 505 506 /** 507 * Implementation of traffic_selector_t.is_dynamic 508 */ 509 static bool is_dynamic(private_traffic_selector_t *this) 510 { 511 return this->dynamic; 526 512 } 527 513 … … 870 856 this->public.get_protocol = (u_int8_t(*)(traffic_selector_t*))get_protocol; 871 857 this->public.is_host = (bool(*)(traffic_selector_t*,host_t*))is_host; 858 this->public.is_dynamic = (bool(*)(traffic_selector_t*))is_dynamic; 872 859 this->public.is_contained_in = (bool(*)(traffic_selector_t*,traffic_selector_t*))is_contained_in; 873 860 this->public.includes = (bool(*)(traffic_selector_t*,host_t*))includes; trunk/src/charon/config/traffic_selector.h
r4547 r4639 93 93 * Get starting address of this ts as a chunk. 94 94 * 95 * Chunk is in network order gets allocated.95 * Chunk is in network and points to internal data. 96 96 * 97 97 * @return chunk containing the address … … 102 102 * Get ending address of this ts as a chunk. 103 103 * 104 * Chunk is in network order gets allocated.104 * Chunk is in network and points to internal data. 105 105 * 106 106 * @return chunk containing the address … … 154 154 */ 155 155 bool (*is_host) (traffic_selector_t *this, host_t* host); 156 157 /** 158 * Check if a traffic selector has been created by create_dynamic(). 159 * 160 * @return TRUE if TS is dynamic 161 */ 162 bool (*is_dynamic)(traffic_selector_t *this); 156 163 157 164 /** trunk/src/charon/encoding/payloads/traffic_selector_substructure.c
r3589 r4639 270 270 this->start_port = traffic_selector->get_from_port(traffic_selector); 271 271 this->end_port = traffic_selector->get_to_port(traffic_selector); 272 this->starting_address = traffic_selector->get_from_address(traffic_selector);273 this->ending_address = traffic_selector->get_to_address(traffic_selector);272 this->starting_address = chunk_clone(traffic_selector->get_from_address(traffic_selector)); 273 this->ending_address = chunk_clone(traffic_selector->get_to_address(traffic_selector)); 274 274 275 275 compute_length(this); trunk/src/charon/kernel/kernel_interface.c
- Property svn:mergeinfo changed from
/branches/bus-refactor/src/charon/kernel/kernel_interface.c:4403-4432
/branches/kernel-interface/src/charon/kernel/kernel_interface.c:4343-4429
/branches/kernel-klips/src/charon/kernel/kernel_interface.c:4433-4617
/branches/two-sim/src/charon/kernel/kernel_interface.c:4101-4405
/trunk/src/charon/kernel/kernel_interface.c:2-2640 to
/branches/bus-refactor/src/charon/kernel/kernel_interface.c:4403-4432
/branches/ha/src/charon/kernel/kernel_interface.c:4456-4457,4459-4460,4478,4533,4627,4638
/branches/kernel-interface/src/charon/kernel/kernel_interface.c:4343-4429
/branches/kernel-klips/src/charon/kernel/kernel_interface.c:4433-4617
/branches/two-sim/src/charon/kernel/kernel_interface.c:4101-4405
/trunk/src/charon/kernel/kernel_interface.c:2-2640
- Property svn:mergeinfo changed from
trunk/src/charon/plugins/kernel_klips
- Property svn:mergeinfo set to /branches/ha/src/charon/plugins/kernel_klips:4638
trunk/src/charon/plugins/kernel_netlink
- Property svn:mergeinfo changed from
/branches/bus-refactor/src/charon/plugins/kernel_netlink:4403-4432
/branches/kernel-interface/src/charon/plugins/kernel_netlink:4343-4429
/branches/kernel-klips/src/charon/plugins/kernel_netlink:4433-4617 to
/branches/bus-refactor/src/charon/plugins/kernel_netlink:4403-4432
/branches/ha/src/charon/plugins/kernel_netlink:4456-4457,4459-4460,4478,4533,4627,4638
/branches/kernel-interface/src/charon/plugins/kernel_netlink:4343-4429
/branches/kernel-klips/src/charon/plugins/kernel_netlink:4433-4617
- Property svn:mergeinfo changed from
trunk/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c
- Property svn:mergeinfo changed from
/branches/bus-refactor/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4403-4432
/branches/kernel-interface/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4343-4429
/branches/kernel-klips/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4433-4617
/branches/two-sim/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4101-4405
/trunk/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:2-4100 to
/branches/bus-refactor/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4403-4432
/branches/ha/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4456-4457,4459-4460,4478,4533,4627,4638
/branches/kernel-interface/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4343-4429
/branches/kernel-klips/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4433-4617
/branches/two-sim/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:4101-4405
/trunk/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c:2-4100
- Property svn:mergeinfo changed from
trunk/src/charon/plugins/load_tester
- Property svn:mergeinfo set to /branches/ha/src/charon/plugins/load_tester:4533,4627,4638
trunk/src/charon/plugins/sql/pool.c
r4212 r4639 35 35 */ 36 36 host_t *start = NULL, *end = NULL; 37 38 /**39 * create a host from a blob40 */41 static host_t *host_create_from_blob(chunk_t blob)42 {43 return host_create_from_chunk(blob.len == 4 ? AF_INET : AF_INET6, blob, 0);44 }45 37 46 38 /** … … 133 125 } 134 126 135 start = host_create_from_ blob(start_chunk);136 end = host_create_from_ blob(end_chunk);127 start = host_create_from_chunk(AF_UNSPEC, start_chunk, 0); 128 end = host_create_from_chunk(AF_UNSPEC, end_chunk, 0); 137 129 size = get_pool_size(start_chunk, end_chunk); 138 130 printf("%8s %15H %15H ", name, start, end); … … 542 534 "name", "address", "status", len, "start", len, "end", "identity"); 543 535 } 544 address = host_create_from_ blob(address_chunk);536 address = host_create_from_chunk(AF_UNSPEC, address_chunk, 0); 545 537 identity = identification_create_from_encoding(identity_type, identity_chunk); 546 538 trunk/src/charon/plugins/sql/sql_attribute.c
r4632 r4639 46 46 47 47 /** 48 * read a host_t address from the addresses table49 */50 static host_t *host_from_chunk(chunk_t chunk)51 {52 switch (chunk.len)53 {54 case 4:55 return host_create_from_chunk(AF_INET, chunk, 0);56 case 16:57 return host_create_from_chunk(AF_INET6, chunk, 0);58 default:59 return NULL;60 }61 }62 63 /**64 48 * lookup/insert an identity 65 49 */ … … 146 130 DB_UINT, now, DB_UINT, id, DB_UINT, identity) > 0) 147 131 { 148 host = host_ from_chunk(address);132 host = host_create_from_chunk(AF_UNSPEC, address, 0); 149 133 if (host) 150 134 { … … 178 162 DB_UINT, id, DB_UINT, now - timeout) > 0) 179 163 { 180 host = host_ from_chunk(address);164 host = host_create_from_chunk(AF_UNSPEC, address, 0); 181 165 if (host) 182 166 { trunk/src/charon/sa/child_sa.c
r4618 r4639 498 498 soft = this->config->get_lifetime(this->config, TRUE); 499 499 hard = this->config->get_lifetime(this->config, FALSE); 500 500 501 status = charon->kernel_interface->add_sa(charon->kernel_interface, 501 502 src, dst, spi, this->protocol, this->reqid, … … 618 619 this->my_spi, this->protocol, this->reqid, mode, this->ipcomp, 619 620 this->my_cpi, routed); 620 621 621 if (mode == MODE_TUNNEL) 622 622 { … … 626 626 this->my_cpi, routed); 627 627 } 628 628 629 629 if (status != SUCCESS) 630 630 { … … 634 634 enumerator->destroy(enumerator); 635 635 } 636 636 637 637 if (status == SUCCESS) 638 638 { … … 682 682 return NOT_SUPPORTED; 683 683 } 684 685 684 /* update his (responder) SA */ 686 685 if (charon->kernel_interface->update_sa(charon->kernel_interface, this->other_spi, … … 700 699 enumerator_t *enumerator; 701 700 traffic_selector_t *my_ts, *other_ts; 702 701 703 702 /* always use high priorities, as hosts getting updated are INSTALLED */ 704 703 enumerator = create_policy_enumerator(this); … … 715 714 other_ts, my_ts, POLICY_FWD, FALSE); 716 715 } 717 716 718 717 /* check whether we have to update a "dynamic" traffic selector */ 719 718 if (!me->ip_equals(me, this->my_addr) && … … 727 726 other_ts->set_address(other_ts, other); 728 727 } 729 728 730 729 /* we reinstall the virtual IP to handle interface roaming 731 730 * correctly */ … … 735 734 charon->kernel_interface->add_ip(charon->kernel_interface, vip, me); 736 735 } 737 736 738 737 /* reinstall updated policies */ 739 738 charon->kernel_interface->add_policy(charon->kernel_interface, … … 756 755 } 757 756 } 758 757 759 758 /* apply hosts */ 760 759 if (!this->config->use_proxy_mode(this->config) || this->mode != MODE_TRANSPORT) … … 855 854 enumerator->destroy(enumerator); 856 855 } 857 856 858 857 this->my_ts->destroy_offset(this->my_ts, offsetof(traffic_selector_t, destroy)); 859 858 this->other_ts->destroy_offset(this->other_ts, offsetof(traffic_selector_t, destroy)); … … 982 981 return &this->public; 983 982 } 984 trunk/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
r4566 r4639 43 43 */ 44 44 long opt_exponent_len; 45 45 46 46 /* 47 47 * Generator value. … … 89 89 */ 90 90 BIGNUM *pub_key; 91 91 92 92 /** 93 93 * Shared secret trunk/src/libstrongswan/utils/host.c
r4607 r4639 505 505 host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port) 506 506 { 507 private_host_t *this = host_create_empty(); 508 507 private_host_t *this; 508 509 switch (family) 510 { 511 case AF_INET: 512 if (address.len < IPV4_LEN) 513 { 514 return NULL; 515 } 516 address.len = IPV4_LEN; 517 break; 518 case AF_INET6: 519 if (address.len < IPV6_LEN) 520 { 521 return NULL; 522 } 523 address.len = IPV6_LEN; 524 break; 525 case AF_UNSPEC: 526 switch (address.len) 527 { 528 case IPV4_LEN: 529 family = AF_INET; 530 break; 531 case IPV6_LEN: 532 family = AF_INET6; 533 break; 534 default: 535 return NULL; 536 } 537 break; 538 default: 539 return NULL; 540 } 541 this = host_create_empty(); 509 542 this->address.sa_family = family; 510 543 switch (family) 511 544 { 512 545 case AF_INET: 513 { 514 if (address.len != IPV4_LEN) 515 { 516 break; 517 } 518 memcpy(&(this->address4.sin_addr.s_addr), address.ptr, IPV4_LEN); 546 memcpy(&this->address4.sin_addr.s_addr, address.ptr, address.len); 519 547 this->address4.sin_port = htons(port); 520 548 this->socklen = sizeof(struct sockaddr_in); 521 return &(this->public); 522 } 523 case AF_INET6: 524 { 525 if (address.len != IPV6_LEN) 526 { 527 break; 528 } 529 memcpy(&(this->address6.sin6_addr.s6_addr), address.ptr, IPV6_LEN); 549 break; 550 case AF_INET6: 551 memcpy(&this->address6.sin6_addr.s6_addr, address.ptr, address.len); 530 552 this->address6.sin6_port = htons(port); 531 553 this->socklen = sizeof(struct sockaddr_in6); 532 return &this->public; 533 } 534 default: 535 break; 536 } 537 free(this); 538 return NULL; 554 break; 555 } 556 return &this->public; 539 557 } 540 558 trunk/src/libstrongswan/utils/host.h
r4618 r4639 171 171 172 172 /** 173 * Constructor to create a host_t object from an address chunk 173 * Constructor to create a host_t object from an address chunk. 174 * 175 * If family is AF_UNSPEC, it is guessed using address.len. 174 176 * 175 177 * @param family Address family, such as AF_INET or AF_INET6
