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/ikev1.c
          +++ new/iked/ikev1/ikev1.c
↓ open down ↓ 48 lines elided ↑ open up ↑
  49   49  
  50   50  #include <netinet/in.h>
  51   51  #include <netdb.h>
  52   52  
  53   53  #ifdef HAVE_NETINET6_IPSEC_H
  54   54  # include <netinet6/ipsec.h>
  55   55  #else
  56   56  # ifdef HAVE_NETIPSEC_IPSEC_H
  57   57  #  include <netipsec/ipsec.h>
  58   58  # else
  59      -#  include <linux/ipsec.h>
       59 +#  ifndef sun   /* XXX KEBE SAYS OpenSolaris */
       60 +#    include <linux/ipsec.h>
       61 +#  endif
  60   62  # endif
  61   63  #endif
  62   64  
       65 +#ifdef sun      /* XXX KEBE SAYS OpenSolaris */
       66 +#define IPSEC_ULPROTO_ANY 0
       67 +#endif
       68 +
  63   69  #include "racoon.h"
  64   70  
  65   71  #include "isakmp.h"
  66   72  #include "ikev2.h"
  67   73  #include "keyed_hash.h"
  68   74  #include "isakmp_impl.h"
  69   75  #include "ikev1_impl.h"
  70   76  #include "ipsec_doi.h"
  71   77  #include "isakmp_ident.h"
  72   78  /* #include "isakmp_agg.h" */
