#ifndef _VPN_CONTROL_H
#define _VPN_CONTROL_H
#include "algorithm_types.h"
#include <net/if.h>
#if __has_include(<nw/private.h>)
#include <nw/private.h>
#else
#include <network/nat64.h>
#endif
#define VPNCONTROLSOCK_PATH ADMINPORTDIR "/vpncontrol.sock"
#define FROM_LOCAL 0
#define FROM_REMOTE 1
extern char *vpncontrolsock_path;
extern uid_t vpncontrolsock_owner;
extern gid_t vpncontrolsock_group;
extern mode_t vpncontrolsock_mode;
#define VPNCTL_CMD_BIND 0x0001
#define VPNCTL_CMD_UNBIND 0x0002
#define VPNCTL_CMD_REDIRECT 0x0003
#define VPNCTL_CMD_PING 0x0004
#define VPNCTL_CMD_CONNECT 0x0011
#define VPNCTL_CMD_DISCONNECT 0x0012
#define VPNCTL_CMD_START_PH2 0x0013
#define VPNCTL_CMD_XAUTH_INFO 0x0014
#define VPNCTL_CMD_START_DPD 0x0015
#define VPNCTL_CMD_ASSERT 0x0016
#define VPNCTL_CMD_RECONNECT 0x0017
#define VPNCTL_CMD_SET_NAT64_PREFIX 0x0018
#define VPNCTL_STATUS_IKE_FAILED 0x8001
#define VPNCTL_STATUS_PH1_START_US 0x8011
#define VPNCTL_STATUS_PH1_START_PEER 0x8012
#define VPNCTL_STATUS_PH1_ESTABLISHED 0x8013
#define VPNCTL_STATUS_PH2_START 0x8021
#define VPNCTL_STATUS_PH2_ESTABLISHED 0x8022
#define VPNCTL_STATUS_NEED_AUTHINFO 0x8101
#define VPNCTL_STATUS_NEED_REAUTHINFO 0x8102
#define VPNCTL_STATUS_PEER_RESP 0x8103
#define VPNCTL_FLAG_MODECFG_USED 0x0001
#define VPNCTL_FLAG_IKE_VERSION 0x0002
#define VPNCTL_FLAG_IKEV2 VPNCTL_FLAG_IKE_VERSION
#ifndef __IPSEC_BUILD__
#define XAUTH_TYPE 16520
#define XAUTH_USER_NAME 16521
#define XAUTH_USER_PASSWORD 16522
#define XAUTH_PASSCODE 16523
#define XAUTH_MESSAGE 16524
#define XAUTH_CHALLENGE 16525
#define XAUTH_DOMAIN 16526
#define XAUTH_STATUS 16527
#define XAUTH_NEXT_PIN 16528
#define XAUTH_ANSWER 16529
#define XAUTH_TYPE_GENERIC 0
#define XAUTH_TYPE_CHAP 1
#define XAUTH_TYPE_OTP 2
#define XAUTH_TYPE_SKEY 3
#define INTERNAL_IP4_ADDRESS 1
#define INTERNAL_IP4_NETMASK 2
#define INTERNAL_IP4_DNS 3
#define INTERNAL_IP4_NBNS 4
#define INTERNAL_ADDRESS_EXPIRY 5
#define INTERNAL_IP4_DHCP 6
#define APPLICATION_VERSION 7
#define INTERNAL_IP6_ADDRESS 8
#define INTERNAL_IP6_NETMASK 9
#define INTERNAL_IP6_DNS 10
#define INTERNAL_IP6_NBNS 11
#define INTERNAL_IP6_DHCP 12
#define INTERNAL_IP4_SUBNET 13
#define SUPPORTED_ATTRIBUTES 14
#define INTERNAL_IP6_SUBNET 15
#define UNITY_BANNER 28672
#define UNITY_SAVE_PASSWD 28673
#define UNITY_DEF_DOMAIN 28674
#define UNITY_SPLITDNS_NAME 28675
#define UNITY_SPLIT_INCLUDE 28676
#define UNITY_NATT_PORT 28677
#define UNITY_LOCAL_LAN 28678
#define UNITY_PFS 28679
#define UNITY_FW_TYPE 28680
#define UNITY_BACKUP_SERVERS 28681
#define UNITY_DDNS_HOSTNAME 28682
struct isakmp_data {
u_int16_t type;
u_int16_t lorv;
};
#endif
struct vpnctl_hdr {
u_int16_t msg_type;
u_int16_t flags;
u_int32_t cookie;
u_int32_t reserved;
u_int16_t result;
u_int16_t len;
};
struct vpnctl_cmd_bind {
struct vpnctl_hdr hdr;
u_int32_t address;
u_int16_t vers_len;
};
struct vpnctl_cmd_unbind {
struct vpnctl_hdr hdr;
u_int32_t address;
};
struct vpnctl_cmd_connect {
struct vpnctl_hdr hdr;
u_int32_t address;
};
struct vpnctl_cmd_set_nat64_prefix {
struct vpnctl_hdr hdr;
nw_nat64_prefix_t nat64_prefix;
};
struct vpnctl_sa_selector {
u_int32_t src_tunnel_address;
u_int32_t src_tunnel_mask;
u_int32_t dst_tunnel_address;
u_int32_t dst_tunnel_mask;
u_int16_t src_tunnel_port;
u_int16_t dst_tunnel_port;
u_int16_t ul_protocol;
u_int16_t reserved;
};
struct vpnctl_algo {
u_int16_t algo_class;
u_int16_t algo;
u_int16_t key_len;
u_int16_t reserved;
};
struct vpnctl_cmd_start_ph2 {
struct vpnctl_hdr hdr;
u_int32_t address;
u_int32_t lifetime;
u_int16_t pfs_group;
u_int16_t selector_count;
u_int16_t algo_count;
u_int16_t reserved;
};
struct vpnctl_cmd_assert {
struct vpnctl_hdr hdr;
u_int32_t src_address;
u_int32_t dst_address;
};
struct vpnctl_cmd_xauth_info {
struct vpnctl_hdr hdr;
u_int32_t address;
};
struct vpnctl_cmd_redirect {
struct vpnctl_hdr hdr;
u_int32_t address;
u_int32_t redirect_address;
u_int16_t force;
};
struct vpnctl_cmd_start_dpd {
struct vpnctl_hdr hdr;
u_int32_t address;
};
#define VPNCTL_NTYPE_INVALID_PAYLOAD_TYPE 1
#define VPNCTL_NTYPE_DOI_NOT_SUPPORTED 2
#define VPNCTL_NTYPE_SITUATION_NOT_SUPPORTED 3
#define VPNCTL_NTYPE_INVALID_COOKIE 4
#define VPNCTL_NTYPE_INVALID_MAJOR_VERSION 5
#define VPNCTL_NTYPE_INVALID_MINOR_VERSION 6
#define VPNCTL_NTYPE_INVALID_EXCHANGE_TYPE 7
#define VPNCTL_NTYPE_INVALID_FLAGS 8
#define VPNCTL_NTYPE_INVALID_MESSAGE_ID 9
#define VPNCTL_NTYPE_INVALID_PROTOCOL_ID 10
#define VPNCTL_NTYPE_INVALID_SPI 11
#define VPNCTL_NTYPE_INVALID_TRANSFORM_ID 12
#define VPNCTL_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
#define VPNCTL_NTYPE_NO_PROPOSAL_CHOSEN 14
#define VPNCTL_NTYPE_BAD_PROPOSAL_SYNTAX 15
#define VPNCTL_NTYPE_PAYLOAD_MALFORMED 16
#define VPNCTL_NTYPE_INVALID_KEY_INFORMATION 17
#define VPNCTL_NTYPE_INVALID_ID_INFORMATION 18
#define VPNCTL_NTYPE_INVALID_CERT_ENCODING 19
#define VPNCTL_NTYPE_INVALID_CERTIFICATE 20
#define VPNCTL_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
#define VPNCTL_NTYPE_INVALID_CERT_AUTHORITY 22
#define VPNCTL_NTYPE_INVALID_HASH_INFORMATION 23
#define VPNCTL_NTYPE_AUTHENTICATION_FAILED 24
#define VPNCTL_NTYPE_INVALID_SIGNATURE 25
#define VPNCTL_NTYPE_ADDRESS_NOTIFICATION 26
#define VPNCTL_NTYPE_NOTIFY_SA_LIFETIME 27
#define VPNCTL_NTYPE_CERTIFICATE_UNAVAILABLE 28
#define VPNCTL_NTYPE_UNSUPPORTED_EXCHANGE_TYPE 29
#define VPNCTL_NTYPE_UNEQUAL_PAYLOAD_LENGTHS 30
#define VPNCTL_NTYPE_LOAD_BALANCE 40501
#define VPNCTL_NTYPE_PEER_DEAD 50001
#define VPNCTL_NTYPE_PH1_DELETE 50002
#define VPNCTL_NTYPE_IDLE_TIMEOUT 50003
#define VPNCTL_NTYPE_LOCAL_CERT_PREMATURE 50004
#define VPNCTL_NTYPE_LOCAL_CERT_EXPIRED 50005
#define VPNCTL_NTYPE_PEER_CERT_PREMATURE 50006
#define VPNCTL_NTYPE_PEER_CERT_EXPIRED 50007
#define VPNCTL_NTYPE_PEER_CERT_INVALID_SUBJNAME 50008
#define VPNCTL_NTYPE_PEER_CERT_INVALID_SUBJALTNAME 50009
#define VPNCTL_NTYPE_INTERNAL_ERROR -1
struct vpnctl_status_phase_change {
struct vpnctl_hdr hdr;
u_int32_t address;
};
struct vpnctl_status_need_authinfo {
struct vpnctl_hdr hdr;
u_int32_t address;
};
struct split_address {
u_int32_t splitaddr;
u_int32_t splitmask;
};
struct vpnctl_modecfg_params {
u_int32_t outer_local_addr;
u_int16_t outer_remote_port;
u_int16_t outer_local_port;
u_int8_t ifname[IFNAMSIZ];
};
struct vpnctl_status_failed {
struct vpnctl_hdr hdr;
u_int32_t address;
u_int16_t ike_code;
u_int16_t from;
u_int8_t data[0];
};
struct vpnctl_status_peer_resp {
struct vpnctl_hdr hdr;
u_int32_t address;
u_int16_t ike_code;
};
#endif