Print this page
Current snapshot of OpenSolaris port.
Checkpoint
Checkpoint
Merge from parent.
Merge with WIDE update.
Pull from WIDE.
Pull from WIDE.
Checkpoint
Re-update.
blah
WIDE update
Update from WIDE.

Split Close
Expand all
Collapse all
          --- old/iked/ikev1/isakmp_quick.c
          +++ new/iked/ikev1/isakmp_quick.c
↓ open down ↓ 55 lines elided ↑ open up ↑
  56   56  #  include <time.h>
  57   57  # endif
  58   58  #endif
  59   59  
  60   60  #ifdef HAVE_NETINET6_IPSEC_H
  61   61  # include <netinet6/ipsec.h>
  62   62  #else
  63   63  # ifdef HAVE_NETIPSEC_IPSEC_H
  64   64  #  include <netipsec/ipsec.h>
  65   65  # else
  66      -#  include <linux/ipsec.h>
       66 +#  ifndef sun   /* XXX KEBE SAYS OpenSolaris */
       67 +#    include <linux/ipsec.h>
       68 +#  endif
  67   69  # endif
  68   70  #endif
  69   71  
       72 +#ifdef sun      /* XXX KEBE SAYS OpenSolaris */
       73 +#define IPSEC_ULPROTO_ANY 0
       74 +#endif
       75 +
  70   76  #include "racoon.h"
  71   77  
  72   78  #include "var.h"
  73   79  /* #include "vmbuf.h" */
  74   80  /* #include "schedule.h" */
  75   81  /* #include "misc.h" */
  76   82  #include "plog.h"
  77   83  #include "debug.h"
  78   84  
  79   85  /* #include "localconf.h" */
↓ open down ↓ 10 lines elided ↑ open up ↑
  90   96  #include "crypto_impl.h"
  91   97  #include "pfkey.h"
  92   98  /* #include "policy.h" */
  93   99  #include "algorithm.h"
  94  100  #include "sockmisc.h"
  95  101  #include "proposal.h"
  96  102  /* #include "sainfo.h" */
  97  103  /* #include "admin.h" */
  98  104  #include "strnames.h"
  99  105  
      106 +#ifdef sun
      107 +#include "ikev1_natt.h"
      108 +#define IPSECDOI_PREFIX_HOST 32 /* Hack for port of NAT-OA from ipsec-tools. */
      109 +#endif
      110 +
 100  111  #include "ike_conf.h"
 101  112  
 102  113  /* quick mode */
 103  114  static rc_vchar_t *quick_ir1mx (struct ph2handle *, rc_vchar_t *, rc_vchar_t *);
 104  115  static int get_sainfo_r (struct ph2handle *);
 105  116  static int get_proposal_r (struct ph2handle *);
 106  117  #ifdef INET6
 107  118  static uint32_t setscopeid (struct sockaddr *, struct sockaddr *)
 108  119          GCC_ATTRIBUTE((unused));
 109  120  #endif