↓ open down ↓ 229 lines elided ↑ open up ↑
 302  308  
 303  309                          /* copy-in new addresses */
 304  310                          iph1->remote = rcs_sadup(remote);
 305  311                          iph1->local = rcs_sadup(local);
 306  312  
 307  313                          /*
 308  314                           * set the flag to prevent further port floating.
 309  315                           * (FIXME: should we allow it? E.g. when the NAT gw 
 310  316                           * is rebooted?)
 311  317                           */
      318 +#ifdef sun
      319 +                        iph1->natt_flags |= NAT_PORTS_CHANGED;
      320 +#else
 312  321                          iph1->natt_flags |= NAT_PORTS_CHANGED | NAT_ADD_NON_ESP_MARKER;
      322 +#endif
 313  323                  }
 314  324  #endif
 315  325  
 316  326                  /* must be same addresses in one stream of a phase at least. */
 317  327                  if (rcs_cmpsa(iph1->remote, remote) != 0) {
 318  328                          char *saddr_db, *saddr_act;
 319  329  
 320  330                          saddr_db = strdup(rcs_sa2str(iph1->remote));
 321  331                          saddr_act = strdup(rcs_sa2str(remote));
 322  332  
↓ open down ↓ 505 lines elided ↑ open up ↑
 828  838          if (iph2->sendbuf == NULL) {
 829  839                  plog(PLOG_INTERR, PLOGLOC, NULL, "no buffer found as sendbuf\n");
 830  840                  return -1;
 831  841          }
 832  842          VPTRINIT(iph2->sendbuf);
 833  843  
 834  844          /* turn off schedule */
 835  845          if (iph2->scr)
 836  846                  SCHED_KILL(iph2->scr);
 837  847  
      848 +#ifdef sun
      849 +        /* Bail now to await inverse-ACQUIRE response. */
      850 +        if (iph2->status == PHASE2ST_START && iph2->side == RESPONDER)
      851 +                return (0);
      852 +#endif /* sun/OpenSolaris */
      853 +
 838  854          /* send */
 839  855          plog(PLOG_DEBUG, PLOGLOC, NULL, "===\n");
 840  856          if ((ph2exchange[etypesw2(isakmp->etype)]
 841  857               [iph2->side]
 842  858               [iph2->status]) (iph2, msg) != 0) {
 843  859                  plog(PLOG_PROTOERR, PLOGLOC, 0,
 844  860                       "failed to process packet.\n");
 845  861                  return -1;
 846  862          }
 847  863  #ifdef ENABLE_STATS
↓ open down ↓ 281 lines elided ↑ open up ↑
1129 1145                  /* release ipsecsa handler due to internal error. */
1130 1146                  plog(PLOG_INTERR, PLOGLOC, 0,
1131 1147                       "failed to initiate phase 2 negotiation for %s\n",
1132 1148                       rcs_sa2str_wop(iph2->dst));
1133 1149                  isakmp_fail_initiate_ph2(iph2);
1134 1150                  return;
1135 1151          }
1136 1152          return;
1137 1153  }
1138 1154  
     1155 +#ifdef sun
     1156 +static int
     1157 +isakmp_ph2_inv_acquire(invacq_t *invacq)
     1158 +{
     1159 +        struct ph2handle *iph2 = invacq->iph2;
     1160 +        struct rcpfk_msg *param = invacq->answer;
     1161 +        struct isakmp *isakmp = (struct isakmp *)iph2->msg1->v;
     1162 +
     1163 +        sadb_request_finish(&invacq->request);
     1164 +        free(invacq);
     1165 +
     1166 +        /* 
     1167 +         * Initialize iph2->selector, iph2->proposal, and iph2-> with the results of an
     1168 +         * inverse-ACQUIRE.
     1169 +         *
     1170 +         * XXX KEBE SAYS -- We need a way to figure out a p2_pfs equivalent
     1171 +         * for racoon2.  We store this in Phase I/PAD state in in.iked.
     1172 +         */
     1173 +
     1174 +        /* Then send the Quick Mode reply. */
     1175 +        /* assert(iph2->status == PHASE2ST_STATUS2); */
     1176 +
     1177 +        /* change status of isakmp status entry */
     1178 +        iph2->status = PHASE2ST_STATUS2;
     1179 +
     1180 +        if (extract_extended_acquire(param, &iph2->selector, NULL) != 0) {
     1181 +                /* XXX KEBE SAYS MORE ERROR HANDLING? */
     1182 +                return (-1);
     1183 +        }
     1184 +
     1185 +        /* XXX KEBE SAYS FILL ME IN XXX */
     1186 +
     1187 +        if (set_proposal_from_policy(iph2, iph2->ph1->rmconf,
     1188 +            iph2->selector->pl) != 0) {
     1189 +                /* XXX KEBE SAYS MORE ERROR HANDLING? */
     1190 +                return (-1);
     1191 +        }
     1192 +
     1193 +        if (ipsecdoi_selectph2proposal(iph2) < 0) {
     1194 +                /* XXX KEBE SAYS MORE ERROR HANDLING?  PROPER RETURN? */
     1195 +                isakmp_info_send_n1(iph2->ph1, ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN,
     1196 +                    NULL);
     1197 +                return (-1);
     1198 +        }
     1199 +
     1200 +        /* The following was moved here from quick_main(). */
     1201 +        plog(PLOG_DEBUG, PLOGLOC, NULL, "===\n");
     1202 +        if ((ph2exchange[etypesw2(isakmp->etype)]
     1203 +             [iph2->side]
     1204 +             [iph2->status]) (iph2, iph2->msg1) < 0) {
     1205 +                plog(PLOG_PROTOERR, PLOGLOC, 0,
     1206 +                     "failed to process packet.\n");
     1207 +                /* don't release handler */
     1208 +                return -1;
     1209 +        }
     1210 +#ifdef ENABLE_STATS
     1211 +        gettimeofday(&end, NULL);
     1212 +        syslog(LOG_NOTICE, "%s(%s): %8.6f",
     1213 +               "phase2",
     1214 +               s_isakmp_state(ISAKMP_ETYPE_QUICK, iph2->side, iph2->status),
     1215 +               timedelta(&start, &end));
     1216 +#endif
     1217 +}
     1218 +#endif
     1219 +
