715 {SADB_IDENTTYPE_PREFIX, "ipv6-prefix"},
716 {SADB_IDENTTYPE_PREFIX, "subnet"},
717 {SADB_IDENTTYPE_PREFIX, "subnetv4"},
718 {SADB_IDENTTYPE_PREFIX, "subnetv6"},
719 {SADB_IDENTTYPE_FQDN, "fqdn"},
720 {SADB_IDENTTYPE_FQDN, "dns"},
721 {SADB_IDENTTYPE_FQDN, "domain"},
722 {SADB_IDENTTYPE_FQDN, "domainname"},
723 {SADB_IDENTTYPE_USER_FQDN, "user_fqdn"},
724 {SADB_IDENTTYPE_USER_FQDN, "mbox"},
725 {SADB_IDENTTYPE_USER_FQDN, "mailbox"},
726 {SADB_X_IDENTTYPE_DN, "dn"},
727 {SADB_X_IDENTTYPE_DN, "asn1dn"},
728 {SADB_X_IDENTTYPE_GN, "gn"},
729 {SADB_X_IDENTTYPE_GN, "asn1gn"},
730 {SADB_X_IDENTTYPE_ADDR_RANGE, "ipv4-range"},
731 {SADB_X_IDENTTYPE_ADDR_RANGE, "ipv6-range"},
732 {SADB_X_IDENTTYPE_ADDR_RANGE, "rangev4"},
733 {SADB_X_IDENTTYPE_ADDR_RANGE, "rangev6"},
734 {SADB_X_IDENTTYPE_KEY_ID, "keyid"},
735 {NULL, 0}
736 };
737
738 static int
739 parse_idtype(char *type, uint16_t *idnum)
740 {
741 keywdtab_t *idp;
742
743 if (type == NULL)
744 return (-1);
745
746 for (idp = idtypes; idp->kw_str != NULL; idp++) {
747 if (strcasecmp(idp->kw_str, type) == 0) {
748 if (idnum != NULL)
749 *idnum = idp->kw_tag;
750 return (1);
751 }
752 }
753
754 return (-1);
755 }
883 /*
884 * Preshared key field types...used for parsing preshared keys that
885 * have been entered on the command line. The code to parse preshared
886 * keys (parse_ps, parse_key, parse_psfldid, parse_ikmtype, ...) is
887 * mostly duplicated from in.iked's readps.c.
888 */
889 #define PSFLD_LOCID 1
890 #define PSFLD_LOCIDTYPE 2
891 #define PSFLD_REMID 3
892 #define PSFLD_REMIDTYPE 4
893 #define PSFLD_MODE 5
894 #define PSFLD_KEY 6
895
896 static keywdtab_t psfldtypes[] = {
897 {PSFLD_LOCID, "localid"},
898 {PSFLD_LOCIDTYPE, "localidtype"},
899 {PSFLD_REMID, "remoteid"},
900 {PSFLD_REMIDTYPE, "remoteidtype"},
901 {PSFLD_MODE, "ike_mode"},
902 {PSFLD_KEY, "key"},
903 {NULL, 0}
904 };
905
906 static int
907 parse_psfldid(char *type, uint16_t *idnum)
908 {
909 keywdtab_t *pfp;
910
911 if (type == NULL)
912 return (-1);
913
914 for (pfp = psfldtypes; pfp->kw_str != NULL; pfp++) {
915 if (strcasecmp(pfp->kw_str, type) == 0) {
916 if (idnum != NULL)
917 *idnum = pfp->kw_tag;
918 return (1);
919 }
920 }
921
922 return (-1);
923 }
924
925 static keywdtab_t ikemodes[] = {
926 {IKE_XCHG_IDENTITY_PROTECT, "main"},
927 {IKE_XCHG_AGGRESSIVE, "aggressive"},
928 {IKE_XCHG_IP_AND_AGGR, "both"},
929 {NULL, 0}
930 };
931
932 static int
933 parse_ikmtype(char *mode, uint16_t *modenum)
934 {
935 keywdtab_t *ikmp;
936
937 if (mode == NULL)
938 return (-1);
939
940 for (ikmp = ikemodes; ikmp->kw_str != NULL; ikmp++) {
941 if (strcasecmp(ikmp->kw_str, mode) == 0) {
942 if (modenum != NULL)
943 *modenum = ikmp->kw_tag;
944 return (1);
945 }
946 }
947
948 return (-1);
949 }
3328 print_get_help();
3329 break;
3330 }
3331 do_getstats(cmd);
3332 break;
3333 case IKE_SVC_SET_DBG:
3334 case IKE_SVC_SET_PRIV:
3335 do_setvar(cmd, argc, argv);
3336 break;
3337 case IKE_SVC_SET_PIN:
3338 case IKE_SVC_DEL_PIN:
3339 do_setdel_pin(cmd, argc, argv);
3340 break;
3341 case IKE_SVC_DUMP_P1S:
3342 case IKE_SVC_DUMP_RULES:
3343 case IKE_SVC_DUMP_GROUPS:
3344 case IKE_SVC_DUMP_ENCRALGS:
3345 case IKE_SVC_DUMP_AUTHALGS:
3346 case IKE_SVC_DUMP_PS:
3347 case IKE_SVC_DUMP_CERTCACHE:
3348 if (argc != NULL) {
3349 print_dump_help();
3350 break;
3351 }
3352 do_dump(cmd);
3353 break;
3354 case IKE_SVC_GET_P1:
3355 case IKE_SVC_GET_RULE:
3356 case IKE_SVC_GET_PS:
3357 case IKE_SVC_DEL_P1:
3358 case IKE_SVC_DEL_RULE:
3359 case IKE_SVC_DEL_PS:
3360 do_getdel(cmd, argc, argv);
3361 break;
3362 case IKE_SVC_NEW_RULE:
3363 case IKE_SVC_NEW_PS:
3364 do_new(cmd, argc, argv);
3365 break;
3366 case IKE_SVC_FLUSH_P1S:
3367 case IKE_SVC_FLUSH_CERTCACHE:
3368 if (argc != 0) {
|
715 {SADB_IDENTTYPE_PREFIX, "ipv6-prefix"},
716 {SADB_IDENTTYPE_PREFIX, "subnet"},
717 {SADB_IDENTTYPE_PREFIX, "subnetv4"},
718 {SADB_IDENTTYPE_PREFIX, "subnetv6"},
719 {SADB_IDENTTYPE_FQDN, "fqdn"},
720 {SADB_IDENTTYPE_FQDN, "dns"},
721 {SADB_IDENTTYPE_FQDN, "domain"},
722 {SADB_IDENTTYPE_FQDN, "domainname"},
723 {SADB_IDENTTYPE_USER_FQDN, "user_fqdn"},
724 {SADB_IDENTTYPE_USER_FQDN, "mbox"},
725 {SADB_IDENTTYPE_USER_FQDN, "mailbox"},
726 {SADB_X_IDENTTYPE_DN, "dn"},
727 {SADB_X_IDENTTYPE_DN, "asn1dn"},
728 {SADB_X_IDENTTYPE_GN, "gn"},
729 {SADB_X_IDENTTYPE_GN, "asn1gn"},
730 {SADB_X_IDENTTYPE_ADDR_RANGE, "ipv4-range"},
731 {SADB_X_IDENTTYPE_ADDR_RANGE, "ipv6-range"},
732 {SADB_X_IDENTTYPE_ADDR_RANGE, "rangev4"},
733 {SADB_X_IDENTTYPE_ADDR_RANGE, "rangev6"},
734 {SADB_X_IDENTTYPE_KEY_ID, "keyid"},
735 {0, NULL}
736 };
737
738 static int
739 parse_idtype(char *type, uint16_t *idnum)
740 {
741 keywdtab_t *idp;
742
743 if (type == NULL)
744 return (-1);
745
746 for (idp = idtypes; idp->kw_str != NULL; idp++) {
747 if (strcasecmp(idp->kw_str, type) == 0) {
748 if (idnum != NULL)
749 *idnum = idp->kw_tag;
750 return (1);
751 }
752 }
753
754 return (-1);
755 }
883 /*
884 * Preshared key field types...used for parsing preshared keys that
885 * have been entered on the command line. The code to parse preshared
886 * keys (parse_ps, parse_key, parse_psfldid, parse_ikmtype, ...) is
887 * mostly duplicated from in.iked's readps.c.
888 */
889 #define PSFLD_LOCID 1
890 #define PSFLD_LOCIDTYPE 2
891 #define PSFLD_REMID 3
892 #define PSFLD_REMIDTYPE 4
893 #define PSFLD_MODE 5
894 #define PSFLD_KEY 6
895
896 static keywdtab_t psfldtypes[] = {
897 {PSFLD_LOCID, "localid"},
898 {PSFLD_LOCIDTYPE, "localidtype"},
899 {PSFLD_REMID, "remoteid"},
900 {PSFLD_REMIDTYPE, "remoteidtype"},
901 {PSFLD_MODE, "ike_mode"},
902 {PSFLD_KEY, "key"},
903 {0, NULL}
904 };
905
906 static int
907 parse_psfldid(char *type, uint16_t *idnum)
908 {
909 keywdtab_t *pfp;
910
911 if (type == NULL)
912 return (-1);
913
914 for (pfp = psfldtypes; pfp->kw_str != NULL; pfp++) {
915 if (strcasecmp(pfp->kw_str, type) == 0) {
916 if (idnum != NULL)
917 *idnum = pfp->kw_tag;
918 return (1);
919 }
920 }
921
922 return (-1);
923 }
924
925 static keywdtab_t ikemodes[] = {
926 {IKE_XCHG_IDENTITY_PROTECT, "main"},
927 {IKE_XCHG_AGGRESSIVE, "aggressive"},
928 {IKE_XCHG_IP_AND_AGGR, "both"},
929 {0, NULL}
930 };
931
932 static int
933 parse_ikmtype(char *mode, uint16_t *modenum)
934 {
935 keywdtab_t *ikmp;
936
937 if (mode == NULL)
938 return (-1);
939
940 for (ikmp = ikemodes; ikmp->kw_str != NULL; ikmp++) {
941 if (strcasecmp(ikmp->kw_str, mode) == 0) {
942 if (modenum != NULL)
943 *modenum = ikmp->kw_tag;
944 return (1);
945 }
946 }
947
948 return (-1);
949 }
3328 print_get_help();
3329 break;
3330 }
3331 do_getstats(cmd);
3332 break;
3333 case IKE_SVC_SET_DBG:
3334 case IKE_SVC_SET_PRIV:
3335 do_setvar(cmd, argc, argv);
3336 break;
3337 case IKE_SVC_SET_PIN:
3338 case IKE_SVC_DEL_PIN:
3339 do_setdel_pin(cmd, argc, argv);
3340 break;
3341 case IKE_SVC_DUMP_P1S:
3342 case IKE_SVC_DUMP_RULES:
3343 case IKE_SVC_DUMP_GROUPS:
3344 case IKE_SVC_DUMP_ENCRALGS:
3345 case IKE_SVC_DUMP_AUTHALGS:
3346 case IKE_SVC_DUMP_PS:
3347 case IKE_SVC_DUMP_CERTCACHE:
3348 if (argc != 0) {
3349 print_dump_help();
3350 break;
3351 }
3352 do_dump(cmd);
3353 break;
3354 case IKE_SVC_GET_P1:
3355 case IKE_SVC_GET_RULE:
3356 case IKE_SVC_GET_PS:
3357 case IKE_SVC_DEL_P1:
3358 case IKE_SVC_DEL_RULE:
3359 case IKE_SVC_DEL_PS:
3360 do_getdel(cmd, argc, argv);
3361 break;
3362 case IKE_SVC_NEW_RULE:
3363 case IKE_SVC_NEW_PS:
3364 do_new(cmd, argc, argv);
3365 break;
3366 case IKE_SVC_FLUSH_P1S:
3367 case IKE_SVC_FLUSH_CERTCACHE:
3368 if (argc != 0) {
|