↓ open down ↓ 70 lines elided ↑ open up ↑
 180  191                  pfkey_timeover_stub, iph2);
 181  192  
 182  193          error = 0;
 183  194  
 184  195  end:
 185  196          return error;
 186  197  }
 187  198  
 188  199  /*
 189  200   * send to responder
 190      - *      HDR*, HASH(1), SA, Ni [, KE ] [, IDi2, IDr2 ]
      201 + *      HDR*, HASH(1), SA, Ni [, KE ] [, IDi2, IDr2 ] [, NAT-OAi, NAT-OAr ]
 191  202   */
 192  203  int
 193  204  quick_i1send(struct ph2handle *iph2, rc_vchar_t *msg /* must be null pointer */)
 194  205  {
 195  206          rc_vchar_t *body = NULL;
 196  207          rc_vchar_t *hash = NULL;
 197  208          struct isakmp_gen *gen;
 198  209          char *p;
 199  210          int tlen;
 200  211          int error = ISAKMP_INTERNAL_ERROR;
 201  212          int pfsgroup, idci, idcr;
 202  213          int np;
 203  214          struct ipsecdoi_id_b *id, *id_p;
      215 +#ifdef sun
      216 +        int natoa = ISAKMP_NPTYPE_NONE;
      217 +        rc_vchar_t *nat_oai = NULL;
      218 +        rc_vchar_t *nat_oar = NULL;
      219 +#endif
 204  220  
 205  221          /* validity check */
 206  222          if (msg != NULL) {
 207  223                  plog(PLOG_INTERR, PLOGLOC, NULL,
 208  224                          "msg has to be NULL in this function.\n");
 209  225                  goto end;
 210  226          }
 211  227          if (iph2->status != PHASE2ST_GETSPIDONE) {
 212  228                  plog(PLOG_INTERR, PLOGLOC, NULL,
 213  229                          "status mismatched %d.\n", iph2->status);
↓ open down ↓ 54 lines elided ↑ open up ↑
 268  284           && id->port == 0
 269  285           && id_p->port == 0
 270  286           && iph2->selector->pl != 0
 271  287           && (iph2->selector->pl->my_sa_ipaddr != 0
 272  288             || iph2->selector->pl->peers_sa_ipaddr != 0)
 273  289           && ipsecdoi_transportmode(iph2->proposal)) {
 274  290                  idci = idcr = 0;
 275  291          } else
 276  292                  idci = idcr = 1;
 277  293  
      294 +#ifdef sun
      295 +        /*
      296 +         * RFC3947 5.2. if we propose UDP-Encapsulated-Transport
      297 +         * we should send NAT-OA
      298 +         *
      299 +         * XXX KEBE ASKS if we should send it for tunnel mode anyway, like
      300 +         * we do with in.iked?
      301 +         */
      302 +        if (ipsecdoi_transportmode(iph2->proposal)
      303 +            && (iph2->ph1->natt_flags & NAT_DETECTED)) {
      304 +                natoa = iph2->ph1->natt_options->payload_nat_oa;
      305 +
      306 +                nat_oai = ipsecdoi_sockaddr2id(iph2->src,
      307 +                    IPSECDOI_PREFIX_HOST, IPSEC_ULPROTO_ANY);
      308 +                nat_oar = ipsecdoi_sockaddr2id(iph2->dst,
      309 +                    IPSECDOI_PREFIX_HOST, IPSEC_ULPROTO_ANY);
      310 +
      311 +                if (nat_oai == NULL || nat_oar == NULL) {
      312 +                        plog(PLOG_INTERR, PLOGLOC, NULL,
      313 +                            "failed to generate NAT-OA payload.\n");
      314 +                        goto end;
      315 +                }
      316 +
      317 +                plog(PLOG_INFO, PLOGLOC, NULL, "Using NAT-OA.\n");
      318 +                plog(PLOG_DEBUG, PLOGLOC, NULL, "NAT-OAi:\n");
      319 +                plogdump(PLOG_DEBUG, PLOGLOC, 0, nat_oai->v, nat_oai->l);
      320 +                plog(PLOG_DEBUG, PLOGLOC, NULL, "NAT-OAr:\n");
      321 +                plogdump(PLOG_DEBUG, PLOGLOC, 0, nat_oar->v, nat_oar->l);
      322 +        } else {
      323 +                plog(PLOG_INFO, PLOGLOC, NULL, "Not using NAT-OA.\n");
      324 +                plog(PLOG_INFO, PLOGLOC, NULL, "transportmode == %d, "
      325 +                    "natt_flags == 0x%x\n",
      326 +                    ipsecdoi_transportmode(iph2->proposal),
      327 +                    iph2->ph1->natt_flags & NAT_DETECTED);
      328 +                natoa = ISAKMP_NPTYPE_NONE;
      329 +        }
      330 +#endif
      331 +
 278  332          /* create SA;NONCE payload, and KE if need, and IDii, IDir. */
 279  333          tlen = + sizeof(*gen) + iph2->sa->l
 280  334                  + sizeof(*gen) + iph2->nonce->l;
 281  335          if (pfsgroup)
 282  336                  tlen += (sizeof(*gen) + iph2->dhpub->l);
 283  337          if (idci)
 284  338                  tlen += sizeof(*gen) + iph2->id->l;
 285  339          if (idcr)
 286  340                  tlen += sizeof(*gen) + iph2->id_p->l;
      341 +#ifdef sun
      342 +        if (natoa != ISAKMP_NPTYPE_NONE)
      343 +                tlen += 2 * sizeof(*gen) + nat_oai->l + nat_oar->l;
      344 +#endif
 287  345  
 288  346          body = rc_vmalloc(tlen);
 289  347          if (body == NULL) {
 290  348                  plog(PLOG_INTERR, PLOGLOC, NULL,
 291  349                          "failed to get buffer to send.\n");
 292  350                  goto end;
 293  351          }
 294  352  
 295  353          p = body->v;
 296  354  
 297  355          /* add SA payload */
 298  356          p = set_isakmp_payload(p, iph2->sa, ISAKMP_NPTYPE_NONCE);
 299  357  
 300  358          /* add NONCE payload */
 301  359          if (pfsgroup)
 302  360                  np = ISAKMP_NPTYPE_KE;
 303  361          else if (idci || idcr)
 304  362                  np = ISAKMP_NPTYPE_ID;
 305  363          else
 306      -                np = ISAKMP_NPTYPE_NONE;
      364 +                np = natoa;
 307  365          p = set_isakmp_payload(p, iph2->nonce, np);
 308  366  
 309  367          /* add KE payload if need. */
 310      -        np = (idci || idcr) ? ISAKMP_NPTYPE_ID : ISAKMP_NPTYPE_NONE;
      368 +        np = (idci || idcr) ? ISAKMP_NPTYPE_ID : natoa;
 311  369          if (pfsgroup)
 312  370                  p = set_isakmp_payload(p, iph2->dhpub, np);
 313  371  
 314  372          /* IDci */
 315      -        np = (idcr) ? ISAKMP_NPTYPE_ID : ISAKMP_NPTYPE_NONE;
      373 +        np = (idcr) ? ISAKMP_NPTYPE_ID : natoa;
 316  374          if (idci)
 317  375                  p = set_isakmp_payload(p, iph2->id, np);
 318  376  
 319  377          /* IDcr */
 320  378          if (idcr)
 321      -                p = set_isakmp_payload(p, iph2->id_p, ISAKMP_NPTYPE_NONE);
      379 +                p = set_isakmp_payload(p, iph2->id_p, natoa);
 322  380  
      381 +#ifdef sun
      382 +        /* NAT-OA */
      383 +        if (natoa != ISAKMP_NPTYPE_NONE) {
      384 +                p = set_isakmp_payload(p, nat_oai, natoa);
      385 +                p = set_isakmp_payload(p, nat_oar, ISAKMP_NPTYPE_NONE);
      386 +        }
      387 +#endif
      388 +
 323  389          /* generate HASH(1) */
 324  390          hash = oakley_compute_hash1(iph2->ph1, iph2->msgid, body);
 325  391          if (hash == NULL)
 326  392                  goto end;
 327  393  
 328  394          /* send isakmp payload */
 329  395          iph2->sendbuf = quick_ir1mx(iph2, body, hash);
 330  396          if (iph2->sendbuf == NULL)
 331  397                  goto end;
 332  398  
↓ open down ↓ 5 lines elided ↑ open up ↑
 338  404          /* change status of isakmp status entry */
 339  405          iph2->status = PHASE2ST_MSG1SENT;
 340  406  
 341  407          error = 0;
 342  408  
 343  409  end:
 344  410          if (body != NULL)
 345  411                  rc_vfree(body);
 346  412          if (hash != NULL)
 347  413                  rc_vfree(hash);
      414 +        if (nat_oai != NULL)
      415 +                rc_vfree(nat_oai);
      416 +        if (nat_oar != NULL)
      417 +                rc_vfree(nat_oar);
 348  418  
 349  419          return error;
 350  420  }
 351  421  
 352  422  /*
 353  423   * receive from responder
 354      - *      HDR*, HASH(2), SA, Nr [, KE ] [, IDi2, IDr2 ]
      424 + *      HDR*, HASH(2), SA, Nr [, KE ] [, IDi2, IDr2 ] [, NAT-OAi, NAT-OAr ]
 355  425   */
 356  426  int
 357  427  quick_i2recv(struct ph2handle *iph2, rc_vchar_t *msg0)
 358  428  {
 359  429          rc_vchar_t *msg = NULL;
 360  430          rc_vchar_t *hbuf = NULL;        /* for hash computing. */
 361  431          rc_vchar_t *pbuf = NULL;        /* for payload parsing */
      432 +        rc_vchar_t *idci = NULL;
      433 +        rc_vchar_t *idcr = NULL;
 362  434          struct isakmp_parse_t *pa;
 363  435          struct isakmp *isakmp = (struct isakmp *)msg0->v;
 364  436          struct isakmp_pl_hash *hash = NULL;
 365      -        int f_id;
 366  437          char *p;
 367  438          int tlen;
 368  439          int error = ISAKMP_INTERNAL_ERROR;
 369  440  
 370  441          /* validity check */
 371  442          if (iph2->status != PHASE2ST_MSG1SENT) {
 372  443                  plog(PLOG_INTERR, PLOGLOC, NULL,
 373  444                          "status mismatched %d.\n", iph2->status);
 374  445                  goto end;
 375  446          }
↓ open down ↓ 56 lines elided ↑ open up ↑
 432  503                          "failed to get hash buffer.\n");
 433  504                  goto end;
 434  505          }
 435  506          p = hbuf->v + iph2->nonce->l;   /* retain the space for Ni_b */
 436  507  
 437  508          /*
 438  509           * parse the payloads.
 439  510           * copy non-HASH payloads into hbuf, so that we can validate HASH.
 440  511           */
 441  512          iph2->sa_ret = NULL;
 442      -        f_id = 0;       /* flag to use checking ID */
 443  513          tlen = 0;       /* count payload length except of HASH payload. */
 444  514          for (; pa->type; pa++) {
 445  515  
 446  516                  /* copy to buffer for HASH */
 447  517                  /* Don't modify the payload */
 448  518                  memcpy(p, pa->ptr, pa->len);
 449  519  
 450  520                  switch (pa->type) {
 451  521                  case ISAKMP_NPTYPE_SA:
 452  522                          if (iph2->sa_ret != NULL) {
↓ open down ↓ 10 lines elided ↑ open up ↑
 463  533                          if (isakmp_p2ph(&iph2->nonce_p, pa->ptr) < 0)
 464  534                                  goto end;
 465  535                          break;
 466  536  
 467  537                  case ISAKMP_NPTYPE_KE:
 468  538                          if (isakmp_p2ph(&iph2->dhpub_p, pa->ptr) < 0)
 469  539                                  goto end;
 470  540                          break;
 471  541  
 472  542                  case ISAKMP_NPTYPE_ID:
 473      -                    {
 474      -                        rc_vchar_t *vp;
 475      -
 476      -                        /* check ID value */
 477      -                        if (f_id == 0) {
 478      -                                /* for IDci */
 479      -                                f_id = 1;
 480      -                                vp = iph2->id;
      543 +                        if (idci == NULL) {
      544 +                                if (isakmp_p2ph(&idci, pa->ptr) < 0)
      545 +                                        goto end;
      546 +                        } else if (idcr == NULL) {
      547 +                                if (isakmp_p2ph(&idcr, pa->ptr) < 0)
      548 +                                        goto end;
 481  549                          } else {
 482      -                                /* for IDcr */
 483      -                                vp = iph2->id_p;
 484  550                          }
 485      -
 486      -                        if (memcmp(vp->v, (caddr_t)pa->ptr + sizeof(struct isakmp_gen), vp->l)) {
 487      -
 488      -                                plog(PLOG_PROTOERR, PLOGLOC, NULL,
 489      -                                        "mismatched ID was returned.\n");
 490      -                                error = ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED;
 491      -                                goto end;
 492      -                        }
 493      -                    }
 494  551                          break;
 495  552  
 496  553                  case ISAKMP_NPTYPE_N:
 497  554                          isakmp_check_notify(pa->ptr, iph2->ph1);
 498  555                          break;
 499  556  
 500  557  #ifdef ENABLE_NATT
 501  558                  case ISAKMP_NPTYPE_NATOA_DRAFT:
 502  559                  case ISAKMP_NPTYPE_NATOA_RFC:
      560 +#ifdef sun
      561 +                        /* DON'T ignore original source/destination. */
      562 +                {
      563 +                        struct sockaddr_storage addr;
      564 +                        struct sockaddr *daddr;
      565 +                        uint8_t prefix;
      566 +                        uint16_t ul_proto;
      567 +                        rc_vchar_t *vp = NULL;
      568 +
      569 +                        if (isakmp_p2ph(&vp, pa->ptr) < 0)
      570 +                                goto end;
      571 +
      572 +                        error = ipsecdoi_id2sockaddr(vp,
      573 +                            (struct sockaddr *) &addr,
      574 +                            &prefix, &ul_proto);
      575 +
      576 +                        rc_vfree(vp);
      577 +
      578 +                        if (error)
      579 +                                goto end;
      580 +
      581 +                        daddr = rcs_sadup((struct sockaddr *) &addr);
      582 +                        if (daddr == NULL)
      583 +                                goto end;
      584 +
      585 +                        if (iph2->natoa_src == NULL)
      586 +                                iph2->natoa_src = daddr;
      587 +                        else if (iph2->natoa_dst == NULL)
      588 +                                iph2->natoa_dst = daddr;
      589 +                        else {
      590 +                                racoon_free(daddr);
      591 +                                goto end;
      592 +                        }
      593 +                }
      594 +#else
 503  595                          /* Ignore original source/destination messages */
      596 +#endif
 504  597                          break;
 505  598  #endif
 506  599  
 507  600                  default:
 508  601                          /* don't send information, see ident_r1recv() */
 509  602                          isakmp_log(0, 0, iph2->ph1->remote, 0,
 510  603                                     PLOG_PROTOERR, PLOGLOC,
 511  604                                     "ignore the packet, "
 512  605                                     "received unexpecting payload type %d.\n",
 513  606                                     pa->type);
↓ open down ↓ 7 lines elided ↑ open up ↑
 521  614          }
 522  615  
 523  616          /* payload existency check */
 524  617          if (hash == NULL || iph2->sa_ret == NULL || iph2->nonce_p == NULL) {
 525  618                  isakmp_log(0, 0, iph2->ph1->remote, 0,
 526  619                             PLOG_PROTOERR, PLOGLOC,
 527  620                             "few isakmp message received.\n");
 528  621                  goto end;
 529  622          }
 530  623  
      624 +       /* identity check */
      625 +       if (idci != NULL) {
      626 +               struct sockaddr_storage proposed_addr, got_addr;
      627 +               uint8_t proposed_prefix, got_prefix;
      628 +               uint16_t proposed_ulproto, got_ulproto;
      629 +
      630 +               error = ipsecdoi_id2sockaddr(iph2->id,
      631 +                                       (struct sockaddr *) &proposed_addr,
      632 +                                       &proposed_prefix, &proposed_ulproto);
      633 +               if (error)
      634 +                       goto end;
      635 +               
      636 +               error = ipsecdoi_id2sockaddr(idci,
      637 +                                       (struct sockaddr *) &got_addr,
      638 +                                       &got_prefix, &got_ulproto);
      639 +               if (error)
      640 +                       goto end;
      641 +
      642 +               if (proposed_prefix != got_prefix
      643 +                || proposed_ulproto != got_ulproto) {
      644 +                       plog(PLOG_DEBUG, PLOGLOC, NULL,
      645 +                               "IDci prefix/ulproto does not match proposal.\n");
      646 +                       error = ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED;
      647 +                       goto end;
      648 +               }
      649 +
      650 +               if (rcs_cmpsa((struct sockaddr *) &proposed_addr,
      651 +                                  (struct sockaddr *) &got_addr) == 0) {
      652 +                       plog(PLOG_DEBUG, PLOGLOC, NULL,
      653 +                               "IDci matches proposal.\n");
      654 +#ifdef ENABLE_NATT
      655 +               } else if (iph2->natoa_src != NULL
      656 +                       && rcs_cmpsa_wop(iph2->natoa_src,
      657 +                                      (struct sockaddr *) &got_addr) == 0
      658 +                       && extract_port((struct sockaddr *) &proposed_addr) ==
      659 +                          extract_port((struct sockaddr *) &got_addr)) {
      660 +                       plog(PLOG_DEBUG, PLOGLOC, NULL,
      661 +                               "IDci matches NAT-OAi.\n");
      662 +#endif
      663 +               } else {
      664 +                       plog(PLOG_INTERR, PLOGLOC, NULL,
      665 +                               "mismatched IDci was returned.\n");
      666 +                       error = ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED;
      667 +                       goto end;
      668 +               }
      669 +       }
      670 +       if (idcr != NULL) {
      671 +               struct sockaddr_storage proposed_addr, got_addr;
      672 +               uint8_t proposed_prefix, got_prefix;
      673 +               uint16_t proposed_ulproto, got_ulproto;
      674 +
      675 +               error = ipsecdoi_id2sockaddr(iph2->id_p,
      676 +                                       (struct sockaddr *) &proposed_addr,
      677 +                                       &proposed_prefix, &proposed_ulproto);
      678 +               if (error)
      679 +                       goto end;
      680 +
      681 +               error = ipsecdoi_id2sockaddr(idcr,
      682 +                                       (struct sockaddr *) &got_addr,
      683 +                                       &got_prefix, &got_ulproto);
      684 +               if (error)
      685 +                       goto end;
      686 +
      687 +               if (proposed_prefix != got_prefix
      688 +                || proposed_ulproto != got_ulproto) {
      689 +                       plog(PLOG_DEBUG, PLOGLOC, NULL,
      690 +                               "IDcr prefix/ulproto does not match proposal.\n");
      691 +                       error = ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED;
      692 +                       goto end;
      693 +               }
      694 +
      695 +               if (rcs_cmpsa((struct sockaddr *) &proposed_addr,
      696 +                                  (struct sockaddr *) &got_addr) == 0) {
      697 +                       plog(PLOG_DEBUG, PLOGLOC, NULL,
      698 +                               "IDcr matches proposal.\n");
      699 +#ifdef ENABLE_NATT
      700 +               } else if (iph2->natoa_dst != NULL
      701 +                       && rcs_cmpsa_wop(iph2->natoa_dst,
      702 +                                      (struct sockaddr *) &got_addr) == 0
      703 +                       && extract_port((struct sockaddr *) &proposed_addr) ==
      704 +                          extract_port((struct sockaddr *) &got_addr)) {
      705 +                       plog(PLOG_DEBUG, PLOGLOC, NULL,
      706 +                               "IDcr matches NAT-OAr.\n");
      707 +#endif
      708 +               } else {
      709 +                       plog(PLOG_INTERR, PLOGLOC, NULL,
      710 +                               "mismatched IDcr was returned.\n");
      711 +                       error = ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED;
      712 +                       goto end;
      713 +               }
      714 +       }
      715 +
 531  716          /* Fixed buffer for calculating HASH */
 532  717          memcpy(hbuf->v, iph2->nonce->v, iph2->nonce->l);
 533  718          plog(PLOG_DEBUG, PLOGLOC, NULL,
 534  719                  "HASH allocated:hbuf->l=%d actual:tlen=%d\n",
 535  720                  hbuf->l, tlen + iph2->nonce->l);
 536  721          /* adjust buffer length for HASH */
 537  722          hbuf->l = iph2->nonce->l + tlen;
 538  723  
 539  724          /* validate HASH(2) */
 540  725      {
↓ open down ↓ 33 lines elided ↑ open up ↑
 574  759  
 575  760          error = 0;
 576  761  
 577  762  end:
 578  763          if (hbuf)
 579  764                  rc_vfree(hbuf);
 580  765          if (pbuf)
 581  766                  rc_vfree(pbuf);
 582  767          if (msg)
 583  768                  rc_vfree(msg);
      769 +        if (idci)
      770 +                rc_vfree(idci);
      771 +        if (idcr)
      772 +                rc_vfree(idcr);
 584  773  
 585  774          if (error) {
 586  775                  VPTRINIT(iph2->sa_ret);
 587  776                  VPTRINIT(iph2->nonce_p);
 588  777                  VPTRINIT(iph2->dhpub_p);
 589  778                  VPTRINIT(iph2->id);
 590  779                  VPTRINIT(iph2->id_p);
      780 +#ifdef ENABLE_NATT
      781 +                if (iph2->natoa_src) {
      782 +                        racoon_free(iph2->natoa_src);
      783 +                        iph2->natoa_src = NULL;
      784 +                }
      785 +                if (iph2->natoa_dst) {
      786 +                        racoon_free(iph2->natoa_dst);
      787 +                        iph2->natoa_dst = NULL;
      788 +                }
      789 +#endif
 591  790          }
 592  791  
 593  792          return error;
 594  793  }
 595  794  
      795 +static int
      796 +fill_in_ipsec_sas(struct ph2handle *iph2)
      797 +{
      798 +        /*
      799 +         * NOTE:  The OpenSolaris kernel can queue up packets on a larval SA
      800 +         * such that when the SA is filled-in via SADB_UPDATE, these packets
      801 +         * can be immediately processed.  If the reply packet is generated
      802 +         * in-kernel (e.g. ICMP_ECHO processing), an additonal ACQUIRE can
      803 +         * be sent if there is not a corresponding outbound SA waiting in
      804 +         * the wings.  We therefore perform SADB_ADD first so that if an
      805 +         * outbound SA is needed immediately during SADB_UPDATE processing,
      806 +         * it is ready.
      807 +         */
      808 +
      809 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "call pk_sendadd\n");
      810 +        if (pk_sendadd(iph2) < 0) {
      811 +                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey add failed.\n");
      812 +                return (-1);
      813 +        }
      814 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey add sent.\n");
      815 +
      816 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "call pk_sendupdate\n");
      817 +        if (pk_sendupdate(iph2) < 0) {
      818 +                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey update failed.\n");
      819 +                return (-1);
      820 +        }
      821 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey update sent.\n");
      822 +
      823 +        return (0);
      824 +}
      825 +
 596  826  /*
 597  827   * send to responder
 598  828   *      HDR*, HASH(3)
 599  829   */
 600  830  int
 601  831  quick_i2send(struct ph2handle *iph2, rc_vchar_t *msg0)
 602  832  {
 603  833          rc_vchar_t *msg = NULL;
 604  834          rc_vchar_t *buf = NULL;
 605  835          rc_vchar_t *hash = NULL;
↓ open down ↓ 91 lines elided ↑ open up ↑
 697  927          }
 698  928  #endif
 699  929          
 700  930          /* if there is commit bit don't set up SA now. */
 701  931          if (ISSET(iph2->flags, ISAKMP_FLAG_C)) {
 702  932                  iph2->status = PHASE2ST_COMMIT;
 703  933                  error = 0;
 704  934                  goto end;
 705  935          }
 706  936  
 707      -        /* Do UPDATE for initiator */
 708      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "call pk_sendupdate\n");
 709      -        if (pk_sendupdate(iph2) < 0) {
 710      -                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey update failed.\n");
 711      -                goto end;
 712      -        }
 713      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey update sent.\n");
      937 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "call fill_in_ipsec_sas");
      938 +        error = fill_in_ipsec_sas(iph2);
 714  939  
 715      -        /* Do ADD for responder */
 716      -        if (pk_sendadd(iph2) < 0) {
 717      -                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey add failed.\n");
 718      -                goto end;
 719      -        }
 720      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey add sent.\n");
 721      -
 722      -        error = 0;
 723      -
 724  940  end:
 725  941          if (buf != NULL)
 726  942                  rc_vfree(buf);
 727  943          if (msg != NULL)
 728  944                  rc_vfree(msg);
 729  945          if (hash != NULL)
 730  946                  rc_vfree(hash);
 731  947  
 732  948          return error;
 733  949  }