1139 1220  /* new negotiation of phase 2 for responder */
1140 1221  static int
1141 1222  isakmp_ph2begin_r(struct ph1handle *iph1, rc_vchar_t *msg)
1142 1223  {
1143 1224          struct isakmp *isakmp = (struct isakmp *)msg->v;
1144 1225          struct ph2handle *iph2 = 0;
1145 1226          int error;
1146 1227  #ifdef ENABLE_STATS
1147 1228          struct timeval start, end;
1148 1229  #endif
↓ open down ↓ 50 lines elided ↑ open up ↑
1199 1280                  plog(PLOG_INFO, PLOGLOC, NULL,
1200 1281                       "respond new phase 2 negotiation: %s<=>%s\n",
1201 1282                       a, rcs_sa2str(iph2->dst));
1202 1283                  racoon_free(a);
1203 1284          }
1204 1285  
1205 1286  #ifdef ENABLE_STATS
1206 1287          gettimeofday(&start, NULL);
1207 1288  #endif
1208 1289  
     1290 +
1209 1291          error = (ph2exchange[etypesw2(ISAKMP_ETYPE_QUICK)]
1210 1292                   [iph2->side]
1211 1293                   [iph2->status]) (iph2, msg);
1212 1294          if (error != 0) {
1213 1295                  plog(PLOG_INTERR, PLOGLOC, 0,
1214 1296                       "failed to pre-process packet.\n");
1215 1297                  if (error != ISAKMP_INTERNAL_ERROR)
1216 1298                          isakmp_info_send_n1(iph2->ph1, error, NULL);
1217 1299                  /*
1218 1300                   * release handler because it's wrong that ph2handle is kept
1219 1301                   * after failed to check message for responder's.
1220 1302                   */
1221 1303                  unbindph12(iph2);
1222 1304                  remph2(iph2);
1223 1305                  delph2(iph2);
1224 1306                  return -1;
1225 1307          }
1226 1308  
     1309 +#ifdef sun
     1310 +        /* XXX KEBE ASKS - how do you insert inverse-ACQUIRE here? */
     1311 +
     1312 +        /* Assume iph2->msg1 contains a copy of "msg" we passed-in. */
     1313 +        {
     1314 +                invacq_t *invacq = malloc(sizeof (*invacq));
     1315 +                uint32_t newseq = sadb_new_seq();
     1316 +
     1317 +                /*
     1318 +                 * Use newseq to avoid using iph2's, which already has a
     1319 +                 * record via a previous sadb_request_initalize() call.
     1320 +                 */
     1321 +
     1322 +                if (invacq == NULL)
     1323 +                        return (-1);
     1324 +
     1325 +                invacq->iph2 = iph2;
     1326 +                sadb_request_initialize(&invacq->request,
     1327 +                    NULL /* KEBE - reqmethod */, NULL /* KEBE - respmethod */,
     1328 +                    newseq, invacq);
     1329 +                invacq->receiver = isakmp_ph2_inv_acquire;
     1330 +
     1331 +                /* Okay, now we send the inverse-ACQUIRE itself. */
     1332 +                /* XXX KEBE SAYS CODE ME */
     1333 +                ikev1_send_inverse_acquire(iph2, newseq);
     1334 +        }
     1335 +#else
1227 1336          /* send */
1228 1337          plog(PLOG_DEBUG, PLOGLOC, NULL, "===\n");
1229 1338          if ((ph2exchange[etypesw2(isakmp->etype)]
1230 1339               [iph2->side]
1231 1340               [iph2->status]) (iph2, msg) < 0) {
1232 1341                  plog(PLOG_PROTOERR, PLOGLOC, 0,
1233 1342                       "failed to process packet.\n");
1234 1343                  /* don't release handler */
1235 1344                  return -1;
1236 1345          }
1237 1346  #ifdef ENABLE_STATS
1238 1347          gettimeofday(&end, NULL);
1239 1348          syslog(LOG_NOTICE, "%s(%s): %8.6f",
1240 1349                 "phase2",
1241 1350                 s_isakmp_state(ISAKMP_ETYPE_QUICK, iph2->side, iph2->status),
1242 1351                 timedelta(&start, &end));
1243 1352  #endif
     1353 +#endif /* sun/OpenSolaris */
1244 1354  
1245 1355          return 0;
1246 1356  }
1247 1357  
1248 1358  /* called from scheduler */
1249 1359  static void
1250 1360  isakmp_ph1resend_stub(void *p)
1251 1361  {
1252 1362          (void)isakmp_ph1resend((struct ph1handle *)p);
1253 1363  }
↓ open down ↓ 1595 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX