Lines Matching refs:iph1
408 struct ph1handle *iph1; local
463 iph1 = getph1byindex(index);
464 if (iph1 != NULL) {
467 iph1->side == INITIATOR) {
476 if (NATT_AVAILABLE(iph1) &&
477 ! (iph1->natt_flags & NAT_PORTS_CHANGED) &&
478 ((cmpsaddrstrict(iph1->remote, remote) != 0) ||
479 (cmpsaddrstrict(iph1->local, local) != 0)))
482 racoon_free(iph1->remote);
483 racoon_free(iph1->local);
484 iph1->remote = NULL;
485 iph1->local = NULL;
488 iph1->remote = dupsaddr(remote);
489 if (iph1->remote == NULL) {
490 plog(LLV_ERROR, LOCATION, iph1->remote,
492 remph1(iph1);
493 delph1(iph1);
496 iph1->local = dupsaddr(local);
497 if (iph1->local == NULL) {
498 plog(LLV_ERROR, LOCATION, iph1->remote,
500 remph1(iph1);
501 delph1(iph1);
508 iph1->natt_flags |= NAT_PORTS_CHANGED | NAT_ADD_NON_ESP_MARKER;
513 saddr2str_fromto ("%s<->%s", iph1->remote, iph1->local));
515 natt_keepalive_add_ph1 (iph1);
520 if (cmpsaddrstrict(iph1->remote, remote) != 0) {
523 saddr_db = racoon_strdup(saddr2str(iph1->remote));
556 if (iph1 == NULL) {
563 iph1 = getph1byindex0(index);
564 if (iph1 == NULL) {
585 if (iph1->side != INITIATOR) {
589 isakmp_pindex(&iph1->index, 0));
599 if (iph1->etype != isakmp->etype) {
600 plog(LLV_ERROR, LOCATION, iph1->remote,
603 s_isakmp_etype(iph1->etype),
610 return frag_handler(iph1, msg, remote, local);
614 if (ph1_main(iph1, msg) < 0) {
615 plog(LLV_ERROR, LOCATION, iph1->remote,
617 remph1(iph1);
618 delph1(iph1);
638 if (iph1 == NULL) {
639 iph1 = getph1byindex0(index);
640 if (iph1 == NULL) {
646 if (cmpsaddrstrict(iph1->remote, remote) != 0) {
650 saddr2str(iph1->remote));
656 return frag_handler(iph1, msg, remote, local);
659 if (isakmp_info_recv(iph1, msg) < 0)
667 if (iph1 == NULL) {
679 if (iph1->mode_cfg && iph1->mode_cfg->ivm) {
680 oakley_delivm(iph1->mode_cfg->ivm);
681 iph1->mode_cfg->ivm = NULL;
686 return frag_handler(iph1, msg, remote, local);
690 if (iph1->status != PHASE1ST_ESTABLISHED) {
694 isakmp_pindex(&iph1->index, iph1->msgid));
699 iph2 = getph2bymsgid(iph1, msgid);
702 if (isakmp_ph2begin_r(iph1, msg) < 0)
720 plog(LLV_ERROR, LOCATION, iph1->remote,
731 if (iph1 == NULL) {
740 return frag_handler(iph1, msg, remote, local);
743 isakmp_newgroup_r(iph1, msg);
748 if (iph1 == NULL) {
758 return frag_handler(iph1, msg, remote, local);
761 isakmp_cfg_r(iph1, msg);
780 ph1_main(iph1, msg) in ph1_main() argument
781 struct ph1handle *iph1; in ph1_main()
790 if (iph1->status == PHASE1ST_ESTABLISHED)
797 if (ph1exchange[etypesw1(iph1->etype)]
798 [iph1->side]
799 [iph1->status] == NULL) {
800 plog(LLV_ERROR, LOCATION, iph1->remote,
804 error = (ph1exchange[etypesw1(iph1->etype)]
805 [iph1->side]
806 [iph1->status])(iph1, msg);
818 if (iph1->side == RESPONDER && iph1->status == PHASE1ST_START) {
819 plog(LLV_ERROR, LOCATION, iph1->remote,
830 if (iph1->sendbuf == NULL) {
837 VPTRINIT(iph1->sendbuf);
840 SCHED_KILL(iph1->scr);
844 if ((ph1exchange[etypesw1(iph1->etype)]
845 [iph1->side]
846 [iph1->status])(iph1, msg) != 0) {
847 plog(LLV_ERROR, LOCATION, iph1->remote,
855 "phase1", s_isakmp_state(iph1->etype, iph1->side, iph1->status),
858 if (iph1->status == PHASE1ST_ESTABLISHED) {
861 gettimeofday(&iph1->end, NULL);
863 "phase1", s_isakmp_etype(iph1->etype),
864 timedelta(&iph1->start, &iph1->end));
868 (void)time(&iph1->created);
871 iph1->sce = sched_new(iph1->approval->lifetime,
872 isakmp_ph1expire_stub, iph1);
874 if (iph1->mode_cfg->flags & ISAKMP_CFG_VENDORID_XAUTH) {
875 switch(AUTHMETHOD(iph1)) {
883 xauth_sendreq(iph1);
885 iph1->rmconf->ini_contact = 0;
894 if(iph1->dpd_support && iph1->rmconf->dpd_interval)
895 isakmp_sched_r_u(iph1, 0);
901 && iph1->rmconf->ini_contact && !getcontacted(iph1->remote)) {
903 isakmp_info_send_n1(iph1,
906 if (inscontacted(iph1->remote) == -1) {
907 plog(LLV_ERROR, LOCATION, iph1->remote,
913 log_ph1established(iph1);
921 if ((iph1->status == PHASE1ST_ESTABLISHED) &&
922 !iph1->rmconf->mode_cfg) {
923 switch (AUTHMETHOD(iph1)) {
936 script_hook(iph1, SCRIPT_PHASE1_UP);
1030 struct ph1handle *iph1; local
1036 iph1 = newph1();
1037 if (iph1 == NULL)
1040 iph1->status = PHASE1ST_START;
1041 iph1->rmconf = rmconf;
1042 iph1->side = INITIATOR;
1043 iph1->version = ISAKMP_VERSION_NUMBER;
1044 iph1->msgid = 0;
1045 iph1->flags = 0;
1046 iph1->ph2cnt = 0;
1048 iph1->gssapi_state = NULL;
1051 if ((iph1->mode_cfg = isakmp_cfg_mkstate()) == NULL) {
1052 delph1(iph1);
1059 iph1->frag = 1;
1061 iph1->frag = 0;
1062 iph1->frag_chain = NULL;
1064 iph1->approval = NULL;
1067 if (copy_ph1addresses(iph1, rmconf, remote, local) < 0) {
1068 delph1(iph1);
1072 (void)insph1(iph1);
1075 iph1->etype = rmconf->etypes->type;
1081 a = racoon_strdup(saddr2str(iph1->local));
1086 a, saddr2str(iph1->remote));
1091 s_isakmp_etype(iph1->etype));
1094 gettimeofday(&iph1->start, NULL);
1098 if ((ph1exchange[etypesw1(iph1->etype)]
1099 [iph1->side]
1100 [iph1->status])(iph1, NULL) != 0) {
1102 remph1(iph1);
1103 delph1(iph1);
1112 s_isakmp_state(iph1->etype, iph1->side, iph1->status),
1126 struct ph1handle *iph1; in isakmp_ph1begin_r() local
1150 iph1 = newph1(); in isakmp_ph1begin_r()
1151 if (iph1 == NULL) in isakmp_ph1begin_r()
1154 memcpy(&iph1->index.i_ck, &isakmp->i_ck, sizeof(iph1->index.i_ck)); in isakmp_ph1begin_r()
1155 iph1->status = PHASE1ST_START; in isakmp_ph1begin_r()
1156 iph1->rmconf = rmconf; in isakmp_ph1begin_r()
1157 iph1->flags = 0; in isakmp_ph1begin_r()
1158 iph1->side = RESPONDER; in isakmp_ph1begin_r()
1159 iph1->etype = etypeok->type; in isakmp_ph1begin_r()
1160 iph1->version = isakmp->v; in isakmp_ph1begin_r()
1161 iph1->msgid = 0; in isakmp_ph1begin_r()
1163 iph1->gssapi_state = NULL; in isakmp_ph1begin_r()
1166 if ((iph1->mode_cfg = isakmp_cfg_mkstate()) == NULL) { in isakmp_ph1begin_r()
1167 delph1(iph1); in isakmp_ph1begin_r()
1172 iph1->frag = 0; in isakmp_ph1begin_r()
1173 iph1->frag_chain = NULL; in isakmp_ph1begin_r()
1175 iph1->approval = NULL; in isakmp_ph1begin_r()
1183 iph1->natt_flags |= (NAT_PORTS_CHANGED); in isakmp_ph1begin_r()
1187 if (copy_ph1addresses(iph1, rmconf, remote, local) < 0) { in isakmp_ph1begin_r()
1188 delph1(iph1); in isakmp_ph1begin_r()
1191 (void)insph1(iph1); in isakmp_ph1begin_r()
1197 a = racoon_strdup(saddr2str(iph1->local)); in isakmp_ph1begin_r()
1202 a, saddr2str(iph1->remote)); in isakmp_ph1begin_r()
1209 gettimeofday(&iph1->start, NULL); in isakmp_ph1begin_r()
1216 if ((ph1exchange[etypesw1(iph1->etype)] in isakmp_ph1begin_r()
1217 [iph1->side] in isakmp_ph1begin_r()
1218 [iph1->status])(iph1, msg) < 0 in isakmp_ph1begin_r()
1219 || (ph1exchange[etypesw1(iph1->etype)] in isakmp_ph1begin_r()
1220 [iph1->side] in isakmp_ph1begin_r()
1221 [iph1->status])(iph1, msg) < 0) { in isakmp_ph1begin_r()
1224 remph1(iph1); in isakmp_ph1begin_r()
1225 delph1(iph1); in isakmp_ph1begin_r()
1233 s_isakmp_state(iph1->etype, iph1->side, iph1->status), in isakmp_ph1begin_r()
1253 isakmp_ph2begin_i(iph1, iph2) in isakmp_ph2begin_i() argument
1254 struct ph1handle *iph1; in isakmp_ph2begin_i()
1258 if (xauth_check(iph1) != 0) {
1283 bindph12(iph1, iph2);
1299 isakmp_ph2begin_r(iph1, msg) in isakmp_ph2begin_r() argument
1300 struct ph1handle *iph1; in isakmp_ph2begin_r()
1310 if (xauth_check(iph1) != 0) {
1324 iph2->ph1 = iph1;
1330 iph2->ivm = oakley_newiv2(iph1, iph2->msgid);
1335 iph2->dst = dupsaddr(iph1->remote); /* XXX should be considered */
1340 iph2->src = dupsaddr(iph1->local); /* XXX should be considered */
1357 bindph12(iph1, iph2);
1380 plog(LLV_ERROR, LOCATION, iph1->remote,
1788 isakmp_send(iph1, sbuf) in isakmp_send() argument
1789 struct ph1handle *iph1; in isakmp_send()
1797 size_t extralen = NON_ESP_MARKER_USE(iph1) ? NON_ESP_MARKER_LEN : 0;
1811 if (iph1->frag && sbuf->l > ISAKMP_FRAG_MAXLEN)
1839 s = getsockmyaddr(iph1->local);
1845 saddr2str_fromto("from %s to %s", iph1->local, iph1->remote));
1848 if (iph1->frag && sbuf->l > ISAKMP_FRAG_MAXLEN) {
1849 if (isakmp_sendfrags(iph1, sbuf) == -1) {
1858 iph1->local, iph1->remote, lcconf->count_persend);
1874 struct ph1handle *iph1; local
1876 iph1=(struct ph1handle *)p;
1877 if(isakmp_ph1resend(iph1) < 0){
1878 if(iph1->scr != NULL){
1881 sched_kill(iph1->scr);
1882 iph1->scr=NULL;
1885 remph1(iph1);
1886 delph1(iph1);
1891 isakmp_ph1resend(iph1) in isakmp_ph1resend() argument
1892 struct ph1handle *iph1; in isakmp_ph1resend()
1896 if (iph1->retry_counter <= 0) {
1899 isakmp_pindex(&iph1->index, iph1->msgid));
1900 EVT_PUSH(iph1->local, iph1->remote,
1906 if (isakmp_send(iph1, iph1->sendbuf) < 0){
1909 isakmp_pindex(&iph1->index, iph1->msgid));
1910 EVT_PUSH(iph1->local, iph1->remote,
1917 isakmp_pindex(&iph1->index, iph1->msgid));
1919 iph1->retry_counter--;
1921 iph1->scr = sched_new(iph1->rmconf->retry_interval,
1922 isakmp_ph1resend_stub, iph1);
1996 isakmp_ph1expire(iph1) in isakmp_ph1expire() argument
1997 struct ph1handle *iph1; in isakmp_ph1expire()
2001 SCHED_KILL(iph1->sce);
2003 if(iph1->status != PHASE1ST_EXPIRED){
2004 src = racoon_strdup(saddr2str(iph1->local));
2005 dst = racoon_strdup(saddr2str(iph1->remote));
2012 isakmp_pindex(&iph1->index, 0));
2015 iph1->status = PHASE1ST_EXPIRED;
2021 if (LIST_FIRST(&iph1->ph2tree) != NULL) {
2022 iph1->sce = sched_new(1, isakmp_ph1expire_stub, iph1);
2026 iph1->sce = sched_new(1, isakmp_ph1delete_stub, iph1);
2039 isakmp_ph1delete(iph1) in isakmp_ph1delete() argument
2040 struct ph1handle *iph1; in isakmp_ph1delete()
2044 SCHED_KILL(iph1->sce);
2046 if (LIST_FIRST(&iph1->ph2tree) != NULL) {
2047 iph1->sce = sched_new(1, isakmp_ph1delete_stub, iph1);
2053 src = racoon_strdup(saddr2str(iph1->local));
2054 dst = racoon_strdup(saddr2str(iph1->remote));
2060 src, dst, isakmp_pindex(&iph1->index, 0));
2061 EVT_PUSH(iph1->local, iph1->remote, EVTT_PHASE1_DOWN, NULL);
2065 remph1(iph1);
2066 delph1(iph1);
2156 struct ph1handle *iph1 = NULL; local
2185 if ((iph1 = getph1byaddrwop(iph2->src, iph2->dst)) != NULL) {
2186 set_port(iph2->src, extract_port(iph1->local));
2187 set_port(iph2->dst, extract_port(iph1->remote));
2190 iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
2193 iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
2197 if (iph1 == NULL) {
2218 if (iph1->status != PHASE1ST_ESTABLISHED) {
2235 if (isakmp_ph2begin_i(iph1, iph2))
2290 struct ph1handle *iph1; local
2320 if( (iph1 = getph1byaddrwop(iph2->src, iph2->dst)) != NULL){
2325 iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
2326 if(iph1 != NULL)
2330 iph1 = getph1byaddr(iph2->src, iph2->dst, 0);
2335 if (iph1 != NULL
2336 && iph1->status == PHASE1ST_ESTABLISHED) {
2340 plog(LLV_DEBUG2, LOCATION, NULL, "iph1->local: %s\n", saddr2str(iph1->local));
2341 plog(LLV_DEBUG2, LOCATION, NULL, "iph1->remote: %s\n", saddr2str(iph1->remote));
2345 set_port(iph2->src, extract_port(iph1->local));
2346 set_port(iph2->dst, extract_port(iph1->remote));
2352 (void)isakmp_ph2begin_i(iph1, iph2);
2587 isakmp_newmsgid2(iph1) in isakmp_newmsgid2() argument
2588 struct ph1handle *iph1; in isakmp_newmsgid2()
2594 } while (getph2bymsgid(iph1, msgid2));
2603 set_isakmp_header(vbuf, iph1, nptype, etype, flags, msgid) in set_isakmp_header() argument
2605 struct ph1handle *iph1;
2618 memcpy(&isakmp->i_ck, &iph1->index.i_ck, sizeof(cookie_t));
2619 memcpy(&isakmp->r_ck, &iph1->index.r_ck, sizeof(cookie_t));
2621 isakmp->v = iph1->version;
2634 set_isakmp_header1(vbuf, iph1, nptype) in set_isakmp_header1() argument
2636 struct ph1handle *iph1;
2639 return set_isakmp_header (vbuf, iph1, nptype, iph1->etype, iph1->flags, iph1->msgid);
2862 copy_ph1addresses(iph1, rmconf, remote, local) in copy_ph1addresses() argument
2863 struct ph1handle *iph1; in copy_ph1addresses()
2870 iph1->remote = dupsaddr(remote);
2871 if (iph1->remote == NULL)
2881 if (extract_port(iph1->remote) == 0) {
2885 set_port(iph1->remote, port);
2889 iph1->local = getlocaladdr(iph1->remote);
2891 iph1->local = dupsaddr(local);
2892 if (iph1->local == NULL)
2895 if (extract_port(iph1->local) == 0)
2896 set_port(iph1->local, PORT_ISAKMP);
2899 if (extract_port(iph1->local) == lcconf->port_isakmp_natt) {
2901 iph1->natt_flags |= NAT_ADD_NON_ESP_MARKER;
2909 nostate1(iph1, msg) in nostate1() argument
2910 struct ph1handle *iph1; in nostate1()
2913 plog(LLV_ERROR, LOCATION, iph1->remote, "wrong state %u.\n",
2914 iph1->status);
2929 log_ph1established(iph1) in log_ph1established() argument
2930 const struct ph1handle *iph1; in log_ph1established()
2934 src = racoon_strdup(saddr2str(iph1->local));
2935 dst = racoon_strdup(saddr2str(iph1->remote));
2942 isakmp_pindex(&iph1->index, 0));
2944 EVT_PUSH(iph1->local, iph1->remote, EVTT_PHASE1_UP, NULL);
2945 if(!iph1->rmconf->mode_cfg) {
2946 EVT_PUSH(iph1->local, iph1->remote, EVTT_NO_ISAKMP_CFG, NULL);
2976 isakmp_plist_set_all (struct payload_list **plist, struct ph1handle *iph1) in isakmp_plist_set_all() argument
3002 p = set_isakmp_header1(buf, iph1, ptr->payload_type); in isakmp_plist_set_all()
3027 frag_handler(iph1, msg, remote, local) in frag_handler() argument
3028 struct ph1handle *iph1; in frag_handler()
3035 if (isakmp_frag_extract(iph1, msg) == 1) {
3036 if ((newmsg = isakmp_frag_reassembly(iph1)) == NULL) {
3049 script_hook(iph1, script) in script_hook() argument
3050 struct ph1handle *iph1; in script_hook()
3062 if (iph1 == NULL ||
3063 iph1->rmconf == NULL ||
3064 iph1->rmconf->script[script] == NULL)
3068 (void)isakmp_cfg_setenv(iph1, &envp, &envc);
3072 sin = (struct sockaddr_in *)iph1->local;
3087 if (iph1->remote != NULL) {
3088 sin = (struct sockaddr_in *)iph1->remote;
3107 if (privsep_script_exec(iph1->rmconf->script[script]->v,
3194 purge_remote(iph1) in purge_remote() argument
3195 struct ph1handle *iph1; in purge_remote()
3208 isakmp_pindex(&(iph1->index), iph1->msgid));
3211 iph1->status = PHASE1ST_EXPIRED;
3214 new_iph1 = getph1byaddr(iph1->local, iph1->remote, 1);
3268 if ((CMPSADDR(iph1->local, src) || CMPSADDR(iph1->remote, dst)) &&
3269 (CMPSADDR(iph1->local, dst) || CMPSADDR(iph1->remote, src))) {
3291 if (iph2->ph1 != NULL && iph2->ph1 != iph1){
3337 isakmp_pindex(&(iph1->index), iph1->msgid));
3339 SCHED_KILL(iph1->sce);
3341 iph1->sce = sched_new(1, isakmp_ph1delete_stub, iph1);