↓ open down ↓ 110 lines elided ↑ open up ↑
 844 1060          iph2->flags ^= ISAKMP_FLAG_C;   /* reset bit */
 845 1061  
 846 1062  #if 0
 847 1063          /* don't anything if local test mode. */
 848 1064          if (f_local) {
 849 1065                  error = 0;
 850 1066                  goto end;
 851 1067          }
 852 1068  #endif
 853 1069  
 854      -        /* Do UPDATE for initiator */
 855      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "call pk_sendupdate\n");
 856      -        if (pk_sendupdate(iph2) < 0) {
 857      -                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey update failed.\n");
 858      -                goto end;
 859      -        }
 860      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey update sent.\n");
     1070 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "call fill_in_ipsec_sas");
     1071 +        error = fill_in_ipsec_sas(iph2);
 861 1072  
 862      -        /* Do ADD for responder */
 863      -        if (pk_sendadd(iph2) < 0) {
 864      -                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey add failed.\n");
 865      -                goto end;
 866      -        }
 867      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey add sent.\n");
 868      -
 869      -        error = 0;
 870      -
 871 1073  end:
 872 1074          if (msg != NULL)
 873 1075                  rc_vfree(msg);
 874 1076          if (pbuf != NULL)
 875 1077                  rc_vfree(pbuf);
 876 1078          if (notify != NULL)
 877 1079                  rc_vfree(notify);
 878 1080  
 879 1081          return error;
 880 1082  }
 881 1083  
 882 1084  /*
 883 1085   * receive from initiator
 884      - *      HDR*, HASH(1), SA, Ni [, KE ] [, IDi2, IDr2 ]
     1086 + *      HDR*, HASH(1), SA, Ni [, KE ] [, IDi2, IDr2 ] [, NAT-OAi, NAT-OAr ]
 885 1087   */
 886 1088  int
 887 1089  quick_r1recv(struct ph2handle *iph2, rc_vchar_t *msg0)
 888 1090  {
 889 1091          rc_vchar_t *msg = NULL;
 890 1092          rc_vchar_t *hbuf = NULL;        /* for hash computing. */
 891 1093          rc_vchar_t *pbuf = NULL;        /* for payload parsing */
 892 1094          struct isakmp_parse_t *pa;
 893 1095          struct isakmp *isakmp = (struct isakmp *)msg0->v;
 894 1096          struct isakmp_pl_hash *hash = NULL;
↓ open down ↓ 149 lines elided ↑ open up ↑
1044 1246                          }
1045 1247                          break;
1046 1248  
1047 1249                  case ISAKMP_NPTYPE_N:
1048 1250                          isakmp_check_notify(pa->ptr, iph2->ph1);
1049 1251                          break;
1050 1252  
1051 1253  #ifdef ENABLE_NATT
1052 1254                  case ISAKMP_NPTYPE_NATOA_DRAFT:
1053 1255                  case ISAKMP_NPTYPE_NATOA_RFC:
     1256 +#ifdef sun
     1257 +                {
     1258 +                        struct sockaddr_storage addr;
     1259 +                        struct sockaddr *daddr;
     1260 +                        uint8_t prefix;
     1261 +                        uint16_t ul_proto;
     1262 +                        rc_vchar_t *vp = NULL;
     1263 +
     1264 +                        if (isakmp_p2ph(&vp, pa->ptr) < 0)
     1265 +                                goto end;
     1266 +
     1267 +                        error = ipsecdoi_id2sockaddr(vp,
     1268 +                            (struct sockaddr *) &addr,
     1269 +                            &prefix, &ul_proto);
     1270 +
     1271 +                        rc_vfree(vp);
     1272 +
     1273 +                        if (error)
     1274 +                                goto end;
     1275 +
     1276 +                        daddr = rcs_sadup((struct sockaddr *) &addr);
     1277 +                        if (daddr == NULL)
     1278 +                                goto end;
     1279 +
     1280 +                        if (iph2->natoa_dst == NULL)
     1281 +                                iph2->natoa_dst = daddr;
     1282 +                        else if (iph2->natoa_src == NULL)
     1283 +                                iph2->natoa_src = daddr;
     1284 +                        else {
     1285 +                                racoon_free(daddr);
     1286 +                                goto end;
     1287 +                        }
     1288 +                }
     1289 +#else
1054 1290                          /* Ignore original source/destination messages */
     1291 +#endif
1055 1292                          break;
1056 1293  #endif
1057 1294  
1058 1295                  default:
1059 1296                          isakmp_log(0, 0, iph2->ph1->remote, 0,
1060 1297                                     PLOG_PROTOERR, PLOGLOC,
1061 1298                                     "ignore the packet, "
1062 1299                                     "received unexpecting payload type %d.\n",
1063 1300                                     pa->type);
1064 1301                          error = ISAKMP_NTYPE_PAYLOAD_MALFORMED;
↓ open down ↓ 47 lines elided ↑ open up ↑
1112 1349  
1113 1350          if (result) {
1114 1351                  isakmp_log(0, 0, iph2->ph1->remote, 0,
1115 1352                             PLOG_DEBUG, PLOGLOC,
1116 1353                             "HASH(1) mismatch.\n");
1117 1354                  error = ISAKMP_NTYPE_INVALID_HASH_INFORMATION;
1118 1355                  goto end;
1119 1356          }
1120 1357      }
1121 1358  
     1359 +#ifndef sun
1122 1360          /* get sainfo */
1123 1361          error = get_sainfo_r(iph2);
1124 1362          if (error) {
1125 1363                  plog(PLOG_PROTOERR, PLOGLOC, NULL,
1126 1364                          "failed to get sainfo.\n");
1127 1365                  goto end;
1128 1366          }
1129 1367  
1130 1368          /* check the existence of ID payload and create responder's proposal */
1131 1369          error = get_proposal_r(iph2);
↓ open down ↓ 28 lines elided ↑ open up ↑
1160 1398                          "no PFS is specified, but peer sends KE.\n");
1161 1399                  error = ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN;
1162 1400                  goto end;
1163 1401          }
1164 1402          if (iph2->dhpub_p == NULL && iph2->approval->pfs_group != 0) {
1165 1403                  plog(PLOG_PROTOERR, PLOGLOC, NULL,
1166 1404                          "PFS is specified, but peer doesn't sends KE.\n");
1167 1405                  error = ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN;
1168 1406                  goto end;
1169 1407          }
     1408 +        /* change status of isakmp status entry */
     1409 +        iph2->status = PHASE2ST_STATUS2;
1170 1410  
     1411 +#endif /* sun/OpenSolaris */
     1412 +
1171 1413          /*
1172 1414           * save the packet from the initiator in order to resend the
1173 1415           * responder's first packet against this packet.
1174 1416           */
1175 1417          iph2->msg1 = rc_vdup(msg0);
1176 1418  
1177      -        /* change status of isakmp status entry */
1178      -        iph2->status = PHASE2ST_STATUS2;
1179      -
1180 1419          error = 0;
1181 1420  
1182 1421  end:
1183 1422          if (hbuf)
1184 1423                  rc_vfree(hbuf);
1185 1424          if (msg)
1186 1425                  rc_vfree(msg);
1187 1426          if (pbuf)
1188 1427                  rc_vfree(pbuf);
1189 1428  
1190 1429          if (error) {
1191 1430                  VPTRINIT(iph2->sa);
1192 1431                  VPTRINIT(iph2->nonce_p);
1193 1432                  VPTRINIT(iph2->dhpub_p);
1194 1433                  VPTRINIT(iph2->id);
1195 1434                  VPTRINIT(iph2->id_p);
     1435 +#ifdef ENABLE_NATT
     1436 +                if (iph2->natoa_src) {
     1437 +                        racoon_free(iph2->natoa_src);
     1438 +                        iph2->natoa_src = NULL;
     1439 +                }
     1440 +                if (iph2->natoa_dst) {
     1441 +                        racoon_free(iph2->natoa_dst);
     1442 +                        iph2->natoa_dst = NULL;
     1443 +                }
     1444 +#endif
1196 1445          }
1197 1446  
1198 1447          return error;
1199 1448  }
1200 1449  
1201 1450  /*
1202 1451   * call pfkey_getspi.
1203 1452   */
1204 1453  int
1205 1454  quick_r1prep(struct ph2handle *iph2, rc_vchar_t *msg)
↓ open down ↓ 19 lines elided ↑ open up ↑
1225 1474                  pfkey_timeover_stub, iph2);
1226 1475  
1227 1476          error = 0;
1228 1477  
1229 1478  end:
1230 1479          return error;
1231 1480  }
1232 1481  
1233 1482  /*
1234 1483   * send to initiator
1235      - *      HDR*, HASH(2), SA, Nr [, KE ] [, IDi2, IDr2 ]
     1484 + *      HDR*, HASH(2), SA, Nr [, KE ] [, IDi2, IDr2 ] [, NAT-OAi, NAT-OAr ]
1236 1485   */
1237 1486  int
1238 1487  quick_r2send(struct ph2handle *iph2, rc_vchar_t *msg)
1239 1488  {
1240 1489          rc_vchar_t *body = NULL;
1241 1490          rc_vchar_t *hash = NULL;
1242 1491          struct isakmp_gen *gen;
1243 1492          char *p;
1244 1493          int tlen;
1245 1494          int error = ISAKMP_INTERNAL_ERROR;
     1495 +        int natoa = ISAKMP_NPTYPE_NONE;
1246 1496          int pfsgroup;
1247 1497          uint8_t *np_p = NULL;
     1498 +#ifdef ENABLE_NATT
     1499 +        rc_vchar_t *nat_oai = NULL;
     1500 +        rc_vchar_t *nat_oar = NULL;
     1501 +#endif
1248 1502  
1249 1503          /* validity check */
1250 1504          if (msg != NULL) {
1251 1505                  plog(PLOG_INTERR, PLOGLOC, NULL,
1252 1506                          "msg has to be NULL in this function.\n");
1253 1507                  goto end;
1254 1508          }
1255 1509          if (iph2->status != PHASE2ST_GETSPIDONE) {
1256 1510                  plog(PLOG_INTERR, PLOGLOC, NULL,
1257 1511                          "status mismatched %d.\n", iph2->status);
↓ open down ↓ 20 lines elided ↑ open up ↑
1278 1532                                  "failed to set DH value.\n");
1279 1533                          goto end;
1280 1534                  }
1281 1535                  /* generate DH public value */
1282 1536                  if (oakley_dh_generate(iph2->pfsgrp,
1283 1537                                  &iph2->dhpub, &iph2->dhpriv) < 0) {
1284 1538                          goto end;
1285 1539                  }
1286 1540          }
1287 1541  
     1542 +#ifdef ENABLE_NATT
     1543 +        /*
     1544 +         * RFC3947 5.2. if we chose UDP-Encapsulated-Transport
     1545 +         * we should send NAT-OA
     1546 +         */
     1547 +        if (ipsecdoi_transportmode(iph2->proposal)
     1548 +            && (iph2->ph1->natt_flags & NAT_DETECTED)) {
     1549 +                natoa = iph2->ph1->natt_options->payload_nat_oa;
     1550 +                
     1551 +                nat_oai = ipsecdoi_sockaddr2id(iph2->dst,
     1552 +                    IPSECDOI_PREFIX_HOST, IPSEC_ULPROTO_ANY);
     1553 +                nat_oar = ipsecdoi_sockaddr2id(iph2->src,
     1554 +                    IPSECDOI_PREFIX_HOST, IPSEC_ULPROTO_ANY);
     1555 +                
     1556 +                if (nat_oai == NULL || nat_oar == NULL) {
     1557 +                        plog(PLOG_INTERR, PLOGLOC, NULL,
     1558 +                            "failed to generate NAT-OA payload.\n");
     1559 +                        goto end;
     1560 +                }
     1561 +
     1562 +                plog(PLOG_DEBUG, PLOGLOC, NULL, "NAT-OAi:\n");
     1563 +                plogdump(PLOG_DEBUG, PLOGLOC, 0, nat_oai->v, nat_oai->l);
     1564 +                plog(PLOG_DEBUG, PLOGLOC, 0, NULL, "NAT-OAr:\n");
     1565 +                plogdump(PLOG_DEBUG, PLOGLOC, 0, nat_oar->v, nat_oar->l);
     1566 +        }
     1567 +#endif
     1568 +
1288 1569          /* create SA;NONCE payload, and KE and ID if need */
1289 1570          tlen = sizeof(*gen) + iph2->sa_ret->l
1290 1571                  + sizeof(*gen) + iph2->nonce->l;
1291 1572          if (iph2->dhpub_p != NULL && pfsgroup != 0)
1292 1573                  tlen += (sizeof(*gen) + iph2->dhpub->l);
1293 1574          if (iph2->id_p != NULL)
1294 1575                  tlen += (sizeof(*gen) + iph2->id_p->l
1295 1576                          + sizeof(*gen) + iph2->id->l);
1296 1577  
     1578 +#ifdef ENABLE_NATT
     1579 +       if (natoa != ISAKMP_NPTYPE_NONE)
     1580 +               tlen += 2 * sizeof(*gen) + nat_oai->l + nat_oar->l;
     1581 +#endif
     1582 +
1297 1583          body = rc_vmalloc(tlen);
1298 1584          if (body == NULL) { 
1299 1585                  plog(PLOG_INTERR, PLOGLOC, NULL,
1300 1586                          "failed to get buffer to send.\n");
1301 1587                  goto end;
1302 1588          }
1303 1589          p = body->v;
1304 1590  
1305 1591          /* make SA payload */ 
1306 1592          p = set_isakmp_payload(body->v, iph2->sa_ret, ISAKMP_NPTYPE_NONCE);
1307 1593  
1308 1594          /* add NONCE payload */
1309 1595          np_p = &((struct isakmp_gen *)p)->np;   /* XXX */
1310 1596          p = set_isakmp_payload(p, iph2->nonce,
1311 1597                  (iph2->dhpub_p != NULL && pfsgroup != 0)
1312 1598                                  ? ISAKMP_NPTYPE_KE
1313 1599                                  : (iph2->id_p != NULL
1314 1600                                          ? ISAKMP_NPTYPE_ID
1315      -                                        : ISAKMP_NPTYPE_NONE));
     1601 +                                        : natoa));
1316 1602  
1317 1603          /* add KE payload if need. */
1318 1604          if (iph2->dhpub_p != NULL && pfsgroup != 0) {
1319 1605                  np_p = &((struct isakmp_gen *)p)->np;   /* XXX */
1320 1606                  p = set_isakmp_payload(p, iph2->dhpub,
1321 1607                          (iph2->id_p == NULL)
1322      -                                ? ISAKMP_NPTYPE_NONE
     1608 +                                ? natoa
1323 1609                                  : ISAKMP_NPTYPE_ID);
1324 1610          }
1325 1611  
1326 1612          /* add ID payloads received. */
1327 1613          if (iph2->id_p != NULL) {
1328 1614                  /* IDci */
1329 1615                  p = set_isakmp_payload(p, iph2->id_p, ISAKMP_NPTYPE_ID);
1330 1616                  /* IDcr */
1331 1617                  np_p = &((struct isakmp_gen *)p)->np;   /* XXX */
1332      -                p = set_isakmp_payload(p, iph2->id, ISAKMP_NPTYPE_NONE);
     1618 +                p = set_isakmp_payload(p, iph2->id, natoa);
1333 1619          }
     1620 +#ifdef ENABLE_NATT
     1621 +        /* NAT-OA */
     1622 +        if (natoa != ISAKMP_NPTYPE_NONE) {
     1623 +                p = set_isakmp_payload(p, nat_oai, natoa);
     1624 +                p = set_isakmp_payload(p, nat_oar, ISAKMP_NPTYPE_NONE);
     1625 +        }
     1626 +#endif
1334 1627  
1335 1628          /* add a RESPONDER-LIFETIME notify payload if needed */
1336 1629      {
1337 1630          rc_vchar_t *data = NULL;
1338 1631          struct saprop *pp = iph2->approval;
1339 1632          struct saproto *pr;
1340 1633  
1341 1634          if (pp->claim & IPSECDOI_ATTR_SA_LD_TYPE_SEC) {
1342 1635                  uint32_t v = htonl((uint32_t)pp->lifetime);
1343 1636                  data = isakmp_add_attr_l(data, IPSECDOI_ATTR_SA_LD_TYPE,
↓ open down ↓ 74 lines elided ↑ open up ↑
1418 1711          /* change status of isakmp status entry */
1419 1712          iph2->status = PHASE2ST_MSG1SENT;
1420 1713  
1421 1714          error = 0;
1422 1715  
1423 1716  end:
1424 1717          if (body != NULL)
1425 1718                  rc_vfree(body);
1426 1719          if (hash != NULL)
1427 1720                  rc_vfree(hash);
     1721 +#ifdef ENABLE_NATT
     1722 +        if (nat_oai != NULL)
     1723 +                rc_vfree(nat_oai);
     1724 +        if (nat_oar != NULL)
     1725 +                rc_vfree(nat_oar);
     1726 +#endif
1428 1727  
1429 1728          return error;
1430 1729  }
1431 1730  
1432 1731  /*
1433 1732   * receive from initiator
1434 1733   *      HDR*, HASH(3)
1435 1734   */
1436 1735  int
1437 1736  quick_r3recv(struct ph2handle *iph2, rc_vchar_t *msg0)
↓ open down ↓ 249 lines elided ↑ open up ↑
1687 1986                  if (ike_spmif_post_policy_add(iph2->selector,
1688 1987                                                ike_ipsec_mode(iph2->selector->pl),
1689 1988                                                lifetime, iph2->src, iph2->dst,
1690 1989                                                iph2->ph1->rmconf) < 0) {
1691 1990                          plog(PLOG_INTERR, PLOGLOC, NULL,
1692 1991                               "generate policy failed.\n");
1693 1992                          goto end;
1694 1993                  }
1695 1994          }
1696 1995  
1697      -        /* Do UPDATE as responder */
1698      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "call pk_sendupdate\n");
1699      -        if (pk_sendupdate(iph2) < 0) {
1700      -                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey update failed.\n");
1701      -                goto end;
1702      -        }
1703      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey update sent.\n");
     1996 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "call fill_in_ipsec_sas");
     1997 +        error = fill_in_ipsec_sas(iph2);
1704 1998  
1705      -        /* Do ADD for responder */
1706      -        if (pk_sendadd(iph2) < 0) {
1707      -                plog(PLOG_INTERR, PLOGLOC, NULL, "pfkey add failed.\n");
1708      -                goto end;
1709      -        }
1710      -        plog(PLOG_DEBUG, PLOGLOC, NULL, "pfkey add sent.\n");
1711      -
1712      -        error = 0;
1713      -
1714 1999  end:
1715 2000          if (msg != NULL)
1716 2001                  rc_vfree(msg);
1717 2002  
1718 2003          return error;
1719 2004  }
1720 2005  
1721 2006  
1722 2007  /*
1723 2008   * create HASH, body (SA, NONCE) payload with isakmp header.
↓ open down ↓ 395 lines elided ↑ open up ↑
2119 2404                  return ISAKMP_INTERNAL_ERROR;
2120 2405          }
2121 2406          /* Refresh existing generated policies
2122 2407           */
2123 2408          if (iph2->ph1->rmconf->gen_policy) {
2124 2409                  plog(LLV_INFO, LOCATION, NULL,
2125 2410                           "Update the generated policy : %s\n",
2126 2411                           spidx2str(&spidx));
2127 2412                  iph2->spidx_gen = racoon_malloc(sizeof(spidx));
2128 2413                  if (!iph2->spidx_gen) {
2129      -                        plog(LLV_ERROR, LOCATION, NULL,
     2414 +                        plog(PLOG_INTERR, PLOGLOC, NULL,
2130 2415                                   "buffer allocation failed.\n");
2131 2416                          return ISAKMP_INTERNAL_ERROR;
2132 2417                  }
2133 2418                  memcpy(iph2->spidx_gen, &spidx, sizeof(spidx));
2134 2419          }
2135 2420  
2136 2421          /* get outbound policy */
2137 2422      {
2138 2423          struct sockaddr_storage addr;
2139 2424          uint8_t pref;
↓ open down ↓ 29 lines elided ↑ open up ↑
2169 2454          }
2170 2455  
2171 2456          /* set new proposal derived from a policy into the iph2->proposal. */
2172 2457          if (set_proposal_from_policy(iph2, sp_in, sp_out) < 0) {
2173 2458                  plog(PLOG_INTERR, PLOGLOC, NULL,
2174 2459                          "failed to create saprop.\n");
2175 2460                  return ISAKMP_INTERNAL_ERROR;
2176 2461          }
2177 2462  
2178 2463          return 0;
2179      -#endif
     2464 +#endif /* 0 */
2180 2465  }
2181 2466  
2182 2467  #ifdef INET6
2183 2468  static uint32_t
2184 2469  setscopeid(struct sockaddr *sp_addr0, struct sockaddr *sa_addr0)
2185 2470  {
2186 2471          struct sockaddr_in6 *sp_addr, *sa_addr;
2187 2472      
2188 2473          sp_addr = (struct sockaddr_in6 *)sp_addr0;
2189 2474          sa_addr = (struct sockaddr_in6 *)sa_addr0;
↓ open down ↓ 24 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX